Skip to content

Architecture ​

How the engine in src/ is laid out, for whoever works on Arao itself. Deck authors need none of this: the docs are their manual, the Arao skill their agent's guide.

Folders ​

FolderRoleWhat is in it
state/what there isthe deck, its stages, its slides, its theme and the talk's timer: reactive state, made by a create… and read by a use… (the pair shares a provide/inject key private to its file)
composables/effectssmall internal composables, one per file, that tie the state to the browser: the URL, other windows, keys, touch, the mouse, fullscreen
core/the pure howplain modules with no Vue component state: sync, exporter, flip, image, icons, overflow
views/full screenswhat a window shows: the deck's AudienceView, PresenterView and ExportView, and DeckSelectorView, the list of decks createDeckApp shows at /
components/what deck authors writeDeck, Slide, Background, Img, Icon, Snippet, Notes, Agenda; internal/ holds the engine's own components, which no author names: Stage (the scaled canvas), Controls, PresenterBar, Thumbnail (a deck drawn as its cover) and DeckCover (a cover in the list); directives/ holds v-step and v-step-from
addons/drawn over every slideProgressBar, SlideNumber
i18n/the UI's wordsthe engine's own text, one catalogue per language (en.ts, es.ts, de.ts, fr.ts, it.ts, pl.ts, ja.ts, zh-Hans.ts), and i18n.ts, the lookup: t(key, ...values) and lang (Interface language)
env.d.tstypesthe shapes of the virtual modules the Vite plugin gives the engine (virtual:arao/decks, …/images, …/themes…)
styles/CSSonly what is global: tokens.css (every token and its default: the default theme), utilities.css (the utility classes a deck writes, CSS), base.css (the page, the viewport, the steps). Everything else comes with its component (CSS); the themes are not here but in the package's themes/ folder, a theme source (Themes), and the slide layouts in its layouts/ folder (Layouts)

The rule: components/ is what an author names or imports (registered by plugin.ts or exported by index.ts, explicitly, never by folder); components/internal/ is the engine's components that no author names; views/ is full screens.

The engine is strict TypeScript. Each state/ pair names its public face as an interface (DeckFace, SlideControls, TimerControls, ThemeControls), its refs read-only, and keys its provide/inject with an InjectionKey, so a component that injects it gets its type. The package ships .d.ts files for what index.ts exports and for the Vite plugin (dist/types/index.d.ts and vite.d.ts: emitted from tsconfig.build.json, bundled into one file each by scripts/bundle-types.mjs); vite/ and bin/, which Node runs unbuilt, stay JavaScript with JSDoc types, checked by npm run typecheck.

index.ts is the only barrel (the public API); every other module imports the file it uses. plugin.ts is the Vue plugin, app.ts is createDeckApp: it renders the deck the URL's path names (the first segment after Vite's base), or views/DeckSelectorView.vue (a plain page, outside every Deck) when there is no deck to open. It is the one place that reads the path: it puts the URL in its one form first (?deck=x → /x, /X/ → /x, with history.replaceState), and tells the deck which one it is (provideDeckRoute(app, { name, path }), state/deck.ts): its file name and its path as the list writes it. The sync key and the presenter window's URL use that path, not the address bar's, so a project's only deck, which opens at / and stays / there, is one deck with its /<name> windows; the export view reports the name, which the CLI checks. An app of its own (createApp(MyApp).use(Arao)) provides no route: then location.pathname, and no name.

Views ​

Deck.vue makes the deck (createDeck(props)), turns its shortcuts on (useDeckShortcuts(deck)) and shows one view, by the URL. A key runs a command (the engine's map, with the project's src/shortcuts.ts over it, built by the Vite plugin: vite/shortcuts.js); whoever does a command registers it (useShortcuts), and calls the deck directly, as its buttons do: the deck registers the moves, the theme, fullscreen and the presenter window; the controls register menu (their jump list). Typing a slide number and Enter jumps with nothing on screen (useSlideNumber). Touch (the audience view's viewport) moves the deck. Only the audience and presenter views have them. The controls keep Escape (reserved: closes their lists) and the middle tap (their auto-hide).

Deck.vue ── createDeck(props) ── state/deck.ts: stage(s), fullscreen, URL hash, sync
   │  └ useDeckShortcuts(deck) ── composables/useShortcuts.ts: commands, slide number, touch → the deck (audience, presenter)
                                   └ createTheme ── state/theme.ts: the deck's themes, the one it wears, ?theme=
                                   └ createTimer ── state/timer.ts: the timer, the talk's length, and their pure helpers (parseDuration, clock…)
   │
   ├─ thumbnail ───────▶ Thumbnail       Stage (role 'thumbnail', standing at the cover)
   ├─ ?export ─────────▶ ExportView      Stage (role 'export')            → core/exporter.ts book
   ├─ ?presenter ──────▶ PresenterView   PresenterBar
   │                                     Stage (role 'presenter')  + Controls (docked)
   │                                     Stage (role 'preview', one step ahead) + notes
   └─ (default) ───────▶ AudienceView    Stage (role 'audience')   + Controls (auto-hide) + blocked-window notice
                                         cursor auto-hide (its viewport is where the shortcuts read touch)

?export wins over ?presenter. Each Stage (components/internal/Stage.vue) draws the deck's default slot on the scaled canvas, so the presenter view mounts every slide twice. The presenter window listens to no mouse or touch of its own.

Thumbnail mode is not read from the URL: a Deck is a thumbnail when something above it called provideThumbnail({ title }) (state/deck.ts). DeckCover does, once per card of the list, and then renders the deck's .vue file inside it (lazily, when the card nears the viewport). The deck reads nothing of the URL (its theme is the first of its list, resolved as any deck's: default when it names no theme), its stage is a follower that stands at slide 1, step 1, and it skips every effect: no hash route, no sync, no keys, no presenter window, no duration or themes warning; its face's actions are the preview's no-ops. Its slides other than the cover register (so the order is known) but draw no content (drawn, state/slide.ts), so a card mounts one slide's pictures and snippets, not the deck's. The deck fills title with its cover's first heading (else its title prop), which the card shows under the deck's title (its file name in words).

Interface language ​

Every word the engine itself shows (titles, aria-labels, placeholders, the toast, the presenter view, the list of decks, the notes pages' heads and step labels) comes from t(key, ...values) (i18n/i18n.ts), never from a literal in a component. The language is picked once, when the module loads, from navigator.languages: the first with a catalogue (matched by its language subtag; Chinese by its script, so zh-CN is zh-Hans and zh-TW is skipped), else English. No option, no switcher, no reactivity. A catalogue is a plain object: a string per key, or a function of the message's values (word order and plurals are the language's own). English (en.ts) is the reference: a key missing elsewhere would fall back to it unseen, so the library build fails when a catalogue lacks one of its keys, has one it has not, or has a string where it has a function (vite.config.js, catalogueError); the types say the same: every catalogue satisfies Catalogue, the type of en.ts, and t() takes only its keys, with the values each message takes. The engine's UI says its language (lang on the controls, the presenter view, the toast, the list of decks), and gives back the page's (document.documentElement.lang) to what is the deck's inside it: the slides, the notes, the titles. The notes pages' step labels are CSS (content): ExportView sets the message's parts before and after the number as private custom properties (--_ar-from-step-before…).

Provide / inject channels ​

ChannelProvided byRead byCarries
deckcreateDeck (in Deck)useDeck()the public face (below), never the internals
themecreateTheme (in createDeck)useTheme() (the controls: the themes list, "t")the deck's themes, the one it wears, setTheme, cycle
timercreateTimer (in createDeck)useTimer() (the presenter's bar)the timer and the talk's length, with what changes them: start, pause, toggle, reset, setDuration
thumbnailprovideThumbnail (in DeckCover)createDeckthat the deck inside is a thumbnail, and the ref its cover's title goes in
routeprovideDeckRoute (createDeckApp, on the app)createDeck (not in a thumbnail)the deck's file name and path: the sync key, the presenter window's URL, the name the export reports
stageprovideStage (in the Stage part)useStage(): createSlide, and useDeck() (which merges the stage's position into the face)the stage a component is drawn in
slidecreateSlide (in Slide)useSlide(), useSlideForNotes() (Notes), useSlideLayer() (Background)the slide's step, its step registry, its background layer (a Teleport target)
notesuseNotesOutlet (presenter view, export)useNotesTarget() (Notes)where the Notes of the slide on screen draw themselves (a Teleport target)
footerprovideFooter (in Deck)createSlidethe Deck's #footer slot, drawn by every slide

Nothing else is provided. The views get the deck's internals from Deck as a prop (deck), and pass what their parts need as props (the controls' docked/auto-hide, the bar's title). The controls read the slides' titles (useDeck().titles()) and the themes (useTheme()) themselves; which list is open and what is typed in it are their own. No view exposes anything, and Deck holds no ref to its view. v-step finds its slide through the DOM (data-ar-slide, a map in directives/step.ts).

Composables ​

ComposableEffect
useDeckSync(stage, …)every window of the deck in step through core/sync.ts: position, theme, timer, the duration set in the presenter view (the last two kept through a reload)
usePresenterWindow()opens the presenter window or brings it forward; blocked when the browser blocks it
useShortcuts({ command: fn })the shortcuts' registry: one key map (the engine's defaults with the project's src/shortcuts.ts laid over them, checked and built by the Vite plugin when it starts: vite/shortcuts.js, rules in vite/shortcut-rules.js; read by core/shortcuts.ts), one listener on the window, one owner per command (registering a command twice throws). Each caller registers the commands it does: Deck the moves, Controls menu
useDeckShortcuts(deck)called by Deck.vue (audience and presenter only): registers next, prev, first, last, theme, fullscreen, presenter (not in the presenter view) on the deck's own functions, turns on useSlideNumber, and in the audience view reads edge taps and swipes
useSlideNumber({ go, total })digits (by key or by code), then Enter, jump to that slide with nothing on screen; Backspace deletes a digit; Esc, another key or 2 s clear; the digits and Esc are reserved keys
useKeyboard(handlers)key → handler on the window (VueUse onKeyStroke), with the rules every key of the deck keeps: keys inside a text field or an element marked data-ar-own-keys (the presenter's duration editor) are left to it, so are Ctrl/Cmd/Alt + key, a focused button keeps Space and Enter. Its rules (forDeck) are shared by useShortcuts and useSlideNumber; Controls uses it for Escape
useTouchGestures(el, { tap, swipe })taps, by zone (left quarter, right quarter, middle), and swipes, from pointer events: touch and pen (VueUse's useSwipe reads touch events only, so the pen would lose its swipes). Used by useShortcuts (edges, swipes) and useAutoHide (the middle)
useAutoHide({ after, tap })visible: shown on a mouse move, hidden after after ms without one; optionally a tap in the middle shows it for tap ms or hides it; ignores a tap's echo mousemove. The controls' auto-hide and the audience view's cursor (VueUse's useIdle counts keys too, with a fixed timeout and no tap)
useFullscreen(el)fullscreen is true while anything in the window is fullscreen; toggle() leaves it if so, else makes the element fullscreen; the standard API only (VueUse's useFullscreen counts only its own element and falls back to prefixed APIs)
useOverflow({ el, active, step, … })called by Slide.vue, for the slide on screen: Slide.fit (core/overflow.ts fitSlide) at once when it arrives, at each step, theme or render, on the next frame when a box resizes, a font loads or the window changes, and once more when its animations stop; in development, in the audience's window, a console warning when what it shows does not fit (measureSlide), once per slide, step and overflow. Nothing at all, observers included, for a slide off screen, nor in a production build for one without .fit. The export measures each page itself (core/exporter.ts)

VueUse (@vueuse/core, a dependency, external in the build, prebundled by the Vite plugin) also gives useEventListener, which every composable here listens with.

useDeck() ​

What any component inside a Deck gets. The position is that of the stage the caller is drawn in; outside every stage (the controls, the presenter's bar) it is the deck's own stage.

FieldKind
index, step, total, steps, progressread-only refs, of the caller's stage
rolestring: 'audience', 'presenter', 'preview', 'export' or 'thumbnail'
theme, themes, fullscreen, timerread-only refs, deeply (themes.value, timer.value cannot be edited in place)
durationcomputed: the talk's length in effect, in ms, or null (the presenter's, else Deck(duration))
next(), prev(), go(i, step)moves
titles()every slide's title, in order ('' for one without): the controls' jump list
setTheme(name), toggleFullscreen(), openPresenter()actions; setTheme with a name not in themes warns and is ignored

The face, and each stage's copy of it, is frozen: no component can reassign go, setTheme or any other field. Internals stay off it: slide registration, sync, the export, and what changes the timer and the length (useTimer(), state/timer.ts: the presenter's bar uses it; not exported), and cycling the theme (useTheme(), state/theme.ts: the controls use it; not exported). Frozen, Vue leaves it as it is inside reactive() or data(): its refs are not unwrapped there.

One rule for the preview (role 'preview', the presenter view's next step), and for a thumbnail (role 'thumbnail'): it is a copy, it cannot act. Every function of its face does nothing: next, prev, go (the stage is a follower, state/stage.ts) and setTheme, toggleFullscreen, openPresenter (useDeck() swaps them for no-ops, state/deck.ts). Its refs still read: its own position, the deck's theme, timer, duration and fullscreen.

CSS ​

Every component carries its own CSS, in the <style> block of its .vue file: Img, Icon, Snippet, Slide (its zones, its footer, the slide's content), Background, the addons, the views and their parts. The slide layouts are not components' CSS: each is a file of its own (Layouts). Not scoped: a theme or a deck must be able to override any of it, so the selectors are the ar- classes at the specificity they always had (zero, with :where(), where a deck's own rule must win); they are hooks for that, not classes a deck writes. Notes has none: its content is drawn, and styled, where it is teleported (the presenter's notes panel, PresenterView; the export's notes pages, ExportView).

The classes a deck does write are the utility classes, one file: styles/utilities.css. They are the second level of a slide's layout: its structure is its layout's (a CSS file of layouts/), and inside one block (the body, a side of split, a block of grid, a zone) these arrange and mark things (.cols, .row, .stack, .middle, .gap-sm, .grow, .text-lg, .accent, .highlight…), every value a token, so a theme restyles them; the classes of a Slide itself (.top, .middle, .center, .bottom, .no-footer, .with-footer) are there too. No JavaScript: uneven tracks are a custom property the deck sets in the element's style (--ar-cols, --ar-rows), registered with @property as not inherited, so columns inside columns start equal again. Placement, alignment and spacing are .ar-slide .<class>, below a layout's rule for its own blocks and below v-step.collapse's display: none !important; the look (sizes, colours, the marker) is !important, so that it wins over a layout's or a theme's rule on the same element. Each group of classes is a /** … */ doc comment in the file, @class <name> <description> per class: vite/class-docs.js reads them for arao layouts (which prints and lists them after the layouts: the package ships the file for it), and the library build fails if a class a rule names is not documented, or a documented one is in no rule (vite.config.js, utilityDocs).

styles/ keeps what no component owns: tokens.css, utilities.css and base.css. tokens.css declares every token the engine reads, with its default, and nowhere else is a default written: no component holds a literal colour, font, font size, radius, shadow or duration (its header gives the rule for what stays literal: structural values, proportions of a token, weights, a part's inner geometry). The defaults sit at the root with zero specificity (:where(:root)), so they reach what is drawn outside every theme (the presenter view, its notes, the deck list) and any rule of the project's wins over them; an element that shows a theme apart from the one around it (a swatch of the theme picker) carries data-ar-theme-root and takes the slide's colours as the root has them (the defaults with the project's :root rules: private --_ar-root-… copies, resolved at the root), not the theme it sits in. A token whose default is another token cannot sit at the root (var() is resolved where it is declared: the root's --ar-muted would stick to --ar-footer-color whatever the theme), so its default is resolved on every element (:where(*)) into a private --_ar-… that the components read: the footer colour, the table's border and head colour, the code highlight, the controls' accent (with a block of its own for the docked controls, whose default is their text colour), the slide title's size, colour and gap (one each for an h1 and an h2 title, and for the gap under a header band). base.css holds the page (html, body, #app), the viewport the audience and export views share, and the classes v-step sets.

The library build concatenates it all into dist/arao.css in import order, and order decides between two rules of the same specificity on the same element. plugin.ts imports in that order and its header says why: tokens.css; the views (through Deck); Snippet, Img (with Background), Slide, Icon, Notes, Agenda, then utilities.css: Img before the utility classes (the children of their columns clip overflow-x); base.css last (its step fade wins over Snippet's own transitions); the library build fails if dist/arao.css loses two of them (the overflow-x of an Img in a column of the utility classes, the step fade): vite.config.js, CSS_ORDER. index.ts then adds the addons, app.ts the deck selector, then the layouts (virtual:arao/layout-styles) and last the themes (virtual:arao/theme-styles), after all of the engine's CSS, so that a layout's rule wins over an engine rule of the same specificity and a theme's over both; the library build fails if those two imports are not the entry's last two, in that order, after ./arao.css (vite.config.js, themeStylesError).

Layouts ​

Slide has one prop, layout, and no code for any layout: its section carries the class layout-<name>, and it renders every slide the same way (the background layer, the header and the body it finds in its default slot, a zone .ar-zone-<name> per named slot, the footer). The rest is CSS: one file per layout, named as it. The library's are its layouts/ folder, at the package's root (cover, section, split, grid, quote, statement, overlay, caption, image-left, image-right); the project's are the plugin's layouts folder (default src/layouts). The Vite plugin loads both through virtual:arao/layout-styles (an eager glob of the library's files, all but those a project file of the same name replaces, then one of the project's folder); when a project file starts or stops replacing a library one in the dev server, the module is reloaded with the page. A layout's tokens are its parameters: each --ar-layout-<name>-<thing> its file declares or reads is an attribute <thing> of its slides, which Slide sets as that token in the section's style instead of an attribute, from virtual:arao/layout-tokens (by layout, its parameters); one rule, vite/layout-params.js, says what a parameter is (none whose name a slide already has an attribute for: HTML's global ones, Vue's, layout), for the plugin and the library's build alike. The names and parameters are types too: Slide is exported typed generic in its layout (SlideComponent, Slide.vue), its layout a key of SlideLayouts and its other attributes that layout's parameters; SlideLayouts is the library's (LibraryLayouts, generated from layouts/ by scripts/layout-types.mjs when the library is built; CI fails if the committed file is not what it writes) with the project's over them (ProjectLayouts), which the plugin augments in a declaration file it writes into the project (src/arao-layouts.d.ts, rewritten as layout files and their tokens change). A file starts with a doc block saying what the layout is for, an example, its zones (@zone) and its parameters (@param, which only describes a token the CSS reads, and may list the values it takes, {a|b|0..1}, which its type becomes and Slide checks in development); vite/layout-docs.js alone reads it (and the zones: those @zone names, then any .ar-zone-<name> the CSS styles), for the types and for arao layouts, which asks the plugin (api.layouts(), as arao export asks it for the decks: bin/project.js loads the project's config). The types carry it: each layout's entry and its layout member hold its doc (the member is what an editor shows on hovering layout="…": a string literal has no doc of its own), its parameters and zones hold theirs, and the zones are typed too (LibraryLayoutZones with ProjectLayoutZones over them: SlideLayoutZones), so Slide's slots are its layout's: default, #title and its zones (those of any of them where the layout may be one of several), through a mapped type that keeps each zone's doc. The library build stops on a library layout that is not documented in full. Their defaults are other tokens (--ar-accent, --ar-title), so, as in tokens.css, they cannot sit at the root; each file resolves them on its own slides (:where(.layout-<name>)) into private --_ar-… properties its rules read, and a theme, the project's :root or one slide sets the public ones. What every layout shares is the engine's: where the body sits (--ar-body-align, the classes top, center, bottom), and the footer's classes no-footer and with-footer, which win over a layout's own footer token. The slide's bottom padding is always at least the footer's band (max(var(--ar-pad-y), var(--ar-footer-height))), footer or not, so nothing needs to know whether the footer shows. A slide's background is a component, Background, which renders a hidden element where it is written (what v-step applies to) and teleports what it draws into the slide's background layer (useSlideLayer()), where a CSS rule hides the theme's default background behind it; the drawn layer follows the step classes of that element and of the elements around it, and stacks in their document order.

Themes ​

Every theme is a CSS file directly in the folder of a theme source: the library's own themes/ folder, at the package's root, one file per theme named as it (default, whose rule is empty, the defaults in tokens.css being its look, always loaded; the plugin stops if there is no default.css; and the built-in themes, those the builtinThemes option names, all by default), and the plugin's themes option, the project's (folders and installed packages, in order; default src/themes). default sets no token on purpose: the defaults sit at the root with zero specificity so that a project's own :root rule wins over them, which a theme's rule, applied on the element that wears it, would not let it do. The Vite plugin turns the sources into two virtual modules: virtual:arao/theme-styles imports them all, source after source (an eager glob per folder: Vite follows files added or removed; for the library's folder, a glob of the built-in files to load, {default,folio}.css), and virtual:arao/themes exports the names their [data-theme="<name>"] selectors give, sorted (the plugin reads the files and the local partials they @import, skips selectors inside :not(…), resolves CSS escapes and warns about names with white space; when an edit changes those names in the dev server, it reloads the module and the page), default first, then the project's sources, then the built-in themes, each name once (a name a later project source gives again warns: both apply, at equal specificity the later wins). A built-in theme a project source names too is not loaded at all: the project's replaces it, one owner per name (the plugin says so). What the built-in files to load are, and the names, are read again on every change of a theme file in the dev server; when either changes, both modules are reloaded with the page. A package source is resolved at config time (node_modules, from the root up, else Node's resolution; its themes/ folder or the one inside it that its package.json names under "arao"), to its real path, and one not installed or giving no theme stops Vite. A built-in theme left out (builtinThemes) or replaced is in no module: neither its CSS nor, so, the fonts it names reach the build (fontless only sees the CSS imported). state/theme.ts resolves a deck's list: Deck(:themes) without the names that are no theme (one warning; a list left with none is the first theme there is, default), or, without it, every theme the sources give, in the plugin's order: it names no theme itself. Nothing is read from the page's stylesheets: a name the plugin does not know is no theme, and the export view, which checks --theme against the same list, refuses it. The built-in themes are no export of the package: a project names them, it never imports them. The deck selector, like the presenter view, sits in no theme: it reads its --ar-selector-* tokens at the root, and each cover wears its deck's theme.

Web fonts are the Vite plugin's too (vite/fonts.js): it includes fontless, which reads the families in the CSS the project loads (font-family, and the --ar-font-* tokens through processCSSVariables: 'ar-font'), fetches the ones that are not system fonts from the providers at build time, and writes them and their @font-face (with metric fallbacks) into the build. The engine itself knows nothing of it: a theme's tokens name families, and the CSS does the rest. The defaults' tokens too: tokens.css names Gelasio (Georgia's metrics; Georgia, a system font, no provider serves), so every build fetches it.