Mundorum

gnō-

gnō- Architecture

gno/ is a client-side application with no build step: two pages, the editor (authoring/index.html) and the standalone player (player/index.html), and the code they share in lib/. There is no bundler and no package.json; the pages load their scripts with plain <script src> tags and also work opened directly from disk. This is a deliberate scope choice, not a placeholder: gno/ is isolated from the rest of the platform (see the root CLAUDE.md) and doesn’t share tooling or code with backend//frontend/ or noid/.

For the narrative format itself (scenes, entities, dialogs, diverts, Player pause rules), see ../README.md. This document covers how the applications that read/write that format are built.

Stack

Concern Choice How it’s loaded
UI framework Vue 3 (Composition-ish createApp with ref/reactive/computed/watch) unpkg.com/vue@3/dist/vue.global.prod.js
Markdown rendering marked cdnjs
Zip read/write (Download / Upload) JSZip cdnjs
YAML read/write (_graph.yaml, _presentation.yaml) js-yaml cdnjs
Icons Tabler Icons webfont jsdelivr
Fonts Lora / Outfit / JetBrains Mono Google Fonts

All libraries are pulled from CDNs via <script>/<link> tags in each page — no local node_modules. This mirrors the “no build step” constraint but is otherwise independent from the CSS design-token system shared with the rest of the platform (--c-* custom properties), which gno/ also follows even though it doesn’t import assets/tokens.css from frontend/.

Files

File What it holds
lib/gno-core.js Plain functions and constants, no Vue and no app state: the browser-save prefix, the language versions and converters, the .gno parser, the entity analyzer, the Markdown renderer, the Player pipeline (beats, stage frames, speech routing, layout, subscene placement), the image-catalog adapter, scenario-SVG build/parse, the persisted-shape sanitizers, the package decoders (readZipPackage, decodePresentationYaml, decodeLayoutYaml) and small helpers both pages need (listSavedNarratives, readSavedNarrative, withSceneBounds, catalogImage, loadCatalog).
lib/gno-player.js The Player as a Vue component, GnoPlayer (<gno-player>): its template, the reader’s place, graphic mode, entity options, the entities panel and full screen.
lib/gno.css The design tokens (--c-*/--font-*, light and dark), base elements, the narrative pills and blocks that the preview and the Player both render, and the Player’s styles.
authoring/index.html The editor: its own styles, the Vue template (topbar, left nav, four views), and one script with what only the editor uses (the demo narrative, the autosave draft, syntax highlighting, the graph layout) and its createApp.
player/index.html The standalone player: the case picker, loading and caching cases, and a <gno-player>.

Each page loads lib/gno.css before its own styles, then the CDN libraries, lib/gno-core.js, lib/gno-player.js and its own script. They are classic scripts, not modules (which wouldn’t load from disk): the top-level declarations of gno-core.js are globals the later scripts use directly; gno-player.js is wrapped in a function and defines only GnoPlayer. Each page registers it with .component('gno-player', GnoPlayer).

The editor’s favicon is an inline SVG data: URI of the app-tile icon from design/icons/gno-icon-tile.svg, and so is the player’s.

There is no component decomposition inside the editor: it is one Vue root instance with template v-if/v-show blocks per view, and the Player is its only component. Given the files’ size, when making changes prefer grep -n for the section comments (each major function is preceded by a comment explaining its why) over reading them top to bottom.

Resizable side panels

Each side panel has a .panel-splitter on its inner edge (the left navigation’s sits absolutely at the left of #main-area). startPanelResize tracks the pointer on window and writes panelWidths (nav, preview — null means half and half with the source —, scenarioSide), clamped by PANEL_LIMITS; double-click resets one. While dragging, #app.resizing turns off the grid transition and pointer events elsewhere. Widths are a per-browser convenience in their own localStorage key (gno-panel-widths), not part of the narrative bundle. The Graph’s scene panel keeps its own older handle (onPanelResizeDown, nodePanelWidth), and the Player’s entities panel is the component’s own (startEntitiesResize, key gno-player-entities-width), so it works the same in the standalone player.

The four views

The editor is one Vue app with a view ref switching between four panels; all four share the same in-memory narrative (source, the raw .gno text) and its derived state.

Editor

Split pane: a plain <textarea> for the raw .gno source, with a read-only <pre> overlay behind it (highlightGno) providing the colored-token syntax highlighting, plus a live preview pane rendered by renderGno (.gno → HTML via marked, with scene headings, diverts, and @entity mentions substituted into styled spans first).

Graph

A node-per-scene diagram. layoutGraphNodes auto-arranges scenes into left-to-right topological columns (BFS from root scenes, orphans handled separately); layoutGraphEdges draws cubic-bezier divert arrows between nodes based on their final rendered position (sceneDiverts: choices, entity diverts and entity options; a subscene divert, ~>, is drawn dotted instead of dashed). Nodes can be dragged anywhere, including above or left of the origin (the canvas and its arrow layer don’t clip, so there is no lower bound); a dragged position, a chosen color, and a free-text annotation are stored per scene title in nodeMeta (title, not id, so the graph survives scene reordering/renumbering). nodeMeta round-trips through the session autosave and the downloadable _graph.yaml, but is not part of named browser-storage saves or the .gno file itself — it’s presentation metadata, not narrative content.

Zoom (wheel or toolbar) is bounded by ZOOM_MIN/ZOOM_MAX (0.05–4) only to keep the view usable; the toolbar’s Fit button (fitView) zooms and pans so every node is in view, which is also how to find nodes dragged far away.

Presentation

Four sub-tabs building the visual/staging layer on top of the narrative, all persisted together as _presentation.yaml:

Player

The Player is the shared component GnoPlayer (lib/gno-player.js), which the editor shows as its fourth view and the standalone player shows alone. It is given one narrative as props: source (the .gno text, which it parses itself), scenarioDesigns, entityAssociations, libraryCatalogs (the fetched catalogs, { id: { status, images } }, read through catalogImage) and entityOptionsMode. The editor binds them to its live state, so the Player follows every edit. active says whether it is on screen (it starts at the start scene when first shown, and only then takes the Space key); bumping restartKey sends the reader back to the start, which the editor does whenever it loads another narrative (resetPlayerProgress). The toolbar’s full-screen button calls requestFullscreen on the component’s root (with the webkit fallbacks), and fullscreenchange keeps isFullscreen in step, including after Esc; it is hidden when the browser has no element full screen. In full screen the template drops the toolbar, the start warning and the scene heading. With a stage, the root gets fs-stage: the stage is centered on black, sized by stageWrapStyle to fit the window but at most min(iw/W, ih/H) times the design’s W×H, iw×ih being the background image’s natural size (loaded once per URL into backgroundSizes), since the background covers the design (slice); never less than the design’s size, and the design’s size when there is no background. The fallback buttons (.player-below) float over the stage, and .player-fs-exit (top right) shows while the pointer moves (pokeFsExit), for touch screens without Esc.

It steps through the narrative as a reader would. buildScenePlayback splits a scene’s body into beats (pause points), per the rules documented in README.md (a lone -- line, or the end of a dialog/dialog-set unless only diverts follow). Alongside beats it tracks which entities are “on stage” — present since first mention, carrying their last-given state, until an explicit @entity => exit or the scene ends — rendered in a separate panel independent of the narrative text itself. It also lists, per beat, the entity diverts on stage (entityDiverts), the entity options on stage (entityOptions; an entity has either a divert or options, the latest line giving one replaces both) and, for carrying, every entity on stage with the states given to it since it entered (stages).

Entity options open one entity at a time in the top frame (playerOpenOptions, keyed by the moment it was opened at, so a move to another beat or scene closes it; playerActiveOptions is the live value). onStageClick toggles them (in hover mode a click only opens), and in hover mode onStageLayerEnter/onStageLayerLeave open them on the entity and keep them open over the options, closing after a short grace. An option with => (carry) makes playerDivert put the entity’s stages entry in the new frame’s carried; buildScenePlayback replays those states before the scene’s first line, so the entity is on stage from the first beat.

The reader’s place is a stack of frames, playerStack ({ sceneId, reveal, carried? }): the scene being played at the bottom, then any subscene opened over it with ~> (playerDivert pushes; a -> divert replaces the whole stack; playerRegress pops a subscene, or steps back a beat at the bottom). Only the top frame advances and takes clicks. playerSceneData holds what doesn’t depend on the beat (the scene’s playback, design and folded stage frames), so advancing doesn’t re-parse; playerFrames adds each frame’s beat. Before the Player starts, the stack is empty and the start scene stands in for it (playerFrameList). A watcher closes subscene frames whose scene was edited away.

Graphic mode plays the same beats on the scenario’s designed SVG (rules in README.md, “Graphic play”). It is on by default when scenarioDesigns has an entry for the scene’s scenario; playerGraphic is only the reader’s preference and playerUseGraphic the effective mode. The stage is not the exported SVG file loaded into the DOM: it is drawn by the Player’s own <svg> from the live scenarioDesigns data (like the Scenarios canvas), so it tracks edits to the design, the associations and the narrative without a round-trip. The pipeline is a chain of pure functions: buildScenePlayback additionally returns per-beat events (entity mentions) and speeches (prose and dialogs, in order) → foldStageFrames replays the events into who is on stage and where, using pickEntityImage (best label match, first on ties); a member mentioned alone splits an on-stage group (splitGroupsOf: each member re-enters with the image the group’s last labels pick for it, at its own earlier anchor or the group’s, and the mention then applies on top) → routeSpeech assigns speech to text areas (by their authored ID; an entity sharing a speech area’s ID, isSpeechRole, is shown only while that area has speech, and both items of an action_* pair follow actionRole) → buildPlayerStage first settles what each item shows at this moment (and so which items are hidden), then runs layoutBoxes so stacks close up around the hidden items, and finally emits drawable layers in the design’s z-order, with action_* items, and entities carrying a divert, turned into click targets ({ type: 'divert', divert } for both kinds of divert). An entity with options gets { type: 'options', … }, and the <owner>.action_N items (actionRole kind option, owner by optionOwnerKey) are shown only for the entity in ctx.openOptions. Entity images come from the live library catalogs (findCatalogImage), not from anything stored in the design, so an entity is drawn only once its catalog has loaded. The Vue template binds the SVG’s viewBox through v-bind="{viewBox: …}" because the template is parsed as HTML, which lowercases a :viewBox name.

playerStage draws every frame into that one <svg>, each in a <g> transformed into its box: the bottom frame fills the stage, a subscene sits where subsceneBox puts it, behind a backdrop rect, and a subscene with no design becomes a text card (<foreignObject>). The place comes from the frame below: buildPlayerStage is told which subscene is open over it (ctx.subscene) and returns, beside its layers, the box of the matching subscene.<scenario> / subscene item (subscenePlaceholders, boxes before entity frames) as laid out by layoutBoxes; it counts as visible then, so stacks make room for it, and is hidden otherwise. Without one, subsceneBox centers the subscene at its design’s size. Each box is in its parent frame’s units, so the transforms compose down the stack. Frames below the top are .stage-inert. Whether the Player is graphic follows the bottom frame’s design; the controls’ fallbacks (playerActionSlots) follow the top frame’s.

Standalone player

player/index.html is a small Vue app around one <gno-player>. It reads the case from the page’s address (openFromLocation): ?id=<name> opens a named save (readSavedNarrative), ?url=<zip>&cache=0|1|2 a zip on the web, and neither shows the picker. The parameters and the cache modes are described for users in README.md, “Standalone player”.

A web case is downloaded with fetch (cache: 'no-cache' for a forced update, so the HTTP cache can’t serve a stale zip) and read with the same readZipPackage the editor uses for an uploaded zip, so it is converted like any zip. The cache keeps the zip’s bytes, base64, in localStorage under gno-player-cache:<absolute url> ({ url, name, size, cachedAt, zip }): keeping the file rather than the decoded package means a cached case is decoded and converted each time, by whatever version the player is then. A zip is cached only after it has been read successfully. Writing can fail when the storage is full; the case still plays, with a notice.

The decoded package goes into the player’s own reactive state (applyBundle: the same sanitizers as the editor’s), its image libraries’ catalogs are fetched with loadCatalog, and restartKey is bumped. Every load takes a sequence number, so the results of a load (or a catalog fetch) overtaken by a newer one are dropped. A case chosen in the picker is opened with history.pushState, carrying { picker: true } in the history state, which is what keeps the Cases button for it (also after a reload); a popstate listener reopens whatever the address names.

Persistence model

Three independent mechanisms share the same underlying bundle shape (narrative source + graph layout + presentation setup):

Mechanism Trigger Shape
Session autosave Debounced (~600ms) on every edit, flushed immediately on tab hide/close One localStorage draft key; restores work after a reload even without an explicit Save
Named save (Save/Load buttons) Explicit user action One JSON blob per name in localStorage, prefix gno-narrative-v2:<name> (see README.md for the older plain-text saves)
Download / Upload Explicit user action A .zip containing manifest.json + <name>.gno + <name>_graph.yaml + <name>_presentation.yaml + one scene/*.svg per scenario design

Named saves and the session draft keep scenario_designs as live data (the same structure buildScenarioSvg renders from) rather than pre-rendered SVG, so the two representations can never drift apart; only the downloadable zip materializes the SVGs, as files meant to be viewed outside the app. Uploading a single .gno/.md/.txt file (not a zip) loads narrative text only and clears graph/presentation state, since there’s nothing else to restore it from.

Language versions and converters

All three carry the gnō language version in a manifest (makeManifest: { format, version, … }): manifest.json in the zip (which also names the zip’s narrative, graph and presentation files), the manifest field of a named save and of the draft. The YAML and SVG files hold no version. The protocol for changing versions is in gno/CLAUDE.md; what changed in each version is in versions.md.

Every way in goes through one path: decode into a package { source, layout, presentation: { image_libraries, entities, extra_entities, player, scenario_designs } } (a zip via readZipPackage, decodeLayoutYaml and decodePresentationYaml; a save or the draft is already one), bring it to GNO_VERSION with upgradeBundle, then applyBundle swaps it into the live state. manifestVersion reads the version, GNO_FIRST_VERSION (1) when there is no manifest. converterChain walks CONVERTERS ({ from, to, bundle, files? }) from that version up; each step’s bundle(pkg) returns { bundle, notes }. A zip’s raw files ({ path: text }) first go through the steps’ optional files stages (upgradeFiles), for versions that change how something is written in the files, so the current decoders can read them. The notes, or an error for a version with no path to the current one (newer, or unknown), become versionNotice, shown until dismissed. The draft is upgraded in loadCurrentDraft, before the app state is built from it.

Converters are pure, and each keeps its own copies of the patterns it matches (convert_1_to_1_1 has its own entity and heading regexes) so that later changes to the parser can’t alter what an old converter does. The parser, the Player and the editor know only the latest version.

Parsing pipeline

source (raw text) flows through a small set of pure functions, each independent and re-run reactively as the user types:

  1. parseGno(source) — splits the text into scenes by # Title: Scenario (\*|\*\*)? headings (sceneMarker turns the marker into start / end), extracting each scene’s body, its choices (* Label -> Target, or ~> for a subscene) and its entity diverts (@door -> Target, matched by ENTITY_DIVERT_RE; lines of a dialog’s text are skipped), and its entity options (OPTION_RE lines right under a standalone entity line, ENTITY_LINE_RE). Choices, entity diverts and entity options are separate lists because action_N numbers the choices only.
  2. analyzeEntities(source) — regex-based detection of the three @entity forms (standalone, dialog-leading, inline), using Unicode letter/number classes so accented ids are matched in full. A standalone occurrence takes the option lines under it as options, its lineEnd covering them.
  3. renderGno(source, scenes, entities) — produces the live preview HTML, substituting scene headings/diverts/entity mentions with styled spans before handing the rest of each line to marked.
  4. highlightGno(source, entities) — tokenizes each line for the editor’s syntax-highlight overlay.
  5. buildScenePlayback(scene, ...) — (Player-only) turns one scene’s body into the beat/pause sequence described above, plus the entity events and speech the graphic mode consumes (foldStageFrames, routeSpeech, buildPlayerStage).

None of these functions depend on Vue; they operate on plain strings/arrays and are called from computed properties inside the app.