agentic-mermaid 0.4.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_NATIVE.md +94 -627
- package/CHANGELOG.md +651 -0
- package/Instructions_for_agents.md +44 -23
- package/LICENSES/Khroma-MIT.txt +21 -0
- package/LICENSES/Mermaid-MIT.txt +21 -0
- package/LICENSES/es-toolkit-MIT.txt +21 -0
- package/LICENSES/pele-MIT.txt +40 -0
- package/LICENSES/zenuml-core-MIT.txt +21 -0
- package/README.md +93 -50
- package/SECURITY.md +28 -12
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/assets/hero.png +0 -0
- package/dist/agent-core.d.ts +478 -210
- package/dist/agent-core.js +1 -396
- package/dist/agent.d.ts +17 -8
- package/dist/agent.js +1 -408
- package/dist/agentic-mermaid-mcp.js +1 -11
- package/dist/am.js +1 -34562
- package/dist/browser-lazy/chunks/agentic-producer-core-CC6OOLDW.js +1 -0
- package/dist/browser-lazy/chunks/architecture-QUFVKYJR.js +13 -0
- package/dist/browser-lazy/chunks/block-6J3Q63BO.js +11 -0
- package/dist/browser-lazy/chunks/builtin-backends-7SOZZHPF.js +12 -0
- package/dist/browser-lazy/chunks/c4-SQVBZAKJ.js +10 -0
- package/dist/browser-lazy/chunks/chunk-2GPK4VFF.js +5 -0
- package/dist/browser-lazy/chunks/chunk-2I4UPL7Q.js +3 -0
- package/dist/browser-lazy/chunks/chunk-2SH76OTH.js +1 -0
- package/dist/browser-lazy/chunks/chunk-2UIA2IME.js +3 -0
- package/dist/browser-lazy/chunks/chunk-4LHYF3BS.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5B2Z7575.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5FQ534HP.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5UVGUSD6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5X6MJX3H.js +1 -0
- package/dist/browser-lazy/chunks/chunk-AMJLVPUB.js +4 -0
- package/dist/browser-lazy/chunks/chunk-BU5LHXNJ.js +3 -0
- package/dist/browser-lazy/chunks/chunk-BY2CPG6B.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CN7WTBWB.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CQE4HQEW.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CSFUKSU6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-DF6765YX.js +17 -0
- package/dist/browser-lazy/chunks/chunk-E2WMJZNM.js +1 -0
- package/dist/browser-lazy/chunks/chunk-FAIMVOX5.js +6 -0
- package/dist/browser-lazy/chunks/chunk-GVOEAY52.js +1 -0
- package/dist/browser-lazy/chunks/chunk-HLWUNUCM.js +1 -0
- package/dist/browser-lazy/chunks/chunk-ICC7HBJX.js +1 -0
- package/dist/browser-lazy/chunks/chunk-J35HAQQF.js +20 -0
- package/dist/browser-lazy/chunks/chunk-J7FFAFQF.js +1 -0
- package/dist/browser-lazy/chunks/chunk-LH7HUDKW.js +1 -0
- package/dist/browser-lazy/chunks/chunk-N5ELX7LR.js +2 -0
- package/dist/browser-lazy/chunks/chunk-NMQQMRIR.js +1 -0
- package/dist/browser-lazy/chunks/chunk-NO7ZIVRU.js +1 -0
- package/dist/browser-lazy/chunks/chunk-OZ443IVJ.js +16 -0
- package/dist/browser-lazy/chunks/chunk-PQGPS2YV.js +7 -0
- package/dist/browser-lazy/chunks/chunk-QA6GJQ4X.js +1 -0
- package/dist/browser-lazy/chunks/chunk-RIVTHZAQ.js +1 -0
- package/dist/browser-lazy/chunks/chunk-SZELX2EJ.js +1 -0
- package/dist/browser-lazy/chunks/chunk-TYZOZXUJ.js +22 -0
- package/dist/browser-lazy/chunks/chunk-UL6NDWLL.js +1 -0
- package/dist/browser-lazy/chunks/chunk-VQYYGAXP.js +1 -0
- package/dist/browser-lazy/chunks/chunk-VWVZGQE2.js +1 -0
- package/dist/browser-lazy/chunks/chunk-X2UYKWKM.js +4 -0
- package/dist/browser-lazy/chunks/chunk-YCEICNM6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-Z3FDIVLN.js +20 -0
- package/dist/browser-lazy/chunks/class-5QA4SCTS.js +13 -0
- package/dist/browser-lazy/chunks/decode-63UIZGD2.js +1 -0
- package/dist/browser-lazy/chunks/elk.bundled-L4CADV5W.js +24 -0
- package/dist/browser-lazy/chunks/er-7ZSKGN7Y.js +11 -0
- package/dist/browser-lazy/chunks/eventmodeling-2BPLHWRN.js +19 -0
- package/dist/browser-lazy/chunks/flowchart-NEIMZTB5.js +4 -0
- package/dist/browser-lazy/chunks/forest-implementation-AEP24AIP.js +1 -0
- package/dist/browser-lazy/chunks/gantt-RDPIFYAF.js +11 -0
- package/dist/browser-lazy/chunks/gitgraph-N4Y5RYB7.js +9 -0
- package/dist/browser-lazy/chunks/ishikawa-LD3YBDJN.js +6 -0
- package/dist/browser-lazy/chunks/journey-6YQR5DJX.js +16 -0
- package/dist/browser-lazy/chunks/kanban-PLMJ7NBW.js +20 -0
- package/dist/browser-lazy/chunks/mermaid-yaml-runtime-QVYX4EWK.js +136 -0
- package/dist/browser-lazy/chunks/mindmap-K2UBFO3Y.js +12 -0
- package/dist/browser-lazy/chunks/packet-CUW4QY6Y.js +7 -0
- package/dist/browser-lazy/chunks/pie-7F7UUCG3.js +15 -0
- package/dist/browser-lazy/chunks/quadrant-TOONO2WC.js +10 -0
- package/dist/browser-lazy/chunks/radar-J6JVWVAX.js +16 -0
- package/dist/browser-lazy/chunks/render-core-BZOM3K7D.js +3 -0
- package/dist/browser-lazy/chunks/requirement-CMAKDJPO.js +19 -0
- package/dist/browser-lazy/chunks/sankey-AWXQEP3F.js +13 -0
- package/dist/browser-lazy/chunks/sequence-Q2RJRB4L.js +5 -0
- package/dist/browser-lazy/chunks/state-WRBFQEDX.js +4 -0
- package/dist/browser-lazy/chunks/timeline-D2KILFXM.js +6 -0
- package/dist/browser-lazy/chunks/treemap-N3VYX5D4.js +6 -0
- package/dist/browser-lazy/chunks/xychart-G73OGK66.js +16 -0
- package/dist/browser-lazy/chunks/zenuml-H4BXNYXR.js +16 -0
- package/dist/browser-lazy/index.d.ts +544 -275
- package/dist/browser-lazy/index.js +1 -1
- package/dist/browser.global.js +802 -565
- package/dist/chunk-3LGLPG33.js +2 -0
- package/dist/chunk-7CRDX2QR.js +2 -0
- package/dist/chunk-7PPW2BMO.js +2 -0
- package/dist/chunk-DQDKA5ND.js +2 -0
- package/dist/chunk-EHCMJUMD.js +52 -0
- package/dist/chunk-GVCHLSHH.js +4 -0
- package/dist/chunk-H3NCS2XZ.js +19 -0
- package/dist/chunk-JZOJ4YGS.js +201 -0
- package/dist/chunk-MKE7GNYU.js +146 -0
- package/dist/chunk-NKNFOREZ.js +2 -0
- package/dist/chunk-O7H2UX5K.js +2 -0
- package/dist/chunk-OMY6NRQD.js +58 -0
- package/dist/chunk-UA234O4M.js +4 -0
- package/dist/chunk-VUFVLGTH.js +2 -0
- package/dist/chunk-XU5LPD2D.js +2 -0
- package/dist/cli-YGGTJZH7.js +226 -0
- package/dist/elk-constructor.js +2 -0
- package/dist/elk-constructor.node.js +11 -0
- package/dist/index-EeXqJXr5.d.ts +1223 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -334
- package/dist/jsonl-RPJY6YWO.js +2 -0
- package/dist/mcp-cli-63DYXTVD.js +2 -0
- package/dist/{index-BGA_-6LV.d.ts → paint-certification-6rwQjIv_.d.ts} +5283 -6173
- package/dist/server-5NEOHOFS.js +524 -0
- package/dist/svg-styles-BdnoM7AT.d.ts +724 -0
- package/dist/svg-styles.d.ts +1 -0
- package/dist/svg-styles.js +2 -0
- package/dist/svg.d.ts +13 -0
- package/dist/svg.js +2 -0
- package/dist/types-BcS52Mjt.d.ts +1360 -0
- package/dist/zenuml/chunks/appearance-UOQ5KA6O.js +1 -0
- package/dist/zenuml/chunks/builtin-backends-KDKE7YHO.js +12 -0
- package/dist/zenuml/chunks/chunk-42DXZ5C6.js +4 -0
- package/dist/zenuml/chunks/chunk-7TVYPTDW.js +1 -0
- package/dist/zenuml/chunks/chunk-EVPSMEKN.js +1 -0
- package/dist/zenuml/chunks/chunk-OXQWRSBM.js +20 -0
- package/dist/zenuml/chunks/chunk-QWX77U7G.js +2 -0
- package/dist/zenuml/chunks/chunk-RLJEI7YN.js +29 -0
- package/dist/zenuml/chunks/chunk-RZ6XK5CD.js +29 -0
- package/dist/zenuml/chunks/decode-BWERFDGK.js +1 -0
- package/dist/zenuml/chunks/mermaid-yaml-runtime-KZVU74WU.js +136 -0
- package/dist/zenuml/chunks/render-core-V5RQ737O.js +3 -0
- package/dist/zenuml/chunks/zenuml-EA2ZFRUX.js +20 -0
- package/dist/zenuml-frame.global.js +3626 -0
- package/dist/zenuml.d.ts +83 -0
- package/dist/zenuml.js +1 -0
- package/docs/MCP-DIRECTORY-LISTINGS.md +5 -1
- package/docs/README.md +59 -103
- package/docs/agent-api-cookbook.md +26 -16
- package/docs/agent-mutation-policy.md +86 -15
- package/docs/agent-workflow-examples.md +1 -1
- package/docs/api-advanced.md +385 -0
- package/docs/api.md +320 -366
- package/docs/ascii.md +40 -4
- package/docs/browser.md +46 -7
- package/docs/choosing-a-diagram.md +148 -0
- package/docs/code-mode-impact.md +1 -0
- package/docs/comparison.md +244 -28
- package/docs/computational-aesthetics-prototype-plan.md +10 -10
- package/docs/config.md +60 -2
- package/docs/custom-fonts.md +78 -21
- package/docs/diagram-families.md +160 -10
- package/docs/eventmodeling-and-zenuml.md +165 -0
- package/docs/features.md +21 -19
- package/docs/fork-differences.md +105 -32
- package/docs/getting-started.md +56 -51
- package/docs/layout-certification.md +126 -0
- package/docs/mcp-code-mode-rationale.md +20 -12
- package/docs/mcp-http-transport.md +14 -8
- package/docs/quality.md +145 -15
- package/docs/react.md +76 -31
- package/docs/style-authoring.md +23 -11
- package/docs/svg-semantic-contract.md +104 -4
- package/docs/testing-strategy.md +684 -126
- package/docs/theming.md +27 -8
- package/examples/styles/readme-hero.md +25 -0
- package/examples/styles/readme-hero.mmd +13 -0
- package/examples/styles/readme-hero.style.json +7 -0
- package/package.json +114 -57
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +26 -8
- package/skills/agentic-mermaid-diagram-workflow/references/cli.md +13 -3
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +2 -1
- package/skills/agentic-mermaid-diagram-workflow/references/flowchart.md +9 -6
- package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +1 -0
- package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +4 -3
- package/skills/agentic-mermaid-diagram-workflow/references/timeline.md +7 -6
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/agentflow.md +574 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/architecture.md +10 -2
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/c4.md +18 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/classDiagram.md +123 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/cynefin.md +6 -1
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/entityRelationshipDiagram.md +129 -9
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/eventmodeling.md +22 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/flowchart.md +188 -60
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/gitgraph.md +13 -7
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/mindmap.md +110 -1
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/packet.md +38 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/requirementDiagram.md +115 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/sequenceDiagram.md +101 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/stateDiagram.md +87 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/swimlanes.md +105 -2
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/timeline.md +12 -6
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/usecase.md +953 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/venn.md +77 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/xyChart.md +1 -1
- package/dist/browser-lazy/chunks/architecture-KTHE2HX3.js +0 -31
- package/dist/browser-lazy/chunks/chunk-2XCPFAD5.js +0 -46
- package/dist/browser-lazy/chunks/chunk-3H4F7RBT.js +0 -1
- package/dist/browser-lazy/chunks/chunk-4EVLW2NJ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-5Q4S74UO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-6OAPWSDO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-A7L4WWVW.js +0 -143
- package/dist/browser-lazy/chunks/chunk-C7FJO2I3.js +0 -4
- package/dist/browser-lazy/chunks/chunk-D3XXDKIO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-DXA5WL7H.js +0 -4
- package/dist/browser-lazy/chunks/chunk-EPFMQPXX.js +0 -1
- package/dist/browser-lazy/chunks/chunk-FFOHLPDA.js +0 -2
- package/dist/browser-lazy/chunks/chunk-FLD63DXE.js +0 -2
- package/dist/browser-lazy/chunks/chunk-G6OLSHRG.js +0 -7
- package/dist/browser-lazy/chunks/chunk-GRXCKTHX.js +0 -0
- package/dist/browser-lazy/chunks/chunk-I6VE56S7.js +0 -1
- package/dist/browser-lazy/chunks/chunk-KJVNXJ5Y.js +0 -1
- package/dist/browser-lazy/chunks/chunk-L227EPFP.js +0 -11
- package/dist/browser-lazy/chunks/chunk-LNIHDJSF.js +0 -1
- package/dist/browser-lazy/chunks/chunk-M6BT2HIP.js +0 -1
- package/dist/browser-lazy/chunks/chunk-NZRUMODH.js +0 -1
- package/dist/browser-lazy/chunks/chunk-OFRMKQA6.js +0 -1
- package/dist/browser-lazy/chunks/chunk-P7HMSKHJ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-PXKL3O6H.js +0 -1
- package/dist/browser-lazy/chunks/chunk-PZEWZT35.js +0 -1
- package/dist/browser-lazy/chunks/chunk-STQRDZ67.js +0 -1
- package/dist/browser-lazy/chunks/chunk-SUFMSWTX.js +0 -1
- package/dist/browser-lazy/chunks/chunk-T7IJ6V4B.js +0 -3
- package/dist/browser-lazy/chunks/chunk-UAEZO5VL.js +0 -1
- package/dist/browser-lazy/chunks/chunk-WEUWIFG3.js +0 -1
- package/dist/browser-lazy/chunks/chunk-X64T74C5.js +0 -24
- package/dist/browser-lazy/chunks/class-F7R6TJ73.js +0 -9
- package/dist/browser-lazy/chunks/er-BDK7CM5L.js +0 -9
- package/dist/browser-lazy/chunks/flowchart-KFU6XV7S.js +0 -4
- package/dist/browser-lazy/chunks/gantt-I64VVDSP.js +0 -28
- package/dist/browser-lazy/chunks/gitgraph-EDUVJ5IJ.js +0 -8
- package/dist/browser-lazy/chunks/journey-TLO2RNM3.js +0 -40
- package/dist/browser-lazy/chunks/mindmap-OJCNDYPM.js +0 -9
- package/dist/browser-lazy/chunks/pie-HVG6XO7K.js +0 -19
- package/dist/browser-lazy/chunks/quadrant-U6S2L4MJ.js +0 -24
- package/dist/browser-lazy/chunks/radar-ZDLOBTVG.js +0 -32
- package/dist/browser-lazy/chunks/render-core-Y2DFNMQG.js +0 -12
- package/dist/browser-lazy/chunks/sequence-Z4WFS3VB.js +0 -12
- package/dist/browser-lazy/chunks/state-2HV2YGN3.js +0 -4
- package/dist/browser-lazy/chunks/timeline-XM4UFPOC.js +0 -20
- package/dist/browser-lazy/chunks/xychart-7JDHWTQY.js +0 -36
- package/dist/chunk-GGXCNCNA.js +0 -4118
- package/dist/chunk-IVD4NXNE.js +0 -615
- package/dist/chunk-JDMRPUAG.js +0 -37
- package/dist/chunk-JWAAW3FH.js +0 -149
- package/dist/chunk-LCGBT32P.js +0 -62036
- package/dist/chunk-RWMZRUIC.js +0 -4715
- package/dist/mcp-cli-4MLKC3ZH.js +0 -17
- package/docs/mutation-testing.md +0 -285
|
@@ -0,0 +1,1223 @@
|
|
|
1
|
+
import { e8 as PrimitiveCapabilityClaim, e9 as OUTPUT_SECURITY_POLICY_VERSION, cu as SceneNode, ct as SceneDoc, cn as Result, a as ParsedDiagram, bQ as ParseError, ea as ColorMode, eb as AsciiTheme, b0 as FamilyId, e6 as TerminalProjectionDiagnostic, R as RenderRequestReceipt, ec as ResolvedTerminalStyle, ed as MindmapDiagram, ee as GitGraphDiagram, cG as SourcePreservationReceipt, cv as SemanticChannels, ae as ConnectorGeometry, ef as MarkPaint, eg as ConnectorDirection, ag as ConnectorLabelDescriptor, eh as Geometry, bE as MarkerDescriptor, ah as ConnectorMark, ei as ScenePoint, ej as LinearGradientDescriptor, T as TextMeasurementProfile } from './paint-certification-6rwQjIv_.js';
|
|
2
|
+
import { R as RenderOptions, H as MermaidRuntimeConfig, q as DiagramColors, w as MermaidGraph } from './types-BcS52Mjt.js';
|
|
3
|
+
import { k as ExtensionIdentity, C as StyleSpec, V as ExtensionCompatibility, W as ExtensionProvenance, t as SceneRole } from './svg-styles-BdnoM7AT.js';
|
|
4
|
+
|
|
5
|
+
/** Numeric wire version and semantic compatibility version from one source. */
|
|
6
|
+
declare const SCENE_CONTRACT_VERSION: 2;
|
|
7
|
+
|
|
8
|
+
type RubricMetric = 'hard' | 'crossings' | 'bends' | 'straight' | 'portRate' | 'symErr' | 'parallelOverlaps' | 'endpointApproaches' | 'opposingOverlaps';
|
|
9
|
+
/** A broken pass contract must escape candidate fallback unchanged. */
|
|
10
|
+
declare class LayoutPassContractError extends Error {
|
|
11
|
+
readonly pass: string;
|
|
12
|
+
readonly contract: 'ordering' | 'freeze' | 'certificate' | 'measurement' | 'metric-budget';
|
|
13
|
+
readonly code: string;
|
|
14
|
+
constructor(pass: string, contract: 'ordering' | 'freeze' | 'certificate' | 'measurement' | 'metric-budget', message: string);
|
|
15
|
+
}
|
|
16
|
+
/** A pass exceeded its declared allowance on the geometry it actually produced. */
|
|
17
|
+
declare class LayoutMetricBudgetError extends LayoutPassContractError {
|
|
18
|
+
readonly metric: RubricMetric;
|
|
19
|
+
readonly before: number;
|
|
20
|
+
readonly after: number;
|
|
21
|
+
readonly allowance: number;
|
|
22
|
+
readonly code = "LAYOUT_METRIC_BUDGET_EXCEEDED";
|
|
23
|
+
constructor(pass: string, metric: RubricMetric, before: number, after: number, allowance: number);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LayoutCertificationAttempt {
|
|
27
|
+
strategy: string;
|
|
28
|
+
violations: string[];
|
|
29
|
+
}
|
|
30
|
+
/** Shared by graph certification and the family-neutral final geometry veto. */
|
|
31
|
+
declare class LayoutCertificationError extends Error {
|
|
32
|
+
readonly attempts: readonly LayoutCertificationAttempt[];
|
|
33
|
+
readonly code = "LAYOUT_CERTIFICATION_FAILED";
|
|
34
|
+
constructor(attempts: readonly LayoutCertificationAttempt[]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare const BACKEND_CONFORMANCE_VERSION: 4;
|
|
38
|
+
declare const BACKEND_CONFORMANCE_FIXTURE_ID: "backend-claim-matrix@4";
|
|
39
|
+
declare const BACKEND_CONFORMANCE_CHECK_IDS: readonly ["draw-node-determinism", "draw-node-semantics", "document-determinism", "single-svg-document", "finite-serialization", "output-security", "document-semantics", "container-semantics", "shape-semantics", "text-semantics", "connector-semantics", "marker-semantics", "data-mark-semantics", "capability-claims"];
|
|
40
|
+
type BackendConformanceCheckId = (typeof BACKEND_CONFORMANCE_CHECK_IDS)[number];
|
|
41
|
+
interface BackendConformanceCheck {
|
|
42
|
+
readonly id: BackendConformanceCheckId;
|
|
43
|
+
readonly passed: boolean;
|
|
44
|
+
readonly diagnostic?: string;
|
|
45
|
+
}
|
|
46
|
+
type BackendCapabilityConformanceStatus = 'passed' | 'failed' | 'unverified-extension';
|
|
47
|
+
/** A flattened, JSON-safe result for one exact declared claim. */
|
|
48
|
+
interface BackendCapabilityConformanceResult {
|
|
49
|
+
readonly claimKey: string;
|
|
50
|
+
readonly target: string;
|
|
51
|
+
readonly primitive: PrimitiveCapabilityClaim['primitive'];
|
|
52
|
+
readonly feature: PrimitiveCapabilityClaim['feature'];
|
|
53
|
+
readonly operation: PrimitiveCapabilityClaim['operation'];
|
|
54
|
+
readonly realization: PrimitiveCapabilityClaim['realization'];
|
|
55
|
+
/** The declaration's required explanation for a lossy/unsupported cell. */
|
|
56
|
+
readonly limitation?: string;
|
|
57
|
+
/** Stable executable witness identity; absent only for namespaced extensions. */
|
|
58
|
+
readonly witnessId?: string;
|
|
59
|
+
readonly status: BackendCapabilityConformanceStatus;
|
|
60
|
+
readonly observation?: string;
|
|
61
|
+
/** Failure/unverified explanation, distinct from the declared limitation. */
|
|
62
|
+
readonly diagnostic?: string;
|
|
63
|
+
}
|
|
64
|
+
interface BackendConformanceReport {
|
|
65
|
+
readonly version: typeof BACKEND_CONFORMANCE_VERSION;
|
|
66
|
+
readonly fixtureId: typeof BACKEND_CONFORMANCE_FIXTURE_ID;
|
|
67
|
+
readonly backendId: string;
|
|
68
|
+
readonly contracts: {
|
|
69
|
+
readonly scene: typeof SCENE_CONTRACT_VERSION;
|
|
70
|
+
readonly outputSecurity: typeof OUTPUT_SECURITY_POLICY_VERSION;
|
|
71
|
+
};
|
|
72
|
+
/** StyleBackend is an SVG consumer/serializer; PNG is a downstream adapter. */
|
|
73
|
+
readonly directOutputs: readonly ['svg'];
|
|
74
|
+
readonly passed: boolean;
|
|
75
|
+
readonly checks: readonly BackendConformanceCheck[];
|
|
76
|
+
readonly claims: readonly BackendCapabilityConformanceResult[];
|
|
77
|
+
}
|
|
78
|
+
/** Execute the frozen document and claim fixtures against a backend. */
|
|
79
|
+
declare function runBackendConformance(backend: StyleBackend, canonicalId?: string): BackendConformanceReport;
|
|
80
|
+
|
|
81
|
+
interface StyleBackendContext {
|
|
82
|
+
/** User-supplied deterministic re-roll seed (RenderOptions.seed). */
|
|
83
|
+
seed: number;
|
|
84
|
+
/** The selected style (undefined on the default path). */
|
|
85
|
+
style?: StyleSpec;
|
|
86
|
+
}
|
|
87
|
+
interface StyleBackend {
|
|
88
|
+
id: string;
|
|
89
|
+
/** Versioned, feature/operation-level support claims for this Scene consumer. */
|
|
90
|
+
readonly capabilities: readonly PrimitiveCapabilityClaim[];
|
|
91
|
+
/** Serialize one top-level mark (recursing through groups). */
|
|
92
|
+
drawNode(node: SceneNode, ctx: StyleBackendContext): string;
|
|
93
|
+
/** Serialize the whole document. */
|
|
94
|
+
render(doc: SceneDoc, ctx: StyleBackendContext): string;
|
|
95
|
+
}
|
|
96
|
+
interface BackendRegistrationOptions {
|
|
97
|
+
readonly version?: string;
|
|
98
|
+
readonly compatibility: ExtensionCompatibility & {
|
|
99
|
+
readonly core: string;
|
|
100
|
+
readonly scene: string;
|
|
101
|
+
};
|
|
102
|
+
readonly provenance?: ExtensionProvenance;
|
|
103
|
+
}
|
|
104
|
+
interface BackendDescriptor {
|
|
105
|
+
readonly identity: ExtensionIdentity<'backend'>;
|
|
106
|
+
readonly backend: StyleBackend;
|
|
107
|
+
/** Stable preferred input for first-party backends. */
|
|
108
|
+
readonly inputName: string;
|
|
109
|
+
/** Claim-keyed executable SVG conformance: run at registration for a host
|
|
110
|
+
* backend, and at first use (draw, render or this read) for a built-in. */
|
|
111
|
+
readonly conformance: BackendConformanceReport;
|
|
112
|
+
}
|
|
113
|
+
interface HostBackendSelection {
|
|
114
|
+
/** Backend capability inferred from declarative appearance. */
|
|
115
|
+
readonly requestedId: string;
|
|
116
|
+
/** Canonical registry identity, when the requested backend is registered. */
|
|
117
|
+
readonly canonicalId?: string;
|
|
118
|
+
readonly registered: readonly BackendDescriptor[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Trusted, in-process backend selection escape hatch. The callback makes this
|
|
122
|
+
* capability non-serializable by construction: it cannot enter StyleSpec,
|
|
123
|
+
* BrandPack, CLI, MCP, or editor payloads.
|
|
124
|
+
*/
|
|
125
|
+
interface HostBackendPolicy {
|
|
126
|
+
readonly selectBackend: (selection: HostBackendSelection) => string | null | undefined;
|
|
127
|
+
}
|
|
128
|
+
declare const DefaultBackend: StyleBackend;
|
|
129
|
+
/** Register a host backend by canonical `backend:*` identity. */
|
|
130
|
+
declare function registerBackend(backend: StyleBackend, options: BackendRegistrationOptions): () => void;
|
|
131
|
+
declare function knownBackendDescriptors(): readonly BackendDescriptor[];
|
|
132
|
+
declare function getBackend(id: string, policy?: HostBackendPolicy): StyleBackend | undefined;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The internal color waist: every public color dialect is normalized to
|
|
136
|
+
* DiagramColors before layout/render code sees it.
|
|
137
|
+
*/
|
|
138
|
+
declare function resolveDiagramColors(options: RenderOptions, config: MermaidRuntimeConfig, font?: string, preserveUnsafeThemePaints?: boolean): DiagramColors;
|
|
139
|
+
|
|
140
|
+
/** Descriptor-dispatched parser with a forward-compatible extension envelope. */
|
|
141
|
+
declare function parseRegisteredMermaid(source: string): Result<ParsedDiagram, ParseError[]>;
|
|
142
|
+
|
|
143
|
+
/** Tiny shared evidence constants. Keeping these separate prevents an SVG-only
|
|
144
|
+
* entry from importing the executable PNG and terminal policy graphs merely
|
|
145
|
+
* to describe the complete public output matrix. */
|
|
146
|
+
declare const PNG_OUTPUT_POLICY_VERSION: 4;
|
|
147
|
+
declare const TERMINAL_OUTPUT_POLICY_VERSION: 1;
|
|
148
|
+
/** Logical PNG projection scale shared with lightweight CLI help. */
|
|
149
|
+
declare const PNG_DEFAULT_SCALE: 2;
|
|
150
|
+
|
|
151
|
+
/** Logical terminal projection policy shared by every ASCII/Unicode/HTML adapter. */
|
|
152
|
+
declare const TERMINAL_DEFAULT_PADDING_X: 5;
|
|
153
|
+
declare const TERMINAL_BOUNDED_PADDING_X: 1;
|
|
154
|
+
declare const TERMINAL_DEFAULT_PADDING_Y: 5;
|
|
155
|
+
declare const TERMINAL_DEFAULT_BOX_BORDER_PADDING: 1;
|
|
156
|
+
type AsciiRenderColorMode = ColorMode | 'auto';
|
|
157
|
+
interface TerminalOutputPolicyInput {
|
|
158
|
+
useAscii?: boolean;
|
|
159
|
+
paddingX?: number;
|
|
160
|
+
paddingY?: number;
|
|
161
|
+
boxBorderPadding?: number;
|
|
162
|
+
colorMode?: AsciiRenderColorMode;
|
|
163
|
+
theme?: Partial<AsciiTheme>;
|
|
164
|
+
maxWidth?: number;
|
|
165
|
+
targetWidth?: number;
|
|
166
|
+
}
|
|
167
|
+
interface ResolvedTerminalOutputPolicy {
|
|
168
|
+
readonly version: typeof TERMINAL_OUTPUT_POLICY_VERSION;
|
|
169
|
+
readonly useAscii: boolean;
|
|
170
|
+
readonly paddingX: number;
|
|
171
|
+
readonly paddingY: number;
|
|
172
|
+
readonly boxBorderPadding: number;
|
|
173
|
+
/** `auto` is resolved at the request boundary; execution never re-detects it. */
|
|
174
|
+
readonly colorMode: ColorMode;
|
|
175
|
+
/** Structurally validated overrides. Paint safety is projected with diagnostics. */
|
|
176
|
+
readonly theme: Readonly<Partial<AsciiTheme>>;
|
|
177
|
+
readonly maxWidth?: number;
|
|
178
|
+
readonly targetWidth?: number;
|
|
179
|
+
}
|
|
180
|
+
declare class TerminalOutputPolicyError extends TypeError {
|
|
181
|
+
readonly code: 'INVALID_INPUT' | 'INVALID_FIELD' | 'WIDTH_CONFLICT';
|
|
182
|
+
constructor(code: 'INVALID_INPUT' | 'INVALID_FIELD' | 'WIDTH_CONFLICT', message: string);
|
|
183
|
+
}
|
|
184
|
+
/** Normalize terminal controls and defaults before either hashing or execution. */
|
|
185
|
+
declare function resolveTerminalOutputPolicy(input?: TerminalOutputPolicyInput): ResolvedTerminalOutputPolicy;
|
|
186
|
+
|
|
187
|
+
type AsciiWidthErrorReason = 'UNBREAKABLE_GRAPHEME' | 'MINIMUM_GEOMETRY' | 'INVALID_WIDTH';
|
|
188
|
+
declare class AsciiWidthError extends Error {
|
|
189
|
+
readonly requestedWidth: number;
|
|
190
|
+
readonly requiredWidth: number;
|
|
191
|
+
readonly family: FamilyId;
|
|
192
|
+
readonly reason: AsciiWidthErrorReason;
|
|
193
|
+
readonly code = "ASCII_TARGET_WIDTH_IMPOSSIBLE";
|
|
194
|
+
constructor(requestedWidth: number, requiredWidth: number, family: FamilyId, reason: AsciiWidthErrorReason);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
interface AsciiRenderOptions extends RenderOptions, TerminalOutputPolicyInput {
|
|
198
|
+
/** true = ASCII chars (+,-,|,>), false = Unicode box-drawing (┌,─,│,►). Default: false */
|
|
199
|
+
useAscii?: boolean;
|
|
200
|
+
/** Horizontal spacing between nodes. Default: 5 */
|
|
201
|
+
paddingX?: number;
|
|
202
|
+
/** Vertical spacing between nodes. Default: 5 */
|
|
203
|
+
paddingY?: number;
|
|
204
|
+
/** Padding inside node boxes. Default: 1 */
|
|
205
|
+
boxBorderPadding?: number;
|
|
206
|
+
/**
|
|
207
|
+
* Color mode for output.
|
|
208
|
+
* - 'none': No colors (plain text)
|
|
209
|
+
* - 'auto': Auto-detect (terminal ANSI capabilities, or HTML in browsers)
|
|
210
|
+
* - 'ansi16': 16-color ANSI
|
|
211
|
+
* - 'ansi256': 256-color xterm
|
|
212
|
+
* - 'truecolor': 24-bit RGB
|
|
213
|
+
* - 'html': HTML <span> tags with inline color styles (for browser rendering)
|
|
214
|
+
* Default: 'auto'
|
|
215
|
+
*/
|
|
216
|
+
colorMode?: ColorMode | 'auto';
|
|
217
|
+
/** Theme colors for ASCII output. Uses default theme if not provided. */
|
|
218
|
+
theme?: Partial<AsciiTheme>;
|
|
219
|
+
/**
|
|
220
|
+
* Loop 9 M13: cap output width in characters. When set, node labels wrap
|
|
221
|
+
* at word boundaries to fit within `maxWidth / 3` per node. Single words
|
|
222
|
+
* longer than `maxWidth / 2` render anyway (with a console.warn). The
|
|
223
|
+
* overall canvas may still exceed `maxWidth` if the diagram has many
|
|
224
|
+
* parallel columns; this is best-effort wrapping, not hard truncation.
|
|
225
|
+
*/
|
|
226
|
+
maxWidth?: number;
|
|
227
|
+
/** Hard maximum output width in terminal display cells. */
|
|
228
|
+
targetWidth?: number;
|
|
229
|
+
/** Receives explicit graphical-to-terminal projection losses. */
|
|
230
|
+
onProjectionDiagnostic?: (diagnostic: TerminalProjectionDiagnostic) => void;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Render Mermaid diagram text to an ASCII/Unicode string.
|
|
234
|
+
*
|
|
235
|
+
* Synchronous — no async layout engine needed (unlike the SVG renderer).
|
|
236
|
+
* Auto-detects diagram type from the header line and dispatches to
|
|
237
|
+
* the appropriate renderer.
|
|
238
|
+
*
|
|
239
|
+
* @param text - Mermaid source text (any supported diagram type)
|
|
240
|
+
* @param options - Rendering options
|
|
241
|
+
* @returns Multi-line ASCII/Unicode string
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* const result = renderMermaidASCII(`
|
|
246
|
+
* graph LR
|
|
247
|
+
* A --> B --> C
|
|
248
|
+
* `, { useAscii: true })
|
|
249
|
+
*
|
|
250
|
+
* // Output:
|
|
251
|
+
* // +---+ +---+ +---+
|
|
252
|
+
* // | | | | | |
|
|
253
|
+
* // | A |---->| B |---->| C |
|
|
254
|
+
* // | | | | | |
|
|
255
|
+
* // +---+ +---+ +---+
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function renderMermaidASCII(text: ParsedDiagram | string, options?: AsciiRenderOptions): string;
|
|
259
|
+
interface RenderedAscii {
|
|
260
|
+
text: string;
|
|
261
|
+
receipt: RenderRequestReceipt;
|
|
262
|
+
terminalStyle: ResolvedTerminalStyle;
|
|
263
|
+
outputPolicy: ResolvedTerminalOutputPolicy;
|
|
264
|
+
}
|
|
265
|
+
declare function renderMermaidASCIIWithReceipt(input: ParsedDiagram | string, options?: AsciiRenderOptions): RenderedAscii;
|
|
266
|
+
|
|
267
|
+
type ArchitectureAlignmentAxis = 'row' | 'column';
|
|
268
|
+
interface ArchitectureAlignment {
|
|
269
|
+
axis: ArchitectureAlignmentAxis;
|
|
270
|
+
/** Declared services/junctions, in source order (≥2, unique per directive). */
|
|
271
|
+
members: string[];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
type ArchitectureSide = 'L' | 'R' | 'T' | 'B';
|
|
275
|
+
type ArchitectureEndpointBoundary = 'item' | 'group';
|
|
276
|
+
interface ArchitectureChildRef {
|
|
277
|
+
kind: 'group' | 'service' | 'junction';
|
|
278
|
+
id: string;
|
|
279
|
+
}
|
|
280
|
+
interface ArchitectureGroup {
|
|
281
|
+
id: string;
|
|
282
|
+
label: string;
|
|
283
|
+
icon?: string;
|
|
284
|
+
parentId?: string;
|
|
285
|
+
children: ArchitectureChildRef[];
|
|
286
|
+
}
|
|
287
|
+
interface ArchitectureService {
|
|
288
|
+
id: string;
|
|
289
|
+
label: string;
|
|
290
|
+
icon?: string;
|
|
291
|
+
/** Literal STRING icon, distinct from a bundled icon name. */
|
|
292
|
+
iconText?: string;
|
|
293
|
+
parentId?: string;
|
|
294
|
+
}
|
|
295
|
+
interface ArchitectureJunction {
|
|
296
|
+
id: string;
|
|
297
|
+
parentId?: string;
|
|
298
|
+
}
|
|
299
|
+
interface ArchitectureEndpoint {
|
|
300
|
+
id: string;
|
|
301
|
+
side: ArchitectureSide;
|
|
302
|
+
boundary: ArchitectureEndpointBoundary;
|
|
303
|
+
}
|
|
304
|
+
interface ArchitectureEdge {
|
|
305
|
+
source: ArchitectureEndpoint;
|
|
306
|
+
target: ArchitectureEndpoint;
|
|
307
|
+
label?: string;
|
|
308
|
+
hasArrowStart: boolean;
|
|
309
|
+
hasArrowEnd: boolean;
|
|
310
|
+
}
|
|
311
|
+
interface ArchitectureDiagram {
|
|
312
|
+
/** Visible diagram heading from `title ...` (distinct from accTitle). */
|
|
313
|
+
title?: string;
|
|
314
|
+
groups: ArchitectureGroup[];
|
|
315
|
+
services: ArchitectureService[];
|
|
316
|
+
junctions: ArchitectureJunction[];
|
|
317
|
+
edges: ArchitectureEdge[];
|
|
318
|
+
/**
|
|
319
|
+
* `align row|column` directives (upstream v11.16.0), in source order.
|
|
320
|
+
* Parsed, preserved, and honored as deterministic placement constraints.
|
|
321
|
+
*/
|
|
322
|
+
alignments: ArchitectureAlignment[];
|
|
323
|
+
rootChildren: ArchitectureChildRef[];
|
|
324
|
+
accessibilityTitle?: string;
|
|
325
|
+
accessibilityDescription?: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
declare function parseArchitectureDiagram(lines: string[]): ArchitectureDiagram;
|
|
329
|
+
declare function architectureToMermaidGraph(diagram: ArchitectureDiagram): MermaidGraph;
|
|
330
|
+
|
|
331
|
+
declare class MindmapParseError extends Error {
|
|
332
|
+
readonly line?: number | undefined;
|
|
333
|
+
constructor(message: string, line?: number | undefined);
|
|
334
|
+
}
|
|
335
|
+
declare class MindmapDuplicateIdError extends MindmapParseError {
|
|
336
|
+
readonly id: string;
|
|
337
|
+
readonly code = "MINDMAP_DUPLICATE_ID";
|
|
338
|
+
constructor(id: string, line: number);
|
|
339
|
+
}
|
|
340
|
+
/** Parse the indentation-sensitive source from the untrimmed normalized body. */
|
|
341
|
+
declare function parseMindmap(source: string): MindmapDiagram;
|
|
342
|
+
declare function serializeMindmap(diagram: MindmapDiagram): string;
|
|
343
|
+
|
|
344
|
+
declare class GitGraphParseError extends Error {
|
|
345
|
+
readonly line?: number | undefined;
|
|
346
|
+
constructor(message: string, line?: number | undefined);
|
|
347
|
+
}
|
|
348
|
+
declare class GitGraphDuplicateCommitError extends GitGraphParseError {
|
|
349
|
+
readonly id: string;
|
|
350
|
+
readonly code = "GITGRAPH_DUPLICATE_COMMIT_ID";
|
|
351
|
+
constructor(id: string, line: number);
|
|
352
|
+
}
|
|
353
|
+
interface GitGraphParseOptions {
|
|
354
|
+
mainBranchName?: string;
|
|
355
|
+
mainBranchOrder?: number;
|
|
356
|
+
title?: string;
|
|
357
|
+
}
|
|
358
|
+
declare function parseGitGraph(source: string, options?: GitGraphParseOptions): GitGraphDiagram;
|
|
359
|
+
declare function serializeGitGraph(diagram: GitGraphDiagram): string;
|
|
360
|
+
|
|
361
|
+
interface ResolvedArchitectureIcon {
|
|
362
|
+
canonicalName: `mdi:${string}`;
|
|
363
|
+
viewBox: '0 0 24 24';
|
|
364
|
+
path: string;
|
|
365
|
+
source: '@iconify-json/mdi@1.2.3';
|
|
366
|
+
license: 'Apache-2.0';
|
|
367
|
+
}
|
|
368
|
+
declare const ARCHITECTURE_ICON_LIMITS: Readonly<{
|
|
369
|
+
maxIcons: 32;
|
|
370
|
+
maxNameBytes: 128;
|
|
371
|
+
maxPathBytes: 4096;
|
|
372
|
+
}>;
|
|
373
|
+
declare function resolveArchitectureIcon(icon: string): ResolvedArchitectureIcon | null;
|
|
374
|
+
/** Read-only test/docs manifest; callers cannot mutate the registry. */
|
|
375
|
+
declare function architectureIconManifest(): readonly ResolvedArchitectureIcon[];
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Measure the pixel width of a text string.
|
|
379
|
+
*
|
|
380
|
+
* Uses character class buckets for more accurate width estimation
|
|
381
|
+
* than uniform character width assumptions.
|
|
382
|
+
*
|
|
383
|
+
* @param text - The text to measure
|
|
384
|
+
* @param fontSize - Font size in pixels
|
|
385
|
+
* @param fontWeight - Font weight (affects width slightly)
|
|
386
|
+
* @returns Estimated width in pixels
|
|
387
|
+
*/
|
|
388
|
+
interface TextMeasurementContract {
|
|
389
|
+
version: 4;
|
|
390
|
+
unit: 'px';
|
|
391
|
+
fontCalibration: 'Inter-compatible proportional estimate';
|
|
392
|
+
monospaceCalibration: '0.6em-per-cell';
|
|
393
|
+
wideCodepoints: 'src/shared/unicode-ranges.ts';
|
|
394
|
+
emojiDetection: 'Emoji_Presentation-or-Extended_Pictographic';
|
|
395
|
+
ambiguousWidth: 'single-cell';
|
|
396
|
+
paintedAdvanceProjection: 'prepared-positions-or-svg-textLength-spacingAndGlyphs';
|
|
397
|
+
naturalAdvanceExemptions: 'prepared-non-ascii-shaping-runs';
|
|
398
|
+
}
|
|
399
|
+
declare const TEXT_MEASUREMENT_CONTRACT: TextMeasurementContract;
|
|
400
|
+
interface TextMeasurementInput {
|
|
401
|
+
text: string;
|
|
402
|
+
fontSize: number;
|
|
403
|
+
fontWeight: number;
|
|
404
|
+
fontStyle?: 'normal' | 'italic';
|
|
405
|
+
fontFamily?: string;
|
|
406
|
+
}
|
|
407
|
+
interface TextMeasurementResult {
|
|
408
|
+
contract: TextMeasurementContract;
|
|
409
|
+
width: number;
|
|
410
|
+
charWidthUnits: number;
|
|
411
|
+
codePointCount: number;
|
|
412
|
+
fontSize: number;
|
|
413
|
+
fontWeight: number;
|
|
414
|
+
baseRatio: number;
|
|
415
|
+
minPadding: number;
|
|
416
|
+
}
|
|
417
|
+
declare function measureText(input: TextMeasurementInput): TextMeasurementResult;
|
|
418
|
+
declare function measureTextWidth(text: string, fontSize: number, fontWeight: number, fontStyle?: 'normal' | 'italic', fontFamily?: string): number;
|
|
419
|
+
|
|
420
|
+
/** Optional synchronous observation at native parser consumption/build boundaries.
|
|
421
|
+
* Events describe each parser's own language; their kinds are not Mermaid's
|
|
422
|
+
* lexer token numbers or its yy method protocol.
|
|
423
|
+
*/
|
|
424
|
+
interface ParserObservationSource {
|
|
425
|
+
line?: number;
|
|
426
|
+
column?: number;
|
|
427
|
+
offset?: number;
|
|
428
|
+
endOffset?: number;
|
|
429
|
+
/** Coordinates refer to supplied physical text or a parser's normalized view. */
|
|
430
|
+
unit?: 'physical' | 'normalized';
|
|
431
|
+
}
|
|
432
|
+
type ParserObservationValue = null | boolean | number | string | ParserObservationValue[] | {
|
|
433
|
+
[key: string]: ParserObservationValue;
|
|
434
|
+
};
|
|
435
|
+
interface ParserObservation {
|
|
436
|
+
family: string;
|
|
437
|
+
unit: 'token' | 'statement' | 'mutation';
|
|
438
|
+
kind: string;
|
|
439
|
+
text?: string;
|
|
440
|
+
value?: ParserObservationValue;
|
|
441
|
+
source?: ParserObservationSource;
|
|
442
|
+
}
|
|
443
|
+
type ParserObserver = (event: Readonly<ParserObservation>) => void;
|
|
444
|
+
/** Nested scopes replace, then restore, their caller's observer. Async work is
|
|
445
|
+
* deliberately outside this contract: no parser context survives a promise.
|
|
446
|
+
*/
|
|
447
|
+
declare function withParserObservation<T>(family: string, observer: ParserObserver, parse: () => T, options?: {
|
|
448
|
+
mutations?: readonly string[];
|
|
449
|
+
}): T;
|
|
450
|
+
|
|
451
|
+
type AgenticHeaderStatus = 'native' | 'unsupported' | 'inventory-only';
|
|
452
|
+
interface UpstreamHeaderDescriptor {
|
|
453
|
+
value: string;
|
|
454
|
+
agenticStatus: AgenticHeaderStatus;
|
|
455
|
+
}
|
|
456
|
+
interface UpstreamFamilyDescriptor {
|
|
457
|
+
id: string;
|
|
458
|
+
headers: UpstreamHeaderDescriptor[];
|
|
459
|
+
}
|
|
460
|
+
/** Header routing for every public family of the pinned Mermaid version,
|
|
461
|
+
* written by scripts/generate-upstream-family-index.ts. */
|
|
462
|
+
interface UpstreamMermaidFamilyIndex {
|
|
463
|
+
schemaVersion: 2;
|
|
464
|
+
provenance: {
|
|
465
|
+
version: string;
|
|
466
|
+
};
|
|
467
|
+
families: UpstreamFamilyDescriptor[];
|
|
468
|
+
}
|
|
469
|
+
interface UpstreamHeaderMatch {
|
|
470
|
+
family: UpstreamFamilyDescriptor;
|
|
471
|
+
header: UpstreamHeaderDescriptor;
|
|
472
|
+
}
|
|
473
|
+
declare const UPSTREAM_MERMAID_FAMILY_INDEX: UpstreamMermaidFamilyIndex;
|
|
474
|
+
/** Longest-header-first lookup prevents an alias prefix claiming a dialect. */
|
|
475
|
+
declare function findUpstreamFamilyByHeader(firstLine: string, index?: Pick<UpstreamMermaidFamilyIndex, 'families'>): UpstreamHeaderMatch | null;
|
|
476
|
+
|
|
477
|
+
type MermaidFamilyClassification = {
|
|
478
|
+
kind: 'registered';
|
|
479
|
+
familyId: FamilyId;
|
|
480
|
+
} | {
|
|
481
|
+
kind: 'upstream';
|
|
482
|
+
match: UpstreamHeaderMatch;
|
|
483
|
+
} | {
|
|
484
|
+
kind: 'unknown';
|
|
485
|
+
header: string;
|
|
486
|
+
};
|
|
487
|
+
interface FamilyDetectionDiagnostic {
|
|
488
|
+
code: 'UNSUPPORTED_FAMILY' | 'UNKNOWN_HEADER' | 'FAMILY_DESCRIPTOR_MISMATCH';
|
|
489
|
+
message: string;
|
|
490
|
+
line: 1;
|
|
491
|
+
preservation: SourcePreservationReceipt;
|
|
492
|
+
help: string;
|
|
493
|
+
}
|
|
494
|
+
declare function classifyMermaidFamilyFromFirstLine(firstLine: string, mode?: 'strict' | 'loose'): MermaidFamilyClassification;
|
|
495
|
+
declare class MermaidFamilyDetectionError extends Error {
|
|
496
|
+
readonly name = "MermaidFamilyDetectionError";
|
|
497
|
+
readonly code: FamilyDetectionDiagnostic['code'];
|
|
498
|
+
readonly line: 1;
|
|
499
|
+
readonly preservation: SourcePreservationReceipt;
|
|
500
|
+
readonly help: string;
|
|
501
|
+
constructor(diagnostic: FamilyDetectionDiagnostic);
|
|
502
|
+
toJSON(): FamilyDetectionDiagnostic;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Increment when a resolved field changes meaning or is removed. */
|
|
506
|
+
declare const RESOLVED_SCENE_VERSION: 2;
|
|
507
|
+
type Matrix = [a: number, b: number, c: number, d: number, e: number, f: number];
|
|
508
|
+
interface ResolvedScene {
|
|
509
|
+
version: typeof RESOLVED_SCENE_VERSION;
|
|
510
|
+
/** Registered family of the input diagram, independent of shared Scene lowering. */
|
|
511
|
+
family: string;
|
|
512
|
+
width: number;
|
|
513
|
+
height: number;
|
|
514
|
+
/** Byte-identical to renderMermaidSVG with the same input and options. */
|
|
515
|
+
svg: string;
|
|
516
|
+
colors: DiagramColors;
|
|
517
|
+
/** Identified Scene parts paired with the artwork painted for each part. */
|
|
518
|
+
parts: ResolvedPart[];
|
|
519
|
+
/** Resolved primitives outside those parts, including style backdrops. */
|
|
520
|
+
frame: ResolvedPrimitive[];
|
|
521
|
+
}
|
|
522
|
+
/** One Scene part and its backend-painted paths/text; not a source node. */
|
|
523
|
+
interface ResolvedPart {
|
|
524
|
+
/** Scene part ID; source-facing identity, when available, is node.identity. */
|
|
525
|
+
id: string;
|
|
526
|
+
role: SceneRole;
|
|
527
|
+
kind: SceneNode['kind'];
|
|
528
|
+
node: SceneNode;
|
|
529
|
+
primitives: ResolvedPrimitive[];
|
|
530
|
+
}
|
|
531
|
+
/** A painted path or text run, distinct from pre-paint Scene geometry.
|
|
532
|
+
* No independent stable ID. Entries in part.primitives are part-associated;
|
|
533
|
+
* entries in scene.frame have no containing part. */
|
|
534
|
+
type ResolvedPrimitive = ResolvedPath | ResolvedText;
|
|
535
|
+
interface ResolvedPaint {
|
|
536
|
+
fill: string;
|
|
537
|
+
fillOpacity: number;
|
|
538
|
+
stroke: string;
|
|
539
|
+
strokeOpacity: number;
|
|
540
|
+
strokeWidth: number;
|
|
541
|
+
opacity: number;
|
|
542
|
+
lineCap: 'butt' | 'round' | 'square';
|
|
543
|
+
lineJoin: 'miter' | 'round' | 'bevel' | 'arcs' | 'miter-clip';
|
|
544
|
+
miterLimit: number;
|
|
545
|
+
fillRule: 'nonzero' | 'evenodd';
|
|
546
|
+
paintOrder: string;
|
|
547
|
+
dashArray?: number[];
|
|
548
|
+
dashOffset?: number;
|
|
549
|
+
}
|
|
550
|
+
interface ResolvedPath {
|
|
551
|
+
kind: 'path';
|
|
552
|
+
d: string;
|
|
553
|
+
matrix: Matrix;
|
|
554
|
+
paint: ResolvedPaint;
|
|
555
|
+
marker?: true;
|
|
556
|
+
}
|
|
557
|
+
interface ResolvedText {
|
|
558
|
+
kind: 'text';
|
|
559
|
+
text: string;
|
|
560
|
+
x: number;
|
|
561
|
+
y: number;
|
|
562
|
+
fontSize: number;
|
|
563
|
+
fontFamily: string[];
|
|
564
|
+
fontWeight: number;
|
|
565
|
+
fontStyle: 'normal' | 'italic' | 'oblique';
|
|
566
|
+
anchor: 'start' | 'middle' | 'end';
|
|
567
|
+
baseline?: string;
|
|
568
|
+
textLength?: number;
|
|
569
|
+
lengthAdjust?: 'spacing' | 'spacingAndGlyphs';
|
|
570
|
+
letterSpacing?: number;
|
|
571
|
+
matrix: Matrix;
|
|
572
|
+
paint: ResolvedPaint;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Render a diagram as final backend-painted paths and text, in root user
|
|
577
|
+
* space, with no DOM, network, asynchronous work or remaining CSS dependency.
|
|
578
|
+
* Unsupported artwork fails with its owning part id instead of being omitted.
|
|
579
|
+
*/
|
|
580
|
+
declare function renderResolvedScene(text: ParsedDiagram | string, options?: RenderOptions): ResolvedScene;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Safe, declarative Scene construction for external diagram families.
|
|
584
|
+
*
|
|
585
|
+
* SVG serialization is deliberately not an input here. This compiler owns
|
|
586
|
+
* the backend-private projection so
|
|
587
|
+
* extensions cannot smuggle markup, CSS, or fetching references into a
|
|
588
|
+
* backend. The result is the same SceneDoc consumed by built-in backends; this
|
|
589
|
+
* is a construction surface, not a parallel rendering pipeline.
|
|
590
|
+
*/
|
|
591
|
+
|
|
592
|
+
/** Version of the declarative external Scene builder input contract. */
|
|
593
|
+
declare const EXTERNAL_SCENE_API_VERSION: 1;
|
|
594
|
+
type ExternalSceneGeometry = Extract<Geometry, {
|
|
595
|
+
kind: 'rect' | 'circle' | 'ellipse' | 'line' | 'polygon' | 'polyline';
|
|
596
|
+
}>;
|
|
597
|
+
/** External Scene v1 keeps connector paths to one explicitly routed linear
|
|
598
|
+
* M/L[/Z] contour whose vertices exactly equal `points`.
|
|
599
|
+
* Core Scene may carry richer multi-subpath topology, but exposing it here
|
|
600
|
+
* requires a future version whose declarative input can prove `d`/topology
|
|
601
|
+
* agreement rather than creating two geometry authorities. */
|
|
602
|
+
type ExternalSceneConnectorGeometry = Extract<ConnectorGeometry, {
|
|
603
|
+
kind: 'line' | 'polyline';
|
|
604
|
+
}> | Omit<Extract<ConnectorGeometry, {
|
|
605
|
+
kind: 'path';
|
|
606
|
+
}>, 'subpaths' | 'markerMidpoints'>;
|
|
607
|
+
interface ExternalSceneNodeBase {
|
|
608
|
+
readonly id: string;
|
|
609
|
+
readonly role: SceneRole;
|
|
610
|
+
readonly channels?: SemanticChannels;
|
|
611
|
+
}
|
|
612
|
+
interface ExternalSceneShape extends ExternalSceneNodeBase {
|
|
613
|
+
readonly kind: 'shape';
|
|
614
|
+
readonly geometry: ExternalSceneGeometry;
|
|
615
|
+
readonly paint?: MarkPaint;
|
|
616
|
+
}
|
|
617
|
+
/** A quantitative shape. `value` makes the emitted mark claim both the
|
|
618
|
+
* `shape` and `data-mark` primitives in the descriptor ledger. */
|
|
619
|
+
interface ExternalSceneDataMark extends ExternalSceneNodeBase {
|
|
620
|
+
readonly kind: 'data-mark';
|
|
621
|
+
readonly geometry: ExternalSceneGeometry;
|
|
622
|
+
readonly value: number;
|
|
623
|
+
readonly paint?: MarkPaint;
|
|
624
|
+
}
|
|
625
|
+
interface ExternalSceneText extends ExternalSceneNodeBase {
|
|
626
|
+
readonly kind: 'text';
|
|
627
|
+
readonly text: string;
|
|
628
|
+
readonly x: number;
|
|
629
|
+
readonly y: number;
|
|
630
|
+
readonly fontSize: number;
|
|
631
|
+
readonly anchor?: 'start' | 'middle' | 'end';
|
|
632
|
+
readonly paint?: MarkPaint;
|
|
633
|
+
}
|
|
634
|
+
interface ExternalSceneContainer extends ExternalSceneNodeBase {
|
|
635
|
+
readonly kind: 'container';
|
|
636
|
+
readonly children: readonly ExternalSceneNode[];
|
|
637
|
+
}
|
|
638
|
+
interface ExternalSceneConnector extends ExternalSceneNodeBase {
|
|
639
|
+
readonly kind: 'connector';
|
|
640
|
+
readonly geometry: ExternalSceneConnectorGeometry;
|
|
641
|
+
readonly from: string;
|
|
642
|
+
readonly to: string;
|
|
643
|
+
readonly lineStyle?: 'solid' | 'dotted' | 'dashed' | 'thick' | 'invisible';
|
|
644
|
+
readonly paint?: MarkPaint;
|
|
645
|
+
/** Typed topology for the one path contour exposed by external Scene v1. */
|
|
646
|
+
readonly closed?: boolean;
|
|
647
|
+
readonly startMarker?: string;
|
|
648
|
+
/** One marker resource repeated at every typed interior route point. */
|
|
649
|
+
readonly midMarker?: string;
|
|
650
|
+
readonly endMarker?: string;
|
|
651
|
+
readonly relationship?: {
|
|
652
|
+
readonly kind: string;
|
|
653
|
+
readonly direction?: ConnectorDirection;
|
|
654
|
+
};
|
|
655
|
+
readonly labels?: readonly ExternalSceneConnectorLabel[];
|
|
656
|
+
}
|
|
657
|
+
type ExternalSceneConnectorLabel = Pick<ConnectorLabelDescriptor, 'id' | 'text' | 'anchor' | 'bounds' | 'halo' | 'clearance' | 'paint' | 'fontSize' | 'textAnchor'>;
|
|
658
|
+
type ExternalSceneNode = ExternalSceneShape | ExternalSceneDataMark | ExternalSceneText | ExternalSceneContainer | ExternalSceneConnector;
|
|
659
|
+
/** Typed marker resource. Marker geometry is declarative; SVG is never an
|
|
660
|
+
* extension input. Unlike shape marks, markers may use path/compound geometry
|
|
661
|
+
* because their bounded viewport and reference point remain explicit. */
|
|
662
|
+
type ExternalSceneMarker = MarkerDescriptor & Required<Pick<MarkerDescriptor, 'geometry' | 'size' | 'ref'>>;
|
|
663
|
+
interface ExternalSceneDocument {
|
|
664
|
+
readonly title: string;
|
|
665
|
+
readonly description?: string;
|
|
666
|
+
readonly transparent?: boolean;
|
|
667
|
+
}
|
|
668
|
+
interface ExternalSceneInput {
|
|
669
|
+
readonly version: typeof EXTERNAL_SCENE_API_VERSION;
|
|
670
|
+
/** A registered `family:*` id. Admission later checks exact descriptor ownership. */
|
|
671
|
+
readonly family: string;
|
|
672
|
+
readonly width: number;
|
|
673
|
+
readonly height: number;
|
|
674
|
+
readonly colors: DiagramColors;
|
|
675
|
+
readonly metadata: ExternalSceneDocument;
|
|
676
|
+
readonly markers?: readonly ExternalSceneMarker[];
|
|
677
|
+
readonly parts: readonly ExternalSceneNode[];
|
|
678
|
+
}
|
|
679
|
+
/** Compile declarative external primitives into the one canonical SceneDoc. */
|
|
680
|
+
declare function buildExternalScene(untrustedInput: ExternalSceneInput): SceneDoc;
|
|
681
|
+
|
|
682
|
+
/** Runtime admission checks for the Scene contract.
|
|
683
|
+
*
|
|
684
|
+
* Validation is deliberately non-mutating. Built-in lowerings carry a
|
|
685
|
+
* canonical backend-private projection; external family scenes receive stricter containment,
|
|
686
|
+
* reference, and non-fetching checks before a backend can observe them.
|
|
687
|
+
*/
|
|
688
|
+
|
|
689
|
+
declare const SCENE_VALIDATION_VERSION: 2;
|
|
690
|
+
declare const SCENE_VALIDATION_LIMITS: Readonly<{
|
|
691
|
+
readonly maxExtent: 1000000;
|
|
692
|
+
readonly maxNodes: 100000;
|
|
693
|
+
readonly maxDepth: 64;
|
|
694
|
+
readonly maxTextLength: 1000000;
|
|
695
|
+
readonly maxTextBytes: 2000000;
|
|
696
|
+
readonly maxPoints: 50000;
|
|
697
|
+
readonly maxSerializationBytesPerNode: 5000000;
|
|
698
|
+
readonly maxAggregateSerializationBytes: 16000000;
|
|
699
|
+
readonly maxFinalSvgBytes: 8000000;
|
|
700
|
+
}>;
|
|
701
|
+
type SceneValidationDiagnosticCode = 'SCENE_DOCUMENT' | 'SCENE_FINITE' | 'SCENE_BOUNDS' | 'SCENE_ID' | 'SCENE_ROLE' | 'SCENE_PAINT' | 'SCENE_MARKER' | 'SCENE_REFERENCE' | 'SCENE_SECURITY' | 'SCENE_FIDELITY' | 'SCENE_PRIMITIVE_CLAIM' | 'SCENE_CHANNEL_CLAIM';
|
|
702
|
+
interface SceneValidationDiagnostic {
|
|
703
|
+
readonly code: SceneValidationDiagnosticCode;
|
|
704
|
+
readonly path: string;
|
|
705
|
+
readonly message: string;
|
|
706
|
+
}
|
|
707
|
+
interface SceneValidationResult {
|
|
708
|
+
readonly valid: boolean;
|
|
709
|
+
readonly diagnostics: readonly SceneValidationDiagnostic[];
|
|
710
|
+
}
|
|
711
|
+
interface SceneValidationOptions {
|
|
712
|
+
/** `auto` applies strict rules to a valid `family:*` document id. */
|
|
713
|
+
readonly mode?: 'auto' | 'internal' | 'external';
|
|
714
|
+
}
|
|
715
|
+
declare class SceneValidationError extends Error {
|
|
716
|
+
readonly diagnostics: readonly SceneValidationDiagnostic[];
|
|
717
|
+
readonly code = "SCENE_VALIDATION_FAILED";
|
|
718
|
+
constructor(diagnostics: readonly SceneValidationDiagnostic[]);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/** Validate an unknown value against the current Scene behavioral contract. */
|
|
722
|
+
declare function validateSceneDoc(value: unknown, options?: SceneValidationOptions): SceneValidationResult;
|
|
723
|
+
declare function assertValidSceneDoc(value: unknown, options?: SceneValidationOptions): asserts value is SceneDoc;
|
|
724
|
+
|
|
725
|
+
interface SceneConnectorHit {
|
|
726
|
+
readonly id: string;
|
|
727
|
+
readonly role: ConnectorMark['role'];
|
|
728
|
+
readonly connector: ConnectorMark;
|
|
729
|
+
readonly distance: number;
|
|
730
|
+
}
|
|
731
|
+
declare function connectorHitDistance(connector: ConnectorMark, point: ScenePoint): number | undefined;
|
|
732
|
+
declare function hitTestConnector(connector: ConnectorMark, point: ScenePoint, tolerance?: number): boolean;
|
|
733
|
+
/** Hit-test every connector using only typed Scene hit geometry. */
|
|
734
|
+
declare function hitTestSceneConnectors(scene: SceneDoc, point: ScenePoint, tolerance?: number): readonly SceneConnectorHit[];
|
|
735
|
+
|
|
736
|
+
/** A marker resource is renderable only when its geometry, viewport, and
|
|
737
|
+
* reference point are explicit. Connector references reuse this descriptor. */
|
|
738
|
+
type RenderableMarkerDescriptor = MarkerDescriptor & Required<Pick<MarkerDescriptor, 'geometry' | 'size' | 'ref'>>;
|
|
739
|
+
interface MarkerSerializationOptions {
|
|
740
|
+
readonly indent?: number;
|
|
741
|
+
}
|
|
742
|
+
declare function assertRenderableMarker(marker: MarkerDescriptor): asserts marker is RenderableMarkerDescriptor;
|
|
743
|
+
declare function serializeMarkerResource(marker: MarkerDescriptor, options?: MarkerSerializationOptions): string;
|
|
744
|
+
declare function serializeMarkerResources(markers: readonly MarkerDescriptor[], options?: MarkerSerializationOptions): string;
|
|
745
|
+
|
|
746
|
+
/** Validate a typed, same-document gradient resource before serialization. */
|
|
747
|
+
declare function assertRenderableLinearGradient(gradient: LinearGradientDescriptor): void;
|
|
748
|
+
declare function serializeLinearGradientResource(gradient: LinearGradientDescriptor, options?: {
|
|
749
|
+
indent?: number;
|
|
750
|
+
}): string;
|
|
751
|
+
declare function serializeLinearGradientResources(gradients: readonly LinearGradientDescriptor[], options?: {
|
|
752
|
+
indent?: number;
|
|
753
|
+
}): string;
|
|
754
|
+
|
|
755
|
+
declare const RESOURCE_MANIFEST_VERSION: 1;
|
|
756
|
+
interface ResourceLicense {
|
|
757
|
+
/** SPDX identifier or a stable project-local licence identifier. */
|
|
758
|
+
readonly spdx: string;
|
|
759
|
+
/** POSIX path, relative to the installed package root, containing the notice. */
|
|
760
|
+
readonly noticePath: string;
|
|
761
|
+
}
|
|
762
|
+
interface ResourceManifestEntry {
|
|
763
|
+
readonly identity: ExtensionIdentity<'resource'>;
|
|
764
|
+
/** POSIX path relative to the installed package root. */
|
|
765
|
+
readonly path: string;
|
|
766
|
+
/** Declared content type; a host must install an explicit verifier for it. */
|
|
767
|
+
readonly mediaType: string;
|
|
768
|
+
readonly sha256: string;
|
|
769
|
+
readonly bytes: number;
|
|
770
|
+
readonly license: ResourceLicense;
|
|
771
|
+
readonly required: boolean;
|
|
772
|
+
/** Installed resources never fall back to an ambient network fetch. */
|
|
773
|
+
readonly network: 'forbidden';
|
|
774
|
+
}
|
|
775
|
+
interface ResourceManifest {
|
|
776
|
+
readonly version: typeof RESOURCE_MANIFEST_VERSION;
|
|
777
|
+
readonly resources: readonly ResourceManifestEntry[];
|
|
778
|
+
}
|
|
779
|
+
type ResourceMediaTypeVerifier = (bytes: Uint8Array) => boolean;
|
|
780
|
+
/**
|
|
781
|
+
* Validate and defensively copy a manifest into the immutable representation
|
|
782
|
+
* consumed by host resolvers. Caller mutation can never alter this snapshot.
|
|
783
|
+
*/
|
|
784
|
+
declare function snapshotResourceManifest(manifest: unknown): ResourceManifest;
|
|
785
|
+
/** Browser/Worker byte verifier used by bundled in-memory resources. */
|
|
786
|
+
declare function verifyResourceBytes(entry: ResourceManifestEntry, bytes: Uint8Array, options?: {
|
|
787
|
+
readonly mediaTypes?: Readonly<Record<string, ResourceMediaTypeVerifier>>;
|
|
788
|
+
readonly digest?: (bytes: Uint8Array) => Promise<string>;
|
|
789
|
+
}): Promise<void>;
|
|
790
|
+
|
|
791
|
+
interface HostedFontFace {
|
|
792
|
+
family: string;
|
|
793
|
+
file: string;
|
|
794
|
+
weight: string;
|
|
795
|
+
style: string;
|
|
796
|
+
}
|
|
797
|
+
interface HostedFontResource extends HostedFontFace, ResourceManifestEntry {
|
|
798
|
+
}
|
|
799
|
+
/** Canonical installed-resource view. */
|
|
800
|
+
declare const HOSTED_FONT_RESOURCES: readonly HostedFontResource[];
|
|
801
|
+
declare const RESOURCE_MANIFEST: ResourceManifest;
|
|
802
|
+
/** Browser-safe structural checks; byte integrity is enforced by each host resolver. */
|
|
803
|
+
declare function validateResourceManifest(manifest?: unknown): string[];
|
|
804
|
+
declare function hostedFontResource(file: string): HostedFontResource;
|
|
805
|
+
|
|
806
|
+
declare const OUTPUT_COLOR_PROFILE: Readonly<{
|
|
807
|
+
version: 1;
|
|
808
|
+
id: "srgb";
|
|
809
|
+
svgColorInterpolation: "sRGB";
|
|
810
|
+
gamutMapping: "clip-to-srgb";
|
|
811
|
+
png: Readonly<{
|
|
812
|
+
sRGBRenderingIntent: 0;
|
|
813
|
+
cICP: readonly [1, 13, 0, 1];
|
|
814
|
+
iCCP: "absent-when-sRGB-is-present";
|
|
815
|
+
precedence: readonly ["cICP", "iCCP", "sRGB", "gAMA+cHRM"];
|
|
816
|
+
}>;
|
|
817
|
+
}>;
|
|
818
|
+
interface PngColorProfileReceipt {
|
|
819
|
+
chunks: readonly string[];
|
|
820
|
+
sRGBRenderingIntent?: number;
|
|
821
|
+
cICP?: readonly number[];
|
|
822
|
+
hasICC: boolean;
|
|
823
|
+
profile: typeof OUTPUT_COLOR_PROFILE.id;
|
|
824
|
+
}
|
|
825
|
+
interface PngDimensions {
|
|
826
|
+
readonly width: number;
|
|
827
|
+
readonly height: number;
|
|
828
|
+
}
|
|
829
|
+
/** Read validated PNG IHDR dimensions. The whole stream is checked first. */
|
|
830
|
+
declare function inspectPngDimensions(bytes: Uint8Array): PngDimensions;
|
|
831
|
+
declare function inspectPngColorProfile(bytes: Uint8Array): PngColorProfileReceipt;
|
|
832
|
+
declare function applyPngColorProfile(bytes: Uint8Array): Uint8Array;
|
|
833
|
+
|
|
834
|
+
/** Logical PNG projection policy shared by every first-party raster adapter. */
|
|
835
|
+
declare const PNG_DEFAULT_FONT_FAMILY: "Inter";
|
|
836
|
+
/** ~16.7 megapixels / ~64 MiB of raw RGBA before encoder overhead. */
|
|
837
|
+
declare const MAX_PNG_PIXELS: 16777216;
|
|
838
|
+
/** Defends pathological one-pixel-wide/tall rasters that fit the pixel cap. */
|
|
839
|
+
declare const MAX_PNG_RASTER_DIMENSION: 16384;
|
|
840
|
+
/** Hosted WASM stays below the shared native/browser allocation ceiling. */
|
|
841
|
+
declare const MAX_HOSTED_PNG_PIXELS: 4194304;
|
|
842
|
+
/** Bounds the hosted response and its unavoidable base64 representation. */
|
|
843
|
+
declare const MAX_HOSTED_PNG_BYTES: 8388608;
|
|
844
|
+
declare const MAX_PNG_FONT_DIRECTORIES: 16;
|
|
845
|
+
declare const MAX_PNG_FONT_DIRECTORY_LENGTH: 4096;
|
|
846
|
+
type PngFitTo = {
|
|
847
|
+
readonly width: number;
|
|
848
|
+
readonly height?: never;
|
|
849
|
+
} | {
|
|
850
|
+
readonly width?: never;
|
|
851
|
+
readonly height: number;
|
|
852
|
+
};
|
|
853
|
+
/** Provisional general screen-diagram policy, not a universal readability or
|
|
854
|
+
* accessibility standard. Callers with known viewing conditions should set a
|
|
855
|
+
* task-specific effective-text floor. 0 disables the gate. */
|
|
856
|
+
declare const PNG_DEFAULT_MIN_LABEL_PX: 9;
|
|
857
|
+
interface PortablePngOutputOptions {
|
|
858
|
+
scale?: number;
|
|
859
|
+
background?: string;
|
|
860
|
+
fitTo?: PngFitTo;
|
|
861
|
+
minLabelPx?: number;
|
|
862
|
+
}
|
|
863
|
+
interface PngOutputPolicyInput extends PortablePngOutputOptions {
|
|
864
|
+
fontDirs?: readonly string[];
|
|
865
|
+
loadSystemFonts?: boolean;
|
|
866
|
+
}
|
|
867
|
+
type PngOutputOptionScope = 'portable' | 'native-host-only';
|
|
868
|
+
type PngOutputOptionInputKind = 'serializable' | 'callback';
|
|
869
|
+
type PngOutputOptionPolicyState = 'included' | 'excluded';
|
|
870
|
+
type PngOutputOptionReceiptState = 'included' | 'excluded';
|
|
871
|
+
interface PngOutputOptionFieldDescriptor {
|
|
872
|
+
readonly scope: PngOutputOptionScope;
|
|
873
|
+
readonly input: PngOutputOptionInputKind;
|
|
874
|
+
readonly policy: PngOutputOptionPolicyState;
|
|
875
|
+
readonly receipt: PngOutputOptionReceiptState;
|
|
876
|
+
readonly typeScript: string;
|
|
877
|
+
readonly description: string;
|
|
878
|
+
readonly schema?: Readonly<Record<string, unknown>>;
|
|
879
|
+
readonly runtimeValidator?: 'portablePngBackground';
|
|
880
|
+
}
|
|
881
|
+
declare const PNG_OUTPUT_OPTION_FIELD_DESCRIPTORS: {
|
|
882
|
+
readonly scale: {
|
|
883
|
+
readonly typeScript: "number";
|
|
884
|
+
readonly description: "Positive output scale used when no fitTo constraint is supplied.";
|
|
885
|
+
readonly schema: {
|
|
886
|
+
readonly default: 2;
|
|
887
|
+
readonly type: "number";
|
|
888
|
+
readonly exclusiveMinimum: 0;
|
|
889
|
+
};
|
|
890
|
+
readonly scope: "portable";
|
|
891
|
+
readonly input: "serializable";
|
|
892
|
+
readonly policy: "included";
|
|
893
|
+
readonly receipt: "included";
|
|
894
|
+
};
|
|
895
|
+
readonly background: {
|
|
896
|
+
readonly typeScript: "string";
|
|
897
|
+
readonly description: "Portable basic color or hex color painted behind the raster artifact.";
|
|
898
|
+
readonly schema: {
|
|
899
|
+
readonly type: "string";
|
|
900
|
+
readonly minLength: 1;
|
|
901
|
+
readonly pattern: string;
|
|
902
|
+
};
|
|
903
|
+
readonly runtimeValidator: "portablePngBackground";
|
|
904
|
+
readonly scope: "portable";
|
|
905
|
+
readonly input: "serializable";
|
|
906
|
+
readonly policy: "included";
|
|
907
|
+
readonly receipt: "included";
|
|
908
|
+
};
|
|
909
|
+
readonly fitTo: {
|
|
910
|
+
readonly typeScript: "{ width: number; height?: never } | { width?: never; height: number }";
|
|
911
|
+
readonly description: "Exactly one output width or height constraint.";
|
|
912
|
+
readonly schema: {
|
|
913
|
+
readonly type: "object";
|
|
914
|
+
readonly additionalProperties: false;
|
|
915
|
+
readonly properties: {
|
|
916
|
+
readonly width: {
|
|
917
|
+
readonly description: "Exact output width in integer pixels.";
|
|
918
|
+
readonly type: "integer";
|
|
919
|
+
readonly minimum: 1;
|
|
920
|
+
};
|
|
921
|
+
readonly height: {
|
|
922
|
+
readonly description: "Exact output height in integer pixels.";
|
|
923
|
+
readonly type: "integer";
|
|
924
|
+
readonly minimum: 1;
|
|
925
|
+
};
|
|
926
|
+
};
|
|
927
|
+
readonly oneOf: readonly [{
|
|
928
|
+
readonly required: readonly ["width"];
|
|
929
|
+
}, {
|
|
930
|
+
readonly required: readonly ["height"];
|
|
931
|
+
}];
|
|
932
|
+
readonly description: "Exactly one positive output width or height.";
|
|
933
|
+
};
|
|
934
|
+
readonly scope: "portable";
|
|
935
|
+
readonly input: "serializable";
|
|
936
|
+
readonly policy: "included";
|
|
937
|
+
readonly receipt: "included";
|
|
938
|
+
};
|
|
939
|
+
readonly minLabelPx: {
|
|
940
|
+
readonly typeScript: "number";
|
|
941
|
+
readonly description: "Legibility floor in effective px: the render warns (BELOW_READABLE_SIZE) when fitTo/scale rasterizes the smallest configured text below it. 0 disables.";
|
|
942
|
+
readonly schema: {
|
|
943
|
+
readonly type: "number";
|
|
944
|
+
readonly minimum: 0;
|
|
945
|
+
readonly default: 9;
|
|
946
|
+
};
|
|
947
|
+
readonly scope: "portable";
|
|
948
|
+
readonly input: "serializable";
|
|
949
|
+
readonly policy: "included";
|
|
950
|
+
readonly receipt: "included";
|
|
951
|
+
};
|
|
952
|
+
readonly fontDirs: {
|
|
953
|
+
readonly typeScript: "readonly string[]";
|
|
954
|
+
readonly description: "Trusted native host directories searched for additional fonts.";
|
|
955
|
+
readonly schema: {
|
|
956
|
+
readonly type: "array";
|
|
957
|
+
readonly maxItems: 16;
|
|
958
|
+
readonly items: {
|
|
959
|
+
readonly type: "string";
|
|
960
|
+
readonly minLength: 1;
|
|
961
|
+
readonly maxLength: 4096;
|
|
962
|
+
readonly pattern: "\\S";
|
|
963
|
+
};
|
|
964
|
+
};
|
|
965
|
+
readonly scope: "native-host-only";
|
|
966
|
+
readonly input: "serializable";
|
|
967
|
+
readonly policy: "included";
|
|
968
|
+
readonly receipt: "included";
|
|
969
|
+
};
|
|
970
|
+
readonly loadSystemFonts: {
|
|
971
|
+
readonly typeScript: "boolean";
|
|
972
|
+
readonly description: "Allow the native rasterizer to load machine-dependent system fonts.";
|
|
973
|
+
readonly schema: {
|
|
974
|
+
readonly type: "boolean";
|
|
975
|
+
readonly default: false;
|
|
976
|
+
};
|
|
977
|
+
readonly scope: "native-host-only";
|
|
978
|
+
readonly input: "serializable";
|
|
979
|
+
readonly policy: "included";
|
|
980
|
+
readonly receipt: "included";
|
|
981
|
+
};
|
|
982
|
+
readonly onWarning: {
|
|
983
|
+
readonly typeScript: "(warning: PngRasterWarning) => void";
|
|
984
|
+
readonly description: "Native host callback for glyph-coverage and raster-legibility warnings; never serialized or receipted.";
|
|
985
|
+
readonly scope: "native-host-only";
|
|
986
|
+
readonly input: "callback";
|
|
987
|
+
readonly policy: "excluded";
|
|
988
|
+
readonly receipt: "excluded";
|
|
989
|
+
};
|
|
990
|
+
};
|
|
991
|
+
type PngOutputOptionField = keyof typeof PNG_OUTPUT_OPTION_FIELD_DESCRIPTORS;
|
|
992
|
+
type PortablePngOutputOptionField = keyof PortablePngOutputOptions;
|
|
993
|
+
type NativePngOutputPolicyField = keyof PngOutputPolicyInput;
|
|
994
|
+
type NativePngHostOnlyOptionField = Exclude<PngOutputOptionField, PortablePngOutputOptionField>;
|
|
995
|
+
declare const PNG_OUTPUT_OPTION_FIELDS: readonly PngOutputOptionField[];
|
|
996
|
+
declare const PORTABLE_PNG_OUTPUT_OPTION_FIELDS: readonly PortablePngOutputOptionField[];
|
|
997
|
+
/** Serializable fields accepted by the native output-policy resolver. */
|
|
998
|
+
declare const NATIVE_PNG_OUTPUT_POLICY_FIELDS: readonly NativePngOutputPolicyField[];
|
|
999
|
+
/** Native-only font inputs plus the non-serializable warning callback. */
|
|
1000
|
+
declare const NATIVE_PNG_HOST_ONLY_OPTION_FIELDS: readonly NativePngHostOnlyOptionField[];
|
|
1001
|
+
/** Closed JSON Schema projection for portable or native PNG policy inputs. */
|
|
1002
|
+
declare function pngOutputOptionsJsonSchema(substrate?: 'portable' | 'native'): Record<string, unknown>;
|
|
1003
|
+
interface ResolvedPngOutputPolicy {
|
|
1004
|
+
readonly version: typeof PNG_OUTPUT_POLICY_VERSION;
|
|
1005
|
+
readonly scale: number;
|
|
1006
|
+
readonly background: {
|
|
1007
|
+
readonly mode: 'artifact';
|
|
1008
|
+
readonly fallback: '#ffffff';
|
|
1009
|
+
} | {
|
|
1010
|
+
readonly mode: 'explicit';
|
|
1011
|
+
readonly value: string;
|
|
1012
|
+
};
|
|
1013
|
+
readonly fitTo: {
|
|
1014
|
+
readonly mode: 'zoom';
|
|
1015
|
+
readonly value: number;
|
|
1016
|
+
} | {
|
|
1017
|
+
readonly mode: 'width' | 'height';
|
|
1018
|
+
readonly value: number;
|
|
1019
|
+
};
|
|
1020
|
+
readonly minLabelPx: number;
|
|
1021
|
+
readonly fonts: {
|
|
1022
|
+
readonly defaultFamily: typeof PNG_DEFAULT_FONT_FAMILY;
|
|
1023
|
+
readonly bundledResources: readonly string[];
|
|
1024
|
+
readonly callerDirectories: readonly string[];
|
|
1025
|
+
readonly loadSystemFonts: boolean;
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
interface PngRasterDimensions {
|
|
1029
|
+
readonly width: number;
|
|
1030
|
+
readonly height: number;
|
|
1031
|
+
readonly pixels: number;
|
|
1032
|
+
}
|
|
1033
|
+
type PngRasterBudgetPolicy = number | Pick<ResolvedPngOutputPolicy, 'scale' | 'fitTo'>;
|
|
1034
|
+
/**
|
|
1035
|
+
* Read the dimensions a rasterizer will actually allocate from the SVG root.
|
|
1036
|
+
* The viewBox remains an integrity cross-check: mismatched aspect ratios are
|
|
1037
|
+
* rejected rather than letting a custom backend hide a large intrinsic canvas
|
|
1038
|
+
* behind a small viewBox.
|
|
1039
|
+
*/
|
|
1040
|
+
declare function svgIntrinsicDimensions(svg: string): {
|
|
1041
|
+
readonly width: number;
|
|
1042
|
+
readonly height: number;
|
|
1043
|
+
};
|
|
1044
|
+
/** Compute conservative final integer dimensions before a rasterizer allocates. */
|
|
1045
|
+
declare function pngRasterDimensions(svg: string, output: PngRasterBudgetPolicy): PngRasterDimensions;
|
|
1046
|
+
/**
|
|
1047
|
+
* Pin the SVG intrinsic canvas to the already-budgeted integer dimensions.
|
|
1048
|
+
* Native and WASM resvg then render at zoom 1, while browser Canvas receives
|
|
1049
|
+
* the same dimensions in its callback context. This avoids backend-specific
|
|
1050
|
+
* rounding of fitTo ratios.
|
|
1051
|
+
*/
|
|
1052
|
+
declare function prepareSvgForPngRasterization(svg: string, dimensions: PngRasterDimensions): string;
|
|
1053
|
+
/** Shared allocation gate for native, browser, WASM, CLI, and MCP PNG paths. */
|
|
1054
|
+
declare function assertPngRasterBudget(svg: string, output: PngRasterBudgetPolicy): PngRasterDimensions;
|
|
1055
|
+
/** Hosted pre-allocation gate layered over the substrate-neutral dimensions. */
|
|
1056
|
+
declare function assertHostedPngRasterBudget(dimensions: PngRasterDimensions): PngRasterDimensions;
|
|
1057
|
+
/** Canonical portable explicit-background intersection understood identically
|
|
1058
|
+
* by Canvas and resvg. Keep this narrower admission contract separate from the
|
|
1059
|
+
* artifact background, whose safe CSS paint has already passed render-option
|
|
1060
|
+
* validation and is resolved to concrete bytes below. */
|
|
1061
|
+
declare function normalizePortablePngBackground(value: unknown): string | undefined;
|
|
1062
|
+
/** Pick only portable PNG fields from a combined render/transport options bag. */
|
|
1063
|
+
declare function projectPortablePngOutputOptions(input: Readonly<Record<string, unknown>>): PortablePngOutputOptions;
|
|
1064
|
+
/** Pick serializable native PNG policy fields from a combined options bag. */
|
|
1065
|
+
declare function projectNativePngOutputPolicyInput(input: Readonly<Record<string, unknown>>): PngOutputPolicyInput;
|
|
1066
|
+
/** Remove every canonical PNG adapter field, including the host callback. */
|
|
1067
|
+
declare function omitPngOutputOptions<T extends Readonly<Record<string, unknown>>>(input: T): Omit<T, PngOutputOptionField>;
|
|
1068
|
+
/** Normalize portable controls used by browser/WASM/hosted raster adapters. */
|
|
1069
|
+
declare function resolvePortablePngOutputPolicy(input?: PortablePngOutputOptions): ResolvedPngOutputPolicy;
|
|
1070
|
+
/** Normalize native controls and defaults before they participate in a receipt. */
|
|
1071
|
+
declare function resolvePngOutputPolicy(input?: PngOutputPolicyInput): ResolvedPngOutputPolicy;
|
|
1072
|
+
declare const PNG_FONT_SOURCES: readonly ["verified-files", "verified-buffers", "caller-directories", "system-fonts", "embedded-data-uri", "unavailable"];
|
|
1073
|
+
type PngFontSource = typeof PNG_FONT_SOURCES[number];
|
|
1074
|
+
/** Runtime provenance is artifact metadata, never part of the logical request digest. */
|
|
1075
|
+
interface PngRuntimeProvenance {
|
|
1076
|
+
readonly engine: 'resvg';
|
|
1077
|
+
readonly engineVersion: '2.6.2';
|
|
1078
|
+
readonly binding: 'napi' | 'wasm';
|
|
1079
|
+
/** Every class of font input that could affect the produced bytes. */
|
|
1080
|
+
readonly fontSources: readonly PngFontSource[];
|
|
1081
|
+
/** Whether every byte-affecting resource is identified by content in the runtime contract. */
|
|
1082
|
+
readonly reproducibility: 'content-addressed' | 'host-dependent';
|
|
1083
|
+
}
|
|
1084
|
+
declare const PNG_NAPI_RUNTIME: PngRuntimeProvenance;
|
|
1085
|
+
declare const PNG_WASM_RUNTIME: PngRuntimeProvenance;
|
|
1086
|
+
/** Add host-controlled font inputs to the N-API artifact provenance. */
|
|
1087
|
+
declare function pngNapiRuntimeProvenance(input?: {
|
|
1088
|
+
readonly callerDirectories?: readonly string[];
|
|
1089
|
+
readonly loadSystemFonts?: boolean;
|
|
1090
|
+
}): PngRuntimeProvenance;
|
|
1091
|
+
|
|
1092
|
+
declare const BROWSER_CANVAS_RUNTIME: BrowserPngRuntimeProvenance;
|
|
1093
|
+
|
|
1094
|
+
interface PngLegibilityWarning {
|
|
1095
|
+
code: 'BELOW_READABLE_SIZE';
|
|
1096
|
+
naturalWidth: number;
|
|
1097
|
+
naturalHeight: number;
|
|
1098
|
+
/** Final raster height / SVG viewBox height. Font-size follows this vertical
|
|
1099
|
+
* user-unit scale after PNG projection pins the root dimensions. */
|
|
1100
|
+
effectiveScale: number;
|
|
1101
|
+
baseMinLabelPx: number;
|
|
1102
|
+
effectiveMinLabelPx: number;
|
|
1103
|
+
floorPx: number;
|
|
1104
|
+
cause: 'fitTo' | 'scale';
|
|
1105
|
+
message: string;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
interface BrowserPngHostDiagnostic {
|
|
1109
|
+
readonly code: string;
|
|
1110
|
+
readonly message: string;
|
|
1111
|
+
readonly resource?: string;
|
|
1112
|
+
}
|
|
1113
|
+
/** Shared projection warnings retain their structured evidence; injected
|
|
1114
|
+
* rasterizers may append host-specific diagnostics. */
|
|
1115
|
+
type BrowserPngDiagnostic = PngLegibilityWarning | BrowserPngHostDiagnostic;
|
|
1116
|
+
interface BrowserPngRasterContext {
|
|
1117
|
+
readonly outputPolicy: ResolvedPngOutputPolicy;
|
|
1118
|
+
/** Exact integer canvas dimensions approved by the shared raster budget. */
|
|
1119
|
+
readonly rasterDimensions: PngRasterDimensions;
|
|
1120
|
+
/** Canonical portable color after explicit/artifact/fallback precedence. */
|
|
1121
|
+
readonly rasterBackground: string;
|
|
1122
|
+
readonly receipt: RenderRequestReceipt;
|
|
1123
|
+
}
|
|
1124
|
+
interface BrowserPngRasterResult {
|
|
1125
|
+
readonly png: Uint8Array;
|
|
1126
|
+
readonly diagnostics?: readonly BrowserPngDiagnostic[];
|
|
1127
|
+
/** Host-reported font inputs. Omission is recorded as unavailable evidence. */
|
|
1128
|
+
readonly fontSources?: readonly BrowserPngFontSource[];
|
|
1129
|
+
}
|
|
1130
|
+
type BrowserPngRasterizer = (securedSvg: string, context: BrowserPngRasterContext) => Promise<BrowserPngRasterResult>;
|
|
1131
|
+
interface RenderedBrowserPng {
|
|
1132
|
+
readonly png: Uint8Array;
|
|
1133
|
+
readonly receipt: RenderRequestReceipt;
|
|
1134
|
+
readonly diagnostics: readonly BrowserPngDiagnostic[];
|
|
1135
|
+
readonly colorProfile: ReturnType<typeof inspectPngColorProfile>;
|
|
1136
|
+
/** Host provenance is artifact metadata and never changes the logical receipt. */
|
|
1137
|
+
readonly runtime: BrowserPngRuntimeProvenance;
|
|
1138
|
+
}
|
|
1139
|
+
type BrowserPngFontSource = Extract<PngFontSource, 'verified-buffers' | 'embedded-data-uri' | 'unavailable'>;
|
|
1140
|
+
interface BrowserPngRuntimeProvenance {
|
|
1141
|
+
readonly engine: 'canvas';
|
|
1142
|
+
readonly binding: 'browser';
|
|
1143
|
+
readonly fontSources: readonly BrowserPngFontSource[];
|
|
1144
|
+
/** Browser callbacks do not expose content identities for every byte-affecting resource. */
|
|
1145
|
+
readonly reproducibility: 'host-dependent';
|
|
1146
|
+
}
|
|
1147
|
+
/** Trusted browser host inputs; neither callback nor policy is serializable. */
|
|
1148
|
+
interface MermaidBrowserPNGRendererHostOptions {
|
|
1149
|
+
readonly rasterize: BrowserPngRasterizer;
|
|
1150
|
+
readonly backendPolicy?: HostBackendPolicy;
|
|
1151
|
+
readonly textMeasurement?: TextMeasurementProfile;
|
|
1152
|
+
}
|
|
1153
|
+
interface MermaidBrowserPNGRenderer {
|
|
1154
|
+
renderMermaidPNG(source: ParsedDiagram | string, options?: RenderOptions, output?: number | PortablePngOutputOptions): Promise<Uint8Array>;
|
|
1155
|
+
renderMermaidPNGWithReceipt(source: ParsedDiagram | string, options?: RenderOptions, output?: number | PortablePngOutputOptions): Promise<RenderedBrowserPng>;
|
|
1156
|
+
}
|
|
1157
|
+
/** Bind an injected browser rasterizer to one trusted graphical backend policy. */
|
|
1158
|
+
declare function createMermaidBrowserPNGRenderer(hostOptions: MermaidBrowserPNGRendererHostOptions): MermaidBrowserPNGRenderer;
|
|
1159
|
+
declare function renderMermaidPNGInBrowserWithReceipt(source: ParsedDiagram | string, options: RenderOptions, output: number | PortablePngOutputOptions, rasterize: BrowserPngRasterizer): Promise<RenderedBrowserPng>;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Render Mermaid diagram text to an SVG string — synchronously.
|
|
1163
|
+
*
|
|
1164
|
+
* Uses elk.bundled.js with a direct FakeWorker bypass (no setTimeout(0) delay).
|
|
1165
|
+
* The ELK singleton is created lazily on first use and cached forever.
|
|
1166
|
+
*
|
|
1167
|
+
* Use this in React components with useMemo() to avoid flash:
|
|
1168
|
+
* const svg = useMemo(() => renderMermaidSVG(code, opts), [code])
|
|
1169
|
+
*
|
|
1170
|
+
* @param text - Mermaid source text
|
|
1171
|
+
* @param options - Rendering options (colors, font, spacing)
|
|
1172
|
+
* @returns A self-contained SVG string
|
|
1173
|
+
*
|
|
1174
|
+
* @example
|
|
1175
|
+
* ```ts
|
|
1176
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B')
|
|
1177
|
+
*
|
|
1178
|
+
* // With theme
|
|
1179
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', {
|
|
1180
|
+
* bg: '#1a1b26', fg: '#a9b1d6'
|
|
1181
|
+
* })
|
|
1182
|
+
*
|
|
1183
|
+
* // With CSS variables (for live theme switching)
|
|
1184
|
+
* const svg = renderMermaidSVG('graph TD\n A --> B', {
|
|
1185
|
+
* bg: 'var(--background)', fg: 'var(--foreground)', transparent: true
|
|
1186
|
+
* })
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1189
|
+
declare function renderMermaidSVG(text: ParsedDiagram | string, options?: RenderOptions): string;
|
|
1190
|
+
interface RenderedSvg {
|
|
1191
|
+
svg: string;
|
|
1192
|
+
receipt: RenderRequestReceipt;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Trusted host-only renderer construction options. These values are never
|
|
1196
|
+
* copied into RenderOptions, CLI/MCP payloads, or editor state. Receipts contain
|
|
1197
|
+
* only the selected measurement profile's id/version, never its callback.
|
|
1198
|
+
*/
|
|
1199
|
+
interface MermaidRendererHostOptions {
|
|
1200
|
+
readonly backendPolicy?: HostBackendPolicy;
|
|
1201
|
+
readonly textMeasurement?: TextMeasurementProfile;
|
|
1202
|
+
}
|
|
1203
|
+
/** A renderer bound to trusted in-process host policy. */
|
|
1204
|
+
interface MermaidRenderer {
|
|
1205
|
+
renderMermaidSVG(text: ParsedDiagram | string, options?: RenderOptions): string;
|
|
1206
|
+
renderMermaidSVGWithReceipt(text: ParsedDiagram | string, options?: RenderOptions): RenderedSvg;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Construct a trusted in-process renderer. A custom backend is selectable only
|
|
1210
|
+
* through this host object; serializable appearance data still describes the
|
|
1211
|
+
* requested look and cannot name or smuggle executable backend machinery.
|
|
1212
|
+
*/
|
|
1213
|
+
declare function createMermaidRenderer(hostOptions?: MermaidRendererHostOptions): MermaidRenderer;
|
|
1214
|
+
declare function renderMermaidSVGWithReceipt(text: ParsedDiagram | string, options?: RenderOptions): RenderedSvg;
|
|
1215
|
+
/**
|
|
1216
|
+
* Render Mermaid diagram text to an SVG string — async.
|
|
1217
|
+
*
|
|
1218
|
+
* Same result as renderMermaidSVG() but returns a Promise.
|
|
1219
|
+
* Useful in async contexts (server handlers, data loaders, etc.)
|
|
1220
|
+
*/
|
|
1221
|
+
declare function renderMermaidSVGAsync(text: ParsedDiagram | string, options?: RenderOptions): Promise<string>;
|
|
1222
|
+
|
|
1223
|
+
export { PNG_OUTPUT_OPTION_FIELD_DESCRIPTORS as $, type AsciiRenderOptions as A, BACKEND_CONFORMANCE_CHECK_IDS as B, type ExternalSceneText as C, DefaultBackend as D, EXTERNAL_SCENE_API_VERSION as E, type FamilyDetectionDiagnostic as F, HOSTED_FONT_RESOURCES as G, type HostBackendPolicy as H, MAX_HOSTED_PNG_PIXELS as I, MAX_PNG_FONT_DIRECTORIES as J, MAX_PNG_FONT_DIRECTORY_LENGTH as K, MAX_PNG_PIXELS as L, MAX_HOSTED_PNG_BYTES as M, MAX_PNG_RASTER_DIMENSION as N, type MermaidFamilyClassification as O, type PngLegibilityWarning as P, MermaidFamilyDetectionError as Q, NATIVE_PNG_HOST_ONLY_OPTION_FIELDS as R, NATIVE_PNG_OUTPUT_POLICY_FIELDS as S, type NativePngHostOnlyOptionField as T, type NativePngOutputPolicyField as U, PNG_DEFAULT_FONT_FAMILY as V, PNG_DEFAULT_MIN_LABEL_PX as W, PNG_DEFAULT_SCALE as X, PNG_FONT_SOURCES as Y, PNG_NAPI_RUNTIME as Z, PNG_OUTPUT_OPTION_FIELDS as _, type PngOutputPolicyInput as a, projectNativePngOutputPolicyInput as a$, PNG_OUTPUT_POLICY_VERSION as a0, PNG_WASM_RUNTIME as a1, PORTABLE_PNG_OUTPUT_OPTION_FIELDS as a2, type PngFitTo as a3, type PngFontSource as a4, type PngOutputOptionField as a5, type PngOutputOptionFieldDescriptor as a6, type PngOutputOptionInputKind as a7, type PngOutputOptionPolicyState as a8, type PngOutputOptionReceiptState as a9, type TerminalOutputPolicyInput as aA, type TextMeasurementContract as aB, type TextMeasurementInput as aC, type TextMeasurementResult as aD, UPSTREAM_MERMAID_FAMILY_INDEX as aE, type UpstreamFamilyDescriptor as aF, type UpstreamHeaderDescriptor as aG, type UpstreamHeaderMatch as aH, type UpstreamMermaidFamilyIndex as aI, assertHostedPngRasterBudget as aJ, assertPngRasterBudget as aK, assertValidSceneDoc as aL, buildExternalScene as aM, classifyMermaidFamilyFromFirstLine as aN, findUpstreamFamilyByHeader as aO, getBackend as aP, hostedFontResource as aQ, knownBackendDescriptors as aR, measureText as aS, measureTextWidth as aT, normalizePortablePngBackground as aU, omitPngOutputOptions as aV, parseRegisteredMermaid as aW, pngNapiRuntimeProvenance as aX, pngOutputOptionsJsonSchema as aY, pngRasterDimensions as aZ, prepareSvgForPngRasterization as a_, type PngOutputOptionScope as aa, type PngRasterDimensions as ab, type PortablePngOutputOptionField as ac, type PortablePngOutputOptions as ad, RESOURCE_MANIFEST as ae, RESOURCE_MANIFEST_VERSION as af, type RenderedAscii as ag, type ResolvedPngOutputPolicy as ah, type ResolvedTerminalOutputPolicy as ai, SCENE_CONTRACT_VERSION as aj, SCENE_VALIDATION_LIMITS as ak, SCENE_VALIDATION_VERSION as al, type SceneValidationDiagnostic as am, type SceneValidationDiagnosticCode as an, SceneValidationError as ao, type SceneValidationOptions as ap, type SceneValidationResult as aq, type StyleBackend as ar, type StyleBackendContext as as, TERMINAL_BOUNDED_PADDING_X as at, TERMINAL_DEFAULT_BOX_BORDER_PADDING as au, TERMINAL_DEFAULT_PADDING_X as av, TERMINAL_DEFAULT_PADDING_Y as aw, TERMINAL_OUTPUT_POLICY_VERSION as ax, TEXT_MEASUREMENT_CONTRACT as ay, TerminalOutputPolicyError as az, type PngRuntimeProvenance as b, assertRenderableMarker as b$, projectPortablePngOutputOptions as b0, registerBackend as b1, resolvePngOutputPolicy as b2, resolvePortablePngOutputPolicy as b3, resolveTerminalOutputPolicy as b4, runBackendConformance as b5, svgIntrinsicDimensions as b6, validateResourceManifest as b7, validateSceneDoc as b8, verifyResourceBytes as b9, MindmapDuplicateIdError as bA, MindmapParseError as bB, OUTPUT_COLOR_PROFILE as bC, type ParserObservation as bD, type ParserObservationSource as bE, type ParserObservationValue as bF, type ParserObserver as bG, type PngColorProfileReceipt as bH, type PngDimensions as bI, RESOLVED_SCENE_VERSION as bJ, type RenderableMarkerDescriptor as bK, type RenderedBrowserPng as bL, type ResolvedArchitectureIcon as bM, type ResolvedPaint as bN, type ResolvedPart as bO, type ResolvedPath as bP, type ResolvedPrimitive as bQ, type ResolvedScene as bR, type ResolvedText as bS, type ResourceLicense as bT, type ResourceManifest as bU, type ResourceManifestEntry as bV, type SceneConnectorHit as bW, applyPngColorProfile as bX, architectureIconManifest as bY, architectureToMermaidGraph as bZ, assertRenderableLinearGradient as b_, renderMermaidASCII as ba, renderMermaidSVG as bb, type RenderedSvg as bc, ARCHITECTURE_ICON_LIMITS as bd, BROWSER_CANVAS_RUNTIME as be, type BrowserPngDiagnostic as bf, type BrowserPngFontSource as bg, type BrowserPngHostDiagnostic as bh, type BrowserPngRasterContext as bi, type BrowserPngRasterResult as bj, type BrowserPngRasterizer as bk, type BrowserPngRuntimeProvenance as bl, GitGraphDuplicateCommitError as bm, GitGraphParseError as bn, type HostBackendSelection as bo, type HostedFontFace as bp, type HostedFontResource as bq, type LayoutCertificationAttempt as br, LayoutCertificationError as bs, LayoutMetricBudgetError as bt, type MarkerSerializationOptions as bu, type Matrix as bv, type MermaidBrowserPNGRenderer as bw, type MermaidBrowserPNGRendererHostOptions as bx, type MermaidRenderer as by, type MermaidRendererHostOptions as bz, type AsciiRenderColorMode as c, connectorHitDistance as c0, createMermaidBrowserPNGRenderer as c1, createMermaidRenderer as c2, hitTestConnector as c3, hitTestSceneConnectors as c4, inspectPngColorProfile as c5, inspectPngDimensions as c6, parseArchitectureDiagram as c7, parseGitGraph as c8, parseMindmap as c9, renderMermaidASCIIWithReceipt as ca, renderMermaidPNGInBrowserWithReceipt as cb, renderMermaidSVGAsync as cc, renderMermaidSVGWithReceipt as cd, renderResolvedScene as ce, resolveArchitectureIcon as cf, resolveDiagramColors as cg, serializeGitGraph as ch, serializeLinearGradientResource as ci, serializeLinearGradientResources as cj, serializeMarkerResource as ck, serializeMarkerResources as cl, serializeMindmap as cm, snapshotResourceManifest as cn, withParserObservation as co, AsciiWidthError as d, type AsciiWidthErrorReason as e, BACKEND_CONFORMANCE_FIXTURE_ID as f, BACKEND_CONFORMANCE_VERSION as g, type BackendCapabilityConformanceResult as h, type BackendCapabilityConformanceStatus as i, type BackendConformanceCheck as j, type BackendConformanceCheckId as k, type BackendConformanceReport as l, type BackendDescriptor as m, type BackendRegistrationOptions as n, type ExternalSceneConnector as o, type ExternalSceneConnectorGeometry as p, type ExternalSceneConnectorLabel as q, type ExternalSceneContainer as r, type ExternalSceneDataMark as s, type ExternalSceneDocument as t, type ExternalSceneGeometry as u, type ExternalSceneInput as v, type ExternalSceneMarker as w, type ExternalSceneNode as x, type ExternalSceneNodeBase as y, type ExternalSceneShape as z };
|