Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

feat: add share-ready diagram cards (#38)

tt-a1i3be59a0b40e4
diff --git a/README.md b/README.md
index f7e7ac35..60f1afdf 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Archify is an agent skill for Claude, Codex CLI, and opencode. It produces a sel
- **Three live visual presets** — author a default, then try `classic`, `signal-flow`, or `blueprint` on the same topology
- **Explore real topology** — find nodes, inspect relationships, trace routes, compare roles, and play guided stories
- **Motion is optional** — output stays static unless `meta.animation: "trace"` is explicitly enabled
-- **Portable exports** — copy PNG or download PNG, JPEG, WebP, dual-theme SVG, and trace-enabled WebM
+- **Portable exports** — create a 1200×630 Share Card, copy PNG, or download PNG, JPEG, WebP, dual-theme SVG, and trace-enabled WebM
- **Typed and checked** — JSON IR, bundled schema validation, default semantic safety gates, and opt-in composition profiles
- **Self-contained output** — one shareable HTML file with no viewer runtime dependency
- **Built for agent workflows** — install once, then create and refine diagrams through conversation
diff --git a/README_EN.md b/README_EN.md
index f7e7ac35..60f1afdf 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -18,7 +18,7 @@ Archify is an agent skill for Claude, Codex CLI, and opencode. It produces a sel
- **Three live visual presets** — author a default, then try `classic`, `signal-flow`, or `blueprint` on the same topology
- **Explore real topology** — find nodes, inspect relationships, trace routes, compare roles, and play guided stories
- **Motion is optional** — output stays static unless `meta.animation: "trace"` is explicitly enabled
-- **Portable exports** — copy PNG or download PNG, JPEG, WebP, dual-theme SVG, and trace-enabled WebM
+- **Portable exports** — create a 1200×630 Share Card, copy PNG, or download PNG, JPEG, WebP, dual-theme SVG, and trace-enabled WebM
- **Typed and checked** — JSON IR, bundled schema validation, default semantic safety gates, and opt-in composition profiles
- **Self-contained output** — one shareable HTML file with no viewer runtime dependency
- **Built for agent workflows** — install once, then create and refine diagrams through conversation
diff --git a/README_ZH.md b/README_ZH.md
index fdc9c19e..bbc4efcf 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -14,7 +14,7 @@ Archify 是一个可用于 Claude、Codex CLI 和 opencode 的 Agent Skill。它
- **三套实时视觉预设** —— 先确定作者默认风格,再在同一拓扑上试穿 `classic`、`signal-flow` 或 `blueprint`
- **探索真实拓扑** —— 查找节点、检查关系、探查路径、对比角色、播放引导故事
- **动态默认关闭** —— 只有显式设置 `meta.animation: "trace"` 才启用动态
-- **便携导出** —— 复制 PNG,下载 PNG / JPEG / WebP / 双主题 SVG / WebM
+- **便携导出** —— 一键生成 1200×630 Share Card,复制 PNG,或下载 PNG / JPEG / WebP / 双主题 SVG / WebM
- **Typed + Checked** —— Typed JSON IR、内置 Schema 校验、默认语义安全门禁和可选构图档位
- **结果完全独立** —— 一个 HTML 文件即可查看和分享,不依赖 Viewer 服务
- **适合 Agent 工作流** —— 安装一次,通过对话持续生成和细调
diff --git a/archify.zip b/archify.zip
index a5cd0d45..98fd8bd1 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/SKILL.md b/archify/SKILL.md
index 62c05b3d..c6dd4cee 100644
--- a/archify/SKILL.md
+++ b/archify/SKILL.md
@@ -1,6 +1,6 @@
---
name: archify
-description: Create polished, validated architecture, workflow, sequence, data-flow, and lifecycle/state diagrams as explorable standalone HTML with inline SVG, dark/light themes, semantic navigation, optional trace motion, and PNG/JPEG/WebP/SVG/WebM export. Accept plain-language requirements or pasted Mermaid flowchart, sequenceDiagram, and stateDiagram input; inspect repository evidence when the diagram must reflect real code. Use when the user asks to visualize system architecture, infrastructure, cloud/security/network topology, technical workflows, approval or CI/CD flows, API call sequences, request lifecycles, data pipelines, ETL/ELT, data lineage, state machines, or to convert/beautify Mermaid. Prefer typed JSON IR renderers and deterministic validation; deliver static output by default and enable motion only when requested.
+description: Create polished, validated architecture, workflow, sequence, data-flow, and lifecycle/state diagrams as explorable standalone HTML with inline SVG, dark/light themes, semantic navigation, optional trace motion, an optional 1200×630 Share Card PNG, and PNG/JPEG/WebP/SVG/WebM export. Accept plain-language requirements or pasted Mermaid flowchart, sequenceDiagram, and stateDiagram input; inspect repository evidence when the diagram must reflect real code. Use when the user asks to visualize system architecture, infrastructure, cloud/security/network topology, technical workflows, approval or CI/CD flows, API call sequences, request lifecycles, data pipelines, ETL/ELT, data lineage, state machines, or to convert/beautify Mermaid. Prefer typed JSON IR renderers and deterministic validation; deliver static output by default and enable motion only when requested.
license: MIT
metadata:
version: "2.11"
@@ -12,7 +12,9 @@ metadata:
Create professional technical diagrams as self-contained HTML files with inline SVG, a theme toggle, and a built-in image/SVG export menu.
-Every renderer-backed diagram ships with a factual Diagram Guide for discovering its current actions and shortcuts, deterministic semantic node hooks, a counted two-kind Semantic Lens with selective inline legend entrances, a fine-pointer/keyboard Intent Trace before committed focus, a two-endpoint Route Probe over authored directed relationships, a searchable Node Finder, keyboard-accessible one-hop focus with a renderer-owned Semantic Passport and copyable deep link, a live Semantic Radar overview, an optional Named Chapter Rail with static Chapter Delta Preview, a native Story Beat Navigator with Story Follow Camera, Story Director Strip, and Story Horizon, and stable Shareable Story Moment links, a reader-controlled Live/Still Motion Governor for trace artifacts, a viewer-only Share Chapter Cue for one-shot embeds, Presentation Stage, dependency-free pan/zoom, a **dark/light theme toggle** (persists in `localStorage`, respects `prefers-color-scheme`), an **export menu** (copy PNG to clipboard; download PNG/JPEG/WebP rasterized natively at up to 4× resolution; download a **dual-theme SVG**; record a trace-enabled diagram to WebM), and a **CSS-variable color system** that keeps both themes consistent. Temporary Diagram Guide, Semantic Lens, legend preview, Intent Trace, Route Probe, finder, focus, radar, Chapter Delta Preview, Story Trail overlays, Story Director Strip, Story Horizon, beat state, guided-view, playback, presentation, motion-owner, and viewport state never changes the canonical full-diagram export.
+Every renderer-backed diagram ships with a factual Diagram Guide for discovering its current actions and shortcuts, deterministic semantic node hooks, a counted two-kind Semantic Lens with selective inline legend entrances, a fine-pointer/keyboard Intent Trace before committed focus, a two-endpoint Route Probe over authored directed relationships, a searchable Node Finder, keyboard-accessible one-hop focus with a renderer-owned Semantic Passport and copyable deep link, a live Semantic Radar overview, an optional Named Chapter Rail with static Chapter Delta Preview, a native Story Beat Navigator with Story Follow Camera, Story Director Strip, and Story Horizon, and stable Shareable Story Moment links, a reader-controlled Live/Still Motion Governor for trace artifacts, a viewer-only Share Chapter Cue for one-shot embeds, Presentation Stage, dependency-free pan/zoom, a **dark/light theme toggle** (persists in `localStorage`, respects `prefers-color-scheme`), an **export menu** (create a 1200×630 Share Card; copy PNG to clipboard; download PNG/JPEG/WebP rasterized natively at up to 4× resolution; download a **dual-theme SVG**; record a trace-enabled diagram to WebM), and a **CSS-variable color system** that keeps both themes consistent. Temporary Diagram Guide, Semantic Lens, legend preview, Intent Trace, Route Probe, finder, focus, radar, Chapter Delta Preview, Story Trail overlays, Story Director Strip, Story Horizon, beat state, guided-view, playback, presentation, motion-owner, and viewport state never changes the canonical full-diagram export.
+
+Offer the optional 1200×630 Share Card PNG when the user asks for a README, release, social, or launch preview. It uses the current theme and visual preset, contains the entire canonical diagram without cropping, and never claims validation; the checked HTML remains the source of any delivery receipt.
Reading Depth progressively reveals renderer-owned context and fine detail as the reader zooms, while semantic interactions reveal the exact local facts they need at any scale.
diff --git a/archify/assets/template.html b/archify/assets/template.html
index 66fd0bb7..3585f97c 100644
--- a/archify/assets/template.html
+++ b/archify/assets/template.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4324,7 +4326,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4339,6 +4341,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4724,6 +4730,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5001,6 +5103,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5111,7 +5214,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5150,10 +5259,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5192,7 +5308,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/archify/examples/dataflow-product-analytics.html b/archify/examples/dataflow-product-analytics.html
index 4d4db825..4efd6bd0 100644
--- a/archify/examples/dataflow-product-analytics.html
+++ b/archify/examples/dataflow-product-analytics.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4422,7 +4424,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4437,6 +4439,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4822,6 +4828,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5099,6 +5201,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5209,7 +5312,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5248,10 +5357,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5290,7 +5406,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/archify/examples/lifecycle-agent-run.html b/archify/examples/lifecycle-agent-run.html
index 0b09fa6b..34b8b4ae 100644
--- a/archify/examples/lifecycle-agent-run.html
+++ b/archify/examples/lifecycle-agent-run.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4375,7 +4377,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4390,6 +4392,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4775,6 +4781,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5052,6 +5154,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5162,7 +5265,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5201,10 +5310,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5243,7 +5359,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/archify/examples/sequence-cache-miss-request.html b/archify/examples/sequence-cache-miss-request.html
index e47ebef4..738c18eb 100644
--- a/archify/examples/sequence-cache-miss-request.html
+++ b/archify/examples/sequence-cache-miss-request.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4426,7 +4428,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4441,6 +4443,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4826,6 +4832,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5103,6 +5205,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5213,7 +5316,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5252,10 +5361,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5294,7 +5410,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/archify/examples/web-app-rendered.html b/archify/examples/web-app-rendered.html
index b64147bc..b8531fb2 100644
--- a/archify/examples/web-app-rendered.html
+++ b/archify/examples/web-app-rendered.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4391,7 +4393,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4406,6 +4408,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4791,6 +4797,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5068,6 +5170,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5178,7 +5281,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5217,10 +5326,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5259,7 +5375,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/archify/examples/workflow-agent-tool-call-rendered.html b/archify/examples/workflow-agent-tool-call-rendered.html
index 75895bb0..495946a5 100644
--- a/archify/examples/workflow-agent-tool-call-rendered.html
+++ b/archify/examples/workflow-agent-tool-call-rendered.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4455,7 +4457,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4470,6 +4472,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4855,6 +4861,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5132,6 +5234,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5242,7 +5345,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5281,10 +5390,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5323,7 +5439,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/archify/test/share-card-export.test.mjs b/archify/test/share-card-export.test.mjs
new file mode 100644
index 00000000..086c4038
--- /dev/null
+++ b/archify/test/share-card-export.test.mjs
@@ -0,0 +1,93 @@
+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 } from 'node:url';
+
+const here = path.dirname(fileURLToPath(import.meta.url));
+const skillRoot = path.resolve(here, '..');
+const repoRoot = path.resolve(skillRoot, '..');
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-share-card-'));
+
+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) {
+ const output = path.join(tmp, `${mode}.html`);
+ execFileSync(process.execPath, [
+ path.join(skillRoot, `renderers/${mode}/render-${mode}.mjs`),
+ path.join(skillRoot, 'examples', CASES[mode]),
+ output,
+ ]);
+ return fs.readFileSync(output, 'utf8');
+}
+
+function svgBlock(html) {
+ return html.match(/<svg\b[\s\S]*?<\/svg>/)?.[0] || '';
+}
+
+test('all five renderers expose one explicit 1200x630 Share Card export', () => {
+ for (const mode of Object.keys(CASES)) {
+ const html = render(mode);
+ assert.match(html, /data-format="share-card"/, mode);
+ assert.match(html, /Share Card[\s\S]*?1200(?:&times;|×)630 PNG/, mode);
+ assert.match(html, /var SHARE_CARD_WIDTH = 1200;/, mode);
+ assert.match(html, /var SHARE_CARD_HEIGHT = 630;/, mode);
+ assert.match(html, /function rasterizeShareCard\(\)/, mode);
+ assert.match(html, /format === 'share-card'/, mode);
+ }
+});
+
+test('Share Card uses contain-only canonical geometry with fixed safe areas', () => {
+ const html = render('architecture');
+ assert.match(html, /var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING \* 2;/);
+ assert.match(html, /var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;/);
+ assert.match(html, /var fit = Math\.min\(availableWidth \/ data\.width, availableHeight \/ data\.height\);/);
+ assert.match(html, /ctx\.drawImage\(img, drawX, drawY, drawWidth, drawHeight\);/);
+ assert.match(html, /serializeSvg\(sourceScale\)/);
+ assert.match(html, /fitCanvasText\(ctx, title, [^)]+\)/);
+ assert.match(html, /ARCHIFY ·/);
+ assert.doesNotMatch(svgBlock(html), /share-card|Share Card|ARCHIFY ·/);
+});
+
+test('Share Card is a canonical PNG with exact receipt dimensions and filename', () => {
+ const html = render('workflow');
+ assert.match(html, /recordExportReceipt\('share-card', blob, true, \{ width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT \}\)/);
+ assert.match(html, /base \+ '-share-card\.png'/);
+ assert.match(html, /data-last-export-width/);
+ assert.match(html, /data-last-export-height/);
+ assert.match(html, /shareCard: rasterizeShareCard/);
+ assert.match(html, /if \(format === 'share-card'\) return true;/);
+});
+
+test('Share Card stays viewer-only and reuses export cleanup instead of source state', () => {
+ const html = render('sequence');
+ assert.match(html, /html\[data-embed="true"\] \.toolbar/);
+ assert.match(html, /@media print[\s\S]*?\.toolbar/);
+ assert.match(html, /function rasterizeShareCard\(\)[\s\S]*?serializeSvg\(sourceScale\)/);
+ assert.match(html, /if \(!data\.canonicalStateClean\) return Promise\.reject\(new Error\('Share Card export could not remove temporary viewer state'\)\);/);
+ assert.match(html, /canonicalStateClean/);
+ assert.doesNotMatch(svgBlock(html), /data-last-export-|data-format="share-card"/);
+});
+
+test('the skill and every README make the optional Share Card discoverable', () => {
+ const skill = fs.readFileSync(path.join(skillRoot, 'SKILL.md'), 'utf8');
+ assert.match(skill, /optional 1200(?:×|x)630 Share Card PNG/i);
+ assert.match(skill, /current theme and visual preset/i);
+ assert.match(skill, /never claim(?:s|ing)? validation/i);
+
+ for (const readme of ['README.md', 'README_EN.md', 'README_ZH.md']) {
+ const text = fs.readFileSync(path.join(repoRoot, readme), 'utf8');
+ assert.match(text, /Share Card/i, readme);
+ assert.match(text, /1200(?:×|x)630/, readme);
+ }
+});
+
+process.on('exit', () => fs.rmSync(tmp, { recursive: true, force: true }));
diff --git a/archify/test/webm-artifact.smoke.mjs b/archify/test/webm-artifact.smoke.mjs
index 417b359a..631084e9 100644
--- a/archify/test/webm-artifact.smoke.mjs
+++ b/archify/test/webm-artifact.smoke.mjs
@@ -53,6 +53,13 @@ execFileSync(process.execPath, [
output,
], { stdio: ['ignore', 'ignore', 'pipe'] });
+const sequenceOutput = path.join(tmp, 'sequence.html');
+execFileSync(process.execPath, [
+ path.join(skillRoot, 'renderers/sequence/render-sequence.mjs'),
+ path.join(skillRoot, 'examples/cache-miss-request.sequence.json'),
+ sequenceOutput,
+], { stdio: ['ignore', 'ignore', 'pipe'] });
+
assert.equal(typeof WebSocket, 'function', 'Node.js 22+ is required for the Chrome DevTools smoke harness');
function delay(ms) {
@@ -181,14 +188,69 @@ try {
const { sessionId } = await cdp.send('Target.attachToTarget', { targetId, flatten: true });
await cdp.send('Page.enable', {}, sessionId);
await cdp.send('Runtime.enable', {}, sessionId);
- await cdp.send('Page.navigate', { url: pathToFileURL(output).href }, sessionId);
- let ready = false;
- for (let attempt = 0; attempt < 100 && !ready; attempt += 1) {
- ready = await evaluate(cdp, sessionId, 'document.readyState === "complete" && !!(window.Archify && Archify.motion && Archify.motion.canRecord())');
- if (!ready) await delay(50);
+ async function navigateReady(file, condition, label) {
+ await cdp.send('Page.navigate', { url: pathToFileURL(file).href }, sessionId);
+ let ready = false;
+ for (let attempt = 0; attempt < 100 && !ready; attempt += 1) {
+ ready = await evaluate(cdp, sessionId, `document.readyState === "complete" && (${condition})`);
+ if (!ready) await delay(50);
+ }
+ assert.equal(ready, true, `${label} did not expose its browser export surface`);
+ }
+
+ async function captureShareCard(file, label) {
+ await navigateReady(file, '!!(window.Archify && Archify.exportMenu && Archify.exportMenu.shareCard)', label);
+ const sharePayload = await withTimeout(evaluate(cdp, sessionId, String.raw`(async function () {
+ try {
+ var blob = await Archify.exportMenu.shareCard();
+ var bytes = new Uint8Array(await blob.arrayBuffer());
+ var binary = '';
+ for (var offset = 0; offset < bytes.length; offset += 32768) {
+ binary += String.fromCharCode.apply(null, bytes.subarray(offset, offset + 32768));
+ }
+ return { ok: true, type: blob.type, size: blob.size, base64: btoa(binary) };
+ } catch (error) {
+ return { ok: false, error: String(error && error.message || error) };
+ }
+ })()`, true), 10_000, `${label} Share Card export`);
+
+ assert.equal(sharePayload?.ok, true, sharePayload?.error || `${label} Share Card export failed`);
+ assert.equal(sharePayload.type, 'image/png');
+ assert.ok(sharePayload.size > 20_000, `${label} Share Card is unexpectedly small (${sharePayload.size} bytes)`);
+
+ const png = Buffer.from(sharePayload.base64, 'base64');
+ assert.equal(png.subarray(0, 8).toString('hex'), '89504e470d0a1a0a', `${label} output is not a PNG`);
+ assert.equal(png.readUInt32BE(16), 1200, `${label} Share Card width`);
+ assert.equal(png.readUInt32BE(20), 630, `${label} Share Card height`);
+
+ const pngPath = path.join(tmp, `${label}.share-card.png`);
+ fs.writeFileSync(pngPath, png);
+ const pixels = execFileSync(ffmpeg, [
+ '-v', 'error',
+ '-i', pngPath,
+ '-vf', 'scale=120:63',
+ '-frames:v', '1',
+ '-f', 'rawvideo',
+ '-pix_fmt', 'rgb24',
+ '-',
+ ], { maxBuffer: 4 * 1024 * 1024 });
+ const colors = new Set();
+ const counts = new Map();
+ for (let offset = 0; offset < pixels.length; offset += 3) {
+ const color = pixels.subarray(offset, offset + 3).toString('hex');
+ colors.add(color);
+ counts.set(color, (counts.get(color) || 0) + 1);
+ }
+ const largestColorShare = Math.max(...counts.values()) / (pixels.length / 3);
+ assert.ok(colors.size >= 24, `${label} Share Card has only ${colors.size} sampled colors`);
+ assert.ok(largestColorShare < 0.96, `${label} Share Card is visually near-blank (${Math.round(largestColorShare * 100)}% one color)`);
+ console.log(`ok ${label} Share Card: ${sharePayload.size} bytes, 1200x630, ${colors.size} sampled colors`);
}
- assert.equal(ready, true, 'rendered artifact did not expose a recordable motion surface');
+
+ await captureShareCard(output, 'architecture-wide');
+ await captureShareCard(sequenceOutput, 'sequence-tall');
+ await navigateReady(output, '!!(window.Archify && Archify.motion && Archify.motion.canRecord())', 'motion artifact');
const payload = await withTimeout(evaluate(cdp, sessionId, String.raw`(async function () {
try {
diff --git a/docs/assets/archify-live-proof.gif b/docs/assets/archify-live-proof.gif
index 41174311..665ab145 100644
Binary files a/docs/assets/archify-live-proof.gif and b/docs/assets/archify-live-proof.gif differ
diff --git a/docs/assets/archify-live-proof.json b/docs/assets/archify-live-proof.json
index 8ee11989..def5aaa5 100644
--- a/docs/assets/archify-live-proof.json
+++ b/docs/assets/archify-live-proof.json
@@ -7,13 +7,13 @@
"fps": 10,
"frameCount": 54,
"durationSeconds": 5.4,
- "bytes": 1647952,
- "sha256": "0dc62a4a68ca9588a45ad66c14a16ee238bebe1e74ebc441b0c03bc0ba150e1d",
+ "bytes": 1567770,
+ "sha256": "589c2c5e7da6bbdd5e0a8db00124a2275d7a7b54611f3211abc506429fb1afee",
"scenes": [
{
"id": "signal-flow",
"artifact": "docs/gallery/artifacts/agent-tool-call.workflow.html",
- "artifactSha256": "7030e966ff2ec006bf91d01cb43f7732000f1fd9dcc6a1c6ba22a0508e29db6b",
+ "artifactSha256": "102df459ccb3cb752326158f17be955477863eff56d82409a231cf416a5fcc34",
"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": "bdf341257335aa276fab40603a1578ac3803fa5c053a97b30b94d5b234930673",
+ "artifactSha256": "6b7dd7050ca1d764edf98646807571d7a3d104df73712d5a1997ca60e84b9e7c",
"view": "request-boundary",
"eyebrow": "ARCHITECTURE · BLUEPRINT",
"title": "Production Deployment",
@@ -31,7 +31,7 @@
{
"id": "classic",
"artifact": "docs/gallery/artifacts/cache-miss.sequence.html",
- "artifactSha256": "44cc75f18b23e227ccc6adf18277f3601891071c73f332522f53970391d6e993",
+ "artifactSha256": "81f07fbb38ac11f9d437c5f84b7fa3936a17b102c6b38f1feddf8a0db9d5de9a",
"view": "cache-fallback",
"eyebrow": "SEQUENCE · CLASSIC",
"title": "Cache Miss Request",
diff --git a/docs/assets/archify-menu.png b/docs/assets/archify-menu.png
index 4c7e691e..290eb9a6 100644
Binary files a/docs/assets/archify-menu.png and b/docs/assets/archify-menu.png differ
diff --git a/docs/gallery.html b/docs/gallery.html
index 0f62ef97..d3f60977 100644
--- a/docs/gallery.html
+++ b/docs/gallery.html
@@ -324,7 +324,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="7030e966ff2ec006bf91d01cb43f7732000f1fd9dcc6a1c6ba22a0508e29db6b">7030e966ff2e</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="102df459ccb3cb752326158f17be955477863eff56d82409a231cf416a5fcc34">102df459ccb3</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/agent-tool-call.workflow.html?present=1&amp;play=1#view=happy-path" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -352,7 +352,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="bdf341257335aa276fab40603a1578ac3803fa5c053a97b30b94d5b234930673">bdf341257335</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="6b7dd7050ca1d764edf98646807571d7a3d104df73712d5a1997ca60e84b9e7c">6b7dd7050ca1</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/production-deployment.architecture.html?present=1&amp;play=1#view=request-boundary" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -380,7 +380,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="44cc75f18b23e227ccc6adf18277f3601891071c73f332522f53970391d6e993">44cc75f18b23</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="81f07fbb38ac11f9d437c5f84b7fa3936a17b102c6b38f1feddf8a0db9d5de9a">81f07fbb38ac</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/cache-miss.sequence.html?present=1&amp;play=1#view=cache-fallback" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -408,7 +408,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="7ed68a3f5367319e2ed70b05494a9da5563a2d5c3324f6854353952d1240814d">7ed68a3f5367</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="c014911fdec225d17d090b7eb86f99c0337a412de7789e16611eaea83a2dcc9f">c014911fdec2</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/release-delivery.workflow.html?present=1&amp;play=1#view=approval-to-production" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -436,7 +436,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="268db60a80c94d059a8cf4b078efc82c73e44491f65c82059123efe681b43a47">268db60a80c9</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="a2dd874dfb8be7cf71e0762411a30b6cd271fd9e8bd1a364957f65170c15f472">a2dd874dfb8b</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/incident-response.workflow.html?present=1&amp;play=1#view=mitigate-and-verify" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -464,7 +464,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="05a9a8480f66bc519a0797a74b7444ed44e6d9bca6d90594c2f1fe000c5d27a2">05a9a8480f66</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="1c3c5568d93e27ea06bad3f95dca4568514e5d61ae8dd5073b1004b436c6717f">1c3c5568d93e</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/product-analytics.dataflow.html?present=1&amp;play=1#view=consent-boundary" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -492,7 +492,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="aef9e8aa67247ff4099dccc3a77667d2682ad0d817539d52596d3a50b937581a">aef9e8aa6724</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="f1de12afb56f3a09ad6f0faa23ef36a08474662a2c34dc327c29c6f7b25f6ef9">f1de12afb56f</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/async-job-roundtrip.sequence.html?present=1&amp;play=1#view=work-and-retry" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -520,7 +520,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="41f72c50c240c6e4bacca143f36d0441d6ce875c69ebf8e254a2b7fcfc0596b4">41f72c50c240</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="f00d78f91b1f0e14437cc4c75165f57a6dba918beb9a4e88b338657595a3b9b1">f00d78f91b1f</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/event-stream.dataflow.html?present=1&amp;play=1#view=order-transit" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -548,7 +548,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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 · 5E</span></div>
- <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="db2a78f58c8029b33ec7735d27838ff7a174690badc87b68afdbf5ef534fb87f">db2a78f58c80</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="a0d9d31ff65b894838eda9cc79923e6d2e588ce4aed1c28d442b15aa8dc873b9">a0d9d31ff65b</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/agent-run.lifecycle.html?present=1&amp;play=1#view=main-lifecycle" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -576,7 +576,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="3053aafdb595dced900356b8aad708f8c840bf2545506a88e4cee0cfe647b13e">3053aafdb595</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="c86f2c45e60aa640d9c970393011a1cf43ac011e8ae0e39974cb5b94be6fe87a">c86f2c45e60a</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/deployment-release.lifecycle.html?present=1&amp;play=1#view=rollback-outcomes" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -604,7 +604,7 @@
<div class="receipt-cell"><span class="receipt-label">Artifact</span><span class="receipt-value ok">8/8 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="f6b9effa5287cc22e0f012280ba0f3d72684ab39092f0ce34673a86dc504a359">f6b9effa5287</span></div>
+ <div class="receipt-cell"><span class="receipt-label">SHA-256</span><span class="receipt-value" title="662a4094f7a2a63ade99c36bd87d6402263c472fc943aebe98e31520a3f5c6bc">662a4094f7a2</span></div>
</div>
<div class="card-actions">
<a class="card-link primary" href="gallery/artifacts/web-app.architecture.html?present=1&amp;play=1#view=request-path" target="_blank" rel="noopener" data-en="Play named chapter ↗" data-zh="播放命名章节 ↗">Play named chapter ↗</a>
@@ -681,8 +681,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 12,
"edgeCount": 11,
- "artifactBytes": 531692,
- "artifactSha256": "7030e966ff2ec006bf91d01cb43f7732000f1fd9dcc6a1c6ba22a0508e29db6b",
+ "artifactBytes": 537762,
+ "artifactSha256": "102df459ccb3cb752326158f17be955477863eff56d82409a231cf416a5fcc34",
"sourceBytes": 6470,
"sourceSha256": "a3afc6b30044eb256aa15c6195ddfbbcd1a14880d99967ed5605bc621ffb7e5f",
"checks": [
@@ -772,8 +772,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 12,
"edgeCount": 12,
- "artifactBytes": 530848,
- "artifactSha256": "bdf341257335aa276fab40603a1578ac3803fa5c053a97b30b94d5b234930673",
+ "artifactBytes": 536918,
+ "artifactSha256": "6b7dd7050ca1d764edf98646807571d7a3d104df73712d5a1997ca60e84b9e7c",
"sourceBytes": 5308,
"sourceSha256": "c3c4ddc8fd8910d8d2bcf2ba97434017d6fa347eb4ee436d2fb519dd0f27c814",
"checks": [
@@ -863,8 +863,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 7,
"edgeCount": 12,
- "artifactBytes": 525339,
- "artifactSha256": "44cc75f18b23e227ccc6adf18277f3601891071c73f332522f53970391d6e993",
+ "artifactBytes": 531409,
+ "artifactSha256": "81f07fbb38ac11f9d437c5f84b7fa3936a17b102c6b38f1feddf8a0db9d5de9a",
"sourceBytes": 4442,
"sourceSha256": "30098d81006a18813bab447da698edf74604a1463770f01dc056b0af8cb314ef",
"checks": [
@@ -954,8 +954,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 10,
"edgeCount": 10,
- "artifactBytes": 527958,
- "artifactSha256": "7ed68a3f5367319e2ed70b05494a9da5563a2d5c3324f6854353952d1240814d",
+ "artifactBytes": 534028,
+ "artifactSha256": "c014911fdec225d17d090b7eb86f99c0337a412de7789e16611eaea83a2dcc9f",
"sourceBytes": 5256,
"sourceSha256": "44aa56ac6ca807937dfe84a6404e8b07d6394a38ae2ac53248a1985337dfd671",
"checks": [
@@ -1045,8 +1045,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 11,
"edgeCount": 10,
- "artifactBytes": 527816,
- "artifactSha256": "268db60a80c94d059a8cf4b078efc82c73e44491f65c82059123efe681b43a47",
+ "artifactBytes": 533886,
+ "artifactSha256": "a2dd874dfb8be7cf71e0762411a30b6cd271fd9e8bd1a364957f65170c15f472",
"sourceBytes": 5471,
"sourceSha256": "9beb8698b275679a2fc92d4b51288cd5b5fc2115696d06b9168f3d7fef253a72",
"checks": [
@@ -1136,8 +1136,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 10,
"edgeCount": 10,
- "artifactBytes": 529349,
- "artifactSha256": "05a9a8480f66bc519a0797a74b7444ed44e6d9bca6d90594c2f1fe000c5d27a2",
+ "artifactBytes": 535419,
+ "artifactSha256": "1c3c5568d93e27ea06bad3f95dca4568514e5d61ae8dd5073b1004b436c6717f",
"sourceBytes": 5719,
"sourceSha256": "f71c89288f80255bdedcdc0057bcbc155d1d8b1b7476d024b35f4e27c730c974",
"checks": [
@@ -1227,8 +1227,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 7,
"edgeCount": 14,
- "artifactBytes": 526124,
- "artifactSha256": "aef9e8aa67247ff4099dccc3a77667d2682ad0d817539d52596d3a50b937581a",
+ "artifactBytes": 532194,
+ "artifactSha256": "f1de12afb56f3a09ad6f0faa23ef36a08474662a2c34dc327c29c6f7b25f6ef9",
"sourceBytes": 4483,
"sourceSha256": "1b53d7c4ce7b2d8f6f40b8f33a394abe1d37fc991272b534c1ccd0255920ab52",
"checks": [
@@ -1318,8 +1318,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 12,
"edgeCount": 12,
- "artifactBytes": 533356,
- "artifactSha256": "41f72c50c240c6e4bacca143f36d0441d6ce875c69ebf8e254a2b7fcfc0596b4",
+ "artifactBytes": 539426,
+ "artifactSha256": "f00d78f91b1f0e14437cc4c75165f57a6dba918beb9a4e88b338657595a3b9b1",
"sourceBytes": 5528,
"sourceSha256": "6541e9d00ea1efc38e4afc9c1cb4bbbea6e4468781e64da43ad9787cd6d51efc",
"checks": [
@@ -1409,8 +1409,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 10,
"edgeCount": 5,
- "artifactBytes": 522294,
- "artifactSha256": "db2a78f58c8029b33ec7735d27838ff7a174690badc87b68afdbf5ef534fb87f",
+ "artifactBytes": 528364,
+ "artifactSha256": "a0d9d31ff65b894838eda9cc79923e6d2e588ce4aed1c28d442b15aa8dc873b9",
"sourceBytes": 4353,
"sourceSha256": "1d6b34282e014cb2730662b1993158ec67bc0ad2a40520cb441aaee1ad21e4c6",
"checks": [
@@ -1500,8 +1500,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "trace",
"nodeCount": 11,
"edgeCount": 6,
- "artifactBytes": 523671,
- "artifactSha256": "3053aafdb595dced900356b8aad708f8c840bf2545506a88e4cee0cfe647b13e",
+ "artifactBytes": 529741,
+ "artifactSha256": "c86f2c45e60aa640d9c970393011a1cf43ac011e8ae0e39974cb5b94be6fe87a",
"sourceBytes": 4394,
"sourceSha256": "aa614f0c9a82f210e301e382f362dfbd7f290bda4d5501de3c99a6cd81b4c0a4",
"checks": [
@@ -1591,8 +1591,8 @@ receipt 88 checks / 11 artifacts / deterministic hashes</pre>
"animation": "static",
"nodeCount": 10,
"edgeCount": 9,
- "artifactBytes": 523303,
- "artifactSha256": "f6b9effa5287cc22e0f012280ba0f3d72684ab39092f0ce34673a86dc504a359",
+ "artifactBytes": 529373,
+ "artifactSha256": "662a4094f7a2a63ade99c36bd87d6402263c472fc943aebe98e31520a3f5c6bc",
"sourceBytes": 3863,
"sourceSha256": "01567b5e49cad5139baa071533a028d22f0e80fedfb49095e0d9330aee7f87db",
"checks": [
diff --git a/docs/gallery/artifacts/agent-run.lifecycle.html b/docs/gallery/artifacts/agent-run.lifecycle.html
index 0b09fa6b..34b8b4ae 100644
--- a/docs/gallery/artifacts/agent-run.lifecycle.html
+++ b/docs/gallery/artifacts/agent-run.lifecycle.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4375,7 +4377,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4390,6 +4392,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4775,6 +4781,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5052,6 +5154,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5162,7 +5265,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5201,10 +5310,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5243,7 +5359,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/agent-tool-call.workflow.html b/docs/gallery/artifacts/agent-tool-call.workflow.html
index 75895bb0..495946a5 100644
--- a/docs/gallery/artifacts/agent-tool-call.workflow.html
+++ b/docs/gallery/artifacts/agent-tool-call.workflow.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4455,7 +4457,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4470,6 +4472,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4855,6 +4861,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5132,6 +5234,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5242,7 +5345,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5281,10 +5390,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5323,7 +5439,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/async-job-roundtrip.sequence.html b/docs/gallery/artifacts/async-job-roundtrip.sequence.html
index b0efedf8..3dcaf3b5 100644
--- a/docs/gallery/artifacts/async-job-roundtrip.sequence.html
+++ b/docs/gallery/artifacts/async-job-roundtrip.sequence.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4442,7 +4444,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4457,6 +4459,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4842,6 +4848,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5119,6 +5221,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5229,7 +5332,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5268,10 +5377,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5310,7 +5426,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/cache-miss.sequence.html b/docs/gallery/artifacts/cache-miss.sequence.html
index e47ebef4..738c18eb 100644
--- a/docs/gallery/artifacts/cache-miss.sequence.html
+++ b/docs/gallery/artifacts/cache-miss.sequence.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4426,7 +4428,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4441,6 +4443,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4826,6 +4832,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5103,6 +5205,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5213,7 +5316,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5252,10 +5361,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5294,7 +5410,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/deployment-release.lifecycle.html b/docs/gallery/artifacts/deployment-release.lifecycle.html
index 158f4a79..9cb7eef4 100644
--- a/docs/gallery/artifacts/deployment-release.lifecycle.html
+++ b/docs/gallery/artifacts/deployment-release.lifecycle.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4389,7 +4391,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4404,6 +4406,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4789,6 +4795,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5066,6 +5168,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5176,7 +5279,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5215,10 +5324,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5257,7 +5373,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/event-stream.dataflow.html b/docs/gallery/artifacts/event-stream.dataflow.html
index 020cdc2d..073558b8 100644
--- a/docs/gallery/artifacts/event-stream.dataflow.html
+++ b/docs/gallery/artifacts/event-stream.dataflow.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4461,7 +4463,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4476,6 +4478,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4861,6 +4867,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5138,6 +5240,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5248,7 +5351,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5287,10 +5396,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5329,7 +5445,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/incident-response.workflow.html b/docs/gallery/artifacts/incident-response.workflow.html
index 874df100..a5cd5b8d 100644
--- a/docs/gallery/artifacts/incident-response.workflow.html
+++ b/docs/gallery/artifacts/incident-response.workflow.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4424,7 +4426,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4439,6 +4441,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4824,6 +4830,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5101,6 +5203,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5211,7 +5314,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5250,10 +5359,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5292,7 +5408,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/product-analytics.dataflow.html b/docs/gallery/artifacts/product-analytics.dataflow.html
index 4d4db825..4efd6bd0 100644
--- a/docs/gallery/artifacts/product-analytics.dataflow.html
+++ b/docs/gallery/artifacts/product-analytics.dataflow.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4422,7 +4424,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4437,6 +4439,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4822,6 +4828,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5099,6 +5201,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5209,7 +5312,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5248,10 +5357,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5290,7 +5406,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/production-deployment.architecture.html b/docs/gallery/artifacts/production-deployment.architecture.html
index 1c5d9444..6fb39799 100644
--- a/docs/gallery/artifacts/production-deployment.architecture.html
+++ b/docs/gallery/artifacts/production-deployment.architecture.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4441,7 +4443,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4456,6 +4458,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4841,6 +4847,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5118,6 +5220,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5228,7 +5331,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5267,10 +5376,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5309,7 +5425,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/release-delivery.workflow.html b/docs/gallery/artifacts/release-delivery.workflow.html
index f87dfaa0..0db11fbb 100644
--- a/docs/gallery/artifacts/release-delivery.workflow.html
+++ b/docs/gallery/artifacts/release-delivery.workflow.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4424,7 +4426,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4439,6 +4441,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4824,6 +4830,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5101,6 +5203,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5211,7 +5314,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5250,10 +5359,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5292,7 +5408,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/artifacts/web-app.architecture.html b/docs/gallery/artifacts/web-app.architecture.html
index b64147bc..b8531fb2 100644
--- a/docs/gallery/artifacts/web-app.architecture.html
+++ b/docs/gallery/artifacts/web-app.architecture.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4391,7 +4393,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4406,6 +4408,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4791,6 +4797,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5068,6 +5170,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5178,7 +5281,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5217,10 +5326,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5259,7 +5375,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/docs/gallery/manifest.json b/docs/gallery/manifest.json
index 77ea1493..b11c663a 100644
--- a/docs/gallery/manifest.json
+++ b/docs/gallery/manifest.json
@@ -26,8 +26,8 @@
"animation": "trace",
"nodeCount": 12,
"edgeCount": 11,
- "artifactBytes": 531692,
- "artifactSha256": "7030e966ff2ec006bf91d01cb43f7732000f1fd9dcc6a1c6ba22a0508e29db6b",
+ "artifactBytes": 537762,
+ "artifactSha256": "102df459ccb3cb752326158f17be955477863eff56d82409a231cf416a5fcc34",
"sourceBytes": 6470,
"sourceSha256": "a3afc6b30044eb256aa15c6195ddfbbcd1a14880d99967ed5605bc621ffb7e5f",
"checks": [
@@ -117,8 +117,8 @@
"animation": "trace",
"nodeCount": 12,
"edgeCount": 12,
- "artifactBytes": 530848,
- "artifactSha256": "bdf341257335aa276fab40603a1578ac3803fa5c053a97b30b94d5b234930673",
+ "artifactBytes": 536918,
+ "artifactSha256": "6b7dd7050ca1d764edf98646807571d7a3d104df73712d5a1997ca60e84b9e7c",
"sourceBytes": 5308,
"sourceSha256": "c3c4ddc8fd8910d8d2bcf2ba97434017d6fa347eb4ee436d2fb519dd0f27c814",
"checks": [
@@ -208,8 +208,8 @@
"animation": "trace",
"nodeCount": 7,
"edgeCount": 12,
- "artifactBytes": 525339,
- "artifactSha256": "44cc75f18b23e227ccc6adf18277f3601891071c73f332522f53970391d6e993",
+ "artifactBytes": 531409,
+ "artifactSha256": "81f07fbb38ac11f9d437c5f84b7fa3936a17b102c6b38f1feddf8a0db9d5de9a",
"sourceBytes": 4442,
"sourceSha256": "30098d81006a18813bab447da698edf74604a1463770f01dc056b0af8cb314ef",
"checks": [
@@ -299,8 +299,8 @@
"animation": "trace",
"nodeCount": 10,
"edgeCount": 10,
- "artifactBytes": 527958,
- "artifactSha256": "7ed68a3f5367319e2ed70b05494a9da5563a2d5c3324f6854353952d1240814d",
+ "artifactBytes": 534028,
+ "artifactSha256": "c014911fdec225d17d090b7eb86f99c0337a412de7789e16611eaea83a2dcc9f",
"sourceBytes": 5256,
"sourceSha256": "44aa56ac6ca807937dfe84a6404e8b07d6394a38ae2ac53248a1985337dfd671",
"checks": [
@@ -390,8 +390,8 @@
"animation": "trace",
"nodeCount": 11,
"edgeCount": 10,
- "artifactBytes": 527816,
- "artifactSha256": "268db60a80c94d059a8cf4b078efc82c73e44491f65c82059123efe681b43a47",
+ "artifactBytes": 533886,
+ "artifactSha256": "a2dd874dfb8be7cf71e0762411a30b6cd271fd9e8bd1a364957f65170c15f472",
"sourceBytes": 5471,
"sourceSha256": "9beb8698b275679a2fc92d4b51288cd5b5fc2115696d06b9168f3d7fef253a72",
"checks": [
@@ -481,8 +481,8 @@
"animation": "trace",
"nodeCount": 10,
"edgeCount": 10,
- "artifactBytes": 529349,
- "artifactSha256": "05a9a8480f66bc519a0797a74b7444ed44e6d9bca6d90594c2f1fe000c5d27a2",
+ "artifactBytes": 535419,
+ "artifactSha256": "1c3c5568d93e27ea06bad3f95dca4568514e5d61ae8dd5073b1004b436c6717f",
"sourceBytes": 5719,
"sourceSha256": "f71c89288f80255bdedcdc0057bcbc155d1d8b1b7476d024b35f4e27c730c974",
"checks": [
@@ -572,8 +572,8 @@
"animation": "trace",
"nodeCount": 7,
"edgeCount": 14,
- "artifactBytes": 526124,
- "artifactSha256": "aef9e8aa67247ff4099dccc3a77667d2682ad0d817539d52596d3a50b937581a",
+ "artifactBytes": 532194,
+ "artifactSha256": "f1de12afb56f3a09ad6f0faa23ef36a08474662a2c34dc327c29c6f7b25f6ef9",
"sourceBytes": 4483,
"sourceSha256": "1b53d7c4ce7b2d8f6f40b8f33a394abe1d37fc991272b534c1ccd0255920ab52",
"checks": [
@@ -663,8 +663,8 @@
"animation": "trace",
"nodeCount": 12,
"edgeCount": 12,
- "artifactBytes": 533356,
- "artifactSha256": "41f72c50c240c6e4bacca143f36d0441d6ce875c69ebf8e254a2b7fcfc0596b4",
+ "artifactBytes": 539426,
+ "artifactSha256": "f00d78f91b1f0e14437cc4c75165f57a6dba918beb9a4e88b338657595a3b9b1",
"sourceBytes": 5528,
"sourceSha256": "6541e9d00ea1efc38e4afc9c1cb4bbbea6e4468781e64da43ad9787cd6d51efc",
"checks": [
@@ -754,8 +754,8 @@
"animation": "trace",
"nodeCount": 10,
"edgeCount": 5,
- "artifactBytes": 522294,
- "artifactSha256": "db2a78f58c8029b33ec7735d27838ff7a174690badc87b68afdbf5ef534fb87f",
+ "artifactBytes": 528364,
+ "artifactSha256": "a0d9d31ff65b894838eda9cc79923e6d2e588ce4aed1c28d442b15aa8dc873b9",
"sourceBytes": 4353,
"sourceSha256": "1d6b34282e014cb2730662b1993158ec67bc0ad2a40520cb441aaee1ad21e4c6",
"checks": [
@@ -845,8 +845,8 @@
"animation": "trace",
"nodeCount": 11,
"edgeCount": 6,
- "artifactBytes": 523671,
- "artifactSha256": "3053aafdb595dced900356b8aad708f8c840bf2545506a88e4cee0cfe647b13e",
+ "artifactBytes": 529741,
+ "artifactSha256": "c86f2c45e60aa640d9c970393011a1cf43ac011e8ae0e39974cb5b94be6fe87a",
"sourceBytes": 4394,
"sourceSha256": "aa614f0c9a82f210e301e382f362dfbd7f290bda4d5501de3c99a6cd81b4c0a4",
"checks": [
@@ -936,8 +936,8 @@
"animation": "static",
"nodeCount": 10,
"edgeCount": 9,
- "artifactBytes": 523303,
- "artifactSha256": "f6b9effa5287cc22e0f012280ba0f3d72684ab39092f0ce34673a86dc504a359",
+ "artifactBytes": 529373,
+ "artifactSha256": "662a4094f7a2a63ade99c36bd87d6402263c472fc943aebe98e31520a3f5c6bc",
"sourceBytes": 3863,
"sourceSha256": "01567b5e49cad5139baa071533a028d22f0e80fedfb49095e0d9330aee7f87db",
"checks": [
diff --git a/examples/archify-repo-grid.html b/examples/archify-repo-grid.html
index 473965b6..4669e6bc 100644
--- a/examples/archify-repo-grid.html
+++ b/examples/archify-repo-grid.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4338,7 +4340,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4353,6 +4355,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4738,6 +4744,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5015,6 +5117,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5125,7 +5228,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5164,10 +5273,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5206,7 +5322,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/archify-repo.html b/examples/archify-repo.html
index 5ce3810b..9c26a7ad 100644
--- a/examples/archify-repo.html
+++ b/examples/archify-repo.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4400,7 +4402,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4415,6 +4417,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4800,6 +4806,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5077,6 +5179,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5187,7 +5290,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5226,10 +5335,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5268,7 +5384,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/dataflow-product-analytics.html b/examples/dataflow-product-analytics.html
index 4d4db825..4efd6bd0 100644
--- a/examples/dataflow-product-analytics.html
+++ b/examples/dataflow-product-analytics.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4422,7 +4424,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4437,6 +4439,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4822,6 +4828,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5099,6 +5201,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5209,7 +5312,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5248,10 +5357,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5290,7 +5406,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/lifecycle-agent-run.html b/examples/lifecycle-agent-run.html
index 0b09fa6b..34b8b4ae 100644
--- a/examples/lifecycle-agent-run.html
+++ b/examples/lifecycle-agent-run.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4375,7 +4377,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4390,6 +4392,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4775,6 +4781,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5052,6 +5154,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5162,7 +5265,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5201,10 +5310,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5243,7 +5359,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/maka-architecture.html b/examples/maka-architecture.html
index 8ab7af4c..3906a80b 100644
--- a/examples/maka-architecture.html
+++ b/examples/maka-architecture.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4422,7 +4424,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4437,6 +4439,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4822,6 +4828,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5099,6 +5201,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5209,7 +5312,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5248,10 +5357,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5290,7 +5406,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/sequence-cache-miss-request.html b/examples/sequence-cache-miss-request.html
index e47ebef4..738c18eb 100644
--- a/examples/sequence-cache-miss-request.html
+++ b/examples/sequence-cache-miss-request.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4426,7 +4428,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4441,6 +4443,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4826,6 +4832,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5103,6 +5205,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5213,7 +5316,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5252,10 +5361,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5294,7 +5410,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/web-app-rendered.html b/examples/web-app-rendered.html
index b64147bc..b8531fb2 100644
--- a/examples/web-app-rendered.html
+++ b/examples/web-app-rendered.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4391,7 +4393,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4406,6 +4408,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4791,6 +4797,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5068,6 +5170,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5178,7 +5281,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5217,10 +5326,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5259,7 +5375,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/web-app.html b/examples/web-app.html
index b64147bc..b8531fb2 100644
--- a/examples/web-app.html
+++ b/examples/web-app.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4391,7 +4393,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4406,6 +4408,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4791,6 +4797,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5068,6 +5170,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5178,7 +5281,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5217,10 +5326,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5259,7 +5375,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)
diff --git a/examples/workflow-agent-tool-call-rendered.html b/examples/workflow-agent-tool-call-rendered.html
index 75895bb0..495946a5 100644
--- a/examples/workflow-agent-tool-call-rendered.html
+++ b/examples/workflow-agent-tool-call-rendered.html
@@ -3788,6 +3788,8 @@
Export <span aria-hidden="true">&#9662;</span>
</button>
<div class="export-menu" id="export-menu" role="menu" aria-label="Export">
+ <button data-format="share-card" type="button" role="menuitem" tabindex="-1">Share Card <span class="hint">1200&times;630 PNG</span></button>
+ <hr role="separator">
<button data-action="copy" type="button" role="menuitem" tabindex="-1">Copy to clipboard <span class="hint">PNG</span></button>
<hr role="separator">
<button data-format="png" type="button" role="menuitem" tabindex="-1">Download PNG</button>
@@ -4455,7 +4457,7 @@
})();
/* ============================================================
- Export — PNG / JPEG / WebP / SVG / WebM and Copy PNG (clipboard)
+ Export — Share Card / PNG / JPEG / WebP / SVG / WebM and Copy PNG
Raster exports are always rendered at 4x source resolution for
maximum sharpness. The trick: we set the serialized SVG's
@@ -4470,6 +4472,10 @@
var RASTER_SCALE = 4;
var MOTION_DURATION = 6000;
var MOTION_FPS = 30;
+ var SHARE_CARD_WIDTH = 1200;
+ var SHARE_CARD_HEIGHT = 630;
+ var SHARE_CARD_PADDING = 36;
+ var SHARE_CARD_HEADER = 112;
function diagramFilename() {
var title = (document.title || 'diagram')
@@ -4855,6 +4861,102 @@
});
}
+ function fitCanvasText(ctx, text, maxWidth, startSize, minSize, weight) {
+ var value = String(text || '').trim();
+ var size = startSize;
+ var family = "'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ while (size > minSize) {
+ ctx.font = (weight || '600') + ' ' + size + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ size -= 1;
+ }
+ ctx.font = (weight || '600') + ' ' + minSize + 'px ' + family;
+ if (ctx.measureText(value).width <= maxWidth) return value;
+ var suffix = '\u2026';
+ while (value.length > 1 && ctx.measureText(value + suffix).width > maxWidth) {
+ value = value.slice(0, -1);
+ }
+ return value + suffix;
+ }
+
+ function rasterizeShareCard() {
+ var svg = document.querySelector('.diagram-container svg');
+ var vb = svg.viewBox.baseVal;
+ var sourceScale = Math.min(2, pickSafeScale(vb.width, vb.height));
+ var data = serializeSvg(sourceScale);
+ if (!data.canonicalStateClean) return Promise.reject(new Error('Share Card export could not remove temporary viewer state'));
+ var svgBlob = new Blob([data.svgString], { type: 'image/svg+xml;charset=utf-8' });
+ var svgUrl = URL.createObjectURL(svgBlob);
+
+ return new Promise(function (resolve, reject) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = SHARE_CARD_WIDTH;
+ canvas.height = SHARE_CARD_HEIGHT;
+ var ctx = canvas.getContext('2d');
+ var computed = getComputedStyle(document.documentElement);
+ var bg = computed.getPropertyValue('--bg').trim() || currentBg();
+ var text = computed.getPropertyValue('--text').trim() || '#ffffff';
+ var muted = computed.getPropertyValue('--text-muted').trim() || '#94a3b8';
+ var border = computed.getPropertyValue('--panel-border').trim() || '#334155';
+ var accent = computed.getPropertyValue('--frontend-stroke').trim() || '#22d3ee';
+ var titleNode = document.querySelector('.header h1');
+ var subtitleNode = document.querySelector('.header .subtitle');
+ var title = titleNode ? titleNode.textContent : document.title;
+ var subtitle = subtitleNode ? subtitleNode.textContent : '';
+ var preset = document.documentElement.getAttribute('data-preset') || 'classic';
+ var theme = document.documentElement.getAttribute('data-theme') || 'dark';
+ var presetLabel = preset === 'signal-flow' ? 'FLOW' : preset.toUpperCase();
+
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, SHARE_CARD_WIDTH, SHARE_CARD_HEIGHT);
+
+ ctx.fillStyle = accent;
+ ctx.fillRect(SHARE_CARD_PADDING, 27, 42, 3);
+
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillStyle = text;
+ var fittedTitle = fitCanvasText(ctx, title, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 330, 29, 18, '700');
+ ctx.fillText(fittedTitle, SHARE_CARD_PADDING, 62);
+
+ ctx.fillStyle = muted;
+ var fittedSubtitle = fitCanvasText(ctx, subtitle, SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2 - 280, 13, 11, '500');
+ ctx.fillText(fittedSubtitle, SHARE_CARD_PADDING, 87);
+
+ ctx.font = "600 12px 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
+ ctx.textAlign = 'right';
+ ctx.fillStyle = accent;
+ ctx.fillText('ARCHIFY · ' + presetLabel + ' · ' + theme.toUpperCase(), SHARE_CARD_WIDTH - SHARE_CARD_PADDING, 50);
+ ctx.textAlign = 'left';
+
+ var availableWidth = SHARE_CARD_WIDTH - SHARE_CARD_PADDING * 2;
+ var availableHeight = SHARE_CARD_HEIGHT - SHARE_CARD_HEADER - SHARE_CARD_PADDING;
+ var fit = Math.min(availableWidth / data.width, availableHeight / data.height);
+ var drawWidth = data.width * fit;
+ var drawHeight = data.height * fit;
+ var drawX = SHARE_CARD_PADDING + (availableWidth - drawWidth) / 2;
+ var drawY = SHARE_CARD_HEADER + (availableHeight - drawHeight) / 2;
+
+ ctx.strokeStyle = border;
+ ctx.lineWidth = 1;
+ ctx.strokeRect(drawX - 0.5, drawY - 0.5, drawWidth + 1, drawHeight + 1);
+ ctx.drawImage(img, drawX, drawY, drawWidth, drawHeight);
+ URL.revokeObjectURL(svgUrl);
+
+ canvas.toBlob(function (blob) {
+ if (!blob) reject(new Error('toBlob returned null for Share Card'));
+ else resolve(blob);
+ }, 'image/png');
+ };
+ img.onerror = function (e) {
+ URL.revokeObjectURL(svgUrl);
+ reject(e);
+ };
+ img.src = svgUrl;
+ });
+ }
+
function motionMimeType() {
if (typeof MediaRecorder === 'undefined') return '';
var candidates = [
@@ -5132,6 +5234,7 @@
// canvas.toBlob('image/webp') silently returns a PNG on browsers without
// WebP encoding (older Safari), so detect explicitly.
function supports(format) {
+ if (format === 'share-card') return true;
if (format === 'svg' || format === 'png') return true;
if (format === 'webm') return canRecordMotion();
var mime = format === 'jpeg' ? 'image/jpeg' : 'image/webp';
@@ -5242,7 +5345,13 @@
document.documentElement.removeAttribute('data-last-export-error');
document.documentElement.removeAttribute('data-last-export-error-format');
if (format === 'webm') toast('Recording 6 seconds of motion…');
- return (format === 'svg'
+ return (format === 'share-card'
+ ? rasterizeShareCard().then(function (blob) {
+ recordExportReceipt('share-card', blob, true, { width: SHARE_CARD_WIDTH, height: SHARE_CARD_HEIGHT });
+ download(blob, base + '-share-card.png');
+ toast('Downloaded Share Card');
+ })
+ : format === 'svg'
? Promise.resolve(serializeSvg(1, { autoTheme: true })).then(function (d) {
var blob = new Blob([d.svgString], { type: 'image/svg+xml;charset=utf-8' });
recordExportReceipt('svg', blob, d.canonicalStateClean);
@@ -5281,10 +5390,17 @@
// A compact, machine-readable receipt for local QA and generated proof
// galleries. It exposes no diagram contents, only the completed format,
// byte count, and whether temporary viewer state was excluded.
- function recordExportReceipt(format, blob, canonical) {
+ function recordExportReceipt(format, blob, canonical, dimensions) {
document.documentElement.setAttribute('data-last-export-format', format);
document.documentElement.setAttribute('data-last-export-bytes', String(blob.size));
document.documentElement.setAttribute('data-last-export-canonical', canonical ? 'true' : 'false');
+ if (dimensions) {
+ document.documentElement.setAttribute('data-last-export-width', String(dimensions.width));
+ document.documentElement.setAttribute('data-last-export-height', String(dimensions.height));
+ } else {
+ document.documentElement.removeAttribute('data-last-export-width');
+ document.documentElement.removeAttribute('data-last-export-height');
+ }
}
function runCopy() {
@@ -5323,7 +5439,7 @@
});
Archify.motion = { canRecord: canRecordMotion, recordWebm: recordWebm };
- Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport };
+ Archify.exportMenu = { open: open, close: close, isOpen: isOpen, run: runExport, shareCard: rasterizeShareCard };
// Auto-open on page load for demo/screenshot purposes: ?openExport=1
// Wait for fonts (so the menu doesn't flash before typography lands)