Skip to content

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

perf(renderers): resolve brand marks only when a document names one

goatliamia24fee8d1ca25
diff --git a/archify/renderers/shared/cli.mjs b/archify/renderers/shared/cli.mjs
index d3fe4365..77317688 100644
--- a/archify/renderers/shared/cli.mjs
+++ b/archify/renderers/shared/cli.mjs
@@ -18,7 +18,6 @@ import {
removeOwnedRegularFile,
verifyAtomicOutput,
} from './atomic-output.mjs';
-import { prepareDiagramBrandMarks } from './brand-marks.mjs';
import { resolveLocale, translateMessage } from './i18n.mjs';
const outputPathGuards = new Map();
@@ -86,9 +85,29 @@ export function loadDiagram({ rendererDir, diagramType, defaultExample, argv = p
// Brand URL capture is the only asynchronous authoring step. Typed renderers
// opt into it through this wrapper without changing loadDiagram's long-lived
// synchronous safety contract.
+// Brand resolution walks the element collection and returns immediately when no
+// element names a mark, so a document without one never needs the brand tables.
+const BRAND_COLLECTIONS = {
+ architecture: 'components',
+ workflow: 'nodes',
+ sequence: 'participants',
+ dataflow: 'nodes',
+ lifecycle: 'states',
+};
+
+function declaresBrandMark(diagramType, diagram) {
+ const collection = BRAND_COLLECTIONS[diagramType];
+ const elements = collection && Array.isArray(diagram?.[collection]) ? diagram[collection] : [];
+ return elements.some((element) => element && element.brand !== undefined && element.brand !== null
+ && String(element.brand).trim() !== '');
+}
+
export async function loadDiagramWithBrandMarks(options) {
const loaded = loadDiagram(options);
- await prepareDiagramBrandMarks(options.diagramType, loaded.diagram);
+ if (declaresBrandMark(options.diagramType, loaded.diagram)) {
+ const { prepareDiagramBrandMarks } = await import('./brand-marks.mjs');
+ await prepareDiagramBrandMarks(options.diagramType, loaded.diagram);
+ }
return loaded;
}