agentic-mermaid 0.1.1 → 0.2.0
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 +155 -91
- package/CHANGELOG.md +163 -4
- package/Instructions_for_agents.md +10 -10
- package/LICENSES/Apache-2.0.txt +202 -0
- package/README.md +31 -38
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/assets/hero.png +0 -0
- package/dist/agent-core.d.ts +463 -0
- package/dist/agent-core.js +397 -0
- package/dist/agent.d.ts +73 -1868
- package/dist/agent.js +336 -37325
- package/dist/agentic-mermaid-mcp.js +7 -38399
- package/dist/am.js +33626 -40446
- package/dist/chunk-2P5FKUQC.js +3485 -0
- package/dist/chunk-2S3VSS6I.js +149 -0
- package/dist/chunk-2SILJDW2.js +37 -0
- package/dist/chunk-BJYMBT4I.js +61963 -0
- package/dist/chunk-FDM43XU7.js +615 -0
- package/dist/chunk-MYPDVZCO.js +4702 -0
- package/dist/index-DWPa2MJs.d.ts +6780 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +310 -33014
- package/dist/mcp-cli-5J47WEY3.js +17 -0
- package/docs/README.md +39 -31
- package/docs/agent-api-cookbook.md +44 -35
- package/docs/agent-mutation-policy.md +1 -1
- package/docs/agent-workflow-examples.md +2 -2
- package/docs/api.md +284 -77
- package/docs/ascii.md +26 -16
- package/docs/code-mode-impact.md +214 -0
- package/docs/comparison.md +23 -11
- package/docs/computational-aesthetics-prototype-plan.md +252 -0
- package/docs/config.md +26 -10
- package/docs/custom-fonts.md +265 -0
- package/docs/custom-style-cookbook.md +130 -9
- package/docs/diagram-families.md +48 -23
- package/docs/features.md +59 -52
- package/docs/fork-differences.md +6 -3
- package/docs/getting-started.md +23 -16
- package/docs/issue-derived-test-cases.md +29 -22
- package/docs/mcp-code-mode-rationale.md +13 -6
- package/docs/mcp-http-transport.md +20 -13
- package/docs/mermaid-layout-complaints.md +66 -52
- package/docs/mutation-testing.md +145 -66
- package/docs/quality.md +23 -14
- package/docs/react.md +2 -2
- package/docs/schemas/style-spec.schema.json +1221 -30
- package/docs/style-authoring.md +241 -38
- package/docs/svg-semantic-contract.md +49 -0
- package/docs/testing-strategy.md +166 -58
- package/docs/theming.md +19 -32
- package/examples/styles/catalog.json +54 -0
- package/examples/styles/cloudflare-workers-inspired-prototype.mmd +9 -0
- package/examples/styles/cloudflare-workers-inspired-prototype.style.json +110 -0
- package/examples/styles/cupertino-prototype.mmd +10 -0
- package/examples/styles/cupertino-prototype.style.json +63 -0
- package/examples/styles/mid-century-report.style.json +2 -2
- package/examples/styles/star-chart-atlas.style.json +2 -1
- package/examples/styles/transit-route-map.style.json +2 -2
- package/examples/styles/vercel-inspired-prototype.mmd +6 -0
- package/examples/styles/vercel-inspired-prototype.style.json +87 -0
- package/package.json +85 -45
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +17 -36
- package/skills/agentic-mermaid-diagram-workflow/references/cli.md +4 -5
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +15 -31
- package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +10 -14
- package/skills/agentic-mermaid-live-editor/SKILL.md +100 -206
- package/TODO.md +0 -684
- package/dist/index-wjRjbsP-.d.ts +0 -1102
- package/docs/assets/improvements/box-start-connector.png +0 -0
- package/docs/assets/improvements/comment-dropped-lint.png +0 -0
- package/docs/assets/improvements/er-content-loss.png +0 -0
- package/docs/assets/improvements/fan-in-trunks.png +0 -0
- package/docs/assets/improvements/gantt-family.png +0 -0
- package/docs/assets/improvements/gantt-milestone-clamp.png +0 -0
- package/docs/assets/improvements/gantt-verify-seam.png +0 -0
- package/docs/assets/improvements/subgraph-container-edges.png +0 -0
- package/docs/assets/improvements/wrapper-frontmatter.png +0 -0
- package/docs/assets/improvements/wrapper-init-directive.png +0 -0
- package/docs/assets/improvements/wrapper-leading-comment.png +0 -0
- package/docs/assets/style-cookbook/mid-century-report.png +0 -0
- package/docs/assets/style-cookbook/star-chart-atlas.png +0 -0
- package/docs/assets/style-cookbook/transit-route-map.png +0 -0
- package/docs/contributing/adding-diagram-types.md +0 -144
- package/docs/contributing/diagram-family-citizenship.matrix.json +0 -2127
- package/docs/contributing/diagram-family-citizenship.md +0 -82
- package/docs/contributing/harvesting-upstream-tests.md +0 -126
- package/docs/contributing/lessons-learned.md +0 -276
- package/docs/contributing/releasing.md +0 -82
- package/docs/contributing/visual-review-evidence.md +0 -53
- package/docs/design/families/README.md +0 -26
- package/docs/design/families/architecture-beta.md +0 -48
- package/docs/design/families/flowchart-parser-conformance.md +0 -22
- package/docs/design/families/gantt-research.md +0 -137
- package/docs/design/families/gantt.md +0 -329
- package/docs/design/families/journey-agentic-cards-before.png +0 -0
- package/docs/design/families/journey-experience-curve-implementation.png +0 -0
- package/docs/design/families/journey-mermaid-classic-implementation.png +0 -0
- package/docs/design/families/journey-mermaid-classic-prototype.png +0 -0
- package/docs/design/families/journey-mermaid-classic-prototype.svg +0 -163
- package/docs/design/families/journey-mermaid-classic-prototype.svg.png +0 -0
- package/docs/design/families/journey-migration-parity.md +0 -439
- package/docs/design/families/journey-section-overlap-after.png +0 -0
- package/docs/design/families/journey-section-overlap-before.png +0 -0
- package/docs/design/families/journey-usage-research.md +0 -423
- package/docs/design/families/journey.md +0 -153
- package/docs/design/families/xychart.md +0 -85
- package/docs/design/system/README.md +0 -45
- package/docs/design/system/abstraction-audit.md +0 -224
- package/docs/design/system/abstraction-recommendations.md +0 -655
- package/docs/design/system/architecture.mmd +0 -29
- package/docs/design/system/architecture.svg +0 -137
- package/docs/design/system/layout-guarantees-and-robustness.md +0 -351
- package/docs/design/system/layout-rubric.md +0 -138
- package/docs/design/system/route-contracts.md +0 -848
- package/docs/design/system/source-preservation-ladder.md +0 -52
- package/docs/design/system/styles-rollout.md +0 -216
- package/docs/design/system/ugly-layouts.md +0 -119
- package/docs/layout-characterization/README.md +0 -245
- package/docs/layout-characterization/contact-sheet-families.md +0 -498
- package/docs/layout-characterization/contact-sheet.md +0 -638
- package/docs/layout-characterization/properties.md +0 -281
- package/docs/layout-characterization/visual-quality.md +0 -160
- package/docs/layout-characterization/visual-snapshots/architecture.svg +0 -79
- package/docs/layout-characterization/visual-snapshots/class.svg +0 -60
- package/docs/layout-characterization/visual-snapshots/er.svg +0 -61
- package/docs/layout-characterization/visual-snapshots/flowchart.svg +0 -58
- package/docs/layout-characterization/visual-snapshots/gantt.svg +0 -52
- package/docs/layout-characterization/visual-snapshots/journey.svg +0 -98
- package/docs/layout-characterization/visual-snapshots/pie.svg +0 -36
- package/docs/layout-characterization/visual-snapshots/quadrant.svg +0 -47
- package/docs/layout-characterization/visual-snapshots/sequence.svg +0 -59
- package/docs/layout-characterization/visual-snapshots/state.svg +0 -52
- package/docs/layout-characterization/visual-snapshots/timeline.svg +0 -64
- package/docs/layout-characterization/visual-snapshots/xychart.svg +0 -97
- package/docs/project/divergences.md +0 -98
- package/docs/project/dogfooding-docs-strategy.md +0 -66
- package/docs/project/hosted-mcp-cloudflare-plan.md +0 -338
- package/docs/project/lessons-learned.md +0 -1019
- package/docs/project/remove-role-styling-plan.md +0 -176
- package/examples/agent-improve-auth-flow.ts +0 -206
- package/examples/agent-loop.ts +0 -53
- package/examples/mcp-vs-cli-complex-diagrams.ts +0 -133
- package/llms.txt +0 -104
- package/skill-evals/README.md +0 -77
- package/skill-evals/fixtures/architecture-cache/input.mmd +0 -5
- package/skill-evals/fixtures/class-payment/input.mmd +0 -4
- package/skill-evals/fixtures/er-orders/input.mmd +0 -10
- package/skill-evals/fixtures/flowchart-cache/input.mmd +0 -3
- package/skill-evals/fixtures/gantt-release/input.mmd +0 -7
- package/skill-evals/fixtures/journey-checkout/input.mmd +0 -6
- package/skill-evals/fixtures/pie-exports/input.mmd +0 -5
- package/skill-evals/fixtures/quadrant-priorities/input.mmd +0 -11
- package/skill-evals/fixtures/sequence-retry/input.mmd +0 -8
- package/skill-evals/fixtures/state-lifecycle/input.mmd +0 -5
- package/skill-evals/fixtures/timeline-release/input.mmd +0 -6
- package/skill-evals/fixtures/xychart-growth/input.mmd +0 -5
- package/skill-evals/shared-benchmark.json +0 -510
- package/src/agent/analyze.ts +0 -157
- package/src/agent/apply.ts +0 -146
- package/src/agent/architecture-body.ts +0 -458
- package/src/agent/certificates.ts +0 -110
- package/src/agent/class-body.ts +0 -319
- package/src/agent/core.ts +0 -207
- package/src/agent/create.ts +0 -106
- package/src/agent/describe.ts +0 -368
- package/src/agent/er-body.ts +0 -224
- package/src/agent/facts.ts +0 -360
- package/src/agent/families-builtin.ts +0 -920
- package/src/agent/families.ts +0 -232
- package/src/agent/family-layouts.ts +0 -832
- package/src/agent/flowchart-body.ts +0 -372
- package/src/agent/flowchart-unsupported.ts +0 -243
- package/src/agent/font-coverage.ts +0 -288
- package/src/agent/gantt-body.ts +0 -495
- package/src/agent/index.ts +0 -10
- package/src/agent/journey-body.ts +0 -374
- package/src/agent/label-metrics.ts +0 -28
- package/src/agent/layout-to-rendered.ts +0 -63
- package/src/agent/mutate.ts +0 -97
- package/src/agent/mutation-ops.ts +0 -51
- package/src/agent/op-schema.ts +0 -443
- package/src/agent/parse.ts +0 -223
- package/src/agent/pie-body.ts +0 -270
- package/src/agent/png.ts +0 -171
- package/src/agent/quadrant-body.ts +0 -336
- package/src/agent/quality.ts +0 -363
- package/src/agent/readability-audit.ts +0 -92
- package/src/agent/rendered-route-audit.ts +0 -61
- package/src/agent/sequence-body.ts +0 -345
- package/src/agent/serialize.ts +0 -214
- package/src/agent/state-body.ts +0 -589
- package/src/agent/structural-count.ts +0 -150
- package/src/agent/timeline-body.ts +0 -280
- package/src/agent/trace-log.ts +0 -43
- package/src/agent/types.ts +0 -995
- package/src/agent/verify.ts +0 -603
- package/src/agent/xychart-body.ts +0 -472
- package/src/architecture/config.ts +0 -282
- package/src/architecture/layout.ts +0 -496
- package/src/architecture/parser.ts +0 -375
- package/src/architecture/renderer.ts +0 -611
- package/src/architecture/types.ts +0 -113
- package/src/ascii/ansi.ts +0 -423
- package/src/ascii/architecture.ts +0 -210
- package/src/ascii/canvas.ts +0 -443
- package/src/ascii/class-diagram.ts +0 -697
- package/src/ascii/converter.ts +0 -475
- package/src/ascii/draw.ts +0 -1693
- package/src/ascii/edge-bundling.ts +0 -328
- package/src/ascii/edge-routing.ts +0 -330
- package/src/ascii/er-diagram.ts +0 -439
- package/src/ascii/gantt.ts +0 -276
- package/src/ascii/grid.ts +0 -747
- package/src/ascii/index.ts +0 -196
- package/src/ascii/journey.ts +0 -169
- package/src/ascii/meta.ts +0 -244
- package/src/ascii/multiline-utils.ts +0 -80
- package/src/ascii/pathfinder.ts +0 -301
- package/src/ascii/pie.ts +0 -67
- package/src/ascii/quadrant.ts +0 -158
- package/src/ascii/reverse.ts +0 -216
- package/src/ascii/sequence.ts +0 -499
- package/src/ascii/shapes/circle.ts +0 -27
- package/src/ascii/shapes/corners.ts +0 -143
- package/src/ascii/shapes/diamond.ts +0 -27
- package/src/ascii/shapes/hexagon.ts +0 -27
- package/src/ascii/shapes/index.ts +0 -106
- package/src/ascii/shapes/rectangle.ts +0 -168
- package/src/ascii/shapes/rounded.ts +0 -27
- package/src/ascii/shapes/special.ts +0 -332
- package/src/ascii/shapes/stadium.ts +0 -110
- package/src/ascii/shapes/state.ts +0 -192
- package/src/ascii/shapes/types.ts +0 -73
- package/src/ascii/timeline.ts +0 -141
- package/src/ascii/types.ts +0 -312
- package/src/ascii/validate.ts +0 -120
- package/src/ascii/width.ts +0 -81
- package/src/ascii/wrap.ts +0 -131
- package/src/ascii/xychart.ts +0 -919
- package/src/browser.ts +0 -29
- package/src/class/layout.ts +0 -240
- package/src/class/parser.ts +0 -332
- package/src/class/renderer.ts +0 -638
- package/src/class/types.ts +0 -129
- package/src/cli/agent-instructions.ts +0 -1
- package/src/cli/am-bin.ts +0 -6
- package/src/cli/exit-codes.ts +0 -18
- package/src/cli/index.ts +0 -1132
- package/src/cli/init-agent.ts +0 -147
- package/src/cli/run-entrypoint.ts +0 -10
- package/src/color-resolver.ts +0 -152
- package/src/elk-instance.ts +0 -114
- package/src/er/layout.ts +0 -187
- package/src/er/parser.ts +0 -226
- package/src/er/renderer.ts +0 -792
- package/src/er/types.ts +0 -99
- package/src/family-rubric.ts +0 -425
- package/src/font-manifest.ts +0 -31
- package/src/gantt/layout.ts +0 -365
- package/src/gantt/parser.ts +0 -282
- package/src/gantt/pipeline.ts +0 -27
- package/src/gantt/renderer.ts +0 -414
- package/src/gantt/schedule.ts +0 -513
- package/src/gantt/types.ts +0 -255
- package/src/index.ts +0 -368
- package/src/journey/layout.ts +0 -554
- package/src/journey/parse-core.ts +0 -251
- package/src/journey/parser.ts +0 -101
- package/src/journey/renderer.ts +0 -917
- package/src/journey/types.ts +0 -144
- package/src/layout/geometry.ts +0 -182
- package/src/layout/pass.ts +0 -142
- package/src/layout/passes/index.ts +0 -3916
- package/src/layout-engine.ts +0 -1565
- package/src/layout-rubric.ts +0 -659
- package/src/mcp/artifacts.ts +0 -137
- package/src/mcp/dynamic-harness.ts +0 -31
- package/src/mcp/dynamic-modules.d.ts +0 -7
- package/src/mcp/facade.ts +0 -608
- package/src/mcp/harness-runtime.ts +0 -203
- package/src/mcp/hosted-server.ts +0 -468
- package/src/mcp/mcp-bin.ts +0 -3
- package/src/mcp/mcp-cli.ts +0 -82
- package/src/mcp/protocol.ts +0 -13
- package/src/mcp/sandbox.ts +0 -195
- package/src/mcp/sdk-decl.ts +0 -391
- package/src/mcp/server.ts +0 -362
- package/src/mcp/tool-surface.ts +0 -146
- package/src/mermaid-source.ts +0 -655
- package/src/multiline-utils.ts +0 -228
- package/src/parser.ts +0 -1031
- package/src/pie/layout.ts +0 -168
- package/src/pie/parser.ts +0 -136
- package/src/pie/renderer.ts +0 -234
- package/src/pie/types.ts +0 -82
- package/src/quadrant/layout.ts +0 -191
- package/src/quadrant/parser.ts +0 -183
- package/src/quadrant/renderer.ts +0 -322
- package/src/quadrant/types.ts +0 -113
- package/src/render-family-hooks.ts +0 -244
- package/src/renderer.ts +0 -1099
- package/src/route-contracts.ts +0 -2723
- package/src/scene/backend.ts +0 -76
- package/src/scene/fidelity.ts +0 -183
- package/src/scene/hybrid-backend.ts +0 -174
- package/src/scene/ir.ts +0 -181
- package/src/scene/marks.ts +0 -127
- package/src/scene/rough-backend.ts +0 -378
- package/src/scene/seed.ts +0 -46
- package/src/scene/style-registry.ts +0 -556
- package/src/sequence/layout.ts +0 -456
- package/src/sequence/parser.ts +0 -255
- package/src/sequence/renderer.ts +0 -604
- package/src/sequence/types.ts +0 -154
- package/src/shape-clipping.ts +0 -351
- package/src/shared/accessibility-directives.ts +0 -22
- package/src/shared/batched.ts +0 -61
- package/src/shared/color-math.ts +0 -93
- package/src/shared/svg-a11y.ts +0 -29
- package/src/shared/syntax-error.ts +0 -17
- package/src/shared/unicode-ranges.ts +0 -135
- package/src/styles.ts +0 -318
- package/src/svg-paths.ts +0 -28
- package/src/text-metrics.ts +0 -248
- package/src/theme.ts +0 -710
- package/src/timeline/layout.ts +0 -381
- package/src/timeline/parser.ts +0 -215
- package/src/timeline/renderer.ts +0 -538
- package/src/timeline/types.ts +0 -105
- package/src/types.ts +0 -462
- package/src/website-worker-modules.d.ts +0 -18
- package/src/xychart/axis-utils.ts +0 -109
- package/src/xychart/colors.ts +0 -124
- package/src/xychart/config.ts +0 -88
- package/src/xychart/layout.ts +0 -656
- package/src/xychart/parser.ts +0 -504
- package/src/xychart/renderer.ts +0 -640
- package/src/xychart/types.ts +0 -282
package/dist/agent.d.ts
CHANGED
|
@@ -1,1882 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { AsciiWarning } from './agent-core.js';
|
|
2
|
+
export { ASCII_ROUTE_PARITY_CONTRACT, ApplyOpsInput, AsciiRegion, AsciiWarningCode, AsciiWithMeta, BOUND_PROVENANCE, BoundBasis, BoundProvenance, BuildError, CheckMermaidObjectSpec, CheckMermaidResult, CheckMermaidSpec, CheckedBuildError, CreateMermaidOptions, DEFAULT_BOUNDS, DescribeOptions, DescribeTree, FamilyConformanceError, LayoutCertificateProof, LayoutMermaidOptions, LayoutRenderOptions, MermaidFact, OpEnvelope, OpFamily, OpFieldDoc, OpValidationError, QualityBounds, QualityMeasurementOptions, QualityMetrics, QualityVerdict, RankedViolation, RegionKind, RenderedLayoutArtifact, VerifySummary, ViolationSeverity, analyzeMermaid, analyzeMermaidSource, applyOps, asciiToMermaid, buildChecked, buildMermaid, checkMermaid, checkMermaidSource, checkQuality, collectActionRecords, createMermaid, describeMermaid, describeMermaidFacts, describeMermaidFactsSource, describeMermaidSource, describeMermaidTree, describeOps, edgeIdOf, hasOpSchema, layoutCertificateProof, layoutMermaid, layoutMermaidWithReceipt, measureQuality, mutate, mutateChecked, opMenu, opSignatures, projectPositionedView, registerFamily, renderMermaidASCII, renderMermaidASCIIWithMeta, renderMermaidASCIIWithReceipt, renderMermaidSVG, renderMermaidSVGWithReceipt, serializeMermaid, synthesizeFromGraph, validateOp, verifyMermaid, verifySummary } from './agent-core.js';
|
|
3
|
+
import { P as ParsedDiagram, R as RenderOptions, a as PngOutputPolicyInput, b as RenderRequestReceipt, c as PngRuntimeProvenance, H as HostBackendPolicy, A as AsciiRenderOptions, d as RenderedRegion, D as DiagramActionRecord } from './index-DWPa2MJs.js';
|
|
4
|
+
export { e as Accessibility, f as AnyMutationOp, g as AnyPort, h as ArchitectureBody, i as ArchitectureEdge, j as ArchitectureEndpoint, k as ArchitectureEndpointBoundary, l as ArchitectureGroup, m as ArchitectureJunction, n as ArchitectureMutationOp, o as ArchitectureService, p as ArchitectureSide, q as ArchitectureValidDiagram, r as ArchitectureVisualOverrides, s as AsciiRenderColorMode, t as AsciiWidthError, u as AsciiWidthErrorReason, B as BACKEND_CONFORMANCE_CHECK_IDS, v as BACKEND_CONFORMANCE_FIXTURE_ID, w as BACKEND_CONFORMANCE_VERSION, x as BINDABLE_ROLE_STYLE_PROPERTIES, y as BINDABLE_SCENE_ROLES, z as BRAND_CONSTRAINT_DESCRIPTORS, C as BRAND_CONSTRAINT_KINDS, E as BUILTIN_FAMILY_METADATA, F as BUILTIN_FAMILY_METADATA_COVERS_DIAGRAM_KIND, G as BUILTIN_SCENE_ROLE_TRAITS, I as BackendCapabilityConformanceResult, J as BackendCapabilityConformanceStatus, K as BackendConformanceCheck, L as BackendConformanceCheckId, M as BackendConformanceReport, N as BackendDescriptor, O as BackendRegistrationOptions, Q as BindableSceneRole, S as BrandConstraint, T as BrandConstraintAction, U as BrandConstraintKind, V as BuiltinFamilyId, W as BuiltinFamilyMetadata, X as CAPABILITY_NEGOTIATION_VERSION, Y as CORE_CAPABILITY_OFFERS, Z as CORE_SCENE_FEATURES, _ as CORE_SCENE_OPERATIONS, $ as CORE_SCENE_PRIMITIVES, a0 as CapabilityDecision, a1 as CapabilityId, a2 as CapabilityOffer, a3 as CapabilityRequirement, a4 as CapabilityRequirementLevel, a5 as CapabilityResolution, a6 as ClassBody, a7 as ClassMutationOp, a8 as ClassNode, a9 as ClassNote, aa as ClassRelation, ab as ClassRelationKind, ac as ClassValidDiagram, ad as CliRenderTransport, ae as CodeModeRenderTransport, af as ConnectorContourSemantics, ag as ConnectorEndpoints, ah as ConnectorGeometry, ai as ConnectorHitGeometry, aj as ConnectorLabelDescriptor, ak as ConnectorMark, al as ConnectorRelationship, am as ConnectorRoute, an as ConnectorStroke, ao as ConnectorSubpath, ap as ConnectorTerminalLabelProjection, aq as ConnectorTerminalMarkerPlacement, ar as ConnectorTerminalMarkerProjection, as as ConnectorTerminalProjection, at as ConnectorTerminalStrokeLoss, au as DEFAULT_LABEL_CHAR_CAP, av as DefaultBackend, aw as DiagramActionKind, ax as DiagramActionSecurity, ay as DiagramAnalysis, az as DiagramBody, aA as DiagramKind, aB as DiamondFacet, aC as EXACT_ROLE_STYLE_CONTRACT, aD as EXACT_STYLE_SCENE_ROLES, aE as EXTERNAL_SCENE_API_VERSION, aF as EdgeId, aG as EdgeRouteCertificate, aH as ErAttribute, aI as ErBody, aJ as ErCardinality, aK as ErEntity, aL as ErMutationOp, aM as ErRelation, aN as ErValidDiagram, aO as ExactStyleSceneRole, aP as ExtensionDiagramBody, aQ as ExtensionIdentity, aR as ExtensionValidDiagram, aS as ExternalFamilyId, aT as ExternalSceneConnector, aU as ExternalSceneConnectorGeometry, aV as ExternalSceneConnectorLabel, aW as ExternalSceneContainer, aX as ExternalSceneDataMark, aY as ExternalSceneDocument, aZ as ExternalSceneGeometry, a_ as ExternalSceneInput, a$ as ExternalSceneMarker, b0 as ExternalSceneNode, b1 as ExternalSceneNodeBase, b2 as ExternalSceneShape, b3 as ExternalSceneText, b4 as ExtractedLabel, b5 as FAMILY_CAPABILITY_COLUMNS, b6 as FAMILY_CONFORMANCE_MAX_EXAMPLE_BYTES, b7 as FAMILY_CONFORMANCE_VERSION, b8 as FAMILY_DESCRIPTOR_CONTRACT_VERSION, b9 as FamilyCapability, ba as FamilyCapabilityConformanceResult, bb as FamilyCapabilityEvidence, bc as FamilyCapabilityState, bd as FamilyConformanceReport, be as FamilyConformanceStatus, bf as FamilyDescriptor, bg as FamilyDetectionDiagnostic, bh as FamilyEdgeRouteCertificate, bi as FamilyId, bj as FamilyOperations, bk as FamilyParsedBody, bl as FamilyPositionedProjectionContext, bm as FamilyPositionedProjectionOptions, bn as FamilyPositionedView, bo as FamilyRouteCertificate, bp as FamilyScenePositivePrimitive, bq as FamilyScenePrimitiveApplicability, br as FamilyScenePrimitiveEvidence, bs as FamilySceneRolePrimitiveDeclaration, bt as FeedbackEdgeAnalysis, bu as Finite, bv as FlowchartMutationOp, bw as FlowchartValidDiagram, bx as GanttBody, by as GanttBodySection, bz as GanttBodyTask, bA as GanttBodyTaskTag, bB as GanttMutationOp, bC as GanttScheduleAnalysisSummary, bD as GanttStatement, bE as GanttValidDiagram, bF as GitGraphBody, bG as GitGraphMutationOp, bH as GitGraphValidDiagram, bI as GroupId, bJ as HOSTED_FONT_RESOURCES, bK as InitDirective, bL as JourneyBody, bM as JourneyMutationOp, bN as JourneySection, bO as JourneyTask, bP as JourneyValidDiagram, bQ as LayoutRouteCertificate, bR as LayoutRouteClass, bS as LayoutWarning, bT as LibraryRenderTransport, bU as MAX_HOSTED_PNG_BYTES, bV as MAX_HOSTED_PNG_PIXELS, bW as MAX_PNG_FONT_DIRECTORIES, bX as MAX_PNG_FONT_DIRECTORY_LENGTH, bY as MAX_PNG_PIXELS, bZ as MAX_PNG_RASTER_DIMENSION, b_ as MarkerDescriptor, b$ as MermaidFamilyClassification, c0 as MermaidFamilyDetectionError, c1 as MindmapBody, c2 as MindmapMutationOp, c3 as MindmapValidDiagram, c4 as MutableValidDiagram, c5 as MutationError, c6 as NATIVE_PNG_HOST_ONLY_OPTION_FIELDS, c7 as NATIVE_PNG_OUTPUT_POLICY_FIELDS, c8 as NativePngHostOnlyOptionField, c9 as NativePngOutputPolicyField, ca as NodeId, cb as PNG_DEFAULT_FONT_FAMILY, cc as PNG_DEFAULT_SCALE, cd as PNG_FONT_SOURCES, ce as PNG_NAPI_RUNTIME, cf as PNG_OUTPUT_OPTION_FIELDS, cg as PNG_OUTPUT_OPTION_FIELD_DESCRIPTORS, ch as PNG_OUTPUT_POLICY_VERSION, ci as PNG_WASM_RUNTIME, cj as PORTABLE_PNG_OUTPUT_OPTION_FIELDS, ck as PRIMITIVE_REALIZATIONS, cl as ParseError, cm as ParticipantId, cn as PieBody, co as PieMutationOp, cp as PieSlice, cq as PieValidDiagram, cr as PngFitTo, cs as PngFontSource, ct as PngOutputOptionField, cu as PngOutputOptionFieldDescriptor, cv as PngOutputOptionInputKind, cw as PngOutputOptionPolicyState, cx as PngOutputOptionReceiptState, cy as PngOutputOptionScope, cz as PngRasterDimensions, cA as PortSemanticRole, cB as PortSide, cC as PortablePngOutputOptionField, cD as PortablePngOutputOptions, cE as PreservedDiagramBody, cF as PreservedSourceSpans, cG as PreservedValidDiagram, cH as QuadrantAxis, cI as QuadrantBody, cJ as QuadrantMutationOp, cK as QuadrantPoint, cL as QuadrantValidDiagram, cM as RENDER_CONTRACT_VERSION, cN as RENDER_OUTPUTS, cO as RENDER_OUTPUT_DESCRIPTORS, cP as RESOURCE_MANIFEST, cQ as RESOURCE_MANIFEST_VERSION, cR as ROLE_STYLE_PROPERTY_DESCRIPTORS, cS as RadarBody, cT as RadarBodyAxis, cU as RadarBodyCurve, cV as RadarMutationOp, cW as RadarValidDiagram, cX as RegionContainmentCertificate, cY as RenderCapabilityError, cZ as RenderOutputDescriptor, c_ as RenderOutputTransports, c$ as RenderedAscii, d0 as RenderedLayout, d1 as RenderedLayoutEdge, d2 as RenderedLayoutGroup, d3 as RenderedLayoutNode, d4 as RenderedRegionKind, d5 as ResolvedPngOutputPolicy, d6 as ResolvedTerminalOutputPolicy, d7 as Result, d8 as RoleStyleFor, d9 as RoleStyleSpec, da as RoleStyles, db as RouteBlocker, dc as RouteCertificate, dd as RouteClass, de as RoutePortAssignment, df as SCENE_CONTRACT_VERSION, dg as SCENE_ROLE_DESCRIPTORS, dh as SCENE_VALIDATION_LIMITS, di as SCENE_VALIDATION_VERSION, dj as SEMANTIC_BINDING_CHANNELS, dk as SHARED_RENDER_OPTION_FIELDS, dl as STYLE_COLOR_TOKEN_DESCRIPTORS, dm as STYLE_SPEC_FIELD_DESCRIPTORS, dn as STYLE_SPEC_FORMAT_VERSION, dp as SceneDoc, dq as SceneNode, dr as SceneRole, ds as SceneValidationDiagnostic, dt as SceneValidationDiagnosticCode, du as SceneValidationError, dv as SceneValidationOptions, dw as SceneValidationResult, dx as SemanticBinding, dy as SemanticBindingChannel, dz as SemanticChannels, dA as SemanticSlots, dB as SequenceBody, dC as SequenceMessage, dD as SequenceMessageStyle, dE as SequenceMutationOp, dF as SequenceParticipant, dG as SequenceValidDiagram, dH as SerializedFlowchartGraph, dI as SourceComment, dJ as SourceMap, dK as SourceMapSpans, dL as SourcePreservationReceipt, dM as SourceSpan, dN as SourceSpanPoint, dO as StateBody, dP as StateMutationOp, dQ as StateNode, dR as StateTransition, dS as StateValidDiagram, dT as StyleBackend, dU as StyleBackendContext, dV as StyleColors, dW as StyleDescriptor, dX as StyleInput, dY as StyleReferenceResolution, dZ as StyleRegistrationOptions, d_ as StyleSpec, d$ as TERMINAL_BOUNDED_PADDING_X, e0 as TERMINAL_DEFAULT_BOX_BORDER_PADDING, e1 as TERMINAL_DEFAULT_PADDING_X, e2 as TERMINAL_DEFAULT_PADDING_Y, e3 as TERMINAL_OUTPUT_POLICY_VERSION, e4 as TEXT_MEASUREMENT_CONTRACT, e5 as TerminalOutputPolicyError, e6 as TerminalOutputPolicyInput, e7 as TextMeasurementContract, e8 as TextMeasurementInput, e9 as TextMeasurementResult, ea as Tier1WarningCode, eb as Tier2WarningCode, ec as TimelineBody, ed as TimelineEvent, ee as TimelineMutationOp, ef as TimelinePeriod, eg as TimelineSection, eh as TimelineValidDiagram, ei as UNREGISTERED_FAMILY_CAPABILITY_STATES, ej as UPSTREAM_MERMAID_FAMILY_INDEX, ek as UpstreamFamilyDescriptor, el as UpstreamHeaderDescriptor, em as UpstreamHeaderMatch, en as UpstreamManifestDiff, eo as UpstreamMermaidFamilyIndex, ep as UpstreamMermaidManifest, eq as ValidDiagram, er as ValidDiagramMeta, es as ValidDiagramPayload, et as VerifyOptions, eu as VerifyResult, ev as WARNING_SEVERITY, ew as WARNING_TIER, ex as WarningCode, ey as WarningSeverity, ez as WarningTier, eA as XyChartAxis, eB as XyChartAxisSpec, eC as XyChartBody, eD as XyChartMutationOp, eE as XyChartSeries, eF as XyChartValidDiagram, eG as asArchitecture, eH as asClass, eI as asEr, eJ as asFlowchart, eK as asGantt, eL as asGitGraph, eM as asJourney, eN as asMindmap, eO as asPie, eP as asQuadrant, eQ as asRadar, eR as asSequence, eS as asState, eT as asTimeline, eU as asXyChart, eV as assertHostedPngRasterBudget, eW as assertPngRasterBudget, eX as assertValidSceneDoc, eY as buildExternalScene, eZ as builtinFamilyMetadata, e_ as classifyMermaidFamilyFromFirstLine, e$ as createExtensionIdentity, f0 as declareFamilyScenePrimitiveEvidence, f1 as detectRegisteredFamilyFromFirstLine, f2 as effectiveFamilyCapabilityState, f3 as err, f4 as findUpstreamFamilyByHeader, f5 as getBackend, f6 as getFamily, f7 as getFamilyConformanceReport, f8 as getStyle, f9 as hostedFontResource, fa as inferBackend, fb as isBuiltinFamilyId, fc as isExternalFamilyId, fd as knownBackendDescriptors, fe as knownBuiltinFamilies, ff as knownFamilies, fg as knownStyleDescriptors, fh as knownStyles, fi as measureText, fj as measureTextWidth, fk as negotiateCapabilities, fl as negotiateRenderCapabilities, fm as normalizePortablePngBackground, fn as ok, fo as omitPngOutputOptions, fp as parseRegisteredMermaid, fq as parseSemVer, fr as pngNapiRuntimeProvenance, fs as pngOutputOptionsJsonSchema, ft as pngRasterDimensions, fu as prepareSvgForPngRasterization, fv as projectNativePngOutputPolicyInput, fw as projectPortablePngOutputOptions, fx as registerBackend, fy as registerStyle, fz as resolvePngOutputPolicy, fA as resolvePortablePngOutputPolicy, fB as resolveSceneRoleTraits, fC as resolveStyleReference, fD as resolveStyleStack, fE as resolveTerminalOutputPolicy, fF as runBackendConformance, fG as sceneRoleTraits, fH as semVerSatisfies, fI as sharedRenderOptionsJsonSchema, fJ as styleInputJsonSchema, fK as styleSpecJsonSchema, fL as svgIntrinsicDimensions, fM as terminalConnectorCapabilityClaims, fN as toFinite, fO as validatePrimitiveCapabilities, fP as validateResourceManifest, fQ as validateSceneDoc, fR as validateSerializableRenderOptions, fS as validateStyleSpec, fT as verifyNoExternalRefs, fU as verifyResourceBytes } from './index-DWPa2MJs.js';
|
|
3
5
|
|
|
4
|
-
type Result<T, E> = {
|
|
5
|
-
ok: true;
|
|
6
|
-
value: T;
|
|
7
|
-
} | {
|
|
8
|
-
ok: false;
|
|
9
|
-
error: E;
|
|
10
|
-
};
|
|
11
|
-
declare function ok<T, E = never>(value: T): Result<T, E>;
|
|
12
|
-
declare function err<E, T = never>(error: E): Result<T, E>;
|
|
13
|
-
type DiagramKind = 'flowchart' | 'state' | 'sequence' | 'class' | 'er' | 'timeline' | 'journey' | 'xychart' | 'architecture' | 'pie' | 'quadrant' | 'gantt';
|
|
14
|
-
interface SequenceParticipant {
|
|
15
|
-
id: string;
|
|
16
|
-
label: string;
|
|
17
|
-
kind: 'participant' | 'actor';
|
|
18
|
-
}
|
|
19
|
-
type SequenceMessageStyle = 'sync' | 'reply' | 'async' | 'async-dashed' | 'lost' | 'lost-dashed';
|
|
20
|
-
interface SequenceMessage {
|
|
21
|
-
from: string;
|
|
22
|
-
to: string;
|
|
23
|
-
text: string;
|
|
24
|
-
style: SequenceMessageStyle;
|
|
25
|
-
}
|
|
26
|
-
type SequenceStatement = {
|
|
27
|
-
kind: 'participant';
|
|
28
|
-
ref: number;
|
|
29
|
-
} | {
|
|
30
|
-
kind: 'message';
|
|
31
|
-
ref: number;
|
|
32
|
-
} | {
|
|
33
|
-
kind: 'opaque-block';
|
|
34
|
-
lines: string[];
|
|
35
|
-
};
|
|
36
|
-
interface SequenceBody {
|
|
37
|
-
kind: 'sequence';
|
|
38
|
-
participants: SequenceParticipant[];
|
|
39
|
-
messages: SequenceMessage[];
|
|
40
|
-
statements?: SequenceStatement[];
|
|
41
|
-
}
|
|
42
|
-
interface TimelineEvent {
|
|
43
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
44
|
-
id: string;
|
|
45
|
-
text: string;
|
|
46
|
-
}
|
|
47
|
-
interface TimelinePeriod {
|
|
48
|
-
id: string;
|
|
49
|
-
/** The temporal label (e.g., "2020", "Q1 2024"). */
|
|
50
|
-
label: string;
|
|
51
|
-
events: TimelineEvent[];
|
|
52
|
-
}
|
|
53
|
-
interface TimelineSection {
|
|
54
|
-
id: string;
|
|
55
|
-
/** Undefined = implicit/ungrouped section. */
|
|
56
|
-
label?: string;
|
|
57
|
-
periods: TimelinePeriod[];
|
|
58
|
-
}
|
|
59
|
-
interface TimelineBody {
|
|
60
|
-
kind: 'timeline';
|
|
61
|
-
title?: string;
|
|
62
|
-
sections: TimelineSection[];
|
|
63
|
-
}
|
|
64
|
-
interface JourneyTask {
|
|
65
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
66
|
-
id: string;
|
|
67
|
-
text: string;
|
|
68
|
-
/** Satisfaction score, integer 1..5 (Mermaid journey convention). */
|
|
69
|
-
score: number;
|
|
70
|
-
actors: string[];
|
|
71
|
-
}
|
|
72
|
-
interface JourneySection {
|
|
73
|
-
id: string;
|
|
74
|
-
/** Undefined = implicit/ungrouped section. */
|
|
75
|
-
label?: string;
|
|
76
|
-
tasks: JourneyTask[];
|
|
77
|
-
}
|
|
78
|
-
interface JourneyBody {
|
|
79
|
-
kind: 'journey';
|
|
80
|
-
title?: string;
|
|
81
|
-
/** Optional accessibility title from Mermaid accTitle. */
|
|
82
|
-
accessibilityTitle?: string;
|
|
83
|
-
/** Optional accessibility description from Mermaid accDescr. */
|
|
84
|
-
accessibilityDescription?: string;
|
|
85
|
-
sections: JourneySection[];
|
|
86
|
-
}
|
|
87
|
-
type ClassRelationKind = 'inheritance' | 'composition' | 'aggregation' | 'association' | 'dependency' | 'realization' | 'link-solid' | 'link-dashed';
|
|
88
|
-
interface ClassNode {
|
|
89
|
-
/** The bare class name (e.g., 'Animal'). */
|
|
90
|
-
id: string;
|
|
91
|
-
/** Optional display label (e.g., from `class X["My Label"]` or `class X as "..."`). */
|
|
92
|
-
label?: string;
|
|
93
|
-
/** Members, each as the raw source string ('+String name', '+eat()', '<<interface>>'). */
|
|
94
|
-
members: string[];
|
|
95
|
-
}
|
|
96
|
-
interface ClassRelation {
|
|
97
|
-
from: string;
|
|
98
|
-
to: string;
|
|
99
|
-
kind: ClassRelationKind;
|
|
100
|
-
/** Optional relationship label, e.g., from `A --> B : uses`. */
|
|
101
|
-
label?: string;
|
|
102
|
-
/** Optional cardinality on the `from` side (e.g., '"1"'). */
|
|
103
|
-
fromCardinality?: string;
|
|
104
|
-
/** Optional cardinality on the `to` side. */
|
|
105
|
-
toCardinality?: string;
|
|
106
|
-
}
|
|
107
|
-
interface ClassNote {
|
|
108
|
-
text: string;
|
|
109
|
-
/** Class id the note is attached to (undefined = freestanding). */
|
|
110
|
-
for?: string;
|
|
111
|
-
}
|
|
112
|
-
interface ClassBody {
|
|
113
|
-
kind: 'class';
|
|
114
|
-
title?: string;
|
|
115
|
-
classes: ClassNode[];
|
|
116
|
-
relations: ClassRelation[];
|
|
117
|
-
notes: ClassNote[];
|
|
118
|
-
}
|
|
119
|
-
type ErCardinality = 'one-only' | 'zero-or-one' | 'zero-or-many' | 'one-or-many';
|
|
120
|
-
interface ErAttribute {
|
|
121
|
-
/** The full source line (e.g., 'string name PK "comment"'). */
|
|
122
|
-
text: string;
|
|
123
|
-
}
|
|
124
|
-
interface ErEntity {
|
|
125
|
-
id: string;
|
|
126
|
-
attributes: ErAttribute[];
|
|
127
|
-
}
|
|
128
|
-
interface ErRelation {
|
|
129
|
-
from: string;
|
|
130
|
-
to: string;
|
|
131
|
-
leftCard: ErCardinality;
|
|
132
|
-
rightCard: ErCardinality;
|
|
133
|
-
/** Solid (--) or dashed (..) line. */
|
|
134
|
-
dashed: boolean;
|
|
135
|
-
label?: string;
|
|
136
|
-
}
|
|
137
|
-
interface ErBody {
|
|
138
|
-
kind: 'er';
|
|
139
|
-
entities: ErEntity[];
|
|
140
|
-
relations: ErRelation[];
|
|
141
|
-
}
|
|
142
|
-
type ArchitectureSide = 'L' | 'R' | 'T' | 'B';
|
|
143
|
-
interface ArchitectureGroup {
|
|
144
|
-
id: string;
|
|
145
|
-
label: string;
|
|
146
|
-
icon?: string;
|
|
147
|
-
/** Undefined = root (not nested in another group). */
|
|
148
|
-
parentId?: string;
|
|
149
|
-
}
|
|
150
|
-
interface ArchitectureService {
|
|
151
|
-
id: string;
|
|
152
|
-
label: string;
|
|
153
|
-
icon?: string;
|
|
154
|
-
/** Undefined = ungrouped (not inside a group). */
|
|
155
|
-
parentId?: string;
|
|
156
|
-
}
|
|
157
|
-
interface ArchitectureJunction {
|
|
158
|
-
id: string;
|
|
159
|
-
parentId?: string;
|
|
160
|
-
}
|
|
161
|
-
interface ArchitectureEndpoint {
|
|
162
|
-
id: string;
|
|
163
|
-
side: ArchitectureSide;
|
|
164
|
-
}
|
|
165
|
-
interface ArchitectureEdge {
|
|
166
|
-
source: ArchitectureEndpoint;
|
|
167
|
-
target: ArchitectureEndpoint;
|
|
168
|
-
label?: string;
|
|
169
|
-
hasArrowStart: boolean;
|
|
170
|
-
hasArrowEnd: boolean;
|
|
171
|
-
}
|
|
172
|
-
interface ArchitectureBody {
|
|
173
|
-
kind: 'architecture';
|
|
174
|
-
groups: ArchitectureGroup[];
|
|
175
|
-
services: ArchitectureService[];
|
|
176
|
-
junctions: ArchitectureJunction[];
|
|
177
|
-
edges: ArchitectureEdge[];
|
|
178
|
-
}
|
|
179
|
-
/** A single chart axis: an optional bare-text name plus EITHER categorical
|
|
180
|
-
* labels (x-axis only) OR a numeric range. All three fields are optional;
|
|
181
|
-
* a structured axis carries at least one of them. */
|
|
182
|
-
interface XyChartAxis {
|
|
183
|
-
/** Optional bare-text axis name/title. */
|
|
184
|
-
name?: string;
|
|
185
|
-
/** Categorical labels (x-axis only) — mutually exclusive with range. */
|
|
186
|
-
categories?: string[];
|
|
187
|
-
/** Numeric range — mutually exclusive with categories. */
|
|
188
|
-
range?: {
|
|
189
|
-
min: number;
|
|
190
|
-
max: number;
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
interface XyChartSeries {
|
|
194
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
195
|
-
id: string;
|
|
196
|
-
kind: 'bar' | 'line';
|
|
197
|
-
/** Optional bare-text series name. */
|
|
198
|
-
name?: string;
|
|
199
|
-
/** Data values; all finite. */
|
|
200
|
-
values: number[];
|
|
201
|
-
}
|
|
202
|
-
interface XyChartBody {
|
|
203
|
-
kind: 'xychart';
|
|
204
|
-
title?: string;
|
|
205
|
-
/** Header orientation suffix: `xychart-beta horizontal`. Default vertical. */
|
|
206
|
-
horizontal?: boolean;
|
|
207
|
-
xAxis?: XyChartAxis;
|
|
208
|
-
yAxis?: XyChartAxis;
|
|
209
|
-
series: XyChartSeries[];
|
|
210
|
-
}
|
|
211
|
-
interface PieSlice {
|
|
212
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
213
|
-
id: string;
|
|
214
|
-
/** The slice label (contents of the `"..."` quotes). */
|
|
215
|
-
label: string;
|
|
216
|
-
/** The slice value — a positive finite number. */
|
|
217
|
-
value: number;
|
|
218
|
-
}
|
|
219
|
-
interface PieBody {
|
|
220
|
-
kind: 'pie';
|
|
221
|
-
title?: string;
|
|
222
|
-
/** When true (`pie showData`), the legend shows each slice's numeric value. */
|
|
223
|
-
showData: boolean;
|
|
224
|
-
/** Slices in source order (drawn clockwise). */
|
|
225
|
-
slices: PieSlice[];
|
|
226
|
-
}
|
|
227
|
-
/** Axis label pair. The "far" side is optional in the grammar. */
|
|
228
|
-
interface QuadrantAxis {
|
|
229
|
-
/** x-axis: left label / y-axis: bottom label. */
|
|
230
|
-
near: string;
|
|
231
|
-
/** x-axis: right label / y-axis: top label. Optional. */
|
|
232
|
-
far?: string;
|
|
233
|
-
}
|
|
234
|
-
interface QuadrantPoint {
|
|
235
|
-
label: string;
|
|
236
|
-
/** Normalized x in [0, 1] (0 = left, 1 = right). */
|
|
237
|
-
x: number;
|
|
238
|
-
/** Normalized y in [0, 1] (0 = bottom, 1 = top). */
|
|
239
|
-
y: number;
|
|
240
|
-
}
|
|
241
|
-
interface QuadrantBody {
|
|
242
|
-
kind: 'quadrant';
|
|
243
|
-
title?: string;
|
|
244
|
-
xAxis?: QuadrantAxis;
|
|
245
|
-
yAxis?: QuadrantAxis;
|
|
246
|
-
/**
|
|
247
|
-
* Quadrant region labels indexed 1..4 by Mermaid's numbering:
|
|
248
|
-
* 1 = top-right, 2 = top-left, 3 = bottom-left, 4 = bottom-right.
|
|
249
|
-
* Stored 0-based where index `n-1` holds quadrant-`n`.
|
|
250
|
-
*/
|
|
251
|
-
quadrants: [string?, string?, string?, string?];
|
|
252
|
-
/** Plotted points in source order. */
|
|
253
|
-
points: QuadrantPoint[];
|
|
254
|
-
}
|
|
255
|
-
type GanttBodyTaskTag = 'active' | 'done' | 'crit' | 'milestone' | 'vert';
|
|
256
|
-
interface GanttBodyTask {
|
|
257
|
-
/** Stable within one parse; recomputed each parse. Not a durable identifier. */
|
|
258
|
-
id: string;
|
|
259
|
-
/** Mermaid task id from `:id, start, end` — referenced by after/until/click. */
|
|
260
|
-
taskId?: string;
|
|
261
|
-
label: string;
|
|
262
|
-
/** Status/shape tags in canonical order (active/done/crit/milestone/vert). */
|
|
263
|
-
tags: GanttBodyTaskTag[];
|
|
264
|
-
/** Raw start expression: a date in the diagram's dateFormat or `after id…`.
|
|
265
|
-
* Undefined = starts when the previous task ends (Mermaid default). */
|
|
266
|
-
start?: string;
|
|
267
|
-
/** Raw end expression: a date, a duration token (`3d`), or `until id…`. */
|
|
268
|
-
end: string;
|
|
269
|
-
}
|
|
270
|
-
interface GanttBodySection {
|
|
271
|
-
id: string;
|
|
272
|
-
/** Undefined = implicit/ungrouped section. */
|
|
273
|
-
label?: string;
|
|
274
|
-
tasks: GanttBodyTask[];
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Segment-preserving statement list (the sequence-body pattern): typed ops see
|
|
278
|
-
* sections/tasks/title; calendar directives (dateFormat, excludes, weekend…),
|
|
279
|
-
* click lines, comments, and markers ride along VERBATIM as opaque-block
|
|
280
|
-
* segments — never dropped, edited at the source level only.
|
|
281
|
-
*/
|
|
282
|
-
type GanttStatement = {
|
|
283
|
-
kind: 'title';
|
|
284
|
-
} | {
|
|
285
|
-
kind: 'section';
|
|
286
|
-
ref: number;
|
|
287
|
-
} | {
|
|
288
|
-
kind: 'task';
|
|
289
|
-
section: number;
|
|
290
|
-
ref: number;
|
|
291
|
-
} | {
|
|
292
|
-
kind: 'opaque-block';
|
|
293
|
-
lines: string[];
|
|
294
|
-
};
|
|
295
|
-
interface GanttBody {
|
|
296
|
-
kind: 'gantt';
|
|
297
|
-
title?: string;
|
|
298
|
-
sections: GanttBodySection[];
|
|
299
|
-
/** Optional for synthesized payloads; parsed bodies always populate it. */
|
|
300
|
-
statements?: GanttStatement[];
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* A state node. Simple states carry an optional display label; composite states
|
|
304
|
-
* additionally carry their own nested `states` + `transitions` (and an optional
|
|
305
|
-
* per-composite `direction`). The reserved pseudostate `[*]` is NOT a StateNode
|
|
306
|
-
* — it is modeled contextually as the endpoint id '[*]' on transitions (source
|
|
307
|
-
* = start pseudostate, target = end pseudostate), scoped per composite level.
|
|
308
|
-
*/
|
|
309
|
-
interface StateNode {
|
|
310
|
-
id: string;
|
|
311
|
-
/** Optional display label (`state "Label" as id` / `id : Label`). */
|
|
312
|
-
label?: string;
|
|
313
|
-
/** Composite children — present iff this is a composite state. */
|
|
314
|
-
states?: StateNode[];
|
|
315
|
-
/** Composite-internal transitions — present iff this is a composite state. */
|
|
316
|
-
transitions?: StateTransition[];
|
|
317
|
-
/** Optional per-composite layout direction. */
|
|
318
|
-
direction?: Direction;
|
|
319
|
-
}
|
|
320
|
-
interface StateTransition {
|
|
321
|
-
/** Source state id, or '[*]' for a start pseudostate. */
|
|
322
|
-
from: string;
|
|
323
|
-
/** Target state id, or '[*]' for an end pseudostate. */
|
|
324
|
-
to: string;
|
|
325
|
-
label?: string;
|
|
326
|
-
}
|
|
327
|
-
interface StateBody {
|
|
328
|
-
kind: 'state';
|
|
329
|
-
states: StateNode[];
|
|
330
|
-
transitions: StateTransition[];
|
|
331
|
-
/** Optional top-level layout direction. */
|
|
332
|
-
direction?: Direction;
|
|
333
|
-
}
|
|
334
|
-
interface SourceComment {
|
|
335
|
-
text: string;
|
|
336
|
-
line: number;
|
|
337
|
-
}
|
|
338
|
-
interface InitDirective {
|
|
339
|
-
raw: string;
|
|
340
|
-
parsed: MermaidConfigMap;
|
|
341
|
-
}
|
|
342
|
-
interface Accessibility {
|
|
343
|
-
title?: string;
|
|
344
|
-
descr?: string;
|
|
345
|
-
}
|
|
346
|
-
interface ValidDiagramMeta {
|
|
347
|
-
frontmatter?: MermaidFrontmatterMap;
|
|
348
|
-
initDirectives: InitDirective[];
|
|
349
|
-
comments: SourceComment[];
|
|
350
|
-
accessibility: Accessibility;
|
|
351
|
-
/**
|
|
352
|
-
* The leading source wrapper (frontmatter block, `%%{init}%%` directives,
|
|
353
|
-
* `%%` comments, and blank lines before the diagram header), preserved
|
|
354
|
-
* byte-verbatim. serializeMermaid re-emits it untouched by default;
|
|
355
|
-
* canonical wrapper synthesis is opt-in via `{ wrapper: 'canonical' }`.
|
|
356
|
-
* Absent on diagrams synthesized from JSON payloads, which fall back to
|
|
357
|
-
* canonical synthesis.
|
|
358
|
-
*/
|
|
359
|
-
wrapperSource?: string;
|
|
360
|
-
/**
|
|
361
|
-
* In-body `%%` comments that structured serialization does not preserve,
|
|
362
|
-
* computed at parse time by diffing against the canonical serialization.
|
|
363
|
-
* Surfaced by verify as the Tier 3 `COMMENT_DROPPED` lint. Opaque bodies
|
|
364
|
-
* preserve comments verbatim and never set this.
|
|
365
|
-
*/
|
|
366
|
-
droppedComments?: SourceComment[];
|
|
367
|
-
}
|
|
368
|
-
interface SourceLocation {
|
|
369
|
-
line: number;
|
|
370
|
-
col: number;
|
|
371
|
-
}
|
|
372
|
-
interface SourceMap {
|
|
373
|
-
nodes: Map<string, SourceLocation>;
|
|
374
|
-
edges: Map<string, SourceLocation>;
|
|
375
|
-
groups: Map<string, SourceLocation>;
|
|
376
|
-
/** Stable label spans where known: `node:<id>`, `edge#<i>:<from>-><to>`, `group:<id>`. */
|
|
377
|
-
labels: Map<string, SourceLocation>;
|
|
378
|
-
}
|
|
379
|
-
type DiagramActionKind = 'href' | 'call' | 'callback';
|
|
380
|
-
type DiagramActionSecurity = 'safe' | 'unsafe' | 'source-only' | 'unsupported';
|
|
381
|
-
interface DiagramActionRecord {
|
|
382
|
-
/** Stable source-side action id (`action:<family>:<target>:<n>`). */
|
|
383
|
-
id?: string;
|
|
384
|
-
/** Region id this action attaches to when a rendered layout exposes regions. */
|
|
385
|
-
regionId?: string;
|
|
386
|
-
family: DiagramKind;
|
|
387
|
-
target: string;
|
|
388
|
-
action: DiagramActionKind;
|
|
389
|
-
/** Original action payload after the target id; never executed by analysis. */
|
|
390
|
-
raw: string;
|
|
391
|
-
line?: number;
|
|
392
|
-
href?: string;
|
|
393
|
-
security: DiagramActionSecurity;
|
|
394
|
-
executable: false;
|
|
395
|
-
message?: string;
|
|
396
|
-
}
|
|
397
|
-
interface FeedbackEdgeAnalysis {
|
|
398
|
-
edgeIndex: number;
|
|
399
|
-
from: NodeId;
|
|
400
|
-
to: NodeId;
|
|
401
|
-
label?: string;
|
|
402
|
-
routeClass: RouteClass;
|
|
403
|
-
}
|
|
404
|
-
interface GanttScheduleAnalysisSummary {
|
|
405
|
-
criticalPathTaskIds: string[];
|
|
406
|
-
slackByTaskId: Record<string, number>;
|
|
407
|
-
projectStart: number;
|
|
408
|
-
projectEnd: number;
|
|
409
|
-
entryTaskIds: string[];
|
|
410
|
-
sinkTaskIds: string[];
|
|
411
|
-
}
|
|
412
|
-
interface DiagramAnalysis {
|
|
413
|
-
kind: DiagramKind;
|
|
414
|
-
feedbackEdges: FeedbackEdgeAnalysis[];
|
|
415
|
-
actions: DiagramActionRecord[];
|
|
416
|
-
gantt?: GanttScheduleAnalysisSummary;
|
|
417
|
-
}
|
|
418
|
-
type DiagramBody = {
|
|
419
|
-
kind: 'flowchart';
|
|
420
|
-
graph: MermaidGraph;
|
|
421
|
-
} | StateBody | SequenceBody | TimelineBody | ClassBody | ErBody | JourneyBody | ArchitectureBody | XyChartBody | PieBody | QuadrantBody | GanttBody
|
|
422
|
-
/**
|
|
423
|
-
* Opaque body — the parser understood the family header but encountered
|
|
424
|
-
* unmodeled syntax. `source` is the ORIGINAL body with indentation, blank
|
|
425
|
-
* lines, and comments PRESERVED (per the Loop 5 Phase A fix), so the
|
|
426
|
-
* serializer can re-emit byte-for-byte. Distinct from `ValidDiagram.canonicalSource`,
|
|
427
|
-
* which for structured bodies is the rebuilt canonical form.
|
|
428
|
-
*/
|
|
429
|
-
| {
|
|
430
|
-
kind: 'opaque';
|
|
431
|
-
family: DiagramKind;
|
|
432
|
-
source: string;
|
|
433
|
-
};
|
|
434
|
-
interface ValidDiagram {
|
|
435
|
-
readonly kind: DiagramKind;
|
|
436
|
-
readonly meta: ValidDiagramMeta;
|
|
437
|
-
readonly body: DiagramBody;
|
|
438
|
-
readonly source: SourceMap;
|
|
439
|
-
/**
|
|
440
|
-
* Load-bearing round-trip pillar. See AGENT_NATIVE.md § (3).
|
|
441
|
-
*
|
|
442
|
-
* For STRUCTURED bodies, `canonicalSource` is the normalized text
|
|
443
|
-
* (`normalized.text` from `mermaid-source.ts`) — used by `renderMermaidSVG`
|
|
444
|
-
* + the legacy parser for the flowchart pathway. After `serializeMermaid`,
|
|
445
|
-
* the re-emitted source is rebuilt from the structured body.
|
|
446
|
-
*
|
|
447
|
-
* For OPAQUE bodies, the serializer emits `body.source` directly (NOT
|
|
448
|
-
* `canonicalSource`) so original indentation and blank lines round-trip
|
|
449
|
-
* byte-for-byte. `canonicalSource` is still set, but it's the normalized
|
|
450
|
-
* (line-trimmed) form — useful for layout / rendering, not for fidelity.
|
|
451
|
-
*
|
|
452
|
-
* This split exists because the legacy flowchart parser needs trimmed
|
|
453
|
-
* lines, but opaque-fallback round-trip needs the original. Treat
|
|
454
|
-
* `body.source` as the source of truth for opaque-body fidelity.
|
|
455
|
-
*/
|
|
456
|
-
readonly canonicalSource: string;
|
|
457
|
-
}
|
|
458
|
-
type FlowchartValidDiagram = ValidDiagram & {
|
|
459
|
-
body: {
|
|
460
|
-
kind: 'flowchart';
|
|
461
|
-
graph: MermaidGraph;
|
|
462
|
-
};
|
|
463
|
-
};
|
|
464
|
-
type StateValidDiagram = ValidDiagram & {
|
|
465
|
-
body: StateBody;
|
|
466
|
-
};
|
|
467
|
-
type SequenceValidDiagram = ValidDiagram & {
|
|
468
|
-
body: SequenceBody;
|
|
469
|
-
};
|
|
470
|
-
type TimelineValidDiagram = ValidDiagram & {
|
|
471
|
-
body: TimelineBody;
|
|
472
|
-
};
|
|
473
|
-
type ClassValidDiagram = ValidDiagram & {
|
|
474
|
-
body: ClassBody;
|
|
475
|
-
};
|
|
476
|
-
type ErValidDiagram = ValidDiagram & {
|
|
477
|
-
body: ErBody;
|
|
478
|
-
};
|
|
479
|
-
type JourneyValidDiagram = ValidDiagram & {
|
|
480
|
-
body: JourneyBody;
|
|
481
|
-
};
|
|
482
|
-
type ArchitectureValidDiagram = ValidDiagram & {
|
|
483
|
-
body: ArchitectureBody;
|
|
484
|
-
};
|
|
485
|
-
type XyChartValidDiagram = ValidDiagram & {
|
|
486
|
-
body: XyChartBody;
|
|
487
|
-
};
|
|
488
|
-
type PieValidDiagram = ValidDiagram & {
|
|
489
|
-
body: PieBody;
|
|
490
|
-
};
|
|
491
|
-
type QuadrantValidDiagram = ValidDiagram & {
|
|
492
|
-
body: QuadrantBody;
|
|
493
|
-
};
|
|
494
|
-
type GanttValidDiagram = ValidDiagram & {
|
|
495
|
-
body: GanttBody;
|
|
496
|
-
};
|
|
497
|
-
type MutableValidDiagram = FlowchartValidDiagram | StateValidDiagram | SequenceValidDiagram | TimelineValidDiagram | ClassValidDiagram | ErValidDiagram | JourneyValidDiagram | ArchitectureValidDiagram | XyChartValidDiagram | PieValidDiagram | QuadrantValidDiagram | GanttValidDiagram;
|
|
498
|
-
declare function asFlowchart(d: ValidDiagram): FlowchartValidDiagram | null;
|
|
499
|
-
declare function asState(d: ValidDiagram): StateValidDiagram | null;
|
|
500
|
-
declare function asSequence(d: ValidDiagram): SequenceValidDiagram | null;
|
|
501
|
-
declare function asTimeline(d: ValidDiagram): TimelineValidDiagram | null;
|
|
502
|
-
declare function asClass(d: ValidDiagram): ClassValidDiagram | null;
|
|
503
|
-
declare function asEr(d: ValidDiagram): ErValidDiagram | null;
|
|
504
|
-
declare function asJourney(d: ValidDiagram): JourneyValidDiagram | null;
|
|
505
|
-
declare function asArchitecture(d: ValidDiagram): ArchitectureValidDiagram | null;
|
|
506
|
-
declare function asXyChart(d: ValidDiagram): XyChartValidDiagram | null;
|
|
507
|
-
declare function asPie(d: ValidDiagram): PieValidDiagram | null;
|
|
508
|
-
declare function asQuadrant(d: ValidDiagram): QuadrantValidDiagram | null;
|
|
509
|
-
declare function asGantt(d: ValidDiagram): GanttValidDiagram | null;
|
|
510
|
-
interface ParseError {
|
|
511
|
-
code: string;
|
|
512
|
-
message: string;
|
|
513
|
-
line?: number;
|
|
514
|
-
col?: number;
|
|
515
|
-
}
|
|
516
|
-
interface MutationError {
|
|
517
|
-
code: 'NODE_NOT_FOUND' | 'EDGE_NOT_FOUND' | 'PARTICIPANT_NOT_FOUND' | 'MESSAGE_NOT_FOUND' | 'SECTION_NOT_FOUND' | 'PERIOD_NOT_FOUND' | 'EVENT_NOT_FOUND' | 'TASK_NOT_FOUND' | 'ACTOR_NOT_FOUND' | 'CLASS_NOT_FOUND' | 'MEMBER_NOT_FOUND' | 'RELATION_NOT_FOUND' | 'NOTE_NOT_FOUND' | 'ENTITY_NOT_FOUND' | 'ATTRIBUTE_NOT_FOUND' | 'SERVICE_NOT_FOUND' | 'GROUP_NOT_FOUND' | 'SERIES_NOT_FOUND' | 'SLICE_NOT_FOUND' | 'POINT_NOT_FOUND' | 'STATE_NOT_FOUND' | 'TRANSITION_NOT_FOUND' | 'DUPLICATE_NODE' | 'DUPLICATE_PARTICIPANT' | 'DUPLICATE_CLASS' | 'DUPLICATE_ENTITY' | 'DUPLICATE_STATE' | 'DUPLICATE_TASK' | 'INVALID_OP';
|
|
518
|
-
message: string;
|
|
519
|
-
}
|
|
520
|
-
type NodeId = string;
|
|
521
|
-
type EdgeId = string;
|
|
522
|
-
type GroupId = string;
|
|
523
|
-
type ParticipantId = string;
|
|
524
|
-
type FlowchartMutationOp = {
|
|
525
|
-
kind: 'add_node';
|
|
526
|
-
id: NodeId;
|
|
527
|
-
label: string;
|
|
528
|
-
shape?: NodeShape;
|
|
529
|
-
parent?: GroupId;
|
|
530
|
-
} | {
|
|
531
|
-
kind: 'remove_node';
|
|
532
|
-
id: NodeId;
|
|
533
|
-
} | {
|
|
534
|
-
kind: 'rename_node';
|
|
535
|
-
from: NodeId;
|
|
536
|
-
to: NodeId;
|
|
537
|
-
} | {
|
|
538
|
-
kind: 'set_label';
|
|
539
|
-
target: NodeId | EdgeId;
|
|
540
|
-
label: string;
|
|
541
|
-
} | {
|
|
542
|
-
kind: 'add_edge';
|
|
543
|
-
from: NodeId;
|
|
544
|
-
to: NodeId;
|
|
545
|
-
label?: string;
|
|
546
|
-
style?: EdgeStyle;
|
|
547
|
-
} | {
|
|
548
|
-
kind: 'remove_edge';
|
|
549
|
-
id: EdgeId;
|
|
550
|
-
};
|
|
551
|
-
type SequenceMutationOp = {
|
|
552
|
-
kind: 'add_participant';
|
|
553
|
-
id: ParticipantId;
|
|
554
|
-
label?: string;
|
|
555
|
-
participantKind?: 'participant' | 'actor';
|
|
556
|
-
} | {
|
|
557
|
-
kind: 'remove_participant';
|
|
558
|
-
id: ParticipantId;
|
|
559
|
-
} | {
|
|
560
|
-
kind: 'add_message';
|
|
561
|
-
from: ParticipantId;
|
|
562
|
-
to: ParticipantId;
|
|
563
|
-
text: string;
|
|
564
|
-
style?: SequenceMessageStyle;
|
|
565
|
-
} | {
|
|
566
|
-
kind: 'remove_message';
|
|
567
|
-
index: number;
|
|
568
|
-
} | {
|
|
569
|
-
kind: 'set_message_text';
|
|
570
|
-
index: number;
|
|
571
|
-
text: string;
|
|
572
|
-
};
|
|
573
|
-
type TimelineMutationOp = {
|
|
574
|
-
kind: 'set_title';
|
|
575
|
-
title: string | null;
|
|
576
|
-
} | {
|
|
577
|
-
kind: 'add_section';
|
|
578
|
-
label: string;
|
|
579
|
-
} | {
|
|
580
|
-
kind: 'remove_section';
|
|
581
|
-
index: number;
|
|
582
|
-
} | {
|
|
583
|
-
kind: 'set_section_label';
|
|
584
|
-
index: number;
|
|
585
|
-
label: string;
|
|
586
|
-
} | {
|
|
587
|
-
kind: 'add_period';
|
|
588
|
-
sectionIndex: number;
|
|
589
|
-
label: string;
|
|
590
|
-
events?: string[];
|
|
591
|
-
} | {
|
|
592
|
-
kind: 'remove_period';
|
|
593
|
-
sectionIndex: number;
|
|
594
|
-
periodIndex: number;
|
|
595
|
-
} | {
|
|
596
|
-
kind: 'set_period_label';
|
|
597
|
-
sectionIndex: number;
|
|
598
|
-
periodIndex: number;
|
|
599
|
-
label: string;
|
|
600
|
-
} | {
|
|
601
|
-
kind: 'add_event';
|
|
602
|
-
sectionIndex: number;
|
|
603
|
-
periodIndex: number;
|
|
604
|
-
text: string;
|
|
605
|
-
} | {
|
|
606
|
-
kind: 'remove_event';
|
|
607
|
-
sectionIndex: number;
|
|
608
|
-
periodIndex: number;
|
|
609
|
-
eventIndex: number;
|
|
610
|
-
} | {
|
|
611
|
-
kind: 'set_event_text';
|
|
612
|
-
sectionIndex: number;
|
|
613
|
-
periodIndex: number;
|
|
614
|
-
eventIndex: number;
|
|
615
|
-
text: string;
|
|
616
|
-
};
|
|
617
|
-
type ClassMutationOp = {
|
|
618
|
-
kind: 'set_title';
|
|
619
|
-
title: string | null;
|
|
620
|
-
} | {
|
|
621
|
-
kind: 'add_class';
|
|
622
|
-
id: string;
|
|
623
|
-
label?: string;
|
|
624
|
-
members?: string[];
|
|
625
|
-
} | {
|
|
626
|
-
kind: 'remove_class';
|
|
627
|
-
id: string;
|
|
628
|
-
} | {
|
|
629
|
-
kind: 'rename_class';
|
|
630
|
-
from: string;
|
|
631
|
-
to: string;
|
|
632
|
-
} | {
|
|
633
|
-
kind: 'add_member';
|
|
634
|
-
class: string;
|
|
635
|
-
text: string;
|
|
636
|
-
} | {
|
|
637
|
-
kind: 'remove_member';
|
|
638
|
-
class: string;
|
|
639
|
-
index: number;
|
|
640
|
-
} | {
|
|
641
|
-
kind: 'add_relation';
|
|
642
|
-
from: string;
|
|
643
|
-
to: string;
|
|
644
|
-
relKind: ClassRelationKind;
|
|
645
|
-
label?: string;
|
|
646
|
-
} | {
|
|
647
|
-
kind: 'remove_relation';
|
|
648
|
-
index: number;
|
|
649
|
-
} | {
|
|
650
|
-
kind: 'add_note';
|
|
651
|
-
text: string;
|
|
652
|
-
for?: string;
|
|
653
|
-
} | {
|
|
654
|
-
kind: 'remove_note';
|
|
655
|
-
index: number;
|
|
656
|
-
};
|
|
657
|
-
type ErMutationOp = {
|
|
658
|
-
kind: 'add_entity';
|
|
659
|
-
id: string;
|
|
660
|
-
attributes?: string[];
|
|
661
|
-
} | {
|
|
662
|
-
kind: 'remove_entity';
|
|
663
|
-
id: string;
|
|
664
|
-
} | {
|
|
665
|
-
kind: 'rename_entity';
|
|
666
|
-
from: string;
|
|
667
|
-
to: string;
|
|
668
|
-
} | {
|
|
669
|
-
kind: 'add_attribute';
|
|
670
|
-
entity: string;
|
|
671
|
-
text: string;
|
|
672
|
-
} | {
|
|
673
|
-
kind: 'remove_attribute';
|
|
674
|
-
entity: string;
|
|
675
|
-
index: number;
|
|
676
|
-
} | {
|
|
677
|
-
kind: 'add_relation';
|
|
678
|
-
from: string;
|
|
679
|
-
to: string;
|
|
680
|
-
leftCard: ErCardinality;
|
|
681
|
-
rightCard: ErCardinality;
|
|
682
|
-
dashed?: boolean;
|
|
683
|
-
label?: string;
|
|
684
|
-
} | {
|
|
685
|
-
kind: 'remove_relation';
|
|
686
|
-
index: number;
|
|
687
|
-
};
|
|
688
|
-
type JourneyMutationOp = {
|
|
689
|
-
kind: 'set_title';
|
|
690
|
-
title: string | null;
|
|
691
|
-
} | {
|
|
692
|
-
kind: 'add_section';
|
|
693
|
-
label: string;
|
|
694
|
-
index?: number;
|
|
695
|
-
} | {
|
|
696
|
-
kind: 'remove_section';
|
|
697
|
-
index: number;
|
|
698
|
-
} | {
|
|
699
|
-
kind: 'set_section_label';
|
|
700
|
-
index: number;
|
|
701
|
-
label: string;
|
|
702
|
-
} | {
|
|
703
|
-
kind: 'add_task';
|
|
704
|
-
sectionIndex: number;
|
|
705
|
-
text: string;
|
|
706
|
-
score: number;
|
|
707
|
-
actors?: string[];
|
|
708
|
-
index?: number;
|
|
709
|
-
} | {
|
|
710
|
-
kind: 'remove_task';
|
|
711
|
-
sectionIndex: number;
|
|
712
|
-
taskIndex: number;
|
|
713
|
-
} | {
|
|
714
|
-
kind: 'set_task_text';
|
|
715
|
-
sectionIndex: number;
|
|
716
|
-
taskIndex: number;
|
|
717
|
-
text: string;
|
|
718
|
-
} | {
|
|
719
|
-
kind: 'set_task_score';
|
|
720
|
-
sectionIndex: number;
|
|
721
|
-
taskIndex: number;
|
|
722
|
-
score: number;
|
|
723
|
-
} | {
|
|
724
|
-
kind: 'set_task_actors';
|
|
725
|
-
sectionIndex: number;
|
|
726
|
-
taskIndex: number;
|
|
727
|
-
actors: string[];
|
|
728
|
-
} | {
|
|
729
|
-
kind: 'rename_actor';
|
|
730
|
-
from: string;
|
|
731
|
-
to: string;
|
|
732
|
-
} | {
|
|
733
|
-
kind: 'move_task';
|
|
734
|
-
fromSection: number;
|
|
735
|
-
fromIndex: number;
|
|
736
|
-
toSection: number;
|
|
737
|
-
toIndex: number;
|
|
738
|
-
} | {
|
|
739
|
-
kind: 'move_section';
|
|
740
|
-
from: number;
|
|
741
|
-
to: number;
|
|
742
|
-
} | {
|
|
743
|
-
kind: 'set_accessibility_title';
|
|
744
|
-
title: string | null;
|
|
745
|
-
} | {
|
|
746
|
-
kind: 'set_accessibility_description';
|
|
747
|
-
description: string | null;
|
|
748
|
-
};
|
|
749
|
-
type ArchitectureMutationOp = {
|
|
750
|
-
kind: 'add_service';
|
|
751
|
-
id: string;
|
|
752
|
-
label?: string;
|
|
753
|
-
icon?: string | null;
|
|
754
|
-
group?: string | null;
|
|
755
|
-
} | {
|
|
756
|
-
kind: 'remove_service';
|
|
757
|
-
id: string;
|
|
758
|
-
} | {
|
|
759
|
-
kind: 'rename_service';
|
|
760
|
-
from: string;
|
|
761
|
-
to: string;
|
|
762
|
-
} | {
|
|
763
|
-
kind: 'set_service_label';
|
|
764
|
-
id: string;
|
|
765
|
-
label: string;
|
|
766
|
-
} | {
|
|
767
|
-
kind: 'set_service_icon';
|
|
768
|
-
id: string;
|
|
769
|
-
icon: string | null;
|
|
770
|
-
} | {
|
|
771
|
-
kind: 'move_service';
|
|
772
|
-
id: string;
|
|
773
|
-
group: string | null;
|
|
774
|
-
} | {
|
|
775
|
-
kind: 'add_group';
|
|
776
|
-
id: string;
|
|
777
|
-
label?: string;
|
|
778
|
-
icon?: string | null;
|
|
779
|
-
parent?: string | null;
|
|
780
|
-
} | {
|
|
781
|
-
kind: 'remove_group';
|
|
782
|
-
id: string;
|
|
783
|
-
} | {
|
|
784
|
-
kind: 'add_edge';
|
|
785
|
-
from: string;
|
|
786
|
-
to: string;
|
|
787
|
-
fromSide: ArchitectureSide;
|
|
788
|
-
toSide: ArchitectureSide;
|
|
789
|
-
label?: string | null;
|
|
790
|
-
hasArrowStart?: boolean;
|
|
791
|
-
hasArrowEnd?: boolean;
|
|
792
|
-
} | {
|
|
793
|
-
kind: 'remove_edge';
|
|
794
|
-
index?: number;
|
|
795
|
-
id?: string;
|
|
796
|
-
};
|
|
797
|
-
type StateMutationOp = {
|
|
798
|
-
kind: 'add_state';
|
|
799
|
-
id: string;
|
|
800
|
-
label?: string | null;
|
|
801
|
-
parent?: string | null;
|
|
802
|
-
} | {
|
|
803
|
-
kind: 'remove_state';
|
|
804
|
-
id: string;
|
|
805
|
-
} | {
|
|
806
|
-
kind: 'rename_state';
|
|
807
|
-
from: string;
|
|
808
|
-
to: string;
|
|
809
|
-
} | {
|
|
810
|
-
kind: 'set_state_label';
|
|
811
|
-
id: string;
|
|
812
|
-
label: string | null;
|
|
813
|
-
} | {
|
|
814
|
-
kind: 'add_transition';
|
|
815
|
-
from: string;
|
|
816
|
-
to: string;
|
|
817
|
-
label?: string | null;
|
|
818
|
-
parent?: string | null;
|
|
819
|
-
} | {
|
|
820
|
-
kind: 'remove_transition';
|
|
821
|
-
index?: number;
|
|
822
|
-
from?: string;
|
|
823
|
-
to?: string;
|
|
824
|
-
parent?: string | null;
|
|
825
|
-
} | {
|
|
826
|
-
kind: 'set_transition_label';
|
|
827
|
-
index?: number;
|
|
828
|
-
from?: string;
|
|
829
|
-
to?: string;
|
|
830
|
-
label: string | null;
|
|
831
|
-
parent?: string | null;
|
|
832
|
-
} | {
|
|
833
|
-
kind: 'make_composite';
|
|
834
|
-
id: string;
|
|
835
|
-
members: string[];
|
|
836
|
-
label?: string | null;
|
|
837
|
-
};
|
|
838
|
-
type XyChartAxisSpec = {
|
|
839
|
-
name?: string | null;
|
|
840
|
-
categories?: string[];
|
|
841
|
-
range?: {
|
|
842
|
-
min: number;
|
|
843
|
-
max: number;
|
|
844
|
-
};
|
|
845
|
-
};
|
|
846
|
-
type XyChartMutationOp = {
|
|
847
|
-
kind: 'set_title';
|
|
848
|
-
title: string | null;
|
|
849
|
-
} | {
|
|
850
|
-
kind: 'set_x_axis';
|
|
851
|
-
axis: XyChartAxisSpec | null;
|
|
852
|
-
} | {
|
|
853
|
-
kind: 'set_y_axis';
|
|
854
|
-
axis: XyChartAxisSpec | null;
|
|
855
|
-
} | {
|
|
856
|
-
kind: 'add_series';
|
|
857
|
-
kind2: 'bar' | 'line';
|
|
858
|
-
name?: string | null;
|
|
859
|
-
values: number[];
|
|
860
|
-
} | {
|
|
861
|
-
kind: 'remove_series';
|
|
862
|
-
index: number;
|
|
863
|
-
} | {
|
|
864
|
-
kind: 'set_series_values';
|
|
865
|
-
index: number;
|
|
866
|
-
values: number[];
|
|
867
|
-
} | {
|
|
868
|
-
kind: 'set_series_name';
|
|
869
|
-
index: number;
|
|
870
|
-
name: string | null;
|
|
871
|
-
} | {
|
|
872
|
-
kind: 'reorder_series';
|
|
873
|
-
from: number;
|
|
874
|
-
to: number;
|
|
875
|
-
};
|
|
876
|
-
type PieMutationOp = {
|
|
877
|
-
kind: 'set_title';
|
|
878
|
-
title: string | null;
|
|
879
|
-
} | {
|
|
880
|
-
kind: 'set_show_data';
|
|
881
|
-
showData: boolean;
|
|
882
|
-
} | {
|
|
883
|
-
kind: 'add_slice';
|
|
884
|
-
label: string;
|
|
885
|
-
value: number;
|
|
886
|
-
} | {
|
|
887
|
-
kind: 'remove_slice';
|
|
888
|
-
label: string;
|
|
889
|
-
} | {
|
|
890
|
-
kind: 'rename_slice';
|
|
891
|
-
from: string;
|
|
892
|
-
to: string;
|
|
893
|
-
} | {
|
|
894
|
-
kind: 'set_slice_value';
|
|
895
|
-
label: string;
|
|
896
|
-
value: number;
|
|
897
|
-
} | {
|
|
898
|
-
kind: 'reorder_slice';
|
|
899
|
-
from: number;
|
|
900
|
-
to: number;
|
|
901
|
-
};
|
|
902
|
-
type QuadrantMutationOp = {
|
|
903
|
-
kind: 'set_title';
|
|
904
|
-
title: string | null;
|
|
905
|
-
} | {
|
|
906
|
-
kind: 'set_axis_labels';
|
|
907
|
-
axis: 'x' | 'y';
|
|
908
|
-
near: string | null;
|
|
909
|
-
far?: string | null;
|
|
910
|
-
} | {
|
|
911
|
-
kind: 'set_quadrant_label';
|
|
912
|
-
quadrant: number;
|
|
913
|
-
label: string | null;
|
|
914
|
-
} | {
|
|
915
|
-
kind: 'add_point';
|
|
916
|
-
label: string;
|
|
917
|
-
x: number;
|
|
918
|
-
y: number;
|
|
919
|
-
} | {
|
|
920
|
-
kind: 'remove_point';
|
|
921
|
-
label: string;
|
|
922
|
-
} | {
|
|
923
|
-
kind: 'move_point';
|
|
924
|
-
label: string;
|
|
925
|
-
x: number;
|
|
926
|
-
y: number;
|
|
927
|
-
} | {
|
|
928
|
-
kind: 'rename_point';
|
|
929
|
-
from: string;
|
|
930
|
-
to: string;
|
|
931
|
-
};
|
|
932
|
-
type GanttMutationOp = {
|
|
933
|
-
kind: 'set_title';
|
|
934
|
-
title: string | null;
|
|
935
|
-
} | {
|
|
936
|
-
kind: 'add_section';
|
|
937
|
-
label: string;
|
|
938
|
-
} | {
|
|
939
|
-
kind: 'rename_section';
|
|
940
|
-
index: number;
|
|
941
|
-
label: string;
|
|
942
|
-
} | {
|
|
943
|
-
kind: 'remove_section';
|
|
944
|
-
index: number;
|
|
945
|
-
} | {
|
|
946
|
-
kind: 'add_task';
|
|
947
|
-
sectionIndex: number;
|
|
948
|
-
label: string;
|
|
949
|
-
taskId?: string;
|
|
950
|
-
tags?: GanttBodyTaskTag[];
|
|
951
|
-
start?: string;
|
|
952
|
-
end: string;
|
|
953
|
-
} | {
|
|
954
|
-
kind: 'remove_task';
|
|
955
|
-
sectionIndex: number;
|
|
956
|
-
taskIndex: number;
|
|
957
|
-
} | {
|
|
958
|
-
kind: 'rename_task';
|
|
959
|
-
sectionIndex: number;
|
|
960
|
-
taskIndex: number;
|
|
961
|
-
label: string;
|
|
962
|
-
} | {
|
|
963
|
-
kind: 'set_task_status';
|
|
964
|
-
sectionIndex: number;
|
|
965
|
-
taskIndex: number;
|
|
966
|
-
status: 'active' | 'done' | 'crit' | null;
|
|
967
|
-
} | {
|
|
968
|
-
kind: 'set_task_dates';
|
|
969
|
-
sectionIndex: number;
|
|
970
|
-
taskIndex: number;
|
|
971
|
-
start?: string | null;
|
|
972
|
-
end?: string;
|
|
973
|
-
};
|
|
974
|
-
type AnyMutationOp = FlowchartMutationOp | StateMutationOp | SequenceMutationOp | TimelineMutationOp | ClassMutationOp | ErMutationOp | JourneyMutationOp | ArchitectureMutationOp | XyChartMutationOp | PieMutationOp | QuadrantMutationOp | GanttMutationOp;
|
|
975
|
-
type MutationOp = FlowchartMutationOp;
|
|
976
|
-
declare const FINITE_BRAND: unique symbol;
|
|
977
|
-
type Finite = number & {
|
|
978
|
-
readonly [FINITE_BRAND]: true;
|
|
979
|
-
};
|
|
980
|
-
declare function toFinite(n: number): Finite;
|
|
981
|
-
type WarningSeverity = 'error' | 'warning';
|
|
982
|
-
type WarningTier = 'structural' | 'geometric' | 'lint';
|
|
983
|
-
type Tier1WarningCode = 'EMPTY_DIAGRAM' | 'EDGE_MISANCHORED' | 'OFF_CANVAS' | 'GROUP_BREACH' | 'UNKNOWN_SHAPE' | 'LABEL_OVERFLOW' | 'UNRESOLVABLE_SCHEDULE' | 'RENDER_FAILED';
|
|
984
|
-
type Tier2WarningCode = 'NODE_OVERLAP' | 'ROUTE_SELF_CROSS' | 'ROUTE_HITCH' | 'ROUTE_UNEXPLAINED_BEND' | 'ROUTE_LABEL_ON_SHARED_TRUNK' | 'ROUTE_CONTAINER_MISANCHOR' | 'ROUTE_SHAPE_MISANCHOR' | 'ROUTE_STALE_AFTER_NODE_MOVE';
|
|
985
|
-
/**
|
|
986
|
-
* Tier 3 (advisory lint). Family-specific quality hints for common agent
|
|
987
|
-
* mistakes that still parse and render. Lint warnings never flip verify.ok.
|
|
988
|
-
*/
|
|
989
|
-
type Tier3WarningCode = 'DUPLICATE_EDGE' | 'UNREACHABLE_NODE' | 'DECISION_BRANCH_UNLABELED' | 'COMMENT_DROPPED' | 'UNSUPPORTED_SYNTAX' | 'CONTENT_DROPPED_ON_ROUNDTRIP' | 'INEFFECTIVE_CONFIG';
|
|
990
|
-
type WarningCode = Tier1WarningCode | Tier2WarningCode | Tier3WarningCode;
|
|
991
|
-
type LayoutWarning = {
|
|
992
|
-
code: 'EMPTY_DIAGRAM';
|
|
993
|
-
} | {
|
|
994
|
-
code: 'EDGE_MISANCHORED';
|
|
995
|
-
edge: EdgeId;
|
|
996
|
-
from?: NodeId;
|
|
997
|
-
to?: NodeId;
|
|
998
|
-
} | {
|
|
999
|
-
code: 'OFF_CANVAS';
|
|
1000
|
-
target: NodeId | EdgeId;
|
|
1001
|
-
axis: 'x' | 'y';
|
|
1002
|
-
} | {
|
|
1003
|
-
code: 'GROUP_BREACH';
|
|
1004
|
-
group: GroupId;
|
|
1005
|
-
member: NodeId;
|
|
1006
|
-
} | {
|
|
1007
|
-
code: 'UNKNOWN_SHAPE';
|
|
1008
|
-
node: NodeId;
|
|
1009
|
-
shape: string;
|
|
1010
|
-
} | {
|
|
1011
|
-
code: 'LABEL_OVERFLOW';
|
|
1012
|
-
target: NodeId | EdgeId;
|
|
1013
|
-
charCount: number;
|
|
1014
|
-
limit: number;
|
|
1015
|
-
}
|
|
1016
|
-
/**
|
|
1017
|
-
* The diagram parses (and round-trips) but its semantics cannot resolve, so
|
|
1018
|
-
* rendering will fail loudly — e.g. a Gantt whose schedule hits a bad
|
|
1019
|
-
* calendar date, a dependency cycle, or an everything-excluded calendar.
|
|
1020
|
-
* `reason` carries the named renderer error (GANTT_*…). Closes the
|
|
1021
|
-
* "verify ok but render throws" seam for structured gantt bodies.
|
|
1022
|
-
*/
|
|
1023
|
-
| {
|
|
1024
|
-
code: 'UNRESOLVABLE_SCHEDULE';
|
|
1025
|
-
reason: string;
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
* The diagram parses on the agent side (possibly with unmodeled syntax
|
|
1029
|
-
* preserved verbatim) but the STRICT render parser throws on its canonical
|
|
1030
|
-
* source — `am render` would exit 4. Generalizes UNRESOLVABLE_SCHEDULE's
|
|
1031
|
-
* "verify ok but render throws" seam-closing to every family: found live
|
|
1032
|
-
* when onboarding agents followed verify-before-commit and still shipped
|
|
1033
|
-
* unrenderable quadrant/architecture diagrams. `reason` carries the
|
|
1034
|
-
* renderer's error message.
|
|
1035
|
-
*/
|
|
1036
|
-
| {
|
|
1037
|
-
code: 'RENDER_FAILED';
|
|
1038
|
-
reason: string;
|
|
1039
|
-
} | {
|
|
1040
|
-
code: 'NODE_OVERLAP';
|
|
1041
|
-
a: NodeId;
|
|
1042
|
-
b: NodeId;
|
|
1043
|
-
areaPx: number;
|
|
1044
|
-
} | {
|
|
1045
|
-
code: 'ROUTE_SELF_CROSS';
|
|
1046
|
-
edge: EdgeId;
|
|
1047
|
-
count: number;
|
|
1048
|
-
} | {
|
|
1049
|
-
code: 'ROUTE_HITCH';
|
|
1050
|
-
edge: EdgeId;
|
|
1051
|
-
deviationPx: number;
|
|
1052
|
-
} | {
|
|
1053
|
-
code: 'ROUTE_UNEXPLAINED_BEND';
|
|
1054
|
-
edge: EdgeId;
|
|
1055
|
-
} | {
|
|
1056
|
-
code: 'ROUTE_LABEL_ON_SHARED_TRUNK';
|
|
1057
|
-
edge: EdgeId;
|
|
1058
|
-
sharedWith: EdgeId;
|
|
1059
|
-
} | {
|
|
1060
|
-
code: 'ROUTE_CONTAINER_MISANCHOR';
|
|
1061
|
-
edge: EdgeId;
|
|
1062
|
-
container: GroupId;
|
|
1063
|
-
} | {
|
|
1064
|
-
code: 'ROUTE_SHAPE_MISANCHOR';
|
|
1065
|
-
edge: EdgeId;
|
|
1066
|
-
node: NodeId;
|
|
1067
|
-
} | {
|
|
1068
|
-
code: 'ROUTE_STALE_AFTER_NODE_MOVE';
|
|
1069
|
-
edge: EdgeId;
|
|
1070
|
-
node: NodeId;
|
|
1071
|
-
} | {
|
|
1072
|
-
code: 'DUPLICATE_EDGE';
|
|
1073
|
-
edge: EdgeId;
|
|
1074
|
-
duplicateOf: EdgeId;
|
|
1075
|
-
from: NodeId;
|
|
1076
|
-
to: NodeId;
|
|
1077
|
-
label?: string;
|
|
1078
|
-
} | {
|
|
1079
|
-
code: 'UNREACHABLE_NODE';
|
|
1080
|
-
node: NodeId;
|
|
1081
|
-
} | {
|
|
1082
|
-
code: 'DECISION_BRANCH_UNLABELED';
|
|
1083
|
-
node: NodeId;
|
|
1084
|
-
edge: EdgeId;
|
|
1085
|
-
} | {
|
|
1086
|
-
code: 'COMMENT_DROPPED';
|
|
1087
|
-
count: number;
|
|
1088
|
-
lines: number[];
|
|
1089
|
-
} | {
|
|
1090
|
-
code: 'UNSUPPORTED_SYNTAX';
|
|
1091
|
-
line?: number;
|
|
1092
|
-
syntax: string;
|
|
1093
|
-
message: string;
|
|
1094
|
-
}
|
|
1095
|
-
/**
|
|
1096
|
-
* Structured content was lost across a parse → serialize → re-parse cycle:
|
|
1097
|
-
* the {nodes, edges, groups} tally changed, so canonical serialization is
|
|
1098
|
-
* silently dropping (or duplicating) a node/edge/group even though the bytes
|
|
1099
|
-
* may re-parse. The faithfulness analogue of COMMENT_DROPPED — "100% parse
|
|
1100
|
-
* success is not faithfulness" (Loop 17). Lint, never flips verify.ok.
|
|
1101
|
-
*/
|
|
1102
|
-
| {
|
|
1103
|
-
code: 'CONTENT_DROPPED_ON_ROUNDTRIP';
|
|
1104
|
-
before: {
|
|
1105
|
-
nodes: number;
|
|
1106
|
-
edges: number;
|
|
1107
|
-
groups: number;
|
|
1108
|
-
};
|
|
1109
|
-
after: {
|
|
1110
|
-
nodes: number;
|
|
1111
|
-
edges: number;
|
|
1112
|
-
groups: number;
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* A Mermaid config field was accepted (for config-shape compatibility) but
|
|
1117
|
-
* has no effect on this family's geometry or paint — e.g. Journey's
|
|
1118
|
-
* sequence-era fields. Accepting-and-ignoring silently misleads migrating
|
|
1119
|
-
* users; this lint says so. Never flips verify.ok.
|
|
1120
|
-
*/
|
|
1121
|
-
| {
|
|
1122
|
-
code: 'INEFFECTIVE_CONFIG';
|
|
1123
|
-
field: string;
|
|
1124
|
-
message: string;
|
|
1125
|
-
};
|
|
1126
|
-
declare const WARNING_SEVERITY: Record<WarningCode, WarningSeverity>;
|
|
1127
|
-
declare const WARNING_TIER: Record<WarningCode, WarningTier>;
|
|
1128
|
-
declare const DEFAULT_LABEL_CHAR_CAP = 40;
|
|
1129
|
-
interface VerifyOptions {
|
|
1130
|
-
suppress?: WarningCode[];
|
|
1131
|
-
labelCharCap?: number;
|
|
1132
|
-
}
|
|
1133
|
-
type RenderedRegionKind = 'node' | 'edge' | 'label' | 'group' | 'canvas';
|
|
1134
|
-
interface RenderedRegion {
|
|
1135
|
-
id: string;
|
|
1136
|
-
kind: RenderedRegionKind;
|
|
1137
|
-
elementId?: string;
|
|
1138
|
-
parentId?: string;
|
|
1139
|
-
bounds: {
|
|
1140
|
-
x: Finite;
|
|
1141
|
-
y: Finite;
|
|
1142
|
-
w: Finite;
|
|
1143
|
-
h: Finite;
|
|
1144
|
-
};
|
|
1145
|
-
sourceLine?: number;
|
|
1146
|
-
}
|
|
1147
|
-
interface RenderedLayoutNode {
|
|
1148
|
-
id: NodeId;
|
|
1149
|
-
x: Finite;
|
|
1150
|
-
y: Finite;
|
|
1151
|
-
w: Finite;
|
|
1152
|
-
h: Finite;
|
|
1153
|
-
shape: string;
|
|
1154
|
-
label?: string;
|
|
1155
|
-
}
|
|
1156
|
-
interface RenderedLayoutEdge {
|
|
1157
|
-
id: EdgeId;
|
|
1158
|
-
from: NodeId;
|
|
1159
|
-
to: NodeId;
|
|
1160
|
-
path: [Finite, Finite][];
|
|
1161
|
-
label?: {
|
|
1162
|
-
x: Finite;
|
|
1163
|
-
y: Finite;
|
|
1164
|
-
text: string;
|
|
1165
|
-
};
|
|
1166
|
-
/** Edge route certificate; present only under layoutMermaid(d, { debug: true }) for families with an edge certificate model. */
|
|
1167
|
-
route?: EdgeRouteCertificate;
|
|
1168
|
-
}
|
|
1169
|
-
interface RenderedLayoutGroup {
|
|
1170
|
-
id: GroupId;
|
|
1171
|
-
x: Finite;
|
|
1172
|
-
y: Finite;
|
|
1173
|
-
w: Finite;
|
|
1174
|
-
h: Finite;
|
|
1175
|
-
members: NodeId[];
|
|
1176
|
-
label?: string;
|
|
1177
|
-
/** Parent group id for flattened region-tree consumers; undefined means root-level group. */
|
|
1178
|
-
parentId?: GroupId;
|
|
1179
|
-
}
|
|
1180
|
-
interface RenderedLayout {
|
|
1181
|
-
version: 1;
|
|
1182
|
-
kind: DiagramKind;
|
|
1183
|
-
nodes: RenderedLayoutNode[];
|
|
1184
|
-
edges: RenderedLayoutEdge[];
|
|
1185
|
-
groups: RenderedLayoutGroup[];
|
|
1186
|
-
/** Region-containment certificates for non-edge invariants; present only under layoutMermaid(d, { debug: true }). */
|
|
1187
|
-
certificates?: RegionContainmentCertificate[];
|
|
1188
|
-
/** Optional region sidecar for renderer/action alignment; debug-only in layoutMermaid V1. */
|
|
1189
|
-
regions?: RenderedRegion[];
|
|
1190
|
-
/** Optional source-only actions aligned to region ids; debug-only in layoutMermaid V1. */
|
|
1191
|
-
actions?: DiagramActionRecord[];
|
|
1192
|
-
bounds: {
|
|
1193
|
-
w: Finite;
|
|
1194
|
-
h: Finite;
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
interface VerifyResult {
|
|
1198
|
-
ok: boolean;
|
|
1199
|
-
warnings: LayoutWarning[];
|
|
1200
|
-
layout: RenderedLayout;
|
|
1201
|
-
}
|
|
1202
|
-
interface SerializedFlowchartGraph {
|
|
1203
|
-
direction: Direction;
|
|
1204
|
-
nodes: Record<string, MermaidNode> | Array<[string, MermaidNode]>;
|
|
1205
|
-
edges?: MermaidEdge[];
|
|
1206
|
-
subgraphs?: unknown;
|
|
1207
|
-
classDefs?: unknown;
|
|
1208
|
-
classAssignments?: unknown;
|
|
1209
|
-
nodeStyles?: unknown;
|
|
1210
|
-
linkStyles?: unknown;
|
|
1211
|
-
}
|
|
1212
|
-
interface ValidDiagramPayload {
|
|
1213
|
-
kind: DiagramKind;
|
|
1214
|
-
meta?: Partial<ValidDiagramMeta>;
|
|
1215
|
-
body: {
|
|
1216
|
-
kind: 'flowchart';
|
|
1217
|
-
graph: SerializedFlowchartGraph;
|
|
1218
|
-
} | StateBody | SequenceBody | TimelineBody | ClassBody | ErBody | JourneyBody | ArchitectureBody | XyChartBody | PieBody | QuadrantBody | GanttBody | {
|
|
1219
|
-
kind: 'opaque';
|
|
1220
|
-
family: DiagramKind;
|
|
1221
|
-
source: string;
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
type MermaidFact = string;
|
|
1226
|
-
interface CheckMermaidObjectSpec {
|
|
1227
|
-
/** Required facts. Aliases: expected / require / required. */
|
|
1228
|
-
include?: readonly string[];
|
|
1229
|
-
expected?: readonly string[];
|
|
1230
|
-
require?: readonly string[];
|
|
1231
|
-
required?: readonly string[];
|
|
1232
|
-
/** Forbidden facts. Aliases: absent / forbid / forbidden / unexpected. */
|
|
1233
|
-
exclude?: readonly string[];
|
|
1234
|
-
absent?: readonly string[];
|
|
1235
|
-
forbid?: readonly string[];
|
|
1236
|
-
forbidden?: readonly string[];
|
|
1237
|
-
unexpected?: readonly string[];
|
|
1238
|
-
/** When true, every emitted fact must be listed in the required set. */
|
|
1239
|
-
exact?: boolean;
|
|
1240
|
-
}
|
|
1241
|
-
type CheckMermaidSpec = readonly string[] | CheckMermaidObjectSpec;
|
|
1242
|
-
interface CheckMermaidResult {
|
|
1243
|
-
ok: boolean;
|
|
1244
|
-
/** Required facts not present in the diagram. */
|
|
1245
|
-
missing: string[];
|
|
1246
|
-
/** Forbidden facts that were present, or extra facts under exact:true. */
|
|
1247
|
-
unexpected: string[];
|
|
1248
|
-
/** Full deterministic fact set used for the comparison. */
|
|
1249
|
-
facts: string[];
|
|
1250
|
-
}
|
|
1251
|
-
/** Facts for a parsed diagram. Output is sorted, de-duplicated, and single-line. */
|
|
1252
|
-
declare function describeMermaidFacts(d: ValidDiagram): string[];
|
|
1253
|
-
/** Parse then emit facts. Parse failures are explicit Result errors. */
|
|
1254
|
-
declare function describeMermaidFactsSource(source: string): Result<string[], ParseError[]>;
|
|
1255
|
-
/** Check required/forbidden semantic facts against a parsed diagram. */
|
|
1256
|
-
declare function checkMermaid(d: ValidDiagram, spec: CheckMermaidSpec): CheckMermaidResult;
|
|
1257
|
-
declare function checkMermaidSource(source: string, spec: CheckMermaidSpec): Result<CheckMermaidResult, ParseError[]>;
|
|
1258
|
-
|
|
1259
|
-
interface ExtractedLabel {
|
|
1260
|
-
/** The label text, with quotes stripped. */
|
|
1261
|
-
text: string;
|
|
1262
|
-
/** Best-effort target identifier (node id, participant, period, etc.). */
|
|
1263
|
-
target: string;
|
|
1264
|
-
}
|
|
1265
|
-
interface FamilyLayoutContext {
|
|
1266
|
-
source: NormalizedMermaidSource;
|
|
1267
|
-
options: RenderOptions;
|
|
1268
|
-
/** Render options after public-entrypoint normalization, e.g. security/font/config threading. */
|
|
1269
|
-
renderOptions: RenderOptions;
|
|
1270
|
-
colors: DiagramColors;
|
|
1271
|
-
}
|
|
1272
|
-
interface FamilyLayoutResult<TPositioned extends PositionedDiagram = PositionedDiagram> {
|
|
1273
|
-
positioned: TPositioned;
|
|
1274
|
-
/** Optional family-specific palette override for rendering/finalization. */
|
|
1275
|
-
colors?: DiagramColors;
|
|
1276
|
-
/** Optional family-specific render options override for RenderContext. */
|
|
1277
|
-
options?: RenderOptions;
|
|
1278
|
-
/** False when the family renderer already owns SVG accessibility metadata. */
|
|
1279
|
-
injectAccessibility?: boolean;
|
|
1280
|
-
}
|
|
1281
|
-
interface AsciiContext {
|
|
1282
|
-
source: NormalizedMermaidSource;
|
|
1283
|
-
config: AsciiConfig;
|
|
1284
|
-
colorMode: ColorMode;
|
|
1285
|
-
theme: AsciiTheme;
|
|
1286
|
-
options: {
|
|
1287
|
-
maxWidth?: number;
|
|
1288
|
-
ganttToday?: string;
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
interface FamilyPlugin {
|
|
1292
|
-
/** The DiagramKind this plugin owns. */
|
|
1293
|
-
id: DiagramKind;
|
|
1294
|
-
/** First-non-blank-line predicate. Lowercase, leading whitespace stripped. */
|
|
1295
|
-
detect: (firstLineLower: string) => boolean;
|
|
1296
|
-
/**
|
|
1297
|
-
* Source-based label extractor for universal Tier 1 LABEL_OVERFLOW on opaque
|
|
1298
|
-
* bodies. Each plugin should extract everything an agent would consider a
|
|
1299
|
-
* label — node text, edge text, message text, axis names, section titles.
|
|
1300
|
-
* The generic fallback (extractLabelsGeneric) is used when a family doesn't
|
|
1301
|
-
* provide its own.
|
|
1302
|
-
*/
|
|
1303
|
-
extractLabels?: (source: string) => ExtractedLabel[];
|
|
1304
|
-
/**
|
|
1305
|
-
* Family-specific structured parser. `lines` are the normalized source
|
|
1306
|
-
* lines including the header; `opaqueSource` is the original body for
|
|
1307
|
-
* lossless fallback; `canonicalSource` is the full normalized text (the
|
|
1308
|
-
* legacy flowchart parser consumes it whole). Structured-or-opaque
|
|
1309
|
-
* families return ok(structured ?? opaque); error-semantics families
|
|
1310
|
-
* (flowchart/state) return err(ParseError[]).
|
|
1311
|
-
*/
|
|
1312
|
-
parse?: (lines: string[], opaqueSource: string, meta: ValidDiagramMeta, canonicalSource: string) => Result<DiagramBody, ParseError[]>;
|
|
1313
|
-
/**
|
|
1314
|
-
* Optional source-map builder, run after a successful parse. Today only
|
|
1315
|
-
* flowchart/state index node positions; other families return no map.
|
|
1316
|
-
*/
|
|
1317
|
-
buildSourceMap?: (body: DiagramBody, canonicalSource: string) => SourceMap;
|
|
1318
|
-
/** Optional: family-specific serializer for a structured body. */
|
|
1319
|
-
serialize?: (body: DiagramBody) => string;
|
|
1320
|
-
/** Optional: family-specific structured mutation. */
|
|
1321
|
-
mutate?: (body: DiagramBody, op: AnyMutationOp) => Result<DiagramBody, MutationError>;
|
|
1322
|
-
/** Optional: family-specific verify (Tier 1 + Tier 2). Returns warnings only. */
|
|
1323
|
-
verify?: (body: DiagramBody, opts: VerifyOptions) => LayoutWarning[];
|
|
1324
|
-
/** Optional: family-specific source-to-positioned layout for public SVG rendering. */
|
|
1325
|
-
layout?: (ctx: FamilyLayoutContext) => FamilyLayoutResult | PositionedDiagram;
|
|
1326
|
-
/** Optional: family-specific SVG renderer fed by a positioned layout result. */
|
|
1327
|
-
renderSvg?: (ctx: RenderContext<PositionedDiagram>) => string;
|
|
1328
|
-
/**
|
|
1329
|
-
* Optional: family-specific SceneGraph lowering (SPEC §3.1). Produces the
|
|
1330
|
-
* semantic render-mark tree that style backends consume; renderSvg for a
|
|
1331
|
-
* lowered family is DefaultBackend serialization of this scene.
|
|
1332
|
-
*/
|
|
1333
|
-
lowerScene?: (ctx: RenderContext<PositionedDiagram>) => SceneDoc;
|
|
1334
|
-
/** Optional: family-specific ASCII renderer. */
|
|
1335
|
-
renderAscii?: (ctx: AsciiContext) => string;
|
|
1336
|
-
}
|
|
1337
|
-
interface BuiltinFamilyMetadata {
|
|
1338
|
-
/** Built-in DiagramKind exposed by Agentic Mermaid. */
|
|
1339
|
-
id: DiagramKind;
|
|
1340
|
-
/** Human-facing family name used in docs and editor examples. */
|
|
1341
|
-
label: string;
|
|
1342
|
-
/** Mermaid headers routed to this family. */
|
|
1343
|
-
headers: readonly string[];
|
|
1344
|
-
/** SDK narrower advertised for structured mutation. */
|
|
1345
|
-
narrower: `as${string}`;
|
|
1346
|
-
/** Editor example category label. */
|
|
1347
|
-
editorDiagramType: string;
|
|
1348
|
-
/** Basic editor example that must exist for this family. */
|
|
1349
|
-
editorExampleId: string;
|
|
1350
|
-
/** Short glyph used by the editor example picker. */
|
|
1351
|
-
editorGlyph: string;
|
|
1352
|
-
/** Minimal canonical source: correct header + core syntax. Exposed via
|
|
1353
|
-
* `am capabilities` so agents learn each family's dialect from the
|
|
1354
|
-
* discovery envelope instead of error-message trial-and-error (the
|
|
1355
|
-
* onboarding probes burned most of their iterations on exactly this —
|
|
1356
|
-
* architecture-beta headers, quadrant [x, y] brackets). A test pins
|
|
1357
|
-
* every example to parse, verify, and render clean. */
|
|
1358
|
-
example: string;
|
|
1359
|
-
}
|
|
1360
|
-
declare const BUILTIN_FAMILY_METADATA: readonly [{
|
|
1361
|
-
readonly id: "flowchart";
|
|
1362
|
-
readonly label: "Flowchart";
|
|
1363
|
-
readonly headers: readonly ["flowchart", "graph"];
|
|
1364
|
-
readonly narrower: "asFlowchart";
|
|
1365
|
-
readonly editorDiagramType: "Flowchart";
|
|
1366
|
-
readonly editorExampleId: "flowchart-basic";
|
|
1367
|
-
readonly editorGlyph: "F";
|
|
1368
|
-
readonly example: "flowchart TD\n A[Start] --> B{Ship?}\n B -->|yes| C[Deploy]\n B -->|no| D[Fix]";
|
|
1369
|
-
}, {
|
|
1370
|
-
readonly id: "state";
|
|
1371
|
-
readonly label: "State";
|
|
1372
|
-
readonly headers: readonly ["stateDiagram", "stateDiagram-v2"];
|
|
1373
|
-
readonly narrower: "asState";
|
|
1374
|
-
readonly editorDiagramType: "State";
|
|
1375
|
-
readonly editorExampleId: "state-basic";
|
|
1376
|
-
readonly editorGlyph: "S";
|
|
1377
|
-
readonly example: "stateDiagram-v2\n [*] --> Draft\n Draft --> Review : submit\n Review --> [*] : approve";
|
|
1378
|
-
}, {
|
|
1379
|
-
readonly id: "sequence";
|
|
1380
|
-
readonly label: "Sequence";
|
|
1381
|
-
readonly headers: readonly ["sequenceDiagram"];
|
|
1382
|
-
readonly narrower: "asSequence";
|
|
1383
|
-
readonly editorDiagramType: "Sequence";
|
|
1384
|
-
readonly editorExampleId: "sequence-basic";
|
|
1385
|
-
readonly editorGlyph: "Q";
|
|
1386
|
-
readonly example: "sequenceDiagram\n participant U as User\n participant S as Server\n U->>S: request\n S-->>U: response";
|
|
1387
|
-
}, {
|
|
1388
|
-
readonly id: "timeline";
|
|
1389
|
-
readonly label: "Timeline";
|
|
1390
|
-
readonly headers: readonly ["timeline"];
|
|
1391
|
-
readonly narrower: "asTimeline";
|
|
1392
|
-
readonly editorDiagramType: "Timeline";
|
|
1393
|
-
readonly editorExampleId: "timeline-basic";
|
|
1394
|
-
readonly editorGlyph: "T";
|
|
1395
|
-
readonly example: "timeline\n title Roadmap\n 2025 : Alpha : Beta\n 2026 : GA";
|
|
1396
|
-
}, {
|
|
1397
|
-
readonly id: "class";
|
|
1398
|
-
readonly label: "Class";
|
|
1399
|
-
readonly headers: readonly ["classDiagram"];
|
|
1400
|
-
readonly narrower: "asClass";
|
|
1401
|
-
readonly editorDiagramType: "Class";
|
|
1402
|
-
readonly editorExampleId: "class-basic";
|
|
1403
|
-
readonly editorGlyph: "C";
|
|
1404
|
-
readonly example: "classDiagram\n class Account {\n +id: string\n +close() void\n }\n Account <|-- Savings\n Account \"1\" o-- \"*\" Transaction : logs";
|
|
1405
|
-
}, {
|
|
1406
|
-
readonly id: "er";
|
|
1407
|
-
readonly label: "ER";
|
|
1408
|
-
readonly headers: readonly ["erDiagram"];
|
|
1409
|
-
readonly narrower: "asEr";
|
|
1410
|
-
readonly editorDiagramType: "ER";
|
|
1411
|
-
readonly editorExampleId: "er-basic";
|
|
1412
|
-
readonly editorGlyph: "ER";
|
|
1413
|
-
readonly example: "erDiagram\n CUSTOMER ||--o{ ORDER : places\n ORDER {\n string id\n }";
|
|
1414
|
-
}, {
|
|
1415
|
-
readonly id: "journey";
|
|
1416
|
-
readonly label: "Journey";
|
|
1417
|
-
readonly headers: readonly ["journey"];
|
|
1418
|
-
readonly narrower: "asJourney";
|
|
1419
|
-
readonly editorDiagramType: "Journey";
|
|
1420
|
-
readonly editorExampleId: "journey-basic";
|
|
1421
|
-
readonly editorGlyph: "J";
|
|
1422
|
-
readonly example: "journey\n title Checkout\n section Browse\n Find product: 4: Shopper\n section Buy\n Pay: 3: Shopper";
|
|
1423
|
-
}, {
|
|
1424
|
-
readonly id: "architecture";
|
|
1425
|
-
readonly label: "Architecture";
|
|
1426
|
-
readonly headers: readonly ["architecture-beta"];
|
|
1427
|
-
readonly narrower: "asArchitecture";
|
|
1428
|
-
readonly editorDiagramType: "Architecture";
|
|
1429
|
-
readonly editorExampleId: "architecture-basic";
|
|
1430
|
-
readonly editorGlyph: "A";
|
|
1431
|
-
readonly example: "architecture-beta\n group backend(cloud)[Backend]\n service api(server)[API] in backend\n service db(database)[Database] in backend\n service cache(disk)[Cache] in backend\n api:R --> L:db\n api:B -[reads]-> T:cache";
|
|
1432
|
-
}, {
|
|
1433
|
-
readonly id: "xychart";
|
|
1434
|
-
readonly label: "XY chart";
|
|
1435
|
-
readonly headers: readonly ["xychart", "xychart-beta"];
|
|
1436
|
-
readonly narrower: "asXyChart";
|
|
1437
|
-
readonly editorDiagramType: "XY Chart";
|
|
1438
|
-
readonly editorExampleId: "xychart-basic";
|
|
1439
|
-
readonly editorGlyph: "XY";
|
|
1440
|
-
readonly example: "xychart-beta\n title \"Revenue\"\n x-axis [Q1, Q2, Q3]\n y-axis \"USD\" 0 --> 100\n bar [45, 62, 80]";
|
|
1441
|
-
}, {
|
|
1442
|
-
readonly id: "pie";
|
|
1443
|
-
readonly label: "Pie";
|
|
1444
|
-
readonly headers: readonly ["pie"];
|
|
1445
|
-
readonly narrower: "asPie";
|
|
1446
|
-
readonly editorDiagramType: "Pie";
|
|
1447
|
-
readonly editorExampleId: "pie-basic";
|
|
1448
|
-
readonly editorGlyph: "P";
|
|
1449
|
-
readonly example: "pie title Plans\n \"Free\" : 60\n \"Pro\" : 30\n \"Enterprise\" : 10";
|
|
1450
|
-
}, {
|
|
1451
|
-
readonly id: "quadrant";
|
|
1452
|
-
readonly label: "Quadrant";
|
|
1453
|
-
readonly headers: readonly ["quadrantChart"];
|
|
1454
|
-
readonly narrower: "asQuadrant";
|
|
1455
|
-
readonly editorDiagramType: "Quadrant";
|
|
1456
|
-
readonly editorExampleId: "quadrant-basic";
|
|
1457
|
-
readonly editorGlyph: "4Q";
|
|
1458
|
-
readonly example: "quadrantChart\n title Prioritize\n x-axis Low Effort --> High Effort\n y-axis Low Value --> High Value\n Quick win: [0.2, 0.8]\n Money pit: [0.8, 0.2]";
|
|
1459
|
-
}, {
|
|
1460
|
-
readonly id: "gantt";
|
|
1461
|
-
readonly label: "Gantt";
|
|
1462
|
-
readonly headers: readonly ["gantt"];
|
|
1463
|
-
readonly narrower: "asGantt";
|
|
1464
|
-
readonly editorDiagramType: "Gantt";
|
|
1465
|
-
readonly editorExampleId: "gantt-basic";
|
|
1466
|
-
readonly editorGlyph: "G";
|
|
1467
|
-
readonly example: "gantt\n title Plan\n dateFormat YYYY-MM-DD\n section Build\n Implement :a1, 2026-01-05, 5d\n Review :after a1, 2d";
|
|
1468
|
-
}];
|
|
1469
|
-
type BuiltinFamilyId = typeof BUILTIN_FAMILY_METADATA[number]['id'];
|
|
1470
|
-
type BuiltinFamilyMetadataCoversDiagramKind = [
|
|
1471
|
-
Exclude<DiagramKind, BuiltinFamilyId>,
|
|
1472
|
-
Exclude<BuiltinFamilyId, DiagramKind>
|
|
1473
|
-
] extends [never, never] ? true : never;
|
|
1474
|
-
declare const BUILTIN_FAMILY_METADATA_COVERS_DIAGRAM_KIND: BuiltinFamilyMetadataCoversDiagramKind;
|
|
1475
|
-
declare function builtinFamilyMetadata(kind: DiagramKind): BuiltinFamilyMetadata | undefined;
|
|
1476
|
-
declare function registerFamily(plugin: FamilyPlugin): void;
|
|
1477
|
-
declare function getFamily(kind: DiagramKind): FamilyPlugin | undefined;
|
|
1478
|
-
declare function knownFamilies(): DiagramKind[];
|
|
1479
|
-
|
|
1480
|
-
declare function parseMermaid(source: string): Result<ValidDiagram, ParseError[]>;
|
|
1481
|
-
|
|
1482
|
-
interface SerializeOptions {
|
|
1483
|
-
/**
|
|
1484
|
-
* Wrapper emission policy. 'verbatim' (default) re-emits the leading source
|
|
1485
|
-
* wrapper (frontmatter, init directives, comments) byte-identically from
|
|
1486
|
-
* `meta.wrapperSource`. 'canonical' synthesizes Mermaid's documented shape
|
|
1487
|
-
* instead: one frontmatter block with `title`/`displayMode` at the top
|
|
1488
|
-
* level and everything else nested under `config:`, init directives folded
|
|
1489
|
-
* in (re-emitted raw only when their payload could not be folded), and
|
|
1490
|
-
* wrapper comments dropped. Diagrams without a captured wrapper (e.g.
|
|
1491
|
-
* synthesized from JSON payloads) always use canonical synthesis.
|
|
1492
|
-
*/
|
|
1493
|
-
wrapper?: 'verbatim' | 'canonical';
|
|
1494
|
-
}
|
|
1495
|
-
declare function serializeMermaid(d: ValidDiagram, opts?: SerializeOptions): string;
|
|
1496
|
-
declare function synthesizeFromGraph(payload: ValidDiagramPayload): Result<ValidDiagram, ParseError[]>;
|
|
1497
|
-
|
|
1498
|
-
interface CreateMermaidOptions {
|
|
1499
|
-
/** Layout direction for flowchart/state diagrams (default TD). Ignored elsewhere. */
|
|
1500
|
-
direction?: Direction;
|
|
1501
|
-
}
|
|
1502
|
-
/** A mutation failure annotated with which op in the build list failed. */
|
|
1503
|
-
type BuildError = MutationError & {
|
|
1504
|
-
opIndex: number;
|
|
1505
|
-
};
|
|
1506
|
-
declare function createMermaid(kind: 'flowchart', opts?: CreateMermaidOptions): FlowchartValidDiagram;
|
|
1507
|
-
declare function createMermaid(kind: 'state', opts?: CreateMermaidOptions): StateValidDiagram;
|
|
1508
|
-
declare function createMermaid(kind: 'sequence', opts?: CreateMermaidOptions): SequenceValidDiagram;
|
|
1509
|
-
declare function createMermaid(kind: 'timeline', opts?: CreateMermaidOptions): TimelineValidDiagram;
|
|
1510
|
-
declare function createMermaid(kind: 'class', opts?: CreateMermaidOptions): ClassValidDiagram;
|
|
1511
|
-
declare function createMermaid(kind: 'er', opts?: CreateMermaidOptions): ErValidDiagram;
|
|
1512
|
-
declare function createMermaid(kind: 'journey', opts?: CreateMermaidOptions): JourneyValidDiagram;
|
|
1513
|
-
declare function createMermaid(kind: 'architecture', opts?: CreateMermaidOptions): ArchitectureValidDiagram;
|
|
1514
|
-
declare function createMermaid(kind: 'xychart', opts?: CreateMermaidOptions): XyChartValidDiagram;
|
|
1515
|
-
declare function createMermaid(kind: 'pie', opts?: CreateMermaidOptions): PieValidDiagram;
|
|
1516
|
-
declare function createMermaid(kind: 'quadrant', opts?: CreateMermaidOptions): QuadrantValidDiagram;
|
|
1517
|
-
declare function createMermaid(kind: 'gantt', opts?: CreateMermaidOptions): GanttValidDiagram;
|
|
1518
|
-
declare function createMermaid(kind: DiagramKind, opts?: CreateMermaidOptions): MutableValidDiagram;
|
|
1519
|
-
declare function buildMermaid(kind: 'flowchart', ops: FlowchartMutationOp[], opts?: CreateMermaidOptions): Result<FlowchartValidDiagram, BuildError>;
|
|
1520
|
-
declare function buildMermaid(kind: 'state', ops: StateMutationOp[], opts?: CreateMermaidOptions): Result<StateValidDiagram, BuildError>;
|
|
1521
|
-
declare function buildMermaid(kind: 'sequence', ops: SequenceMutationOp[], opts?: CreateMermaidOptions): Result<SequenceValidDiagram, BuildError>;
|
|
1522
|
-
declare function buildMermaid(kind: 'timeline', ops: TimelineMutationOp[], opts?: CreateMermaidOptions): Result<TimelineValidDiagram, BuildError>;
|
|
1523
|
-
declare function buildMermaid(kind: 'class', ops: ClassMutationOp[], opts?: CreateMermaidOptions): Result<ClassValidDiagram, BuildError>;
|
|
1524
|
-
declare function buildMermaid(kind: 'er', ops: ErMutationOp[], opts?: CreateMermaidOptions): Result<ErValidDiagram, BuildError>;
|
|
1525
|
-
declare function buildMermaid(kind: 'journey', ops: JourneyMutationOp[], opts?: CreateMermaidOptions): Result<JourneyValidDiagram, BuildError>;
|
|
1526
|
-
declare function buildMermaid(kind: 'architecture', ops: ArchitectureMutationOp[], opts?: CreateMermaidOptions): Result<ArchitectureValidDiagram, BuildError>;
|
|
1527
|
-
declare function buildMermaid(kind: 'xychart', ops: XyChartMutationOp[], opts?: CreateMermaidOptions): Result<XyChartValidDiagram, BuildError>;
|
|
1528
|
-
declare function buildMermaid(kind: 'pie', ops: PieMutationOp[], opts?: CreateMermaidOptions): Result<PieValidDiagram, BuildError>;
|
|
1529
|
-
declare function buildMermaid(kind: 'quadrant', ops: QuadrantMutationOp[], opts?: CreateMermaidOptions): Result<QuadrantValidDiagram, BuildError>;
|
|
1530
|
-
declare function buildMermaid(kind: 'gantt', ops: GanttMutationOp[], opts?: CreateMermaidOptions): Result<GanttValidDiagram, BuildError>;
|
|
1531
|
-
declare function buildMermaid(kind: DiagramKind, ops: AnyMutationOp[], opts?: CreateMermaidOptions): Result<MutableValidDiagram, BuildError>;
|
|
1532
|
-
|
|
1533
|
-
declare function edgeIdOf(edge: MermaidEdge, idx?: number): string;
|
|
1534
|
-
|
|
1535
|
-
declare function mutate(d: FlowchartValidDiagram, op: FlowchartMutationOp): Result<FlowchartValidDiagram, MutationError>;
|
|
1536
|
-
declare function mutate(d: StateValidDiagram, op: StateMutationOp): Result<StateValidDiagram, MutationError>;
|
|
1537
|
-
declare function mutate(d: SequenceValidDiagram, op: SequenceMutationOp): Result<SequenceValidDiagram, MutationError>;
|
|
1538
|
-
declare function mutate(d: TimelineValidDiagram, op: TimelineMutationOp): Result<TimelineValidDiagram, MutationError>;
|
|
1539
|
-
declare function mutate(d: ClassValidDiagram, op: ClassMutationOp): Result<ClassValidDiagram, MutationError>;
|
|
1540
|
-
declare function mutate(d: ErValidDiagram, op: ErMutationOp): Result<ErValidDiagram, MutationError>;
|
|
1541
|
-
declare function mutate(d: JourneyValidDiagram, op: JourneyMutationOp): Result<JourneyValidDiagram, MutationError>;
|
|
1542
|
-
declare function mutate(d: ArchitectureValidDiagram, op: ArchitectureMutationOp): Result<ArchitectureValidDiagram, MutationError>;
|
|
1543
|
-
declare function mutate(d: XyChartValidDiagram, op: XyChartMutationOp): Result<XyChartValidDiagram, MutationError>;
|
|
1544
|
-
declare function mutate(d: PieValidDiagram, op: PieMutationOp): Result<PieValidDiagram, MutationError>;
|
|
1545
|
-
declare function mutate(d: QuadrantValidDiagram, op: QuadrantMutationOp): Result<QuadrantValidDiagram, MutationError>;
|
|
1546
|
-
declare function mutate(d: GanttValidDiagram, op: GanttMutationOp): Result<GanttValidDiagram, MutationError>;
|
|
1547
|
-
declare function mutate(d: MutableValidDiagram, op: AnyMutationOp): Result<MutableValidDiagram, MutationError>;
|
|
1548
|
-
/**
|
|
1549
|
-
* mutate with a shape check in front — the one choke point every UNTYPED edit
|
|
1550
|
-
* path funnels through: the declarative applyOps/buildChecked entrypoints, the
|
|
1551
|
-
* Code Mode facade, and the CLI `--op`/`--ops` path. Typed callers keep using
|
|
1552
|
-
* `mutate` directly, where the compiler already guarantees op shape;
|
|
1553
|
-
* `mutateChecked` restores that guarantee at the boundaries where ops arrive as
|
|
1554
|
-
* raw JSON.
|
|
1555
|
-
*
|
|
1556
|
-
* `validateOp` proves the op's SHAPE (field names, primitive types, enums)
|
|
1557
|
-
* BEFORE the mutator runs, so a malformed op is rejected with a prescriptive
|
|
1558
|
-
* INVALID_OP error instead of silently mangling the diagram. Semantics — does
|
|
1559
|
-
* the referenced node exist, is the id a duplicate — stay in the mutator, which
|
|
1560
|
-
* runs second on a shape-proven op. Result shape is identical to `mutate`, so
|
|
1561
|
-
* this is a drop-in wherever the raw mutator was called with untyped ops.
|
|
1562
|
-
*/
|
|
1563
|
-
declare function mutateChecked(d: MutableValidDiagram, op: unknown): Result<MutableValidDiagram, MutationError>;
|
|
1564
|
-
|
|
1565
|
-
declare const MUTATION_OPS_BY_FAMILY: {
|
|
1566
|
-
readonly flowchart: readonly ["add_node", "remove_node", "rename_node", "set_label", "add_edge", "remove_edge"];
|
|
1567
|
-
readonly state: readonly ["add_state", "remove_state", "rename_state", "set_state_label", "add_transition", "remove_transition", "set_transition_label", "make_composite"];
|
|
1568
|
-
readonly sequence: readonly ["add_participant", "remove_participant", "add_message", "remove_message", "set_message_text"];
|
|
1569
|
-
readonly timeline: readonly ["set_title", "add_section", "remove_section", "set_section_label", "add_period", "remove_period", "set_period_label", "add_event", "remove_event", "set_event_text"];
|
|
1570
|
-
readonly class: readonly ["set_title", "add_class", "remove_class", "rename_class", "add_member", "remove_member", "add_relation", "remove_relation", "add_note", "remove_note"];
|
|
1571
|
-
readonly er: readonly ["add_entity", "remove_entity", "rename_entity", "add_attribute", "remove_attribute", "add_relation", "remove_relation"];
|
|
1572
|
-
readonly journey: readonly ["set_title", "add_section", "remove_section", "set_section_label", "add_task", "remove_task", "set_task_text", "set_task_score", "set_task_actors", "rename_actor", "move_task", "move_section", "set_accessibility_title", "set_accessibility_description"];
|
|
1573
|
-
readonly architecture: readonly ["add_service", "remove_service", "rename_service", "set_service_label", "set_service_icon", "move_service", "add_group", "remove_group", "add_edge", "remove_edge"];
|
|
1574
|
-
readonly xychart: readonly ["set_title", "set_x_axis", "set_y_axis", "add_series", "remove_series", "set_series_values", "set_series_name", "reorder_series"];
|
|
1575
|
-
readonly pie: readonly ["set_title", "set_show_data", "add_slice", "remove_slice", "rename_slice", "set_slice_value", "reorder_slice"];
|
|
1576
|
-
readonly quadrant: readonly ["set_title", "set_axis_labels", "set_quadrant_label", "add_point", "remove_point", "move_point", "rename_point"];
|
|
1577
|
-
readonly gantt: readonly ["set_title", "add_section", "rename_section", "remove_section", "add_task", "remove_task", "rename_task", "set_task_status", "set_task_dates"];
|
|
1578
|
-
};
|
|
1579
|
-
type MutableFamilyId = keyof typeof MUTATION_OPS_BY_FAMILY;
|
|
1580
|
-
|
|
1581
|
-
type OpFamily = MutableFamilyId;
|
|
1582
|
-
/** True when `family` has a shape schema (i.e. is a mutable structured family). */
|
|
1583
|
-
declare function hasOpSchema(family: string): family is OpFamily;
|
|
1584
|
-
/**
|
|
1585
|
-
* Structured, model-actionable validation error. `code` is always INVALID_OP
|
|
1586
|
-
* (so it flows through the existing MutationError channel unchanged), but the
|
|
1587
|
-
* payload names the exact problem and enumerates the legal fields so a weak
|
|
1588
|
-
* model can self-correct in one turn.
|
|
1589
|
-
*/
|
|
1590
|
-
interface OpValidationError {
|
|
1591
|
-
code: 'INVALID_OP';
|
|
1592
|
-
/** 'expected_single_op' | 'unknown_kind' | 'unknown_field' | 'missing_field' | 'wrong_type' | 'require_one_of' */
|
|
1593
|
-
reason: string;
|
|
1594
|
-
message: string;
|
|
1595
|
-
family: OpFamily;
|
|
1596
|
-
opKind?: string;
|
|
1597
|
-
/** the offending field, when applicable */
|
|
1598
|
-
field?: string;
|
|
1599
|
-
/** valid field names for this op (or valid op kinds, for unknown_kind) */
|
|
1600
|
-
validFields?: string[];
|
|
1601
|
-
/** nearest valid name to a typo'd field/kind, when an obvious match exists */
|
|
1602
|
-
didYouMean?: string;
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Validate one op's SHAPE against its family schema. Returns null when valid.
|
|
1606
|
-
* The one and only shape choke point: every untyped edit path (declarative
|
|
1607
|
-
* applyOps / buildChecked and the Code Mode facade) calls this — through
|
|
1608
|
-
* mutateChecked — before touching a mutator.
|
|
1609
|
-
*/
|
|
1610
|
-
declare function validateOp(family: OpFamily, op: unknown): OpValidationError | null;
|
|
1611
|
-
/** Machine-readable op menu for a family — { opKind: [fieldName, …] } — the
|
|
1612
|
-
* basis for tool-discovery output. Optional fields are marked with a trailing
|
|
1613
|
-
* `?`; the op's `kind` is implicit and omitted. */
|
|
1614
|
-
declare function opMenu(family: OpFamily): Record<string, string[]>;
|
|
1615
|
-
/** One field of an op, as a model needs it to fill the op correctly: the name,
|
|
1616
|
-
* whether it is required, and a human type that spells out enum values inline
|
|
1617
|
-
* (e.g. `one of "inheritance", "composition", …`). */
|
|
1618
|
-
interface OpFieldDoc {
|
|
1619
|
-
name: string;
|
|
1620
|
-
required: boolean;
|
|
1621
|
-
type: string;
|
|
1622
|
-
note?: string;
|
|
1623
|
-
}
|
|
1624
|
-
/** Full field shapes for every op of a family — the thing a model must know to
|
|
1625
|
-
* author a correct op without guessing (which the prescriptive INVALID_OP error
|
|
1626
|
-
* only teaches AFTER a wrong guess). Surfaced in `am capabilities --json` and
|
|
1627
|
-
* the declarative MCP tool descriptions so field names, required-ness, and enum
|
|
1628
|
-
* vocabularies are discoverable up front. */
|
|
1629
|
-
declare function describeOps(family: OpFamily): Record<string, OpFieldDoc[]>;
|
|
1630
|
-
/** Compact one-line signatures for a family's ops — `add_relation(from, to,
|
|
1631
|
-
* relKind, label?)` — for embedding in a tool description. Optional fields carry
|
|
1632
|
-
* a trailing `?`; enum values are left to `describeOps`/the error to keep the
|
|
1633
|
-
* menu short. */
|
|
1634
|
-
declare function opSignatures(family: OpFamily): string[];
|
|
1635
|
-
|
|
1636
|
-
/** A verify summary reduced to plain JSON (no RenderedLayout proxy graph). */
|
|
1637
|
-
interface VerifySummary {
|
|
1638
|
-
ok: boolean;
|
|
1639
|
-
warnings: VerifyResult['warnings'];
|
|
1640
|
-
}
|
|
1641
|
-
/** A mutation failure annotated with which op in the list failed. */
|
|
1642
|
-
type CheckedBuildError = MutationError & {
|
|
1643
|
-
opIndex: number;
|
|
1644
|
-
};
|
|
1645
|
-
/**
|
|
1646
|
-
* THE single output DTO for the declarative surface. Success and failure share
|
|
1647
|
-
* one shape: `ok` discriminates. Every field is plain JSON — safe to return
|
|
1648
|
-
* straight out as an MCP tool result and safe to JSON round-trip: no
|
|
1649
|
-
* `{ok,value}`-vs-plain split, no provenance proxy, no Map.
|
|
1650
|
-
*/
|
|
1651
|
-
type OpEnvelope = {
|
|
1652
|
-
ok: true;
|
|
1653
|
-
family: DiagramKind;
|
|
1654
|
-
/** canonical Mermaid source of the mutated diagram */
|
|
1655
|
-
source: string;
|
|
1656
|
-
verify: VerifySummary;
|
|
1657
|
-
} | {
|
|
1658
|
-
ok: false;
|
|
1659
|
-
family: OpFamily | DiagramKind | null;
|
|
1660
|
-
/** index of the failing op within the batch, when the failure is op-scoped */
|
|
1661
|
-
opIndex?: number;
|
|
1662
|
-
error: OpValidationError | {
|
|
1663
|
-
code: string;
|
|
1664
|
-
message: string;
|
|
1665
|
-
};
|
|
1666
|
-
};
|
|
1667
|
-
/** Drop the layout proxy graph; keep the model-actionable verdict. The JSON
|
|
1668
|
-
* round-trip guarantees no residual Map / prototype leaks through. */
|
|
1669
|
-
declare function verifySummary(v: VerifyResult): VerifySummary;
|
|
1670
|
-
/**
|
|
1671
|
-
* buildMermaid's contract (createMermaid → fold ops) with the shape check in
|
|
1672
|
-
* front of every op. Same Result shape as buildMermaid, so it is a drop-in for
|
|
1673
|
-
* the untyped build path (Code Mode facade `buildMermaid`, declarative `build`).
|
|
1674
|
-
*/
|
|
1675
|
-
declare function buildChecked(kind: DiagramKind, ops: unknown[], opts?: CreateMermaidOptions): Result<MutableValidDiagram, CheckedBuildError>;
|
|
1676
|
-
interface ApplyOpsInput {
|
|
1677
|
-
/** Existing Mermaid `source` to edit, OR `family` to author from blank. */
|
|
1678
|
-
source?: string;
|
|
1679
|
-
family?: string;
|
|
1680
|
-
ops: unknown;
|
|
1681
|
-
}
|
|
1682
|
-
/**
|
|
1683
|
-
* Plain-JSON-in / plain-JSON-out batch edit. Fail-fast, all-or-nothing: ops
|
|
1684
|
-
* apply in order over a working copy; the first invalid or semantically-rejected
|
|
1685
|
-
* op stops the batch and reports its index — nothing is committed (the input
|
|
1686
|
-
* `source` is untouched, mirroring buildMermaid). Returns the canonical envelope.
|
|
1687
|
-
*/
|
|
1688
|
-
declare function applyOps(input: ApplyOpsInput): OpEnvelope;
|
|
1689
|
-
|
|
1690
|
-
declare function verifyMermaid(input: ValidDiagram | string, opts?: VerifyOptions): VerifyResult;
|
|
1691
|
-
|
|
1692
|
-
interface QualityMetrics {
|
|
1693
|
-
edgeCrossings: number;
|
|
1694
|
-
labelLegibility: number;
|
|
1695
|
-
whitespaceBalance: number;
|
|
1696
|
-
labelEdgeProximity: number;
|
|
1697
|
-
aspectRatio: number;
|
|
1698
|
-
nodeCount: number;
|
|
1699
|
-
edgeCount: number;
|
|
1700
|
-
}
|
|
1701
|
-
interface QualityBounds {
|
|
1702
|
-
/** Max edge crossings per (edge × edge) pair. Default 0.05 = 5%. */
|
|
1703
|
-
maxCrossingsRatio?: number;
|
|
1704
|
-
/** Min label legibility. Default 0.85 = 85% of labels fit. */
|
|
1705
|
-
minLabelLegibility?: number;
|
|
1706
|
-
/** Whitespace fill band [min, max]. Default [0.05, 0.55]. */
|
|
1707
|
-
whitespaceBand?: [number, number];
|
|
1708
|
-
/** Min pixels between any edge-label bbox and a non-attached node, another edge-label, or another edge path. Default 4. */
|
|
1709
|
-
minLabelEdgeProximity?: number;
|
|
1710
|
-
/** Aspect ratio band [min, max]. Default [0.2, 5.0]. */
|
|
1711
|
-
aspectBand?: [number, number];
|
|
1712
|
-
}
|
|
1713
|
-
declare const DEFAULT_BOUNDS: Required<QualityBounds>;
|
|
1714
|
-
type BoundBasis = 'evidence' | 'derived' | 'chosen' | 'sanity';
|
|
1715
|
-
type ViolationSeverity = 'primary' | 'secondary' | 'sanity';
|
|
1716
|
-
interface BoundProvenance {
|
|
1717
|
-
basis: BoundBasis;
|
|
1718
|
-
severity: ViolationSeverity;
|
|
1719
|
-
note: string;
|
|
1720
|
-
}
|
|
1721
|
-
/** Per-metric provenance. Keyed by the QualityMetrics field each bound gates. */
|
|
1722
|
-
declare const BOUND_PROVENANCE: Record<'edgeCrossings' | 'labelLegibility' | 'whitespaceBalance' | 'labelEdgeProximity' | 'aspectRatio', BoundProvenance>;
|
|
1723
|
-
declare function measureQuality(layout: RenderedLayout): QualityMetrics;
|
|
1724
|
-
interface RankedViolation {
|
|
1725
|
-
metric: keyof typeof BOUND_PROVENANCE;
|
|
1726
|
-
severity: ViolationSeverity;
|
|
1727
|
-
message: string;
|
|
1728
|
-
}
|
|
1729
|
-
interface QualityVerdict {
|
|
1730
|
-
ok: boolean;
|
|
1731
|
-
metrics: QualityMetrics;
|
|
1732
|
-
/** Human-readable violation strings. Backward-compatible. */
|
|
1733
|
-
violations: string[];
|
|
1734
|
-
/**
|
|
1735
|
-
* The same violations, each tagged with its evidence-based severity so a
|
|
1736
|
-
* consumer can weight a crossings violation above a whitespace one
|
|
1737
|
-
* (Purchase 1997/2002). Ordered primary → secondary → sanity.
|
|
1738
|
-
*/
|
|
1739
|
-
ranked: RankedViolation[];
|
|
1740
|
-
}
|
|
1741
|
-
declare function checkQuality(layout: RenderedLayout, bounds?: QualityBounds): QualityVerdict;
|
|
1742
|
-
|
|
1743
|
-
type LayoutCertificateProof = 'edge-route' | 'region-containment';
|
|
1744
|
-
declare function layoutCertificateProof(cert: LayoutRouteCertificate): LayoutCertificateProof;
|
|
1745
|
-
|
|
1746
|
-
type RegionKind = 'node' | 'edge' | 'label' | 'subgraph';
|
|
1747
|
-
type AsciiWarningCode = 'ASCII_RENDER_FAILED' | 'ASCII_EDGE_REGION_UNMAPPED';
|
|
1748
|
-
interface AsciiWarning {
|
|
1749
|
-
code: AsciiWarningCode;
|
|
1750
|
-
message: string;
|
|
1751
|
-
severity: 'degraded';
|
|
1752
|
-
}
|
|
1753
|
-
declare const ASCII_ROUTE_PARITY_CONTRACT: {
|
|
1754
|
-
readonly version: 1;
|
|
1755
|
-
readonly routeIntent: "shared-route-classes";
|
|
1756
|
-
readonly svgSource: "route-contract classifyRoutes() + certificates";
|
|
1757
|
-
readonly asciiSource: "grid router seeded with classifyRoutes() routeClass metadata, longest-path layering, and direct-lane-first routing";
|
|
1758
|
-
readonly degradationWarnings: readonly ["ASCII_RENDER_FAILED", "ASCII_EDGE_REGION_UNMAPPED"];
|
|
1759
|
-
};
|
|
1760
|
-
interface AsciiRegion {
|
|
1761
|
-
kind: RegionKind;
|
|
1762
|
-
/** Stable identifier for the diagram element (e.g. node id, participant id). */
|
|
1763
|
-
id: string;
|
|
1764
|
-
/** Optional 1-based source line where the element was declared, when known. */
|
|
1765
|
-
sourceLine?: number;
|
|
1766
|
-
/** 0-based row in the rendered canvas where the region starts. */
|
|
1767
|
-
canvasRow: number;
|
|
1768
|
-
/** 0-based column where the region starts (inclusive). */
|
|
1769
|
-
canvasColStart: number;
|
|
1770
|
-
/** 0-based column where the region ends (exclusive). */
|
|
1771
|
-
canvasColEnd: number;
|
|
1772
|
-
/** Optional row count when the region spans multiple lines (boxed node). */
|
|
1773
|
-
rowSpan?: number;
|
|
1774
|
-
}
|
|
1775
|
-
interface AsciiWithMeta {
|
|
1776
|
-
ascii: string;
|
|
1777
|
-
regions: AsciiRegion[];
|
|
1778
|
-
warnings: AsciiWarning[];
|
|
1779
|
-
routeParity: typeof ASCII_ROUTE_PARITY_CONTRACT;
|
|
1780
|
-
}
|
|
1781
|
-
declare function renderMermaidASCIIWithMeta(input: string, opts?: AsciiRenderOptions): AsciiWithMeta;
|
|
1782
|
-
|
|
1783
|
-
interface DescribeOptions {
|
|
1784
|
-
/** 'text' (default): prose summary. 'json': structured AX tree (#7349). 'facts': deterministic semantic facts. */
|
|
1785
|
-
format?: 'text' | 'json' | 'facts';
|
|
1786
|
-
}
|
|
1787
|
-
/** Structured accessibility tree (#7349): the graph as a list of nodes + edges. */
|
|
1788
|
-
interface DescribeTree {
|
|
1789
|
-
kind: string;
|
|
1790
|
-
nodes: Array<{
|
|
1791
|
-
id: string;
|
|
1792
|
-
label: string;
|
|
1793
|
-
}>;
|
|
1794
|
-
edges: Array<{
|
|
1795
|
-
from: string;
|
|
1796
|
-
to: string;
|
|
1797
|
-
label?: string;
|
|
1798
|
-
}>;
|
|
1799
|
-
entryPoints: string[];
|
|
1800
|
-
sinks: string[];
|
|
1801
|
-
}
|
|
1802
|
-
declare function describeMermaidSource(source: string, opts?: DescribeOptions): string;
|
|
1803
|
-
declare function describeMermaid(d: ValidDiagram, opts?: DescribeOptions): string;
|
|
1804
|
-
/**
|
|
1805
|
-
* #7349: machine-readable accessibility tree — the graph as a flat node/edge
|
|
1806
|
-
* list with entry points and sinks. More useful to agents and screen-reader
|
|
1807
|
-
* tooling than prose. Covers the structured families; source-level/opaque
|
|
1808
|
-
* families expose extracted labels as nodes and no edges.
|
|
1809
|
-
*/
|
|
1810
|
-
declare function describeMermaidTree(d: ValidDiagram): DescribeTree;
|
|
1811
|
-
|
|
1812
|
-
declare function analyzeMermaid(d: ValidDiagram): DiagramAnalysis;
|
|
1813
|
-
declare function analyzeMermaidSource(source: string): Result<DiagramAnalysis, ParseError[]>;
|
|
1814
|
-
declare function collectActionRecords(d: ValidDiagram): DiagramActionRecord[];
|
|
1815
|
-
|
|
1816
|
-
/**
|
|
1817
|
-
* Reverse an ASCII flowchart render back to (best-effort) Mermaid source.
|
|
1818
|
-
* Returns synthesized ids (N0, N1, …) with recovered labels and edges.
|
|
1819
|
-
*/
|
|
1820
|
-
declare function asciiToMermaid(ascii: string, opts?: {
|
|
1821
|
-
direction?: 'TD' | 'LR';
|
|
1822
|
-
}): Result<string, ParseError[]>;
|
|
1823
|
-
|
|
1824
|
-
declare function renderMermaidSVG(input: ValidDiagram | string, opts?: Parameters<typeof renderMermaidSVG$1>[1]): string;
|
|
1825
|
-
declare function renderMermaidASCII(input: ValidDiagram | string, opts?: Parameters<typeof renderMermaidASCII$1>[1]): string;
|
|
1826
|
-
interface LayoutMermaidOptions {
|
|
1827
|
-
debug?: boolean;
|
|
1828
|
-
regions?: boolean;
|
|
1829
|
-
actions?: boolean;
|
|
1830
|
-
}
|
|
1831
|
-
declare function layoutMermaid(d: ValidDiagram, opts?: LayoutMermaidOptions): RenderedLayout;
|
|
1832
|
-
|
|
1833
|
-
/**
|
|
1834
|
-
* Loud-tofu guard: emitted when rendered text contains characters no loaded
|
|
1835
|
-
* font covers (they would silently rasterize as empty boxes). Delivered to
|
|
1836
|
-
* `PngOptions.onWarning` when provided, otherwise written to stderr — never
|
|
1837
|
-
* silent either way.
|
|
1838
|
-
*/
|
|
1839
6
|
interface PngFontWarning {
|
|
1840
7
|
code: 'PNG_FONT_COVERAGE';
|
|
1841
|
-
/** Coarse script bucket of the uncovered characters ('CJK', 'emoji', …). */
|
|
1842
8
|
script: string;
|
|
1843
|
-
/** The uncovered characters, unique, ascending codepoint order. */
|
|
1844
9
|
chars: string[];
|
|
1845
|
-
/** Human-readable summary naming the script and the escape hatches. */
|
|
1846
10
|
message: string;
|
|
1847
11
|
}
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
scale?: number;
|
|
1851
|
-
/** Background color, any CSS color string (default 'white'). */
|
|
1852
|
-
background?: string;
|
|
1853
|
-
/** Constrain output dimensions; otherwise honors scale on the SVG bounds. */
|
|
1854
|
-
fitTo?: {
|
|
1855
|
-
width?: number;
|
|
1856
|
-
height?: number;
|
|
1857
|
-
};
|
|
1858
|
-
/** Style name | spec | stack, same as RenderOptions.style. Faces referenced
|
|
1859
|
-
* by the built-in looks are bundled in assets/fonts/; other families fall
|
|
1860
|
-
* back to DejaVu Sans unless supplied via fontDirs. */
|
|
1861
|
-
style?: StyleInput | StyleInput[];
|
|
1862
|
-
/** Ink-wobble seed for styled looks, same as RenderOptions.seed. */
|
|
1863
|
-
seed?: number;
|
|
1864
|
-
/** Extra font directories searched in addition to the bundled ones —
|
|
1865
|
-
* the escape hatch for custom styles that reference unbundled families
|
|
1866
|
-
* and for scripts the bundled fonts don't cover (CJK, emoji). */
|
|
1867
|
-
fontDirs?: string[];
|
|
1868
|
-
/** Also load the OS's installed fonts (default false). Opting in trades
|
|
1869
|
-
* cross-machine determinism for coverage — useful when the diagram needs
|
|
1870
|
-
* CJK/emoji glyphs and a system font provides them. Coverage warnings are
|
|
1871
|
-
* skipped in this mode: the system font set is unknown to the checker. */
|
|
1872
|
-
loadSystemFonts?: boolean;
|
|
12
|
+
|
|
13
|
+
interface PngOptions extends RenderOptions, PngOutputPolicyInput {
|
|
1873
14
|
/** Receives glyph-coverage warnings instead of the default stderr write.
|
|
1874
15
|
* Warnings never change the PNG bytes; identical inputs render
|
|
1875
16
|
* identically whether or not a handler is installed. */
|
|
1876
17
|
onWarning?: (warning: PngFontWarning) => void;
|
|
1877
18
|
}
|
|
1878
19
|
/**
|
|
1879
|
-
* Render a Mermaid diagram (source string or
|
|
20
|
+
* Render a Mermaid diagram (source string or ParsedDiagram) to a PNG byte array.
|
|
1880
21
|
* Deterministic within one runtime; cross-runtime parity is guarded for
|
|
1881
22
|
* same-machine Bun ≡ Node on x86_64/ARM64 when Node + built dist are present.
|
|
1882
23
|
*
|
|
@@ -1884,6 +25,70 @@ interface PngOptions {
|
|
|
1884
25
|
* the CLI/MCP integration straightforward. Library consumers can wrap in
|
|
1885
26
|
* `Promise.resolve()` if they want async semantics.
|
|
1886
27
|
*/
|
|
1887
|
-
declare function renderMermaidPNG(input:
|
|
28
|
+
declare function renderMermaidPNG(input: ParsedDiagram | string, opts?: PngOptions): Uint8Array;
|
|
29
|
+
interface RenderedPng {
|
|
30
|
+
png: Uint8Array;
|
|
31
|
+
receipt: RenderRequestReceipt;
|
|
32
|
+
/** Artifact/runtime provenance; deliberately excluded from request digests. */
|
|
33
|
+
runtime: PngRuntimeProvenance;
|
|
34
|
+
}
|
|
35
|
+
declare function renderMermaidPNGWithReceipt(input: ParsedDiagram | string, opts?: PngOptions): RenderedPng;
|
|
36
|
+
/** Trusted Node/Bun host policy; never copied into RenderOptions or receipts. */
|
|
37
|
+
interface MermaidPNGRendererHostOptions {
|
|
38
|
+
readonly backendPolicy?: HostBackendPolicy;
|
|
39
|
+
}
|
|
40
|
+
interface MermaidPNGRenderer {
|
|
41
|
+
renderMermaidPNG(input: ParsedDiagram | string, opts?: PngOptions): Uint8Array;
|
|
42
|
+
renderMermaidPNGWithReceipt(input: ParsedDiagram | string, opts?: PngOptions): RenderedPng;
|
|
43
|
+
}
|
|
44
|
+
/** Bind the native PNG adapter to a trusted in-process graphical backend. */
|
|
45
|
+
declare function createMermaidPNGRenderer(hostOptions?: MermaidPNGRendererHostOptions): MermaidPNGRenderer;
|
|
46
|
+
|
|
47
|
+
type RendererActionFormat = 'svg' | 'png' | 'ascii' | 'unicode';
|
|
48
|
+
type RendererActionDisposition = 'embedded-inert' | 'sidecar-only';
|
|
49
|
+
interface RendererAction extends DiagramActionRecord {
|
|
50
|
+
surface: RendererActionFormat;
|
|
51
|
+
disposition: RendererActionDisposition;
|
|
52
|
+
/** Surface-coordinate hit region, absent when the target was not rendered. */
|
|
53
|
+
region?: RenderedRegion;
|
|
54
|
+
}
|
|
55
|
+
interface RendererActionSurface {
|
|
56
|
+
version: 1;
|
|
57
|
+
format: RendererActionFormat;
|
|
58
|
+
coordinateSpace: 'pixel' | 'cell';
|
|
59
|
+
/** Only regions referenced by at least one action. */
|
|
60
|
+
regions: RenderedRegion[];
|
|
61
|
+
/** Callbacks remain metadata-only and `executable` is always false. */
|
|
62
|
+
actions: RendererAction[];
|
|
63
|
+
}
|
|
64
|
+
type RenderMermaidActionRequest = {
|
|
65
|
+
format: 'svg';
|
|
66
|
+
options?: RenderOptions;
|
|
67
|
+
} | {
|
|
68
|
+
format: 'png';
|
|
69
|
+
options?: PngOptions;
|
|
70
|
+
} | {
|
|
71
|
+
format: 'ascii' | 'unicode';
|
|
72
|
+
options?: AsciiRenderOptions;
|
|
73
|
+
};
|
|
74
|
+
type RenderedActionArtifact = {
|
|
75
|
+
format: 'svg';
|
|
76
|
+
output: string;
|
|
77
|
+
actionSurface: RendererActionSurface;
|
|
78
|
+
} | {
|
|
79
|
+
format: 'png';
|
|
80
|
+
output: Uint8Array;
|
|
81
|
+
actionSurface: RendererActionSurface;
|
|
82
|
+
} | {
|
|
83
|
+
format: 'ascii' | 'unicode';
|
|
84
|
+
output: string;
|
|
85
|
+
actionSurface: RendererActionSurface;
|
|
86
|
+
warnings: AsciiWarning[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Render SVG, PNG, ASCII, or Unicode and return one renderer-neutral inert
|
|
90
|
+
* action/hit-region sidecar. The ordinary byte/string render APIs are unchanged.
|
|
91
|
+
*/
|
|
92
|
+
declare function renderMermaidWithActions(input: ParsedDiagram | string, request: RenderMermaidActionRequest): RenderedActionArtifact;
|
|
1888
93
|
|
|
1889
|
-
export {
|
|
94
|
+
export { AsciiRenderOptions, AsciiWarning, DiagramActionRecord, HostBackendPolicy, type MermaidPNGRenderer, type MermaidPNGRendererHostOptions, ParsedDiagram, type PngOptions, PngOutputPolicyInput, PngRuntimeProvenance, type RenderMermaidActionRequest, RenderRequestReceipt, type RenderedActionArtifact, type RenderedPng, RenderedRegion, type RendererAction, type RendererActionDisposition, type RendererActionFormat, type RendererActionSurface, createMermaidPNGRenderer, renderMermaidPNG, renderMermaidPNGWithReceipt, renderMermaidWithActions };
|