Skip to main content
Welcome. This site supports keyboard navigation and screen readers. Press ? at any time for keyboard shortcuts. Press [ to focus the sidebar, ] to focus the content. High-contrast themes are available via the toolbar.
serard@dev00:~/cv

This Site Is A Composition Of State Machines

Every interaction on this site — the scroll spy, the headings panel, the sidebar resize, the version-news tooltip, the copy-feedback flash, the keyboard navigation, the mermaid pan/zoom — is driven by one of ~40 pure state machines living under src/lib/ and wired to the DOM through adapters in src/app-shared.ts.

The diagram below proves it. It is generated at build time by walking the TypeScript source with the compiler API, laying the result out with elkjs, and inlining the resulting SVG straight into this page. No JavaScript is required to see it: crawlers, RSS readers, the Firefox reader view, and visitors with scripts disabled all see the same diagram, with every machine name, adapter name and import edge readable as plain text.

When JavaScript is enabled, a tiny hydration adapter attaches click, hover and filter behaviour on top of the same SVG — selection, filtering and the detail panel are themselves driven by four new pure machines: explorer-selection-state, explorer-filter-state, explorer-detail-state and fsm-simulator-state. The explorer is, recursively, a composition of state machines.

Try it live. Double-click any machine node to open its own state diagram in a popover, then click the green event buttons on the right to step through the machine: the active state lights up, fireable transitions turn green, history accumulates at the bottom. Reset replays from the initial state. Drag to pan, scroll to zoom, Esc closes the popover.

State Machine Explorer Interactive diagram of every state machine and adapter that drives this site. 50 machines, 8 adapters, 34 import edges. app-ready app-ready toc-headings-rendered app-ready app-ready toc-headings-rendered toc-animation-done accent-palette-state — 2 states — src/lib/accent-palette-state.ts accent-palette-state 2 states accent-preview-state — 2 states — src/lib/accent-preview-state.ts accent-preview-state 2 states app-readiness-state — 2 states — src/lib/app-readiness-state.ts app-readiness-state 2 states button-tooltip-state — 4 states — src/lib/button-tooltip-state.ts button-tooltip-state 4 states console-font-state — 2 states — src/lib/console-font-state.ts console-font-state 2 states copy-feedback-state — 4 states — src/lib/copy-feedback-state.ts copy-feedback-state 4 states cv-prefetch — 4 states — src/lib/cv-prefetch.ts cv-prefetch 4 states diagram-mode-state — 3 states — src/lib/diagram-mode-state.ts diagram-mode-state 3 states event-bus — 1 state — src/lib/event-bus.ts event-bus 1 state explorer-coordinator — 4 states — src/lib/explorer-coordinator.ts explorer-coordinator 4 states explorer-detail-state — 3 states — src/lib/explorer-detail-state.ts explorer-detail-state 3 states explorer-filter-state — 2 states — src/lib/explorer-filter-state.ts explorer-filter-state 2 states explorer-selection-state — 4 states — src/lib/explorer-selection-state.ts explorer-selection-state 4 states font-size — 3 states — src/lib/font-size.ts font-size 3 states fsm-simulator-state — 2 states — src/lib/fsm-simulator-state.ts fsm-simulator-state 2 states hire-modal-state — 2 states — src/lib/hire-modal-state.ts hire-modal-state 2 states hot-reload-actions — 6 states — src/lib/hot-reload-actions.ts hot-reload-actions 6 states hot-reload-indicator — 6 states — src/lib/hot-reload-indicator.ts hot-reload-indicator 6 states hot-reload-observable — 6 states — src/lib/hot-reload-observable.ts hot-reload-observable 6 states hot-reload-reconnect-state — 2 states — src/lib/hot-reload-reconnect-state.ts hot-reload-reconnect-state 2 states keyboard-nav-state — 2 states — src/lib/keyboard-nav-state.ts keyboard-nav-state 2 states link-prefetch — 4 states — src/lib/link-prefetch.ts link-prefetch 4 states machine-popover-state — 2 states — src/lib/machine-popover-state.ts machine-popover-state 2 states mobile-sidebar-state — 2 states — src/lib/mobile-sidebar-state.ts mobile-sidebar-state 2 states overlay-state — 2 states — src/lib/overlay-state.ts overlay-state 2 states page-load-state — 6 states — src/lib/page-load-state.ts page-load-state 6 states scroll-spy-machine — 2 states — src/lib/scroll-spy-machine.ts scroll-spy-machine 2 states search-ui-state — 2 states — src/lib/search-ui-state.ts search-ui-state 2 states sidebar-resize-state — 2 states — src/lib/sidebar-resize-state.ts sidebar-resize-state 2 states spa-nav-state — 5 states — src/lib/spa-nav-state.ts spa-nav-state 5 states svg-viewport-state — 3 states — src/lib/svg-viewport-state.ts svg-viewport-state 3 states terminal-dots-state — 3 states — src/lib/terminal-dots-state.ts terminal-dots-state 3 states theme-coordinator — 3 states — src/lib/theme-coordinator.ts theme-coordinator 3 states toc-breadcrumb-state — 3 states — src/lib/toc-breadcrumb-state.ts toc-breadcrumb-state 3 states toc-category-state — 2 states — src/lib/toc-category-state.ts toc-category-state 2 states toc-expand-state — 2 states — src/lib/toc-expand-state.ts toc-expand-state 2 states toc-scroll-state — 8 states — src/lib/toc-scroll-state.ts toc-scroll-state 8 states toc-scroll-tooltip-state — 2 states — src/lib/toc-scroll-tooltip-state.ts toc-scroll-tooltip-state 2 states toc-tooltip-state — 4 states — src/lib/toc-tooltip-state.ts toc-tooltip-state 4 states tooltip-state — 4 states — src/lib/tooltip-state.ts tooltip-state 4 states topbar-search-state — 2 states — src/lib/topbar-search-state.ts topbar-search-state 2 states tour-button-demo-state — 5 states — src/lib/tour-button-demo-state.ts tour-button-demo-state 5 states tour-coordinator — 3 states — src/lib/tour-coordinator.ts tour-coordinator 3 states tour-state — 4 states — src/lib/tour-state.ts tour-state 4 states tour-toc-orchestrator — 2 states — src/lib/tour-toc-orchestrator.ts tour-toc-orchestrator 2 states trace-index-state — 4 states — src/lib/trace-index-state.ts trace-index-state 4 states typewriter — 2 states — src/lib/typewriter.ts typewriter 2 states version-check-state — 5 states — src/lib/version-check-state.ts version-check-state 5 states zoom-pan-state — 2 states — src/lib/zoom-pan-state.ts zoom-pan-state 2 states zoom-state — 3 states — src/lib/zoom-state.ts zoom-state 3 states AnalyticsConsentNs — 0 machines — src/app-shared.ts AnalyticsConsentNs 0 machines ContentLinkTooltip — 2 machines — src/app-shared.ts ContentLinkTooltip 2 machines SidebarMask — 0 machines — src/app-shared.ts SidebarMask 0 machines SidebarResize — 3 machines — src/app-shared.ts SidebarResize 3 machines TerminalDots — 1 machine — src/app-shared.ts TerminalDots 1 machine TocTooltip — 3 machines — src/app-shared.ts TocTooltip 3 machines VersionCheck — 1 machine — src/app-shared.ts VersionCheck 1 machine VersionNewsTooltip — 1 machine — src/app-shared.ts VersionNewsTooltip 1 machine

How it works

  1. scripts/extract-state-machines.ts walks src/lib/*.ts with the TypeScript Compiler API and extracts every exported state machine, its state union, and its public methods. It also walks src/app-shared.ts to find every adapter (IIFE module) and which machine factories it references, producing the directed import graph.

  2. scripts/render-state-machine-svg.ts loads the JSON, hands it to elkjs for layered layout, then walks the result and emits a self-contained SVG fragment with data-node-id / data-node-kind / data-edge-from attributes on every element.

  3. scripts/lib/page-renderer.ts sees include: data/state-machines.svg.html in this page's frontmatter and substitutes the file's contents for the literal token State Machine Explorer Interactive diagram of every state machine and adapter that drives this site. 50 machines, 8 adapters, 34 import edges. app-ready app-ready toc-headings-rendered app-ready app-ready toc-headings-rendered toc-animation-done accent-palette-state — 2 states — src/lib/accent-palette-state.ts accent-palette-state 2 states accent-preview-state — 2 states — src/lib/accent-preview-state.ts accent-preview-state 2 states app-readiness-state — 2 states — src/lib/app-readiness-state.ts app-readiness-state 2 states button-tooltip-state — 4 states — src/lib/button-tooltip-state.ts button-tooltip-state 4 states console-font-state — 2 states — src/lib/console-font-state.ts console-font-state 2 states copy-feedback-state — 4 states — src/lib/copy-feedback-state.ts copy-feedback-state 4 states cv-prefetch — 4 states — src/lib/cv-prefetch.ts cv-prefetch 4 states diagram-mode-state — 3 states — src/lib/diagram-mode-state.ts diagram-mode-state 3 states event-bus — 1 state — src/lib/event-bus.ts event-bus 1 state explorer-coordinator — 4 states — src/lib/explorer-coordinator.ts explorer-coordinator 4 states explorer-detail-state — 3 states — src/lib/explorer-detail-state.ts explorer-detail-state 3 states explorer-filter-state — 2 states — src/lib/explorer-filter-state.ts explorer-filter-state 2 states explorer-selection-state — 4 states — src/lib/explorer-selection-state.ts explorer-selection-state 4 states font-size — 3 states — src/lib/font-size.ts font-size 3 states fsm-simulator-state — 2 states — src/lib/fsm-simulator-state.ts fsm-simulator-state 2 states hire-modal-state — 2 states — src/lib/hire-modal-state.ts hire-modal-state 2 states hot-reload-actions — 6 states — src/lib/hot-reload-actions.ts hot-reload-actions 6 states hot-reload-indicator — 6 states — src/lib/hot-reload-indicator.ts hot-reload-indicator 6 states hot-reload-observable — 6 states — src/lib/hot-reload-observable.ts hot-reload-observable 6 states hot-reload-reconnect-state — 2 states — src/lib/hot-reload-reconnect-state.ts hot-reload-reconnect-state 2 states keyboard-nav-state — 2 states — src/lib/keyboard-nav-state.ts keyboard-nav-state 2 states link-prefetch — 4 states — src/lib/link-prefetch.ts link-prefetch 4 states machine-popover-state — 2 states — src/lib/machine-popover-state.ts machine-popover-state 2 states mobile-sidebar-state — 2 states — src/lib/mobile-sidebar-state.ts mobile-sidebar-state 2 states overlay-state — 2 states — src/lib/overlay-state.ts overlay-state 2 states page-load-state — 6 states — src/lib/page-load-state.ts page-load-state 6 states scroll-spy-machine — 2 states — src/lib/scroll-spy-machine.ts scroll-spy-machine 2 states search-ui-state — 2 states — src/lib/search-ui-state.ts search-ui-state 2 states sidebar-resize-state — 2 states — src/lib/sidebar-resize-state.ts sidebar-resize-state 2 states spa-nav-state — 5 states — src/lib/spa-nav-state.ts spa-nav-state 5 states svg-viewport-state — 3 states — src/lib/svg-viewport-state.ts svg-viewport-state 3 states terminal-dots-state — 3 states — src/lib/terminal-dots-state.ts terminal-dots-state 3 states theme-coordinator — 3 states — src/lib/theme-coordinator.ts theme-coordinator 3 states toc-breadcrumb-state — 3 states — src/lib/toc-breadcrumb-state.ts toc-breadcrumb-state 3 states toc-category-state — 2 states — src/lib/toc-category-state.ts toc-category-state 2 states toc-expand-state — 2 states — src/lib/toc-expand-state.ts toc-expand-state 2 states toc-scroll-state — 8 states — src/lib/toc-scroll-state.ts toc-scroll-state 8 states toc-scroll-tooltip-state — 2 states — src/lib/toc-scroll-tooltip-state.ts toc-scroll-tooltip-state 2 states toc-tooltip-state — 4 states — src/lib/toc-tooltip-state.ts toc-tooltip-state 4 states tooltip-state — 4 states — src/lib/tooltip-state.ts tooltip-state 4 states topbar-search-state — 2 states — src/lib/topbar-search-state.ts topbar-search-state 2 states tour-button-demo-state — 5 states — src/lib/tour-button-demo-state.ts tour-button-demo-state 5 states tour-coordinator — 3 states — src/lib/tour-coordinator.ts tour-coordinator 3 states tour-state — 4 states — src/lib/tour-state.ts tour-state 4 states tour-toc-orchestrator — 2 states — src/lib/tour-toc-orchestrator.ts tour-toc-orchestrator 2 states trace-index-state — 4 states — src/lib/trace-index-state.ts trace-index-state 4 states typewriter — 2 states — src/lib/typewriter.ts typewriter 2 states version-check-state — 5 states — src/lib/version-check-state.ts version-check-state 5 states zoom-pan-state — 2 states — src/lib/zoom-pan-state.ts zoom-pan-state 2 states zoom-state — 3 states — src/lib/zoom-state.ts zoom-state 3 states AnalyticsConsentNs — 0 machines — src/app-shared.ts AnalyticsConsentNs 0 machines ContentLinkTooltip — 2 machines — src/app-shared.ts ContentLinkTooltip 2 machines SidebarMask — 0 machines — src/app-shared.ts SidebarMask 0 machines SidebarResize — 3 machines — src/app-shared.ts SidebarResize 3 machines TerminalDots — 1 machine — src/app-shared.ts TerminalDots 1 machine TocTooltip — 3 machines — src/app-shared.ts TocTooltip 3 machines VersionCheck — 1 machine — src/app-shared.ts VersionCheck 1 machine VersionNewsTooltip — 1 machine — src/app-shared.ts VersionNewsTooltip 1 machine above. The SVG ships inside the static HTML.

  4. src/state-machines-explorer.ts runs in the browser, finds the inlined SVG, and attaches interactivity using four pure machines (explorer-selection-state, explorer-filter-state, explorer-detail-state, fsm-simulator-state) plus the existing pan/zoom logic from svg-viewport-state.ts and the modal primitives from machine-popover-state.ts and panel-events.ts. No third-party runtime libraries are loaded — every line of interactivity flows through the same compositional pattern as the rest of the site.

  5. src/lib/fsm-simulator-state.ts is the meta cherry: a state machine that replays other state machines. When you double-click a node, attachSimulator reads the per-node data-node-transitions attribute, hands the transition table to a fresh FsmSimulatorMachine, and on every onStateChange tick toggles .msd-state--active on the current state bubble, .msd-transition-group--available on the green arcs, and rebuilds the event button list. The same machine powers the unit tests under test/unit/fsm-simulator-state.test.ts — there is no DOM code in the machine itself.

⬇ Download