Public API Contract
This page documents the stable public API surface of the Finsteps presentation runtime. Changes to this contract follow semantic versioning rules.
Entry point
The main entry is presentMermaid(options), which
returns a Controller instance.
presentMermaid({
mountEl,
mermaidText,
mpdText | ast,
options
}) => Controller
Required
mountEl:HTMLElementthat hosts the SVG.mermaidText: Mermaid source string.-
astormpdText+options.parseMpd: presentation AST derived from MPD.
Optional (options)
diagram: customDiagramAdapter.camera: customCameraHandle.overlay: customOverlayHandle.actionHandlers: additional action handlers.-
errorPolicy: default error policy (haltOnErrororcontinueOnError). -
hooks: lifecycle hooks for editor / host integration:onInit(controller)onStepChange(state, step)onActionStart(action, step)onActionComplete(action, result)onError(error, context)
Controller
The Controller drives navigation and exposes state and
lifecycle events.
Methods
next()prev()goto(stepIndex | stepId)reset()destroy()-
getState()– returns{ stepIndex, stepId?, stepCount, errorState? } -
setState(partial)– currently supportsstepIndexandstepId. -
getDeps()– read-only access to{ diagram, camera, overlay }. getSteps()– copy of the steps array.getCurrentStep()– current step ornull.-
getExecutionContext()– execution context:{ currentAction?, currentStep?, previousStep? }. -
updateAst(newAst, options?)– update AST dynamically.-
options.preserveState– if true, attempts to keep the current step after update.
-
retry()– retries last failed step/action.clearError()– clears error state.
Events
The controller emits events via on(event, handler):
-
stepchange– payload{ state, previousState, step, previousStep } -
actionerror– payload{ error, step, action, context }; preferred for action failures. -
error– legacy alias foractionerror. -
render– emitted when the diagram is rendered. -
actionstart– payload{ action, step, context }. -
actioncomplete– payload{ action, result: { success, error? }, step, context }. -
astchange– payload{ previousState, newState, previousSteps, newSteps }.
Interfaces
DiagramHandle
getRoot() => SVGSVGElementgetContainer() => HTMLElementresolveTarget(target) => Element | nulldestroy()
CameraHandle
-
fit(target, { padding?, duration?, easing? }) reset()zoom?(factor, center?)pan?(deltaX, deltaY)fitAll?(padding?)destroy()
OverlayHandle
-
showBubble({ id?, target, text }) hideBubble(id?)clear?()destroy()
Semantic versioning discipline
- Backwards compatible additions: minor version.
- Breaking changes in public interfaces or behavior: major version.
- Bug fixes and non‑breaking internal changes: patch version.