---
title: "Time, motion, graphics, and platform facts"
description: "Timers, CSS transitions and animations, springs, scroll-driven motion, SVG and pointer drawing, gestures and menus, and the platform facts in exactViewport and exactPage."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Time, motion, graphics, and platform facts

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/learn/contract-for-agents/time-motion-graphics-and-platform-facts: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

Desktop stills use `@exact/screen-capture`. On macOS, pass the `ScreenDetailed` from
window management as `screen` and optionally a display-local CSS `rect`, or
pass the session handle from `getWindowAtPoint` or `getFrontmostWindow` as
`window`. The window still carries the frame for mapping clicks. Use
`cursor="always"` to draw the pointer. See the [guide-step recipe](https://exact.expo.dev/recipes/screen-capture.md).

`clip-path` clips a box and its contents. Use `polygon(0% 25%, 100% 0%, 50% 100%)`
for an outline that follows the box's size, or `inset(4px round 8px)` for an
inset with rounded corners. Coordinates and radii take `px`, `%`, or unitless
zero. Insets take one to four edges; `round` takes one to four radii and an
optional `/` followed by vertical radii. `circle()` and `ellipse()` take lengths
or `closest-side`/`farthest-side`, with an optional `at` position (one or two
lengths or position keywords). The default reference is the border box, or the
fill box on a web SVG element. Percentages follow its current size; a circle's
percentage radius uses its diagonal divided by √2. `polygon(evenodd, …)` uses
the even-odd fill rule. `path('…')` accepts SVG path data in fixed CSS pixels;
`url(#id)` references a `clipPath` on an SVG element. Other reference boxes,
calculations, relative length units and three/four-value positions are refused.
Basic shapes on SVG children (including groups, text and nested `svg`) are
web-only; a build targeting native hosts refuses a known basic-shape value.
Computed `url(#id)`, `path()` and `none` remain supported. A computed basic
shape on native SVG is ignored with a host note. Use a basic shape on a
surrounding box, or a `url(#id)` clip on the SVG element in `userSpaceOnUse`
coordinates without percentages instead.
See [CSS Masking 1 §5](https://www.w3.org/TR/css-masking-1/#the-clip-path).

A task has one `every(ms, action)`, `after(ms, action)`,
`every(frame, action)`, or keyed `change(action)` entry, on the line under it:

```text
  task ticker mount
    every(1000, tick)
```
 The action is parameterless. Millisecond intervals
are whole-number literals of at least 1. The frame form has no delta-time argument and does not
catch up missed display frames. For deterministic tests, use the driver's clock.
The clock moves in advances, and one advance runs at most 4,096 timer actions
and `then`s (`TIMER_FIRE_LIMIT`), those that change nothing included; the rest is
refused, what committed is kept, and the clock stays at the last one's time. A
fast `every` under a long `clock +N` can reach it: tick slower or move the clock in steps.
A firing whose action changes nothing commits nothing: it wrote no state a new value, and
sent, refreshed and commanded nothing. Where a binding, derive, or a resource's argument,
`when` or `for … in` list reads `performanceNow()`, every firing commits and shows the time.

Use `change(action)` for work that must follow an input change, such as reading
layout or issuing a host command:

```text
  task reveal when visible key=selectedId
    change(reveal)
```

`key=` is required. The action runs once after the first committed state with an
open gate, then once after each changed key or reopened gate. It runs in a separate
commit after the host has applied the preceding commit, with no elapsed-time wait.
Pending key changes coalesce: the action reads the latest committed state. Closing
the gate cancels pending work. A refused action is spent until its key changes or
its gate reopens; a refused input commit queues nothing. On the agent's clock,
`clock settle` runs this work without advancing time. A reload starts fresh.
The compiler rejects an action that can write or refresh its own trigger's inputs,
including through derives, resource arguments, called actions, mutations or other
change tasks (`analyze-change-cycle`). Keep pure computed values in `derive`.
`change` takes no timer options; existing `after` and `every` schedules keep their
elapsed-time behavior.

On Android, these tasks can run while the activity is in the background and its
process can execute; they need no drawn frame. `every(frame, …)` pauses there.
Timers do not keep the process alive or bypass Android's
[Doze and App Standby](https://developer.android.com/training/monitoring-device-state/doze-standby)
restrictions. Use the background packages for work the system schedules;
an in-process poll cannot guarantee a timely alert while the app is suspended.

A task with `when` (a gated task), such as
`task hide when toast != "" key=toastUntil` with `after(5000, expire)`, has its
timer only while the gate holds, as an `if` arm has its nodes, and a new key
restarts it, as a new `for` key makes a new row
(LLP 1092). Nothing
runs when the gate changes: turning true arms the timer from that commit's time,
turning false drops it, and an idle task keeps no host awake and commits
nothing at rest. `key=expr` alone means `when true key=expr`. An `after` fires
at its deadline, its action seeing `performanceNow()` equal to it under a test's or the agent's
clock and no earlier on a device: clear without re-testing the time (a strict
`performanceNow() > until` can do nothing there). A repeat that missed ticks while the app was
suspended fires once on a device, so measure time with `performanceNow()`, never by ticks. The
gate is a bool and the key a string, number or bool; neither may read `performanceNow()`
(`analyze-task-gate-clock`): gate on state and let the timer measure time. A
toast, a debounce (`when draft != saved key=draft` with `after(800, save)`), a
round's tick (`when screen == "play"`), a flight's frames
(`when flying` with `every(frame, step)`) and a sheet's opening
(`when top(nav).name == "icons" key=top(nav).id` with `change(reveal)`) are each
one gated task. A child at a bounded use may declare the same forms: each instance
starts its tasks when it mounts and their gates hold, and stops them when a gate
fails or the instance is destroyed. Actions run in that instance's frame. A
covered screen or hidden tab can stay alive, so pass its activity as a prop and
gate work on it; visibility alone grants no permission. Each instance of an
`every(frame, …)` task runs an action per frame while armed. Reload carries
compatible state and restarts timers, as it does for root tasks.
On the deterministic clock, equal-deadline tasks run in declaration order;
instances of one declaration run in creation order. A gate or key change keeps
that order; destroying and recreating an instance gives it a new place.

**Retry backoff.** For a bounded ladder of delays, use one gated task per step.
Only the active step has a timer, which wakes once at its deadline:

```text
  state waiting = false
  state attempt = 1
  task retry1 when waiting and attempt == 1
    after(250, again)
  task retry2 when waiting and attempt == 2
    after(500, again)
  task retry3 when waiting and attempt >= 3
    after(1000, again)
```

Have `again` clear `waiting` and send the request. On failure, increment `attempt`
and set `waiting` again; reset `attempt` to 1 on success. A new attempt then arms
its step's timer. If the step stays active between retries, use `key=attempt` to
restart its timer. Computed intervals remain refused. A wait that must track a
continuous value can use a gated `every(frame, check)` and compare
`performanceNow()` with its deadline; see "Following the transport" for tempo.

**Repeating while a condition holds.** Use a task with `when` and `every`. The
timer runs only while the condition is true. Any action that makes it false
stops the timer.

```text
  state pulsing = false
  state dim = false
  task pulse when pulsing
    every(1200, step)
  action step
    if dim
      dim = false
    else
      if busy
        dim = true
      else
        pulsing = false
```

The first `step` runs one interval after the condition turns true. Do not build
a loop from mutations: a `then` cannot send its own mutation
(`analyze-then-self-send`). For a purely visual loop, use a CSS `animation`
instead.

`performanceNow()` is the runner's clock in milliseconds since this launch of the app (it
restarts at 0 on every launch, and a window opened later reads the same clock; the driver's clock under the agent, from 0), as the web's
`performance.now()`, not a date: a deadline of `performanceNow() + ms` sent to a server is
in 1970, and one stored is meaningless after a relaunch. Anything stored or sent takes
`time.epochAtZero + performanceNow()` ([timer recipe](https://exact.expo.dev/recipes/timer-that-survives-relaunch.md)). For the date, read the reserved
`exactTime` source and add `time.epochAtZero + performanceNow()`. There is no
`now()`: it is refused (`type-now-renamed`) with those two repairs. Its fields, which a shape declares as it reads them:
`epochAtZero` (Unix milliseconds when `performanceNow()` read zero), `utcOffset` (minutes east
of UTC), `locale` (BCP 47, the first preferred language), `formatLocale` (BCP 47, the
regional format the platform's own formatters use: macOS and iOS's Region, so English
with a Korean region is `en-US` and `en-KR`, with the hour cycle the user forces as
`-u-hc-h23` or `-u-hc-h12`, so `Intl.DateTimeFormat(time.formatLocale)` writes the time in
the device's 12- or 24-hour cycle; Android's locale with that hour cycle; `locale` where a host keeps none apart),
`timeZone` (IANA), `resolvedLocale` (the language of
the string table the app shows, `""` with no tables) and `seed` (a whole number
below 2^32, drawn once per launch, so `%` and `>>> 0` take all of it; mix a round
into it in 32-bit steps, as the [random recipe](https://exact.expo.dev/recipes/random-and-shuffle.md) does). A read does not itself schedule a future render, and a
derive that reads `performanceNow()` is not read again as time passes, and when it is read
again differs by host. For a displayed value that must follow the clock, keep the
time in state that a timer's action (`task … every`) writes. Prefer `clock settle` to waiting for a transition in real time.
`time.utcOffset` is the zone's offset *now*: every host answers it again when the
offset at the clock's instant changes (a DST change, a new zone), checked before a
timer fires, so a midnight timer after the clocks change reads the new offset.
Under the agent it is the drive's zone at the virtual date, checked after each
`clock` (the JS target also before each timer inside one). It is not the offset
of an arbitrary timestamp: to show a past or future instant across a DST change
in the viewer's zone, format it in TypeScript with
`new Intl.DateTimeFormat(time.locale, { timeZone: time.timeZone })`.

Use admitted CSS transitions and keyframes. Check which properties animate and
which require optional capabilities. `-exact-spring(…)` (a `transition` timing
function), `-exact-exit-animation`, `-exact-layout-transition`, and presentation timelines have
specific documented behavior;
they do not admit arbitrary frame callbacks or a second app-state graph.

A native list (`list appearance="auto"`) applies a change at once, as UIKit
does, unless a row carries a layout transition or an exit animation. Then a
change in which rows it holds, or in their order, animates on iOS: rows slide
to their new places and rows that come or go fade, with UIKit's own timing,
not the written duration. Its first rows, a restyle and a list out of a window
still apply at once.

macOS and iOS play eligible box `translate`, `scale`, `rotate` and `opacity`
animations and transitions in Core Animation. A transform stays sampled when
the box takes input, contains an interactive view, uses a noncentral origin,
is sticky or has a layout transition. Filtered pictures also need sampling.
Mounting an interactive descendant returns a running transform to sampling.
On macOS, a box with `backdrop-filter` keeps its transform sampled so the
blur's sampling region follows it. Rounded background colours stay sampled
because AppKit can paint their fill on a separate layer or into an image.
The agent's clock still seeks these animations; taking the clock returns
transitions to the engine.

As in CSS, a `transition` or `animation` value's units, keywords and function
names read in any ASCII case (`0.3S EASE` is `0.3s ease`), its numbers are CSS's
(`1.s` and `infs` are no times), and a keyframes name keeps its case: in
`animation="Spin 1s EASE"` the name is `Spin` and `EASE` is the easing.

A `rotate` keyframe accepts the node's rotation syntax: an angle (degrees when
unitless), optionally with `x`, `y`, `z`, or a three-number axis. For example,
`to rotate="-90deg x"` folds a card edge-on. An angle-only keyframe uses the
node's declared axis, so `to rotate=-90` on `rotate="0deg x"` also folds about X.
An explicit keyframe axis overrides the node's; differing axes interpolate by
spherical interpolation, while a common axis preserves full turns. SVG elements
and route-transition pictures refuse spatial keyframes because their native
transforms are 2D; animate a surrounding box or a box inside the route instead.

In a virtualized list, `-exact-animation-trigger="view"` (the default) holds a
prefetched row's animations until the row first overlaps its list's port.
`"none"` starts them on insertion. Reveal preserves authored pauses; leaving
and returning to the port replays only if the row was retired and mounted again.

## Motion that follows a scroll

A value that follows a scroller is a scroll-driven animation, CSS's own, not a `scroll` action
that writes state (that runs a round trip behind the scroll):

```contract
keyframes follow
  to translate="-1000px 0px"
keyframes fade
  from opacity=0
  to opacity=1

component App
  view
    column timeline-scope="--cols"
      row overflow="hidden" width="12rem"
        row flex-shrink=0 animation="follow 1s linear both" animation-timeline="--cols" animation-range="0px 1000px"
          text "Names"
      row overflow-x="auto" width="12rem" scroll-timeline="--cols x"
        text "Columns"
      column overflow-y="auto" height=300
        for i in range(20) key=i
          view height=60 flex-shrink=0 animation="fade 1s linear both" animation-timeline="view()" animation-range="entry"
```

- **Timelines:** `scroll-timeline` (or `-name` and `-axis`) on a scroller is its offset;
  `view-timeline` (`-name`, `-axis`, `-inset`) on any node is that node crossing its nearest
  scroller. `animation-timeline` names one, or is `scroll()`, `view()`, or `none` (detached,
  so the animation never advances on the clock); a sibling's name needs `timeline-scope` on a
  shared ancestor. One timeline per node and kind.
- **Ranges:** `animation-range` takes lengths and percentages of the timeline, and on a view
  timeline `cover`, `contain`, `entry`, `exit`, `entry-crossing` and `exit-crossing`, each
  with an optional length or percentage.
- **Paint rows only:** keyframes under a timeline animate opacity, transforms, colours and
  `box-shadow`. Every host moves them in the scroll's own frame; the web leaves them to the
  browser, and a browser without scroll-driven animations shows the nodes' own values.

Transform springs retain velocity when interrupted. An SVG path's `d` instead
plays the spring as an easing curve: retargeting starts from the displayed path
with no inherited velocity, including when toggling back (LLP 1055.000 D15,
LLP 1062 D3). This is the same on the web and native hosts. Use a transform for
a rigid path move that must keep its momentum.

To seed a translate spring from an authored pan, write
`-exact-translate-velocity=` followed by a string such as `"800 -600"`: finite x and y
velocities in logical CSS pixels per second. In `panrelease(vx, vy)`, clamp or adjust
each axis, then update this row and the translate target in the same action.
`"0 0"` starts from rest, including on cancellation; omission or Contract `none`
(without quotes) preserves an interrupted spring's velocity. For example, bind
``-exact-translate-velocity=(released ? `${vx} ${vy}` : none)``. Changing only velocity
never restarts motion. Enabling a translate spring after `transition="none"` can
start from nonzero velocity even when the endpoint equals the current position.
The row persists: clear it when a new drag begins or before an unrelated target
change that should inherit velocity. It has no effect on an easing transition or
with `transition="none"`.

Computed animation longhands cannot accompany a literal list in `animation` or
another longhand. For a list that changes with state, compute the complete `animation`
shorthand, including each animation's play state or duration.

On iOS and iPadOS, a touch pinch reports its scale and viewport midpoint
alongside a scroll. Use `pinchrelease` to [change a grid’s columns](https://exact.expo.dev/learn/contract-for-agents/time-motion-graphics-and-platform-facts.md#changing-a-grids-columns)
when either finger lifts; keep buttons (and `wheel` with `ctrlKey` on desktop)
for hosts where `pinchrelease` is silent.

For drawing and pointer-tracking, `pointerdown`, `pointermove` and `pointerup`
hand an action that takes it a `PointerEvent` (`offsetX`/`offsetY` from the
node's content box, `button` and `buttons`, `pressure`, `pointerType`,
`pointerId`, and `clientX`/`clientY` from the viewport, `frame()`'s space), on
any node, a canvas included; set `touch-action="none"` on a drawing surface.
The web browser fixes `touch-action` when the touch starts. On iOS, the host
reads it when UIKit asks whether the pan may begin, so a write in that touch's
`pointerdown` applies there. For the same behavior on every host, set `none` before the
touch starts (LLP 1057.001).
Any button goes down, numbered as the DOM's: `button` 0 primary, 1 middle, 2
secondary, 3 back, 4 forward (-1 on a move), `buttons` bits 1, 4, 2, 8, 16. A
`contextmenu` action may take the same record, where the click was. The back
and forward buttons go Back and Forward at their release, as a browser's do,
unless a `pointerup` handler calls `preventDefault()`. `wheel` hands a `WheelEvent` (deltas,
modifiers; a trackpad pinch is a Control-held wheel) and `preventDefault()` keeps
the scroll from happening; `drop` hands a `DragEvent` whose `files` are `doc:`
handles of any type, a folder's included, with the drag's `text` and `url`,
and takes a file drag over a field inside its node (a dropped file is lent:
copy an attachment the app keeps, [taking a drop](https://exact.expo.dev/recipes/drag-in.md)); an app can show a drop
overlay at `dragenter`, which the `drop` action clears when the drop lands
and `dragleave` clears otherwise, and `dragover` tells a node where the drag is, at most once a frame, to draw where a
drop would land (it decides nothing); a `paste`'s `ClipboardEvent` carries `files` too. See
[Pointer](https://exact.expo.dev/reference/contract-grammar/events.md#pointer) and [Clipboard](https://exact.expo.dev/reference/contract-grammar/events.md#clipboard).
A Paste button can send a mutation that calls `@exact/clipboard`'s `readText()` with the
`clipboard.read` grant. To insert the result at the caret, call `setRangeText(id, text)`
when the mutation answers. On Android the window needs input focus. A Paste image action uses `read()`
and `await item.getType("image/png")` to get a sanitized PNG under `app:/tmp/`.

Use `keycapture=shortcut` on a container when its shortcut must run before
the focused field's `key=` handler. Capture runs outermost first, then the
target's capture and `key` handlers, then `key` bubbles outward. A capture
handler can call `stopPropagation()` to stop later handlers, including the
target's `key` handler when called there. `preventDefault()` keeps the field
from editing. The container gains no Tab stop from `keycapture` alone.

`key` is the DOM's keydown and `keyup` its keyup; an action that takes it hears
a `KeyboardEvent` (`metaKey`, `code`, `repeat`, `isComposing`, …). An Enter or
Escape handler at a field skips `e.isComposing`, as web code does: on the web
the Enter that picks an input method's candidate arrives composing. Track a held modifier as a
page does: set it from the event on every keydown and keyup, and forget it when
the window loses the focus, since a key let go in another app sends no keyup
(the page's `window` `blur`). `exactPage().hasFocus` turning false gates the task
that forgets it, and the hint shows only while the window has the focus:

```contract
shape Page
  hasFocus: bool

component Hints
  resource page = exactPage() as shape Page
  state meta = false
  action held(k: string, e: KeyboardEvent)
    meta = e.metaKey
  action forget()
    meta = false
  task release when meta and not page.hasFocus
    after(1, forget)
  view
    column key=held keyup=held testId="list"
      if meta and page.hasFocus
        text "⌘ held"
```

Drive it with `type "list" key "Meta" down`, `prefer has-focus false` and
`clock +1`. While an input method composes text in a field on macOS or iOS, a
modifier's own keys still reach these handlers, and a ⌘ chord commits the
composed text first (its `input`, then the chord's `key`), so a composer's
⌘Enter `key` action sends what was typed; a button that declares ⌘Enter is not
pressed then. See [Keys](https://exact.expo.dev/reference/contract-grammar/events.md#keys).

A long-press or right-click menu is a `popover` the node names with
`contextPopover="<id>"`: its `button` rows (with `popovertarget="<id>"
popovertargetaction="hide"`), `link` rows, which follow their link (Call as
`link href="tel:…"`), `hr` separators and `role="group"` sections of rows
(`contract vocab menu`) are the menu, and one row with
`contextPreview=true` is the preview, whose `press` is what tapping the preview
does (open the conversation). iOS presents UIKit's context menu, with the row
lifting and the preview popping into the screen its press pushes; macOS an
`NSMenu` without the preview; the web and the default agent open the popover anchored to
the node. On iOS a header's pressable title (a group with a `press` around the
heading, a `button` or a `row`) with a `contextPopover` opens its menu from the navigation bar's title; the
title's avatar, if it has one, lifts alone when the popover is written with no preview
row, which is read as the press begins, before the group's `contextmenu` runs. The menu needs the popover menu-shaped (LLP 1021
D3): each row its text and at most one `image`, with `aria-checked` for a checkmark;
a row with anything else beside its label (an icon box) makes macOS open the
painted popover anchored to the node instead. The node's own `contextmenu` action runs first, so one popover can
serve every row of a list. A node inside an open popover opens its menu over
that popover, which stays open, as HTML nests them. The default agent opens it with
`tap <node> contextmenu` (LLP 1021 §5.1). On an iOS simulator under `--touch platform`,
use a [real long press](https://exact.expo.dev/recipes/ios-driving.md).

The order of a menu's rows is the platform's unless the menu's trigger says otherwise.
UIKit's own order puts the first row nearest the finger, so a menu that opens upward
from a button near the bottom of the screen shows its rows last first. `menuOrder` on
the trigger (the `popovertarget` button, a `header` button that opens a menu, or the
node with `contextPopover`) says it: `"fixed"` keeps the rows as written wherever the
menu opens (a list of presets), `"priority"` always puts the first row nearest the
finger, and `"automatic"`, the default, is the platform's. iOS and tvOS set it as
`preferredMenuElementOrder`; the web, the Mac and the other hosts always show the rows
as written, so they have nothing to apply.

A pick closes a native menu unless the author keeps it open, for a menu that takes several
picks in a row, such as a filter's tags. `keepsMenuPresented=true` on a menu's or a
submenu's popover column keeps it open for that column's own rows, not for the rows of
the submenus they open; on a row it says it for that row, and `false` there closes the
menu again. Those rows leave out `popovertargetaction="hide"`, which still closes the
menu, as it does on the web; so does a row that follows a link or opens a dialog or
another popover. iOS sets UIKit's `keepsMenuPresented` on the row and, after each pick,
updates the open menu in place: its checks, titles and subtitles, rows that come or go,
and an open submenu's header. Two UIKit limits apply on iOS: a row that hides only its
submenu closes the whole menu, and a bar button's menu closes when the button's image
changes. A long-press menu that a hardware keyboard's menu key opens is an edit menu,
which UIKit cannot update, so it closes at every pick. The web already keeps a menu open
until a row hides it. macOS, tvOS, Android,
Linux and Windows close the menu at every pick, and it shows the new checks when it
opens again.

### Ask Siri

On iOS 27, where the new Siri is available, UIKit adds its Ask Siri item to a
context menu that a draggable node's own view opens, and Siri takes what the drag
carries ([dragging out](https://exact.expo.dev/recipes/drag-out.md)). So `draggable` on the node that names
`contextPopover` brings it; `draggable` on an image inside that node does not. UIKit
also adds it to a menu with a row titled as the system's Copy, in the device's
language; what Siri takes from such a menu is not known. No attribute adds the item or
removes it (LLP 1094.000 D4). The simulator never offers it: a drive shows it there
with `prefer ask-siri available` under `--touch platform`, which presents UIKit's own
menus.

### Tips

`tip="<title>"` on an element is a tip that teaches it (LLP 1035.006.000), with
`tipMessage` under the title and `tipImage` a symbol beside it (`symbol:<role>` or
`symbol:sf/<name>`). The element's `id` names the tip, which the platform remembers across
launches, so the build refuses a `tip` without an `id` (`lower-tip-id`), and a `tipMessage`,
`tipImage` or `tipDone` without a `tip` (`lower-tip-parts`). `tipDone=<bool>` says the person
has done what it teaches; once true the tip is retired for good. iOS, iPadOS and macOS show
it as TipKit's popover over the element, or over the navigation bar or toolbar item drawn
for a header's button, when TipKit says it may: one at a time in document order, while the
element is on screen and uncovered, never again after the person closes it. An empty title
is no tip, so a computed one offers it only when it applies. The web, Android, Linux,
Windows and the terminal have no tip system and show none: put nothing essential in a tip.
A plan that binds `tip` links the `tips` capability (TipKit and SwiftUI on Apple). The
driver's `state.tips` lists each tip's TipKit status, whether it shows and what it points
at. Recipe: `tips`.

### Changing a grid's columns

Pocket Lab groups frames into fixed-height rows keyed by row number. Give
each cell its frame's stable id (`frame-0`, `frame-1`, …). Before changing
columns, read the hit cell and its vertical position inside the grid. The
keyed scroll restores that position for the frame's new row. Its column
follows its index in the new layout. This example uses an untransformed
list with zero border and padding. The wheel's offsets are from its content box.

```contract
component Grid
  state columns = 4
  state wheelColumns = 4
  action reflow(next: number, x: number, y: number)
    let cell = match elementsFromPoint(x, y).filter(id => id.startsWith("frame-")).at(0) { case some(id) => id, case none => "" }
    let index = match parseNumber(cell.slice(6)) { case some(n) => n, case none => -1 }
    if index >= 0 and next != columns
      let top = frame(cell).y - frame("grid").y
      columns = next
      scrollIntoView("grid", floor(index / next), offset=-top)
  action pinched(scale: number, x: number, y: number)
    let next = min(7, max(2, round(columns / scale)))
    reflow(next, x, y)
    wheelColumns = next
  action wheelZoom(e: WheelEvent)
    if e.ctrlKey and e.deltaY != 0
      preventDefault()
      let next = min(7, max(2, wheelColumns + e.deltaY / 100))
      wheelColumns = next
      reflow(round(next), frame("grid").x + e.offsetX, frame("grid").y + e.offsetY)
  view
    list id="grid" appearance="none" virtualized=true height="100%" pinchrelease=pinched wheel=wheelZoom
      for r in range(ceil(10000 / columns)) key=r
        row
          for c in range(min(columns, 10000 - r * columns)) key=c
            box id=`frame-${r * columns + c}` width=`${100 / columns}%` height=80
```

### A list inside a draggable sheet on iOS

Put `heightDragFor` on the list and give its ancestor the named `id`. One
contact expands the sheet, then scrolls the list. On the way down it takes
the list back to its start, then lowers the sheet. A contact that moved the
sheet sends its displayed height and its velocity in points per second to
`heightrelease`. A contact that only scrolled can coast on its own.

This sheet has stops at 160, 320 and 480. A slow release chooses the nearest
stop (the higher one at a tie). A flick takes the next stop in its direction.

```contract
component ReadingSheet
  state px = 320
  action snap(height: number, velocity: number)
    if velocity >= 250
      px = height < 320 ? 320 : 480
    else if velocity <= -250
      px = height > 320 ? 320 : 160
    else
      px = height < 240 ? 160 : height < 400 ? 320 : 480
  view
    column id="sheet" height=px min-height=160 max-height=480 box-sizing="border-box" transition="height -exact-spring(300,30,1)"
      list heightDragFor="sheet" heightrelease=snap flex=1 min-height=0
        for n in range(24) key=n
          text `Row ${n}` height=50
```

On iOS 26.5, UIKit settled to 320 from a held height of 399.00 and to 480
from 400.33. At a release height of 376.33, +241.62 points/s stayed at 320
and +266.77 advanced to 480. The example chooses 250 within that bracket.
UIKit also stayed at 320 from 338.33 with a speed of +379.09, so a single
cutoff only approximates its flick decisions across release heights.
UIKit's inset sheet and an unscaled in-page box can reach different heights
on the same finger stroke.

### Swipe to reply

An element takes one `swipe=action` and, beside it, exactly one of `swipe-follow`, a swipe
the node follows, or `swipe-flick`, the platform's flick (below). `swipe-follow="right"`
moves its node with the finger: it follows up to 64 points, then a fifth of the finger's
travel, and the action runs if the node is at or past 64 points when the finger lifts.
`swipe-follow` is the quoted `"right"` or `"left"` written on the element; for a direction
that depends on data, write two `if` branches. A finger reaches it only with a
`touch-action` that leaves it the sideways drag: write `touch-action="pan-y"`, which leaves
vertical drags to the list (`none` keeps both from the page). A `transition` on
`translate` springs the node back after the lift; without one it jumps back. The node's
first child with `swipeIndicator=true` goes from its own `opacity` and `scale` to 1 as the
swipe reaches 64 points, and back by its own `transition` after the lift (not in a painted
content region's picture, which follows a row with no indicator); both are optional. Give the node `position="relative"`, so an absolute indicator
is placed against the node and not against the row around it. `symbol:reply` is a speech
bubble (SF Symbols' `bubble.left`); Messages' left-turning arrow, `arrowshape.turn.up.left`,
has no named symbol, so an app declares it as an icon token. The iOS host plays a selection
haptic as the swipe crosses 64 points, so the action plays none. `apps/messages`' bubble
is a whole example.

`swipe-follow="left"` is the mirror, for Discord's reply or a bubble of your own on the
right: the node follows a leftward drag and the action runs at or past 64 points to the
left. A node follows one direction. The directions are the screen's, in a right-to-left
layout too. Neither reveals buttons: a row's Delete is `delete=` (`contract vocab swipe`).
On a paragraph's run, put it on the paragraph or a box instead: only the web gives a run a
view of its own. `tree` names the event `swiperight` or `swipeleft`.

```contract
component Thread
  state replyTo = ""
  action reply(id: string)
    replyTo = id
  view
    column align-items="flex-start" padding=12 gap=8
      box position="relative" swipe=reply("1") swipe-follow="right" touch-action="pan-y"
        transition="translate -exact-spring(300, 30, 1)" testId="bubble-1"
        image "symbol:reply" swipeIndicator=true position="absolute" left=-32 top=8 opacity=0 scale=0.5
          transition="opacity -exact-spring(300, 30, 1), scale -exact-spring(300, 30, 1)" aria-hidden=true
        text "Lunch tomorrow?" padding="8px 12px" border-radius=18 background-color="-exact-fill"
      if replyTo != ""
        text "Replying to “Lunch tomorrow?”" testId="reply-bar"
```

```contract-test
test "a swipe right answers the message"
  tap "bubble-1" drag 100 0 from 40 10
  clock settle
  expect tree has "reply-bar"
```

A test's drag is a real touch on an iOS simulator: start it where 100 points stay on the
screen and at least 20 points from the window's left edge, which iOS keeps for its back
gesture, and `clock settle` after it, so the spring back has ended when the screen is read.
Drive a node that follows with `drag`, not `swipe`, whose flick also carries it past 64
points on iOS.

### A flick that puts the keys away

`swipe=action` with `swipe-flick="down"` is the platform's discrete swipe: nothing
follows the finger, and the action runs once when iOS recognizes a quick flick down on the
node or anything inside it, its field included. UIKit arbitrates it with the other gestures
under the finger, as it does any swipe: a field whose text overflows scrolls instead. Only
iOS has it, so give the effect a control as well (the keyboard recipe's Done). A swipe fires
nothing where UIKit draws its own control in a node's place (tabs it draws as a segmented
control, a bar's item, a native menu's item, a grouped list's cells): put it on what the
page draws. `lower-swipe-unseen` names one inside a grouped list.

```contract
component Composer
  state draft = ""
  action edit(text: string)
    draft = text
  action hideKeys
    blur("composer")
  view
    column swipe=hideKeys swipe-flick="down" testId="composer-bar"
      textarea id="composer" testId="composer" value=draft input=edit field-sizing="content" max-height=120
```

`tap "composer-bar" swipe down` drives it on iOS under `--touch platform`, and in a test
file, which takes real touches for it: a real flick, a fast drag of 120 points from inside
the target and the viewport, which UIKit's recognizer reads. Without real touches it is
refused, since nothing else reaches the recognizer. The reply says the touch was
delivered, not that UIKit recognized it, so read the action's effect (the keyboard here).

### A confirmation

"Remove book?" with a message, Cancel and a destructive Remove (React Native's
`Alert.alert`) is a `dialog role="alertdialog"`: its `aria-label` is the
title, a `text` the message, each action a `button` with `press` that closes
it, and one Cancel, a closing `button` without `press`. Open it from a button
(`commandfor="<id>" command="show-modal"`) or from any action with
`showModal("<id>")` — a context-menu row's `press` asks before it deletes:

```
action askRemove(id: string)
  pending = id
  showModal("remove")
…
dialog id="remove" role="alertdialog" aria-label="Remove book?"
  text (title + " will be removed from your library.")
  button press=remove(pending) destructive=true commandfor="remove" command="close"
    text "Remove"
  button commandfor="remove" command="close"
    text "Cancel"
```

iOS shows the centred alert, its Cancel kept; the web its modal `dialog`;
macOS `NSAlert`, a sheet on the window, its Cancel on Escape and Return on the
one `buttonStyle="filled"` button that is not destructive, when there is exactly
one (LLP 1115.000 D7.6). Text, a cancel and at most three buttons make an
alert; several actions with no text (an "Open in…" chooser) make an action
sheet, unanchored on an iPhone (its Cancel drawn) when it has a Cancel and a popover
at its invoker when it has none, so a tap outside can dismiss it (LLP 1115 D6).
An alert has no outside, on every host (LLP 1115.000 D13.4): Escape and Back
cancel it (the Mac's one-button alert excepted, below) and a tap or click beside it does nothing, which is `closedby="closerequest"`,
implied for the alert's shape, so leave `closedby` unwritten. Write
`closedby="any"` only to ask for the platform's dismissible form in its place:
an action sheet on an iPhone (a popover on an iPad), a dialog a click outside
closes on the web, a sheet a click on the window behind it closes on the Mac, a
Material dialog a tap outside cancels on Android.
`close("<id>")` from an action closes it as its Cancel does.
Escape (and Command-period on the Mac), Back and a dismissal outside it are
HTML's close request: the `dialog` hears `cancel`, then `close`. Its Cancel, an action
and `close("<id>")` fire `close` alone, as a `command="close"` button does in a
browser. iOS reports a hardware Escape at its alert as the Cancel's tap, so
there it fires `close` alone.

An alert that only tells ("Couldn't save the note." and OK) is a `text` and its
one closing button, with no action: iOS's alert with that one button, macOS's
`NSAlert` with it as the default (Return presses it and Escape does nothing, as
on AppKit's own one-button alert), the web's modal `dialog`, Material's dialog
on Android. Under `closedby="any"` it is the dialog's own sheet on the Mac, which a
click outside dismisses; iOS keeps the alert, since an action sheet drops a
lone Cancel in an iPad's popover. The action that learns of the failure sets the state its `text`
reads and calls `showModal("<id>")` ([tell the person something failed](https://exact.expo.dev/recipes/error-alert.md)).

An alert's own `font-family`, written on the `dialog` or its class, applies to
its title, message and button labels on web, Linux, Android and Windows.
Android and Windows keep the platform face when the family is only inherited.
iOS and macOS keep the system face: `UIAlertController` and `NSAlert` have no
public font API, so the compiler warns when an alert requests a family there.

A prompt (a rename's, `Alert.prompt`) is the alert with a text field: an
`input` among its rows, which counts as its message when it has no `text`:

```
dialog id="rename" role="alertdialog" aria-label="Rename Pattern"
  input value=draft input=editDraft placeholder="Name"
  button commandfor="rename" command="close"
    text "Cancel"
  button press=rename disabled=(draft == "") commandfor="rename" command="close"
    text "Save"
```

iOS shows `UIAlertController` with the field (`addTextField`), macOS `NSAlert`
with it as the accessory view, the web the `dialog` with the field on a line of
its own. The field is the authored `input`'s, going through its machinery: the
input's value writes reach it (what is typed stands until the page writes the
value), its `placeholder`, keyboard, `disabled`, `readonly`, `maxlength` and
`beforeinput` are its, each keystroke is its `input` and the end of editing
its `change`, so the action's `press` reads what was typed. Return is one
rule on every host: the input's `key` handlers hear it first (and may prevent
it); a field with a `submit` handler then commits and runs it, and that is
all, as a hand-built field whose delegate handles Return; any other commits
its edit and presses the first action that is not destructive,
whatever `buttonStyle` says; while that action is disabled Return does nothing, so a Save with `disabled=(draft == "")`
opens dimmed and enables as a name is typed. iOS draws no action bold, as a
hand-built alert does not, unless the action Return presses says
`buttonStyle="filled"`: then it is the alert's preferred action, bold. (An alert
with no field prefers its one filled action that is not destructive, as the Mac
makes it the default button.) Only the alert's shape takes
one field at a time: with it, a cancel and at most three buttons, no `for`
(`lower-alertdialog` says which row breaks it).

On iOS and Android, a native menu button's second `text` is its subtitle.
In a custom `button`, two block texts in a block button or two texts in a flex
column supply the title and subtitle. The second may sit inside an `if`.
Side-by-side texts or an absolutely positioned count form one title.
On Android a checked item keeps its symbol leading and shows the check trailing.
Without a symbol, the check is leading. An Android menu button’s `aria-label` names
the action for accessibility. Otherwise the reader uses its exposed text, falling
back to the painted title and subtitle when all the text is decorative.
Windows window and status menu flyouts draw only the title line. When a checked
item has a symbol, the flyout shows the symbol alone.

A submenu is a row whose `popovertarget` names another menu popover (`Copy ▸
path / link`): a submenu `NSMenuItem` on macOS, a nested `UIMenu` on iOS, and
on the web and under the agent the nested popover, opened by `tap <row>`. Place
it beside its row with `position-area="right span-bottom"`; give its items
`popovertarget="<outer menu id>" popovertargetaction="hide"` so a choice closes
the whole menu; write no `press` on the row that opens it (a native menu never
runs it); and draw the web's `›` as an `aria-hidden` text, since the native
menus draw their own arrow (LLP 1021 §5.2).

Use `aria-keyshortcuts="Mod+Shift+O"` for the primary shortcut on every
host. On Apple platforms it takes Command and files in the Mac menu bar
as a `Meta` chord. Elsewhere it takes Control. The web writes the
resolved chord to the DOM once the browser supplies its platform.
Draw the cap with `text formatShortcut("Mod+Shift+O")`. The server leaves it
empty. The client shows ⇧⌘O on Apple platforms and Ctrl+Shift+O elsewhere.
See [Apple’s modifier order](https://developer.apple.com/design/human-interface-guidelines/keyboards/)
and [Microsoft’s key names](https://learn.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/term-collections/keys-keyboard-shortcuts).

For the Mac menu bar, put `-exact-menu="app"` on an ordinary button to add
an item without a shortcut. Literal destinations are `about` (directly under
About, where Check for Updates… goes), `app`, `file`, `edit`, `view`, `go`,
`window`, `help`, and `none` (no item: the chord stays a shortcut);
explicit placement overrides the usual `aria-keyshortcuts` chord filing. A
placed item shows and takes the button's chord holding ⌘, or else one holding ⌃
(`aria-keyshortcuts="Control+Space"`); a chord of ⌥ or ⇧ alone stays out of
the menu, since those type. ⌃Space is macOS's default shortcut for Select the
Previous Input Source, and where it is on the system takes it first. Its
accessible label or text titles it, and `disabled` disables it. An item in the
app menu or Help is the app's, so it stays enabled while no window is key and
under a sheet or a Contract modal dialog. Keep the button reachable: the agent taps it,
and other hosts show that ordinary button, with no application menu.
On the root, `-exact-menu-remove="show-tab-bar close-all"` removes
selected standard items. Its whitespace-separated list must be literal; unknown
ids and non-root use are refused. The fixed ids are `close-all`, `show-tab-bar`, `show-all-tabs`, `enter-full-screen`,
`minimize`, `zoom`, `bring-all-to-front`, `show-previous-tab`, `show-next-tab`,
`move-tab-to-new-window`, `merge-all-windows`, `back` (Go ▸ Back), `forward` (Go ▸ Forward), `develop` (the
Develop menu; its chords stay), `paste-and-match-style`, `find`,
`spelling-and-grammar`, `substitutions`, `transformations`, `app-help` (Help ▸
*App* Help), `actual-size`, `zoom-in`, `zoom-out`.
Other standard items remain; other hosts ignore removal.
`-exact-menu-keys="close-window=none"` on the root keeps File ▸ Close Window
with no chord, so ⌘W reaches the page; declare `-exact-menu-remove="close-all"`
with it, or AppKit's Close All ⌥⌘W shows as a row of its own.
`close-window=Meta+Shift+W` gives it ⇧⌘W instead: one `aria-keyshortcuts`
chord with `Meta` or `Mod` that is not the host's or the system's own. View has Actual Size
⌘0, Zoom In ⌘+ and Zoom Out ⌘-, a page zoom as a browser's: the viewport,
`px` and `rem` all follow it; an app's own zoom commands set it with
`setPageZoom(factor)`. See the grammar’s “The Mac’s menu bar”.

Two more presentations of a button reach past the window
(LLP 1133.025 D4, D5). `dock` beside a menu
id, or alone, also files the button in the app's Dock menu:
`-exact-menu="file dock"` is New Conversation in File and in the Dock menu.
`-exact-menu="status"`, alone, makes the button the app's status item: a menu
bar item on macOS, a notification-area icon on Windows. Its text or
`aria-label` is the item's title and tooltip, one `img` or `svg` child its
image, and its `popovertarget` menu the item's menu. On macOS the image is
a template. On Windows a `symbol:` uses the taskbar's text colour, an `svg`
is drawn as authored, and a file-backed `img` is contained at the current
display's small-icon size and reloaded when its DPI changes. The app's icon
is the fallback when the image is absent, still loading or fails to load.
On macOS a click opens that menu, or
runs `press` when there is none; on Windows a left click runs `press`, or
opens the menu when there is none, and a right click opens the menu. On both
the button takes no room in the page; elsewhere it is an ordinary button. An
accessory app's status menu ends with the host's Quit, and a Windows status
menu with Exit; `-exact-menu-remove="status-quit"` removes either. On Windows
a placed status item leaves the close button closing the app, as Windows'
guidelines advise; only `keepRunning` makes it hide the window. Bare `focus()` brings the
window forward on macOS and Windows, showing it if it was hidden (Linux logs
it as unsupported); `hideWindow()` puts it away again with the app still
running, as the person's close does under `keepRunning`, or on macOS while a
status item is placed (refused in the journal elsewhere, and where
the app would end without its window); the agent lists the items as
`state.statusItems` and `state.dockMenu`.


`frame(id)` and `measure("literal-id")` are action-only geometry reads returning
`Geometry` (`x`, `y`, `width`, `height`, `provisional`, `unavailable`). Handle `unavailable` and `provisional`.
Native answers are provisional while text in the subtree has estimated geometry,
or an image or video awaits its natural size. Accepted text measurements clear
the estimate at the next layout; unrelated subtrees keep their settled answers.
The id is an element's `id`, not its `testId`: a literal id no element in the view
has answers `unavailable` on every host, and the build warns (`lower-geometry-id`).
`frame` reads the last layout's border box
where the viewer sees it, as `getBoundingClientRect` does: in the viewport, through
every `translate`, `rotate` and `scale` on it and above it (the bounding box of a
turned box), with every scroll offset above it (the page's too) applied, so a drop
target needs no scroll bookkeeping and a dragged card is where it shows. Natively a
transform in flight counts at its end value; the web reads it mid-flight. `measure`
reads the border box as if its `height` were `auto`, at the same origin, with every
other style kept: its in-flow content, plus its padding and border, within its
`min-height` and `max-height`, and the height opposing `top` and `bottom` insets
give an absolutely positioned box. So a navigation root whose children are all
absolutely positioned, with no padding, border or `min-height` of its own,
measures 0 however tall it is laid out. Motion in flight does not count on
any host: `measure` reads a `height` transition at its end and a
`-exact-layout-transition` at the laid-out box, and the motion plays on, so a box
mounted under a parent that is still growing reads its settled size in its first
`resize`. Read a laid-out
size, the screen's included, with `frame`, and size a sheet as a share of the
screen with `navigationDetent="45%"`. Before the first layout both answer
`unavailable` with zeros, as on the web until the page's geometry code loads after
first paint; natively a mount task's `after(1, …)` runs after that layout.
`measure` is also `unavailable` for a box with no single size (an inline run, or
one under `display: none`); on the web while a `keyframes` animation of a font's
weight, stretch or variation settings plays in the box or above it, with no
event when it ends; and, natively, while the tree has a change not yet laid
out or a Mac entry has content regions registered.
Neither is a computed style binding to run every render.
`elementFromPoint(x, y)` names the front-most of the same boxes at a viewport
point by its nearest `id` (`option<string>`), through the same transforms. For a
point read that sees through an overlay, `elementsFromPoint(x, y)` lists every
hit node's own id, front to back, including hit ancestors; id-less nodes are
skipped (except an id-less hit outside its named ancestor's box includes that
ancestor once). `querySelectorAll("[data-paint~=\"accent\"]")` lists the own ids of
mounted, displayed, non-inert nodes bearing the declared `data-paint` word in
tree order. Covered routes and unselected tabs do not answer; a split list
answers with its detail where the host shows them side by side (the web at desktop
widths, and iOS where UIKit's split view shows both columns; over the detail only the
list answers, LLP 1127 D8, and `state window.split` says which shows).
Closed popovers and dialogs do not answer; open ones do. Point reads skip inert
subtrees and use the presenter's placement for open top-layer content. Point reads
also name the front modal dialog or presented route where its native backdrop accepts input,
beneath any later popover. Native sheet chrome outside authored content is
not part of the backdrop. The backdrop's hit region is independent of the
content's clip and pointer events; it never exposes the page or a lower
modal. Both reads run only in actions and give one snapshot. Use `frame(id)`
for each returned id when drawing outlines.
For a drag still built by hand, test the dragged node's visual centre (the middle of
its `frame(id)`, which includes the `translate` the drag gave it), not the
pointer: the box under a lifted card is the card.

SVG uses SVG names. Native SVG geometry has incomplete support for `calc()`,
`min()`, `max()` and `clamp()`, including nested SVG viewports and `<use>`
placement and sizing. Use numeric lengths or percentages there; CSS layout math
on the outer SVG element does not imply support inside its scene.
SVG attribute-only lengths accept user units (unitless), `px`, `in`, `cm`, `mm`,
`pt`, `pc` and `%`: line/linearGradient `x1`/`y1`/`x2`/`y2`, radialGradient
`fx`/`fy`/`fr`, marker `markerWidth`/`markerHeight`/`refX`/`refY`, and each item
of SVG text/tspan `x`/`y`/`dx`/`dy`. Relative units and function text such as
`calc()`, `env()` and `var()` are refused in literals and literal template parts
(LLP 1055.000 D4). Literal concatenations are checked together; an incomplete
fragment that could finish an accepted unit is left to runtime. Literal choices in
conditionals, matches and inlined derives are checked too. Bound values use the
same grammar: an unsupported computed value clears the attribute and journals
`runtime-svg-length` on every target. Marker `refX` also accepts
`left`/`center`/`right`, and `refY` accepts `top`/`center`/`bottom`; native hosts
currently place these keywords at 0.
`foreignObject` renders directly on the web, but draws nothing through SVG `use`.
The compiler warns at a `use` whose unambiguous, unconditional literal target contains
one (`lower-svg-use-foreign-object`). Native hosts refuse `foreignObject` at run
time; for content on every host, position an ordinary box over the `svg`. Canvas 2D calls
live in a data module, and GPU/game surfaces in their optional module. A
hyphenated native tag must be declared by a dependency's `exact.json` `views` or
listed in `app.json`'s `modules`. A string or `{"tag":"map-view"}` declares every host.
For `{"tag":"map-view","hosts":["ios","macos"]}`, bind `page` to `exactPage()`
and place the tag under `if page.platform == "ios" || page.platform == "macos"`.
A view can also use `match page.platform` with indented `case "ios"` and `case "macos"` arms.
Every build checks these guards. Put the guard where the tag is written, including
inside a reusable component. An app module's unknown
attributes pass through unchecked as its props. A package view refuses an attribute
declared as neither a prop nor an event with `lower-native-attr`, apart from standard
box attributes and common module events. A known attribute binds to the module's
box, which takes layout, box and paint rows, handlers, `testId`, `id`, `role`, ARIA,
`disabled` and `inert`; any other known name (`color`, `value`, `command`, `href`) is refused,
so give the module prop another name. A package view's declared non-layout prop
(`exact-camera`'s `object-fit`) goes to the view when written on the tag, even where
the name is a known attribute. Declaring a layout attribute as a view prop is
`bake-view-prop-layout`. A class's rows style only
the box and set no view props; write `object-fit` on the camera tag to configure its
viewfinder. A renamed spelling (`fontSize`) is refused whatever is declared. Do not
turn a missing widget or canvas operation into invented Contract syntax.

In an agent drive (a `*.test.contract` cannot set an extension's substitute with
`prefer` yet), `@exact/camera` accepts
`prefer extension camera.picture={"path":"assets/test/card.jpg"}` for a still,
or `prefer extension camera.clip={"path":"assets/test/walk.mp4"}` for a clip.
Both name app assets. A clip is decoded once and loops on the session clock,
from the track's start: `clock +100` advances its frame by 100 ms. The
viewfinder, a package reading the track's picture and `takePhoto` receive
the same frame. A screenshot sequence follows that clock too. The journal
records the clip's SHA-256, not its frames. Clear either preference with
`=clear` before setting the other; setting both is refused in the journal.
This works on Android, iOS, macOS and web; Linux has no camera substitute.
For a fixture shared across these hosts use H.264 MP4 and a web browser with
H.264 WebCodecs support. See the [camera package's guide](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/packages/camera/test/checklist.md#agent-pictures-and-clips).

On Apple, each package's Swift library loads at its first call, view, picture,
authentication or wake. Permission, preference and foreground updates are kept
until then; they do not load an unused package. A package declaring `"start":
"load"` starts after first pixel. An app's own Swift that imports a package's
Swift module loads that library with the app module. Under the agent,
`state.extensions.<name>.implementation.loaded` reports whether it is mapped
(LLP 1067.000.001).

An app can answer its own data calls in Swift or Kotlin. On Apple, name the
`ExactModule` subclass with `let exactModule` in `modules/apple`. On Android,
define `class exact.app.Module : dev.exact.canvas.ExactModule()` in
`modules/android`. The session owns one instance across Activity recreation.
`native.call` runs a cheap query on main on Apple and on the caller's thread on Android. `native.later` starts on
main and can reply from any thread. Use `context.after` for the session clock
and `context.changed(topic)` for a source that reads `native.watch(topic)`.
On Android, `context.activity` is the activity in front, as a package's
`ExtensionContext.activity` is, for what needs its window (`FLAG_SECURE`,
`screenBrightness`, a screen-capture callback); touch it on main, from `later`.
It is null while no activity exists, and the stopped one while the app is in
the background. A configuration change that remakes the activity drops what
was set on its window (expo/exact#1596).
See the [native module recipe](https://exact.expo.dev/recipes/native-module.md).

Put vendor `.xcframework` bundles beside an Apple native module's Swift files
(`modules/apple`, or its platform-local replacement). The Apple build selects
by platform, device or simulator, and architecture from each bundle's `Info.plist`.
Static libraries are linked into the module. Dynamic frameworks are copied with
their resources into the app's `Frameworks` (`Contents/Frameworks` on macOS) and
signed with the app's identity before the app is signed, in development and
production, including versioned macOS frameworks (`Versions/A`). Their install
names must use `@rpath/<Name>.framework/…`. An xcframework may carry macOS and
iOS slices together: source capture skips the binary bundle, including its
version links. Changing a selected binary requires a new native build. Framework
filenames must be unique across package libraries, module dependencies and the
host runtime (`ExactCore.framework`); a collision fails the build, naming both sources.

Apple native modules can include asset catalogs beside their Swift sources:
`modules/apple/*.xcassets`, or `ios/modules/*.xcassets` / `macos/modules/*.xcassets`
when the app has a platform-local module directory. The local directory replaces
`modules/apple` for that platform; tvOS uses the iOS directory. The Apple build
compiles these catalogs together with its generated assets into the main bundle.
On macOS, a catalog makes the dev build and agent launch the assembled `.app`.
Load custom symbols with `UIImage(named: "donut", in: .main, with: configuration)`
or `NSImage(named: "donut")`; SwiftUI uses `Image("donut", bundle: .main)`.
`symbol:sf/...` still looks up system symbols only. A colour set named
`AccentColor` is the app's accent on Apple hosts (`NSAccentColorName`; the
accent section above). Catalog changes require a
new native build; they are not web assets or live update payloads.

An Icon Composer project is selected explicitly by `host.ios.icon` or
`host.macos.icon` in `app.json`, as an app-relative `.icon` directory; tvOS
does not inherit it. It compiles with the catalogs and replaces the native
raster icon from `icons`, which still supplies the web. See the
[icon inputs in the reference](https://exact.expo.dev/reference/developer.md) for conflicts and fallback.

An iOS native module that uses `canOpenURL` to check for another app lists
its schemes in `app.json`: `"host": { "ios": { "queriesSchemes":
["comgooglemaps", "waze"] } }`. The build writes `LSApplicationQueriesSchemes`.
List at most 50 schemes, without `:` or `://`; changing the list requires a
native rebuild.

An app that was renamed, or whose name Siri mishears, lists the other names Siri
and App Shortcuts' `${applicationName}` should answer to: `"host": { "ios": {
"alternativeNames": [{ "name": "Oldname", "pronunciationHint": "old name" }] } }`,
and `host.macos.alternativeNames` for the Mac. The build writes
`INAlternativeAppNames`, and copies the iPhone app's into its watch app, which
inherits none and must list the same. At most three; the hint, optional, is
written as the name sounds. Apple admits names based on the app's own or ones its
users commonly call it, never another app's. Changing them requires a native
rebuild.

Write pressed `background-color`, `color` and absolute `opacity` in a
`:active` block. `-exact-press-opacity` multiplies the node's presented opacity;
`-exact-press-scale` multiplies its presented scale. The host applies these
values while a finger or mouse holds the innermost pressable inside its box.
Sliding off, cancellation or a pan releases it. Custom nodes ease over 120 ms;
native controls keep the platform's timing. The agent applies the target at
once, so `"tap row down" "screenshot x.png" "tap up"` shows it. Pressing requires
no runner round trip. Active `color` reaches text that inherits the node's
colour; descendants with their own keep it. On custom nodes, authored feedback
replaces the platform's unsaid press. Native buttons and native list rows keep
unwritten fields of the platform's highlighted state. Leave feedback unwritten
for the platform default. A press that changes layout uses app state.

`-exact-hit-slop` grows where a pointer reaches a node without moving or
painting anything, as React Native's `hitSlop` and a UIKit `point(inside:with:)`
override do (Charlie, 2026-11-10). It takes one to four nonnegative lengths, as
`padding` does, with no percentage; `-exact-hit-slop-top` and its siblings set
one side. `-exact-hit-slop="12px"` on a 24px icon button takes a tap 12px
outside it. Where boxes overlap, the front one still takes the pointer, slop
and all, so a button written after a slopped one keeps its own box. An
`overflow` other than `visible` on the node or an ancestor clips the slop.
`tap <target>` still aims at the box's middle, and `elementFromPoint` counts the
slop. On iOS and the JS web target, `verify` counts the slop a press can reach.
For example, `-exact-hit-slop="4px 0px"` can give a 36 pt pill the 44 pt tap
height iOS checks. On the web the slop is a positioned pseudo-element, so it reaches from the
padding edge (a border's width comes off it) and a node that says no `position`
becomes `position: relative`. An `image`, `input` or other replaced element
refuses it with `lower-hit-slop`; give it to the box or button that holds one.

Haptics are already there (LLP 1077 D14). `-exact-press-haptic` (`selection`,
`impact-light|medium|heavy|soft|rigid`) plays at touch-down without a round
trip, as `-exact-press-scale` does. `haptic("selection" | "impact-…" | "success" |
"warning" | "error")` is a host command an action runs, for example when a
drag crosses a threshold. iOS uses the feedback generators; the web vibrates
where it can; Linux does nothing.

An interface size setting is `rem` plus `setRootFontSize(px)`, CSS's `:root {
font-size }` (LLP 1069.000 D3). Size what should scale in `rem` (text, control
heights, paddings) and what should not in `px`; an action calling
`setRootFontSize(size)` re-lays every `rem` out in its own commit, on every host.
The app's size stands over the host's (the browser's setting, iOS Dynamic Type's
body, 13 on macOS, 16 on Linux, and 16 times Windows' Text size factor), as an author's `html { font-size: 20px }` stands over a
browser's font-size setting; `setRootFontSize("medium")` hands it back, so a
"Default" choice that follows Dynamic Type calls that. Smaller and Larger that
should scale Dynamic Type instead of replacing it are percentages:
`setRootFontSize("87.5%")`, `("125%")`, CSS's percentage of `medium`, so the root
is that share of the host's size and follows it when Dynamic Type or the browser's
setting changes. A size of 0 or less is refused (a literal at compile time, a computed one in `logs`). It is not kept
across a launch: a root `task restore mount` with `after(1, applySize)` sets the
stored size again. Do not multiply a scale factor into every size instead.

Platform facts are reserved sources (`exactViewport`, `exactPage`, `exactDelivery`,
`exactSurface`, `exactCanvasPerformance`, `exactTime`, `exactGeometry`, `exactNativeChain`,
`exactSafeAreaUnsettled`); the bake refuses a declared field the source does not have.
`exactDelivery()` includes the string fields `version` and `buildNumber`: the
installed binary's `EXACT_VERSION` and `EXACT_BUILD_NUMBER` at bake time (defaults
`0.1.0` and `1` only when unset). Over-the-air updates leave them unchanged; an
older bake without them answers `""`. The web JS build uses the same variables
at build time, with `""` for each unset variable. Rust-rendered pages read those
values from the web build, including when the server has neither variable set.
`state.delivery` mirrors them. Its boolean `production` is whether the
installed binary was baked with production trust (`EXACT_UPDATE_TRUST=production`:
Apple's `--release`, `--distribution` and `exact release`, Android's `--bundle`,
`host/web/build.mjs --out`; other builds are development ones unless the variable
is set). It is the answer the runner uses to keep agent mode and development
overrides out of a shipped binary, and an over-the-air update cannot change it.
Gate a developer-only control on it, and gate what that control reads as well, so
a production build never asks for it:
`resource overrides = loadOverrides() when not build.production as shape Overrides`.
`exactDelivery()` also carries `refusedReason` (string, `""` when none) and
`refusedSeq` (number, `0` when unknown or none), reporting a typed, non-leaking
code (`"origin"`, `"network"`, `"signature"`, `"rollback"`, `"bad-bundle"`,
`"incompatible"`, `"corrupt"`, `"storage"`, `"boot"`, or `"refused"`) and the
refused candidate's stream sequence when the last update check or boot selection
was refused; both clear once a subsequent check succeeds or activates.

`exactGeometry(id[, space[, node[, regions]]])` reads a node's geometry from the layout
just committed (LLP 1123 D6). `space` is `"owner"` (the default, the document's outside
every content owner), `"window"`, or `"node"` with the `id` of the node whose border box
is the space; `regions` is `"inactive"` to read the inactive reserved regions too, as
UIKit's `includeInactive` does, or empty. Its declared shape chooses what it reads: `available`, `generation`, `size`,
`frame`, `observations` and `margins`. `generation` is the number of the layout the
answer reads, 0 before the first. `observations` has an inset set (`top`, `right`,
`bottom`, `left`) per family: `safeArea`, `keyboard`, `keyboardUndocked`,
`safeAreaCorners`, `layoutMargins`, `layoutMarginsCorners`, `readableContent`,
`readableContentCorners`, `readableContentGuide`, `systemMinimumLayoutMargins` and `bar`.
`margins` has the `layoutMargins`, `readableContent` and `readableContentGuide`
rectangles (`x`, `y`, `width`, `height`). `chrome` is the owner's: `verticalBarEdge`
(`unspecified`, `leading` or `trailing`, UIKit's preferred edge for the iPhone Duo's
vertical bar, shown or not), `sidebarAvailable` (whether the tab controller's sidebar is
available, not whether it shows), `overscan` and the Mac's `auxiliaryTopLeftArea` and
`auxiliaryTopRightArea`; it is `none` outside every owner. `regions` lists the reserved
regions of the node's owner, or of the document: each has an `id`, a `kind` (`division`, the band
along a hinge, or `occlusion`), a `frame` in the space read that includes its `margins`, the
margins, and whether it is `active`; it is `[]` where the host reserves none and `none`
where it has none to report, as before iOS 27.1. `keyboard` has the box's
`guide` (the keyboard's rectangle while one shows, docked or undocked, and while it is
dismissed a rectangle of no height along the box's bottom), the owner's `occupancy` (the
docked keyboard's overlap with the owner, along its bottom), `docked`, and `near` and `away`,
`none` until hosts track them; it is `none` where the host has reported nothing of the
keyboard. Declare every field but `available` and
`generation` an `option`, and each family and rectangle in them too: each is `none`
before the node is laid out and wherever the host does not have it, and the bake refuses
a shape that does not say so. `frame` is the border box as laid out, before the scroll
offsets and transforms above it. In `"window"` it is placed by the map its host reports of
the node's owner, or of the document, into the window, a rectangle under a scaled sheet
scaled with it, and is `none` where the host reports none, as every host does until LLP
1123's activation; it is `none` in a `"node"` space in another owner. Until hosts report an owner's band,
keyboard and margins and the session view's band (LLP 1123 stage 3), a node inside an
owner reads `none` for its safe area and margins and 0 for the keyboard, and one outside
every owner reads 0 for each; on the web every quantity is `none`, and the terminal host
does not deliver the facts. A later layout that changes what it reads answers it again in
a commit of its own, so a branch on it lays out after the layout it read; a chain of such
commits stops after eight, holding the last answer until a layout with another cause, and
a development build alerts `geometry-feedback`. The bake refuses a path from a geometry
fact to what moves the geometry it reads (`bake-geometry-feedback`): any route's
`navigation*` attributes, its bar (its first `header`) and a branch before that header,
the root's tab bar, a toolbar the host places, the system bars, a write of the router's
slot, a popover, a sheet's detents, a picker, full screen, picture in picture or sharing,
a scroll position or snap, `scrollIntoView`, focus, and the window's fitting or
orientation. The path may be direct or run through a branch, a `display` or a class that
hides the node, a `for` key, a derive, a resource, state, a mutation, a child's prop, or
an action that runs without the person: a task's, a sequence's `ended=`, that of an event
the person does not make, such as an image's `load`, or that of a layout event (`resize`,
`intersect`, `reachstart`, `reachend`, `transformgeometry`), which runs on the fact
whenever the view reads one. An action the person runs, by a press, a key, a scroll or
focus, may read a fact, as a UIKit app chooses a popover or a sheet by its width when a
button is pressed: it runs once per event, so it cannot feed back. A fact may decide
content: sizes, text and which content shows. A report that owes no layout, such as a
band no style reads, reaches the facts at the next layout. `exactNativeChain(id)` answers
the native targets of the owner holding the node `id` names, or the session view's outside
every owner, as `entries`: the owner's controller and each `parent` by `number` from 1, then
the related targets (`presenter`, `session`, `root`, `window` and the rest) by `relation`.
Each has `kinds` (`navigation`, `tab`, `split`, `column`), `id`, `generation`, `frame` (its
bounds in its window) and `insets` (its raw safe area in its own coordinates), the last two
`none` while it is unavailable. It answers `available` false, its `entries` `none`, where the
host reported no chain, as no host does yet.
`exactSafeAreaUnsettled()` answers `available`, `count`, the boxes the last layout left
unsettled, and `ids`, the `id`s of those that have one.

A TypeScript-only update currently removes the plan's source-shape requirement
when it pairs the plan with its module. If that update first reads a field of a
reserved source that the installed binary predates, delivery can admit the plan
although the binary cannot answer the field. Release a new native binary and
cohort before pushing the first use of a new reserved-source field. This applies
to every reserved source; a C ABI bump alone does not make the paired plan
require that ABI.

`exactViewport().displayMode` is a string: the current CSS display
mode on the web, `fullscreen`, `window-controls-overlay` (the tall title row
`display_override` asks for) or `standalone` on macOS, `standalone` on other
native hosts. Declare it on the resource's shape; `state.device.displayMode`
reports it too. `prefer display-mode standalone` substitutes it on Apple and
in Chrome, from a page's boot and through a reload, so a test on the web
reaches an app's standalone branch; the browser's own `display-mode` media
query does not change, and Firefox and WebKit refuse the override. This reads the window, not a fullscreen navigation route.
`exactViewport().devicePixelRatio` is `option<number>`: display pixels per
logical point, updated when the display scale changes. It is `none` before a
host reports its scale, including a server render and the terminal. It is the
display's ratio; a game's render scale does not change it.
`safeAreaTop`, `safeAreaRight`, `safeAreaBottom` and `safeAreaLeft` are numeric
logical points with the same document-inset meaning as `env(safe-area-inset-*)`:
on native hosts they are the device insets under `viewport-fit="cover"` and `0`
under `auto` (use `var(--exact-safe-area-inset-*)` for container-local chrome
insets; see [Length calculations and safe areas](https://exact.expo.dev/learn/contract-for-agents/css-layout-and-painting.md#length-calculations-and-safe-areas)).
`segments` is a list of rectangles with numeric `x`, `y`, `width` and `height`
fields in the layout viewport's coordinates, ordered by row then column. With
no hinge it contains the whole viewport. Declare the fields your app uses in a
segment shape and `segments: Segment[]` in its viewport shape. Insets and
rectangles update when the host's document geometry changes, in the same commit
as the size a rotation brings.
`keyboardHeight` is how much of the layout viewport the software keyboard covers,
in logical points, before the page avoids it, whatever `interactive-widget` says:
CSS's `env(keyboard-inset-height)`. It is the keyboard's layout guide on iOS (a
dialog sheet's field included, though the page under the sheet is not avoided and
the agent's `layout.env` then says 0), the IME's inset on Android, and on the web
`navigator.virtualKeyboard.boundingRect` where the page overlays the keys, else how
far the visual viewport falls short of the layout viewport's bottom
(`innerHeight - visualViewport.height - visualViewport.offsetTop`). Under
`resizes-content` without the VirtualKeyboard API the keys shrink the page itself
(its `height` is the shorter one) and nothing covers it: 0. It is 0 with no
keyboard, and on macOS, desktop Linux and Windows. It changes in the commit
that shrinks the viewport, so `height + keyboardHeight` holds still while the keys
move. With a hardware keyboard iOS still shows a short bar of its own, and this is
its height: a row of the app's own on the keys that suits only a software keyboard
tests a height (`when viewport.keyboardHeight >= 120`). A `row role="toolbar"
toolbarPlacement="keyboard"` at the bottom of the page or of a sheet route sits on
the keys under every `interactive-widget`: a sheet's layout ends at the keys while
its field has the focus, whatever the root says; on the page, `overlays-content`
lifts the toolbar onto them and `resizes-content` ends the page there. Because it lifts
the authored row without painting a full-width strip of its own, author a floating glass
capsule directly inside it (for example a transparent toolbar holding a pill with
`backgroundMaterial="glass"` and `border-radius`).
On iOS a scroller's `-exact-keyboard-dismiss-padding: <length>` starts the keyboard
following a finger that drags the scroller in an interactive `keyboardDismissMode`
that far above the keys: give a transcript its composer's height, and the keyboard
and the composer go down together under the finger. Unsaid it is 0, as in UIKit and
SwiftUI; Android and the web read no padding.

`exactViewport().pointer` and `.hover` are CSS's `pointer` (`fine`, `coarse`,
`none`) and `hover` (`hover`, `none`) for the primary input: the web's media
queries; `fine` and `hover` on macOS, Linux and Windows, and `coarse` and `none`
on Android's touch screen and on a Linux one with no mouse or touchpad, read once
at launch; on iOS `coarse` and `none`, or `fine` and
`hover` while an iPad has a trackpad or mouse attached; `none` and `none` on tvOS
and on Android TV.
They change while the app runs. Show a game's on-screen stick under `coarse`
(the starter does, `game/recipes/touch-controls.md`), never by platform. The web's
neutral look sizes its own controls for a touch device instead (`any-pointer:
coarse`: any coarse input, normally a touch screen), so they keep their size
while an iPad's trackpad comes and goes. Under the agent each is the device
class's from launch; `prefer pointer coarse` and
`prefer hover none` substitute them. Chrome emulates a touch screen, so it takes
`coarse` with `none` and `fine` with `hover`, and refuses `pointer none`; the
Firefox and WebKit carriers refuse both.
`exactViewport().accessibilityTextSize` is true while the person's text size is one
of iOS's accessibility sizes (AX1 to AX5, UIKit's `isAccessibilityCategory`), where
UIKit's own views drop decoration and stack what sat side by side; it is an Exact
fact, not a CSS media feature, read wherever Exact draws with UIKit's metrics (iOS,
iPadOS, tvOS, visionOS, watchOS), and also true on Android at `Configuration.fontScale >= 1.3`, Exact's convention
for Android's large-text range. It reads the system setting independently of any
root font the app authors. It is false on the Mac, Linux, Windows and the web.
`EmptyState` drops its symbol then. Under the agent on iOS, `prefer root-font-size
28` (Dynamic Type's AX1 body) or more sets it. That `prefer` sets only the size of the
text Exact draws: UIKit's own text, a native field's among them, keeps the simulator's
text size. To see a screen at the largest size, as `verify` does, set the simulator's:
`xcrun simctl ui <udid> content_size accessibility-extra-extra-extra-large`. With no
size, `content_size` prints the current one: set it back after.
`exactViewport().screenReader` is a string: `"on"`, `"off"` or `"unknown"`, live
as the system reading changes and refreshed on resume (LLP 1039 D10). Apple reads
VoiceOver; Android reads touch exploration, a proxy for TalkBack or another screen
reader; Windows reads `SPI_GETSCREENREADER`. The web, the terminal, the renderer
and Linux without detection report `"unknown"`. `"off"` means the platform reported
it off; it never means detection was unavailable.
Use this fact to pause disruptive self-updating content, such as rolling text or
auto-advance, never to select a separate reduced UI. Pause on `"on"`, and treat
`"unknown"` as possibly on for optional rotation. Keep the same content accessible
and offer manual advance. Reduced motion is an independent reason to pause.
Declare `screenReader: string` on the viewport shape. The agent's
`prefer screen-reader on|off|unknown` substitutes it;
`state.device.screenReader` reports it even without a resource.
See [a rolling stat](https://exact.expo.dev/recipes/rolling-stat.md).

`exactViewport().gpuTier` is `low`, `mid` or `high`: how much GPU work a frame can
afford, chosen once before the GPU device is made from what the adapter reports
(a phone GPU of the Adreno 600 class is `low`), else from the screen (a phone-sized
one `low`, a computer's `high`), never from a measured frame time; a phone-sized
screen is never `high`, nor is any iOS or Android device natively. A game's renderer follows it (`Game::quality`); a HUD can
read it to offer a quality setting. A native host answers its GPU module's tier
once the module loads (`high` before it). Under the agent it is `high` from launch, and
`prefer gpu-tier low` substitutes it and remakes each world's renderer at its rung.
`exactPage().platform` identifies the host from the first frame. Declare
`platform: string` or an enum over the following values in the page resource's shape.
The native hosts report
`ios`, `macos`, `tvos`, `watchos`, `android`, `linux` or `windows`.
A browser or server-rendered web page reports `web`, a terminal app reports
`terminal`, and a runner booted without a host reports `headless`. A browser
on an Android phone therefore reports `web`.

`exactPage` answers `visibilityState`, `frozen`, `onLine`, `canShare`,
`canShareFiles` and `canSharePictures` (whether `share(files=…)` takes
`app:/` files and an element's `"#id"`; the web never takes a picture),
`canOpenFiles`, `name` (the window's name: `main` in the app's first window on
every host, a link's `target` in the window it opened, empty in a `_blank` one;
every window runs the root's tasks, so `task t when page.name == "main"` runs
once however many are open), and `hasFocus` (`document.hasFocus()`: the app's window has the
system's focus; false while another app or window is in front, so an app can
choose an in-window message over a system notification), `persisted` and
`restores` (the back/forward cache: `persisted` is true while the page is put
away, from a `pagehide` with `persisted` until the `pageshow`; `restores`
counts those `pageshow` events, so `task t when page.restores > 0
key=page.restores` runs once for each return, never at launch; a Mac or Windows
window a `keepRunning` close hid is put away, a minimized one only hidden), and
`presented` (below). A reminder that should
open a route uses `showNotification(title="Done", navigate="/thread/42")`
(`@exact/notifications`); its click reaches the navigation root as a warm
`navigate` event or a cold launch location, and without `navigate=` it is
`notificationclick` on the root. Under the agent `state.notifications` lists
each post, and `tap @ref` clicks one. Under the agent each
is the drive's (`prefer has-focus false`; `state.device`). Use dimensions,
media preferences, page facts,
and capability state rather than suffixing files by platform. Preference facts
inform authored policy; the engine does not automatically remove all motion.

`frozen: bool` means the host has entered a lifecycle state in which ordinary
work is subject to stopping until execution resumes. The runner immediately
applies the transitions defined for that fact. Gate a feed with `when not
page.frozen`: its resource or stream goes in the commit that turns `frozen`
true, without waiting for an authored cleanup handler. A sequence stops in that
commit too (LLP 1125 D4). The fact is not itself a process pause, and it is not a
phone or desktop label: `visibilityState` can be hidden while `frozen` stays
false.

On both web targets, the transition into `frozen` also settles physical output
still waiting for presentation, whether it came from a sequence or a standalone
command. Sound plays, haptics, note-ons, MIDI Start, Continue and Timing Clock
are discarded. Sound stops, note-offs, all-notes-off and MIDI Stop are delivered
in order before suspension. Returning does not restore a discarded start.

| Host | `frozen` producer |
|---|---|
| Web (both targets) | Page Lifecycle `freeze`/`resume` on `document`, where fired; false elsewhere |
| Android | Stopped activity without a promoted foreground service carrying a live claim or playing media |
| Linux desktop | Constant false |
| Windows desktop | Constant false |
| iOS and tvOS | Background without active audio eligible for background execution; an idle playback category grants nothing |
| macOS | Constant false |
| watchOS | Constant false: the live watch driver has no page lifecycle producer yet |
| Terminal and render hosts | Constant false |

A browser promises nothing after `hidden`: it may stop or discard a page without
a `freeze` event. False does not promise continued execution. Persist data as it
changes; do not depend on a final asynchronous cleanup. The bake and an agent
launch answer false; `prefer frozen true` substitutes the fact and its defined
transitions, and `prefer frozen false` resumes them. The drive's clock and host
pump continue: timers, replies, hatch callbacks and native announcements can
still run. Qualify process suspension on a real host, outside a drive. See the
[feed recipe](https://exact.expo.dev/recipes/suspending-feed.md).

`presented: bool` is true from the present of the page's first picture: the
moment a person can first see it, and the moment the animations its first commit
began start, since every host starts a commit's new animations at the present of
the first frame that shows them. Time anything else from it, such as a launch
splash's minimum display time (`task hide when page.presented` running
`after(600, done)`), not from mount: on an Android cold launch the first frame
can reach the screen hundreds of milliseconds after the first commit. It stays
true for the page's world; a dev reload or an activated update starts it false
again, and hiding, freezing or the back/forward cache never clear it. It is true
at the first commit under the agent, headless and in the render host, where
nothing presents; `prefer presented false` holds it false so a drive can watch
what waits on it, and moves no animation. The bake answers false.

Leave navigation presentation to the host first: a root `tablist` becomes UIKit's
tab bar on iOS and a sidebar on macOS, and `navigationPresentation` chooses a
route's presentation. Neither pointer coarseness nor `frozen` identifies a phone.

`exactCanvasPerformance("world")` is an opt-in, read-only metrics resource for
that named canvas. Declare only the fields your HUD needs, each as an option:

```contract
shape Metrics
  frames: option<number>
  cpuEncodeMs: option<number>
  gpuMs: option<number>
component App
  resource metrics = exactCanvasPerformance("world") as shape Metrics
  view
    canvas surface=world
```

A canvas without an active metrics resource does no HUD reporting work. A resource
whose `when` condition is false collects nothing. Snapshots arrive at most
once per second while the canvas is visible, including while it is idle. Before
its first snapshot, after disposal, and for unsupported measurements, fields are `none`. Values
never enter kept answers, world saves, replay or simulation hashes.

Numeric fields are `pixelWidth`, `pixelHeight`, `renderScale`, `devicePixelRatio`,
`effectivePixelRatio`, `samples`, `draws`, `triangles`, `instances`, `frames`,
`fps`, `windowMs`, `lateFrames`, `missedFrames`, `longestGapMs`, `maxFps`,
`cpuTickMs`, `cpuFeedMs`,
`cpuEncodeMs`, `cpuSubmitMs`, `gpuMs`, and each CPU/GPU duration's `MaxMs`
variant (`cpuTickMaxMs`, for example). Durations and gaps are milliseconds;
frame counters cover the sampling window and draw counters describe its latest
submitted frame. `fps` is the submitted-frame count over the monotonic wall time
between snapshots (`windowMs`); an idle window reports zero. The first snapshot
and a window driven by the agent's virtual clock leave FPS unavailable.
`processMemoryBytes`, `gameHeapBytes`, `textureMemoryBytes` and
`geometryMemoryBytes` are optional byte counts. `audioState`, `thermalState`
and `quality` are optional strings; `idle` is an optional boolean. Hosts and
surfaces report only measurements they actually support. The game renderer
reports render dimensions, scale, samples, draw counts, frame pacing, CPU
tick/feed/encode durations, and on every host: `quality`, the resolved rung
(`low`, `mid`, `high`) once a binding resolved it; `maxFps`, the frame cap in
force, `none` when the canvas draws at the display's rate; and `idle`, true
while the canvas asks for no frames until something changes (a world at rest
or paused; `none` under the agent's virtual clock). On Apple and Android,
`thermalState` is the last drawn live frame's `nominal`, `fair`, `serious` or
`critical` (Android moderate is `serious`). It is `none` without a reading in
the snapshot window, and always `none` on the web, Linux and Windows. Memory, in bytes:
`processMemoryBytes` is the process's footprint (`phys_footprint` on Apple, the
resident set on Linux and Android), `none` on the web and Windows;
`gameHeapBytes` is the GPU module's linear memory on the web, the simulation's
and renderer's heap, and `none` natively, where that heap is the process's;
`textureMemoryBytes` counts the delivered textures the renderer holds on the
device, retired ones awaiting compaction included (render targets are not
counted) and `geometryMemoryBytes` the renderer's
vertex and index buffers, on every host once the renderer exists.
`audioState` is a game's audio output where its host gives it one (the web,
Apple, Windows): `running`, `suspended` (hidden, or waiting for a gesture),
`interrupted` (suspended by the host's interruption: a call or alarm on iOS,
the window losing focus on Windows) or `closed` (no device: under the
agent's virtual clock, or not yet opened); `none` on the Linux family and for
a game without audio. `gpuMs` and `gpuMaxMs` are the mean and longest GPU
execution of the window's frames, from the first pass's start to the last
pass's end by GPU timestamps, read back a frame or two late: on Metal natively
(macOS, iOS, tvOS), on the web only where the browser grants
`timestamp-query`, and on the Linux family and Windows where the adapter has
timestamp queries; `none` elsewhere and for a window with no sample. A canvas
writes timestamps only while a plan reads the resource (or the agent's `perf`
is armed). `cpuSubmitMs` and
`cpuSubmitMaxMs` are the mean and longest wall time of the queue submission of
the frames the canvas drew in the window, on every host (on Apple the
submission also schedules the frame's presentation); a frame shared by several
canvases is one submission, which each of them reports. The 16 KiB snapshot limit is separate from the public surface
record's limit.

A GPU HUD can show its last successful publication while its world loads:
`resource hud = exactSurface("world") as shape Hud keep`. Only a successful
live publication is kept; defaults, refused publications and disposal do not
replace it. The saved value stands until the first live publication. A changed
surface name or incompatible declared shape discards it. Removing `keep` starts
from the shape's defaults again. Each kept answer has the data-resource limit
of 256 KiB, including its identity and shape, and shares the bounded launch
cache. Other host facts, including canvas performance, cannot opt in.

`exactSurface(name)` is the host's channel for read-only facts about where
the app is running, not only for a GPU surface's published record. The
terminal host publishes `exactSurface("terminal")` (`mode`, `images`,
`colors`, `log`, which counts the `role="log"` nodes it has seen, and
`printed`, the `id` of that log's last child it wrote to scrollback), and an inline app retires printed entries from it (LLP 1101.001
P1; `apps/harness/terminal.contract` shows the task). Declare its shape
(`resource terminal = exactSurface("terminal") as shape Terminal`); on any
other host it stays unloaded. A new host fact uses this channel before
anyone proposes a new reserved source (LLP 1101.002 §0 P11).

A GPU canvas's record (`canvas surface=world()`, read as `exactSurface("world")`)
carries one host fact beside what its module publishes: `presented`, true once a
complete frame of the canvas's current picture has been handed to the compositor,
on every host. It is false until then, and again after a restore, a restarted
world, a lost GPU device or a new target, until the next such frame. It changes
only at those moments, never per frame. Keep a loader over the canvas until it is
true; a record that says the world is set up is not proof that a frame has
drawn. A module cannot publish a field of that name. A surface may have more
than one live canvas, on two routes at once: each runs a world of its own, and
the record is the first live canvas's.

```contract
shape Table
  presented: bool

component App
  resource table = exactSurface("world") as shape Table
  view
    main width="100%" height="100%"
      canvas surface=world() width="100%" height="100%" position="relative"
        if !table.presented
          text "Setting the table" position="absolute" inset=0 aria-busy=true
```

The terminal's `colors` is the selected output bit depth: `0` (monochrome),
`4` (16 ANSI colours), `8` (256 colours), or `24` (RGB). The host reduces
authored colours to that palette; at zero it emits no foreground/background
colour codes, while preserving bold, underline, italic and reverse-video
focus. Images use alternate text in monochrome. Authors can choose different
content, symbols or emphasis rather than relying on colour alone:

```contract
shape Terminal
  colors: number
component App
  resource terminal = exactSurface("terminal") as shape Terminal
  view
    column
      if terminal.colors == 0
        text "! Attention required" font-weight=700
      else
        text "Attention required" color="#d78700"
```

Interactive and headless CLI runs detect the palette from `TERM` and
`COLORTERM`. Nonempty `NO_COLOR` disables colour (including `NO_COLOR=0`);
empty `NO_COLOR` does not. `TERM=dumb`, `unknown`, an absent terminal type
without a colour hint, and unrecognized terminal types fall back to monochrome.
This is conservative environment detection, not a terminal capability query.
Use `--color auto|never|16|256|truecolor` on any terminal app or `exact-terminal`
to override it (`always` means `truecolor`; `--color=never` also works).
An explicit choice overrides `NO_COLOR`. The `--drive` verbs `print` and
`document` always write text; the selected palette also applies to `.ans`
screenshots. Run once from a shell (`--print`), `auto` writes SGR only to a
terminal, and `never` writes plain text, a picture as its alt text. A Rust
embedder may call `Host::set_colors(ColorDepth::Monochrome)` before starting
the loop or emulator; direct painting and `Vt` otherwise default to RGB for
deterministic tests.

A `text` inside a paragraph can carry `press=` (a `span`'s `onclick`) and
`href=` (an `a`). In the terminal a click on the run runs its
handler; without one (and on every host for `href`) it follows the link: a path naming one of the app's routes is `navigate` on the
navigation root, and an `http`, `https`, `mailto` or `tel` URL leaves the app,
as `openURL` does. An app without routes that wants a run to act in the app
(the LLP reader's cross-references) gives the run `press=`. In a terminal the
mouse is the app's only full screen or while a dialog is open; inline, ⌘-click
on the run's link is the terminal's own.

Localized strings use `t("key", name=value)` and app `strings/<locale>.json`
files. Compile against the files to check keys and placeholders. A language
setting calls `setLocale("de")` (`setLocale("")` for System) in its action; the
choice is kept across launches and read before the first frame. The web JS build
keeps the base table in the entry. When the other tables together reach 4 KiB
gzipped, it fetches each by language. A change takes effect when the table
arrives. A failed change keeps the current language and writes a journal line.
A failed launch fetch uses the base table on an empty shell. A rendered page keeps its
text and direction until the client has both a usable table and the rendered answers.
The head requests the chosen table alongside the entry. If the translation stalls, a client-only
page with its entry loaded shows the default language five seconds after launch and switches
when the reader’s language arrives. A rendered page reveals its existing text at the same
deadline, even while its checkpoint is pending. The journal records the wanted language, the
language on screen and the reason for a fallback. A failed checkpoint or missing table for the rendered language can retry
when the reader activates the page or reconnects. Formatting
functions accept a narrow set of literal formats; app wording is an app `fn`.
On Apple platforms the tables are the bundle's localizations, base first, so the
system's own words follow the table it picks. On the Mac a direction you leave
unsaid is AppKit's process direction: an Arabic table on an English Mac leaves
the window and panes left to right, and `state` reports `language.dir` as `ltr`.
Set `host.macos.layoutDirection: "rtl"` in `app.json` to mirror the whole window,
including the split view, toolbar and sidebar, even with an English table.
Omission or `"auto"` keeps AppKit's direction; a launch argument naming either
`AppleTextDirection` or `NSForceRightToLeftWritingDirection` takes precedence.
Elsewhere the direction is the table's. A `direction` you write
wins on every host. `language.dir` is the layout direction: on the Mac, text
under no written `direction` takes each paragraph's base direction from its
first letter, as an `NSTextField` does, so an Arabic sentence in a left-to-right
window keeps its full stop at its own end and stays aligned to the start.
Writing `direction` fixes the base of all text under it, so do not write it to
move a full stop (Markdown text keeps the layout direction). Because the Apple
binary lists its languages, adding or dropping a table other than an app's only
one is a new binary there; editing a translation still ships as an update.

### Folds on iOS

`exactViewport().devicePosture` and the viewport segments are the web's
([foldables](https://exact.expo.dev/recipes/foldables.md)). On the iOS 27.1 simulator UIKit moves an alert
(an `alertdialog` with text) off the hinge whichever way the phone is folded, and a page
or form sheet (a sheet route or a modal `dialog`) when it is folded like a book, the
hinge down the screen: an alert to the middle of the left segment and a page or form
sheet to that segment, its right edge about 12 points into the band (measured in
left-to-right text). Folded like a laptop, the hinge across the screen, an alert moves
to the bottom segment, while a page or form sheet still spans the hinge. The tab bar
stays clear of the hinge either way. [Apple's adaptive-layout
talk](https://developer.apple.com/videos/play/tech-talks/111463/) says instead that
alerts move to the trailing side when the phone is folded like a book and can move to
the top when it is folded like a laptop, and that action sheets, menus and popovers move
clear too, which was not measured.

A route moved off a window edge is still padded as if it reached it: its top when the
phone is folded like a laptop, and its right on segment 0 when it is folded like a book.
