# songstress/ui

> The reader every app reads your declared interface with, its caps, and Songstress's icon set.

Page: https://songstress.app/docs/develop/reference/ui/

See [the declared interface](/docs/develop/interface/). Every app reads what your renderers answer with this reader:
`readScreen`, `readPanel`, `readStatus` and `readAction` keep what Songstress draws of a tree, keep a node they do not
know as `{ type: "unknown" }` ("needs a newer app"), and refuse a tree over `UI_CAPS`. Read your trees with them in
your tests: a tree they keep whole is drawn as you wrote it.

An `icon` anywhere in a manifest or a tree is any name in the form of an id: the names of `ICON_NAMES` are drawn by
every app with a glyph of its own, and any other name is drawn as the extension mark. Your editor offers these names
first wherever the SDK types an icon (`IconName`).

`songstress/ui` imports nothing else, so an app or a test takes it alone.

What it exports is the SDK's own record of its public surface, which the SDK's tests hold to the code. Each type's
fields, every description and every function's usage example are read from the SDK's source when the site is built, and
each example is compiled against the SDK by its tests.

It also exports, as the modules that declare them document them: [KnownIconName](/docs/develop/reference/songstress/#type-KnownIconName), [UI_VERSION](/docs/develop/reference/songstress/#type-UI_VERSION), [ViewEvent](/docs/develop/reference/view/#type-ViewEvent), [ViewImage](/docs/develop/reference/view/#type-ViewImage), [ViewTheme](/docs/develop/reference/view/#type-ViewTheme).

### ALIGNS

How a stack's or a box's children line up across it.

```ts
export declare const ALIGNS: readonly ('start' | 'center' | 'end' | 'stretch')[];
```

### AlbumItem

An album of the library: an `album` node.

```ts
export declare const AlbumItem: import("./types").SdkComponent<LibraryItemProps>;
```

Example:

```tsx
import { AlbumItem, Shelf } from 'songstress/ui'

const albumIds = ['al-1', 'al-2']
const albums = <Shelf title="Albums">{albumIds.map((id) => <AlbumItem key={id} id={id} />)}</Shelf>
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [LibraryItemProps](/docs/develop/reference/ui/#type-LibraryItemProps).

### ArtistItem

An artist of the library: an `artist` node.

```ts
export declare const ArtistItem: import("./types").SdkComponent<LibraryItemProps>;
```

Example:

```tsx
import { ArtistItem, Shelf } from 'songstress/ui'

const artists = (
  <Shelf title="Artists">
    <ArtistItem id="ar-1" />
    <ArtistItem id="ar-2" />
  </Shelf>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [LibraryItemProps](/docs/develop/reference/ui/#type-LibraryItemProps).

### AssetSize

One of the package's own images, as the extension's entry in the server's
contributions list names it: what a reader checks a sprite's frames
against.

| Field | Type | Description |
|---|---|---|
| `path` | `string` | Its path in the package, as `contributes.assets` declares it. |
| `width` | `number` | Its width, in pixels. |
| `height` | `number` | Its height, in pixels. |

### AsyncState

What `useAsync` holds.

| Field | Type | Description |
|---|---|---|
| `data` | `Data \| undefined` | What the function answered last, for these deps; undefined before. |
| `error` | `unknown` | What it threw or rejected with, if it did. |
| `loading` | `boolean` | It is on its way. |
| `reload` | `() => void` | Asks again, for the same deps: what a "Try again" does. |

`reload`, for example:

```ts
import { Button, Text, useAsync } from 'songstress/ui'
import { songstress } from 'songstress/client'

export function Plays() {
  const plays = useAsync(() => songstress.storage.get<number>('plays'), [])
  if (plays.error) return <Button title="Try again" onPress={() => plays.reload()} />
  return <Text>{`${plays.data ?? 0} plays`}</Text>
}
```

### Badge

A short word in a pill: a `badge` node. Its words are its children, or
`text`.

```ts
export declare const Badge: import("./types").SdkComponent<BadgeProps>;
```

Example:

```tsx
import { Badge } from 'songstress/ui'

const fresh = <Badge tone="success">New</Badge>
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [BadgeProps](/docs/develop/reference/ui/#type-BadgeProps).

### BadgeProps

A `Badge`'s props: its words are its children joined, or `text`.

| Field | Type | Description |
|---|---|---|
| `text?` | `string \| undefined` | The words, when there are no children. |
| `children?` | `UiNode` | The words. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `tone?` | `Tone \| undefined` | Its colour, by meaning. |

Refers to [BadgeBlock](/docs/develop/reference/songstress/#type-BadgeBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Box

A surface around blocks: a `box` node, `plain`, the app's `card`, or a
quiet `inset`.

```ts
export declare const Box: import("./types").SdkComponent<BoxProps>;
```

Example:

```tsx
import { Box, Text } from 'songstress/ui'

const week = (
  <Box variant="card" padding="medium" gap="xsmall">
    <Text style="label">This week</Text>
    <Text style="title">42 plays</Text>
  </Box>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [BoxProps](/docs/develop/reference/ui/#type-BoxProps).

### BoxProps

A `Box`'s props.

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | What it holds, top to bottom. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `variant?` | `"card" \| "inset" \| "plain" \| undefined` | Left out, "plain". |
| `padding?` | `Space \| undefined` | Room inside it. Left out, none for plain, the app's own for card and inset. |
| `gap?` | `Space \| undefined` | Room between its children. Left out, "medium". |
| `align?` | `"center" \| "end" \| "start" \| "stretch" \| undefined` | How its children line up across it. Left out, "stretch". |

Refers to [BoxBlock](/docs/develop/reference/songstress/#type-BoxBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Button

A button: a `button` node, `onPress` its `action`.

```ts
export declare const Button: import("./types").SdkComponent<ButtonProps>;
```

Example:

```tsx
import { Button, Text, useState } from 'songstress/ui'

function Counter() {
  const [count, setCount] = useState(0)
  return (
    <>
      <Text>{`Pressed ${count} times`}</Text>
      <Button title="Add one" icon="add" emphasis="primary" onPress={() => setCount((was) => was + 1)} />
    </>
  )
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ButtonProps](/docs/develop/reference/ui/#type-ButtonProps).

### ButtonProps

A `Button`'s props. Its look is `emphasis`; vocabulary 2's `style` is
left out.

| Field | Type | Description |
|---|---|---|
| `onPress` | `Handler<void>` | What pressing it does. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title` | `string` | The button's label. |
| `icon?` | `IconName \| undefined` | An icon from Songstress's icon set. |
| `emphasis?` | `Emphasis \| undefined` | How much it asks to be seen. Left out, from `style`, else "secondary". A page has at most one primary button. |
| `busy?` | `boolean \| undefined` | Work it started is going on: it shows a spinner and cannot be chosen. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be chosen. |

Refers to [ButtonBlock](/docs/develop/reference/songstress/#type-ButtonBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Callout

A banner: a notice across the top of a block, in a tone, with one
button at most: a `banner` node. Its button is `buttonTitle` and
`onPress`.

```ts
export declare const Callout: import("./types").SdkComponent<CalloutProps>;
```

Example:

```tsx
import { Callout } from 'songstress/ui'

const down = <Callout tone="warning" title="The lyrics service is down" text="Lyrics come back when it does." buttonTitle="Try again" onPress={{ type: 'refresh' }} />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [CalloutProps](/docs/develop/reference/ui/#type-CalloutProps).

### CalloutProps

A `Callout`'s props: its button is `buttonTitle` and `onPress`.

| Field | Type | Description |
|---|---|---|
| `buttonTitle?` | `string \| undefined` | The button's label. |
| `onPress?` | `Handler<void> \| undefined` | What the button does. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `tone` | `"danger" \| "info" \| "success" \| "warning"` | Its colour, by meaning. |
| `title` | `string` | What the banner says. |
| `text?` | `string \| undefined` | A sentence more. |

Refers to [BannerBlock](/docs/develop/reference/songstress/#type-BannerBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Canvas

Pixels the extension's client code draws: a `canvas` node, its `draw`
called for each frame the app shows (at most 60 a second, none while it is
out of sight). The web and the macOS desktop from 13.3 draw it; elsewhere
the app says what it needs (read `client.capabilities.canvas` and draw
something else where it is false). Client code only: the server refuses it.

```ts
export declare const Canvas: import("./types").SdkComponent<CanvasProps>;
```

Example:

```tsx
// tsconfig.json's `types` names "songstress/sandbox/canvas": the drawing types.
import { Canvas } from 'songstress/ui'

// A dot that crosses the canvas every two seconds.
const dot = (
  <Canvas
    height={80}
    description="A dot that moves"
    draw={(context, frame) => {
      const x = ((frame.time % 2000) / 2000) * frame.width
      context.fillStyle = '#e50043'
      context.beginPath()
      context.arc(x, frame.height / 2, 6, 0, Math.PI * 2)
      context.fill()
    }}
  />
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [CanvasProps](/docs/develop/reference/ui/#type-CanvasProps).

### CanvasFrame

A frame a canvas is asked for: its laid-out size in whole points, the
device pixels a point, and the milliseconds since it first drew.

| Field | Type | Description |
|---|---|---|
| `width` | `number` | Its width, in points: what `draw` draws in. |
| `height` | `number` | Its height, in points. |
| `pixelRatio` | `number` | Device pixels a point, up to 2. A 2D context is already scaled by it. |
| `time` | `number` | Milliseconds since this canvas first drew. |

### CanvasPointer

The pointer over a canvas, as its `onPointer` is told.

| Field | Type | Description |
|---|---|---|
| `kind` | `"cancel" \| "down" \| "enter" \| "leave" \| "move" \| "up"` | What happened. |
| `x` | `number` | From the canvas's left, in points. |
| `y` | `number` | From the canvas's top, in points. |
| `buttons` | `number` | The buttons held, as a pointer event's `buttons`. |
| `pointer` | `"mouse" \| "pen" \| "touch"` | What points. |

### CanvasProps

A `Canvas`'s props: a 2D canvas (the default) or a WebGL 2 one, and the
function that draws each frame. The canvas is clear at the start of every
`draw`: draw the whole picture each time.

```ts
export type CanvasProps = (CanvasBase & {
    context?: '2d';
    draw: (context: OffscreenCanvasRenderingContext2D, frame: CanvasFrame) => void;
}) | (CanvasBase & {
    context: 'webgl2';
    draw: (context: WebGL2RenderingContext, frame: CanvasFrame) => void;
});
```

Refers to [CanvasFrame](/docs/develop/reference/ui/#type-CanvasFrame).

### Checkbox

On or off, as a checkbox: a `checkbox` node, told a boolean.

```ts
export declare const Checkbox: import("./types").SdkComponent<CheckboxProps>;
```

Example:

```tsx
import { Checkbox, useState } from 'songstress/ui'

function Intros() {
  const [skip, setSkip] = useState(true)
  return <Checkbox label="Skip intros" value={skip} onChange={setSkip} />
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [CheckboxProps](/docs/develop/reference/ui/#type-CheckboxProps).

### CheckboxProps

A `Checkbox`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<boolean> \| undefined` | Told whether it is now ticked. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `help?` | `string \| undefined` | A line of help under it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `value` | `boolean` | Whether it is ticked. |

Refers to [CheckboxBlock](/docs/develop/reference/songstress/#type-CheckboxBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Collapsible

Blocks a tap opens and closes: a `collapsible` node. With `onChange`, it
is open exactly when `open` says.

```ts
export declare const Collapsible: import("./types").SdkComponent<CollapsibleProps>;
```

Example:

```tsx
import { Collapsible, Text, useState } from 'songstress/ui'

function Credits() {
  const [open, setOpen] = useState(false)
  return (
    <Collapsible title="Credits" open={open} onChange={setOpen}>
      <Text>Recorded in one take.</Text>
    </Collapsible>
  )
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [CollapsibleProps](/docs/develop/reference/ui/#type-CollapsibleProps).

### CollapsibleProps

A `Collapsible`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<boolean> \| undefined` | Told `true` or `false` when the person opens or closes it. |
| `children?` | `UiNode` | What it holds, shown open. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title` | `string` | What shows while it is closed. |
| `open?` | `boolean \| undefined` | Open at first; with `onChange`, open exactly when this says. |

Refers to [CollapsibleBlock](/docs/develop/reference/songstress/#type-CollapsibleBlock), [Handler](/docs/develop/reference/ui/#type-Handler), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Cover

The cover of something in the library: a `cover` node.

```ts
export declare const Cover: import("./types").SdkComponent<CoverProps>;
```

Example:

```tsx
import { Cover } from 'songstress/ui'

const art = <Cover of="album" id="al-1" size="large" description="Kind of Blue" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [CoverProps](/docs/develop/reference/ui/#type-CoverProps).

### CoverProps

A `Cover`'s props.

```ts
export type CoverProps = Own<CoverBlock>;
```

Refers to [CoverBlock](/docs/develop/reference/songstress/#type-CoverBlock).

### DatePicker

A day: a `date-picker` node, told the day as YYYY-MM-DD.

```ts
export declare const DatePicker: import("./types").SdkComponent<DatePickerProps>;
```

Example:

```tsx
import { DatePicker, useState } from 'songstress/ui'

function Since() {
  const [since, setSince] = useState('2026-11-01')
  return <DatePicker label="Since" value={since} maximum="2026-12-31" onChange={setSince} />
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [DatePickerProps](/docs/develop/reference/ui/#type-DatePickerProps).

### DatePickerProps

A `DatePicker`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<string> \| undefined` | Told the day chosen, as YYYY-MM-DD. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `help?` | `string \| undefined` | A line of help under it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `value?` | `string \| undefined` | The day chosen, as YYYY-MM-DD. Left out, none. A day that is no real day of the calendar (`2026-02-30`, `9999-99-99`) is left out, here and in `minimum` and `maximum`. |
| `minimum?` | `string \| undefined` | The earliest day it takes, as YYYY-MM-DD. |
| `maximum?` | `string \| undefined` | The latest day it takes, as YYYY-MM-DD. |

Refers to [DatePickerBlock](/docs/develop/reference/songstress/#type-DatePickerBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Divider

A line between blocks: a `divider` node.

```ts
export declare const Divider: import("./types").SdkComponent<DividerProps>;
```

Example:

```tsx
import { Divider, Stack, Text } from 'songstress/ui'

const parts = (
  <Stack gap="small">
    <Text>This week</Text>
    <Divider />
    <Text>Last week</Text>
  </Stack>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [DividerProps](/docs/develop/reference/ui/#type-DividerProps).

### DividerProps

A `Divider`'s props.

```ts
export type DividerProps = Own<DividerBlock>;
```

Refers to [DividerBlock](/docs/develop/reference/songstress/#type-DividerBlock).

### DrawnBanner

A banner, its button as an app draws it.

```ts
export type DrawnBanner = Omit<BannerBlock, 'button'> & {
    button?: HandledButton;
};
```

Refers to [BannerBlock](/docs/develop/reference/songstress/#type-BannerBlock), [HandledButton](/docs/develop/reference/ui/#type-HandledButton).

### DrawnBlock

What a detail page, a section and a panel are built from.

```ts
export type DrawnBlock = DrawnStack | DrawnSection | DrawnCollapsible | DrawnShelf | TextBlock | IconBlock | ImageBlock | BadgeBlock | ProgressBlock | DrawnBanner | DividerBlock | SpacerBlock | DrawnButton | DrawnMenu | LibraryItem | DrawnGridBlock | DrawnBox | DrawnTabs | ProseTextBlock | SpriteBlock | CoverBlock | DrawnEmpty | SkeletonBlock | DrawnIconButton | DrawnSwitch | DrawnCheckbox | DrawnSlider | DrawnSelect | DrawnSegmented | DrawnTextField | DrawnSearchField | DrawnDatePicker | DrawnListBlock | DrawnTable | DrawnTreeBlock | PlayButtonBlock | DrawnMediaCard | DrawnCanvas | UnknownNode;
```

Refers to [DrawnStack](/docs/develop/reference/ui/#type-DrawnStack), [DrawnSection](/docs/develop/reference/ui/#type-DrawnSection), [DrawnCollapsible](/docs/develop/reference/ui/#type-DrawnCollapsible), [DrawnShelf](/docs/develop/reference/ui/#type-DrawnShelf), [TextBlock](/docs/develop/reference/songstress/#type-TextBlock), [IconBlock](/docs/develop/reference/songstress/#type-IconBlock), [ImageBlock](/docs/develop/reference/songstress/#type-ImageBlock), [BadgeBlock](/docs/develop/reference/songstress/#type-BadgeBlock), [ProgressBlock](/docs/develop/reference/songstress/#type-ProgressBlock), [DrawnBanner](/docs/develop/reference/ui/#type-DrawnBanner), [DividerBlock](/docs/develop/reference/songstress/#type-DividerBlock), [SpacerBlock](/docs/develop/reference/songstress/#type-SpacerBlock), [DrawnButton](/docs/develop/reference/ui/#type-DrawnButton), [DrawnMenu](/docs/develop/reference/ui/#type-DrawnMenu), [LibraryItem](/docs/develop/reference/ui/#type-LibraryItem), [DrawnGridBlock](/docs/develop/reference/ui/#type-DrawnGridBlock), [DrawnBox](/docs/develop/reference/ui/#type-DrawnBox), [DrawnTabs](/docs/develop/reference/ui/#type-DrawnTabs), [ProseTextBlock](/docs/develop/reference/songstress/#type-ProseTextBlock), [SpriteBlock](/docs/develop/reference/songstress/#type-SpriteBlock), [CoverBlock](/docs/develop/reference/songstress/#type-CoverBlock), [DrawnEmpty](/docs/develop/reference/ui/#type-DrawnEmpty), [SkeletonBlock](/docs/develop/reference/songstress/#type-SkeletonBlock), [DrawnIconButton](/docs/develop/reference/ui/#type-DrawnIconButton), [DrawnSwitch](/docs/develop/reference/ui/#type-DrawnSwitch), [DrawnCheckbox](/docs/develop/reference/ui/#type-DrawnCheckbox), [DrawnSlider](/docs/develop/reference/ui/#type-DrawnSlider), [DrawnSelect](/docs/develop/reference/ui/#type-DrawnSelect), [DrawnSegmented](/docs/develop/reference/ui/#type-DrawnSegmented), [DrawnTextField](/docs/develop/reference/ui/#type-DrawnTextField), [DrawnSearchField](/docs/develop/reference/ui/#type-DrawnSearchField), [DrawnDatePicker](/docs/develop/reference/ui/#type-DrawnDatePicker), [DrawnListBlock](/docs/develop/reference/ui/#type-DrawnListBlock), [DrawnTable](/docs/develop/reference/ui/#type-DrawnTable), [DrawnTreeBlock](/docs/develop/reference/ui/#type-DrawnTreeBlock), [PlayButtonBlock](/docs/develop/reference/songstress/#type-PlayButtonBlock), [DrawnMediaCard](/docs/develop/reference/ui/#type-DrawnMediaCard), [DrawnCanvas](/docs/develop/reference/ui/#type-DrawnCanvas), [UnknownNode](/docs/develop/reference/ui/#type-UnknownNode).

### DrawnBox

A box, its children as an app draws them.

```ts
export type DrawnBox = Omit<BoxBlock, 'children'> & {
    children: DrawnBlock[];
};
```

Refers to [BoxBlock](/docs/develop/reference/songstress/#type-BoxBlock), [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnButton

A button, as an app draws it.

```ts
export type DrawnButton = Drawn<ButtonBlock>;
```

Refers to [ButtonBlock](/docs/develop/reference/songstress/#type-ButtonBlock).

### DrawnCanvas

A canvas: pixels the extension's client code draws. It exists in a
mounted tree alone: its `draw` is a function. Its `width` is its own, in
points: left out, it is across its parent.

| Field | Type | Description |
|---|---|---|
| `type` | `"canvas"` | Always `"canvas"`: which kind this is. |
| `height` | `number` | Its height, in points, from 32 to 720. |
| `width?` | `number \| undefined` | Its width, in points, from 32 to 720. Left out, across its parent. |
| `context?` | `"2d" \| "webgl2" \| undefined` | What it draws with. Left out, "2d". |
| `motion?` | `"decorative" \| "essential" \| undefined` | Whether it is still under reduced motion (`essential`). Left out, "decorative". |
| `description` | `string` | What it shows, for people who do not see it. |
| `draw` | `HandlerRef` | The function that draws a frame. |
| `onPointer?` | `HandlerRef \| undefined` | The function told of the pointer over it. |
| `key?` | `string \| undefined` | Names the block among its siblings, so that it keeps its place, its focus and what the person typed when the blocks around it change. At most 64 characters. In JSX it is the element's `key`. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |

Refers to [Placed](/docs/develop/reference/songstress/#type-Placed), [HandlerRef](/docs/develop/reference/ui/#type-HandlerRef).

### DrawnCard

A card of a grid or a shelf.

```ts
export type DrawnCard = DrawnMediaCard | LibraryItem | UnknownNode;
```

Refers to [DrawnMediaCard](/docs/develop/reference/ui/#type-DrawnMediaCard), [LibraryItem](/docs/develop/reference/ui/#type-LibraryItem), [UnknownNode](/docs/develop/reference/ui/#type-UnknownNode).

### DrawnCheckbox

A checkbox, as an app draws it.

```ts
export type DrawnCheckbox = Drawn<CheckboxBlock>;
```

Refers to [CheckboxBlock](/docs/develop/reference/songstress/#type-CheckboxBlock).

### DrawnCollapsible

A collapsible block, its children as an app draws them.

```ts
export type DrawnCollapsible = Drawn<Omit<CollapsibleBlock, 'children'>> & {
    children: DrawnBlock[];
};
```

Refers to [CollapsibleBlock](/docs/develop/reference/songstress/#type-CollapsibleBlock), [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnDatePicker

A date picker, as an app draws it.

```ts
export type DrawnDatePicker = Drawn<DatePickerBlock>;
```

Refers to [DatePickerBlock](/docs/develop/reference/songstress/#type-DatePickerBlock).

### DrawnDetail

A detail screen: blocks, top to bottom.

| Field | Type | Description |
|---|---|---|
| `type` | `"detail"` |  |
| `children` | `DrawnBlock[]` | Its blocks, top to bottom. |

Refers to [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnEmpty

An empty state as a block, its button as an app draws it.

```ts
export type DrawnEmpty = Omit<EmptyBlock, 'button'> & {
    button?: HandledButton;
};
```

Refers to [EmptyBlock](/docs/develop/reference/songstress/#type-EmptyBlock), [HandledButton](/docs/develop/reference/ui/#type-HandledButton).

### DrawnEmptyState

What a list or a grid shows when it has nothing to show.

```ts
export type DrawnEmptyState = Omit<EmptyState, 'button'> & {
    button?: HandledButton;
};
```

Refers to [EmptyState](/docs/develop/reference/songstress/#type-EmptyState), [HandledButton](/docs/develop/reference/ui/#type-HandledButton).

### DrawnField

A field of a form.

```ts
export type DrawnField = Field | UnknownNode;
```

Refers to [Field](/docs/develop/reference/songstress/#type-Field), [UnknownNode](/docs/develop/reference/ui/#type-UnknownNode).

### DrawnForm

A form screen, its fields as an app draws them.

```ts
export type DrawnForm = Omit<FormScreen, 'sections'> & {
    sections: {
        title?: string;
        footer?: string;
        fields: DrawnField[];
    }[];
};
```

Refers to [FormScreen](/docs/develop/reference/songstress/#type-FormScreen), [DrawnField](/docs/develop/reference/ui/#type-DrawnField).

### DrawnGrid

A grid screen, its cards as an app draws them.

```ts
export type DrawnGrid = Omit<GridScreen, 'sections' | 'empty'> & {
    sections: {
        title?: string;
        items: DrawnCard[];
    }[];
    empty?: DrawnEmptyState;
};
```

Refers to [GridScreen](/docs/develop/reference/songstress/#type-GridScreen), [DrawnCard](/docs/develop/reference/ui/#type-DrawnCard), [DrawnEmptyState](/docs/develop/reference/ui/#type-DrawnEmptyState).

### DrawnGridBlock

A grid block, its children as an app draws them.

```ts
export type DrawnGridBlock = Omit<GridBlock, 'children'> & {
    children: DrawnBlock[];
};
```

Refers to [GridBlock](/docs/develop/reference/songstress/#type-GridBlock), [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnIconButton

A button that shows an icon alone, as an app draws it.

```ts
export type DrawnIconButton = Drawn<IconButtonBlock>;
```

Refers to [IconButtonBlock](/docs/develop/reference/songstress/#type-IconButtonBlock).

### DrawnLeading

What stands at a row's start.

```ts
export type DrawnLeading = IconBlock | ImageBlock | CoverBlock | SpriteBlock;
```

Refers to [IconBlock](/docs/develop/reference/songstress/#type-IconBlock), [ImageBlock](/docs/develop/reference/songstress/#type-ImageBlock), [CoverBlock](/docs/develop/reference/songstress/#type-CoverBlock), [SpriteBlock](/docs/develop/reference/songstress/#type-SpriteBlock).

### DrawnList

A list screen, its rows as an app draws them.

```ts
export type DrawnList = Omit<ListScreen, 'sections' | 'empty'> & {
    sections: {
        title?: string;
        items: DrawnRow[];
    }[];
    empty?: DrawnEmptyState;
};
```

Refers to [ListScreen](/docs/develop/reference/songstress/#type-ListScreen), [DrawnRow](/docs/develop/reference/ui/#type-DrawnRow), [DrawnEmptyState](/docs/develop/reference/ui/#type-DrawnEmptyState).

### DrawnListBlock

A list block, its rows as an app draws them.

```ts
export type DrawnListBlock = Omit<ListBlock, 'items' | 'empty'> & {
    items: DrawnRow[];
    empty?: DrawnEmptyState;
};
```

Refers to [ListBlock](/docs/develop/reference/songstress/#type-ListBlock), [DrawnRow](/docs/develop/reference/ui/#type-DrawnRow), [DrawnEmptyState](/docs/develop/reference/ui/#type-DrawnEmptyState).

### DrawnListRow

A row of the extension's own, as an app draws it.

```ts
export type DrawnListRow = Omit<Row, keyof DrawnRowParts> & DrawnRowParts;
```

Refers to [Row](/docs/develop/reference/songstress/#type-Row).

### DrawnMediaCard

A card of the extension's own, as an app draws it.

```ts
export type DrawnMediaCard = Omit<Card, 'action' | 'menu'> & {
    action?: Handled;
    menu?: DrawnMenuEntry[];
};
```

Refers to [Card](/docs/develop/reference/songstress/#type-Card), [Handled](/docs/develop/reference/ui/#type-Handled), [DrawnMenuEntry](/docs/develop/reference/ui/#type-DrawnMenuEntry).

### DrawnMenu

A menu button, its entries as an app draws them.

```ts
export type DrawnMenu = Omit<MenuBlock, 'items'> & {
    items: DrawnMenuEntry[];
};
```

Refers to [MenuBlock](/docs/develop/reference/songstress/#type-MenuBlock), [DrawnMenuEntry](/docs/develop/reference/ui/#type-DrawnMenuEntry).

### DrawnMenuEntry

One entry of a menu, as an app draws it.

```ts
export type DrawnMenuEntry = Drawn<MenuEntry>;
```

Refers to [MenuEntry](/docs/develop/reference/songstress/#type-MenuEntry).

### DrawnNode

A node of a tree, and what it holds.

```ts
export type DrawnNode = Omit<TreeNode, 'children' | keyof DrawnRowParts> & DrawnRowParts & {
    children?: DrawnTreeItem[];
};
```

Refers to [TreeNode](/docs/develop/reference/songstress/#type-TreeNode), [DrawnTreeItem](/docs/develop/reference/ui/#type-DrawnTreeItem).

### DrawnPanel

What a panel shows inside one of Songstress's own screens.

| Field | Type | Description |
|---|---|---|
| `children` | `DrawnBlock[]` | Its blocks, top to bottom. |

Refers to [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnRow

A row of a list.

```ts
export type DrawnRow = DrawnListRow | SongRow | UnknownNode;
```

Refers to [DrawnListRow](/docs/develop/reference/ui/#type-DrawnListRow), [SongRow](/docs/develop/reference/songstress/#type-SongRow), [UnknownNode](/docs/develop/reference/ui/#type-UnknownNode).

### DrawnScreen

What a whole page is.

```ts
export type DrawnScreen = DrawnList | DrawnGrid | DrawnDetail | DrawnForm | DrawnTree | UnknownNode;
```

Refers to [DrawnList](/docs/develop/reference/ui/#type-DrawnList), [DrawnGrid](/docs/develop/reference/ui/#type-DrawnGrid), [DrawnDetail](/docs/develop/reference/ui/#type-DrawnDetail), [DrawnForm](/docs/develop/reference/ui/#type-DrawnForm), [DrawnTree](/docs/develop/reference/ui/#type-DrawnTree), [UnknownNode](/docs/develop/reference/ui/#type-UnknownNode).

### DrawnSearchField

A search field, as an app draws it.

```ts
export type DrawnSearchField = Drawn<SearchFieldBlock>;
```

Refers to [SearchFieldBlock](/docs/develop/reference/songstress/#type-SearchFieldBlock).

### DrawnSection

A section, its children as an app draws them.

```ts
export type DrawnSection = Omit<SectionBlock, 'children'> & {
    children: DrawnBlock[];
};
```

Refers to [SectionBlock](/docs/develop/reference/songstress/#type-SectionBlock), [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnSegmented

A segmented control, as an app draws it.

```ts
export type DrawnSegmented = Drawn<SegmentedBlock>;
```

Refers to [SegmentedBlock](/docs/develop/reference/songstress/#type-SegmentedBlock).

### DrawnSelect

A select, as an app draws it.

```ts
export type DrawnSelect = Drawn<SelectBlock>;
```

Refers to [SelectBlock](/docs/develop/reference/songstress/#type-SelectBlock).

### DrawnShelf

A shelf, its cards as an app draws them.

```ts
export type DrawnShelf = Omit<ShelfBlock, 'items'> & {
    items: DrawnCard[];
};
```

Refers to [ShelfBlock](/docs/develop/reference/songstress/#type-ShelfBlock), [DrawnCard](/docs/develop/reference/ui/#type-DrawnCard).

### DrawnSlider

A slider, as an app draws it.

```ts
export type DrawnSlider = Drawn<SliderBlock>;
```

Refers to [SliderBlock](/docs/develop/reference/songstress/#type-SliderBlock).

### DrawnStack

A stack, its children as an app draws them.

```ts
export type DrawnStack = Omit<StackBlock, 'children'> & {
    children: DrawnBlock[];
};
```

Refers to [StackBlock](/docs/develop/reference/songstress/#type-StackBlock), [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnStatus

What a status item shows in the player, as an app draws it.

```ts
export type DrawnStatus = Omit<StatusContent, 'action'> & {
    action?: Handled;
};
```

Refers to [StatusContent](/docs/develop/reference/songstress/#type-StatusContent), [Handled](/docs/develop/reference/ui/#type-Handled).

### DrawnSwitch

A switch, as an app draws it.

```ts
export type DrawnSwitch = Drawn<SwitchBlock>;
```

Refers to [SwitchBlock](/docs/develop/reference/songstress/#type-SwitchBlock).

### DrawnTab

One tab of a `tabs` block, its blocks as an app draws them.

```ts
export type DrawnTab = Omit<TabsBlock['tabs'][number], 'children'> & {
    children: DrawnBlock[];
};
```

Refers to [TabsBlock](/docs/develop/reference/songstress/#type-TabsBlock), [DrawnBlock](/docs/develop/reference/ui/#type-DrawnBlock).

### DrawnTable

A table, its rows as an app draws them.

```ts
export type DrawnTable = Omit<TableBlock, 'rows' | 'empty'> & {
    rows: DrawnTableRow[];
    empty?: DrawnEmptyState;
};
```

Refers to [TableBlock](/docs/develop/reference/songstress/#type-TableBlock), [DrawnTableRow](/docs/develop/reference/ui/#type-DrawnTableRow), [DrawnEmptyState](/docs/develop/reference/ui/#type-DrawnEmptyState).

### DrawnTableRow

A row of a table, as an app draws it.

```ts
export type DrawnTableRow = Omit<TableBlock['rows'][number], 'action'> & {
    action?: Handled;
};
```

Refers to [TableBlock](/docs/develop/reference/songstress/#type-TableBlock), [Handled](/docs/develop/reference/ui/#type-Handled).

### DrawnTabs

A `tabs` block, its tabs as an app draws them.

```ts
export type DrawnTabs = Omit<TabsBlock, 'tabs' | 'onSelect'> & {
    tabs: DrawnTab[];
    onSelect?: Handled;
};
```

Refers to [TabsBlock](/docs/develop/reference/songstress/#type-TabsBlock), [DrawnTab](/docs/develop/reference/ui/#type-DrawnTab), [Handled](/docs/develop/reference/ui/#type-Handled).

### DrawnTextField

A text field, as an app draws it.

```ts
export type DrawnTextField = Drawn<TextFieldBlock>;
```

Refers to [TextFieldBlock](/docs/develop/reference/songstress/#type-TextFieldBlock).

### DrawnTrailing

What stands at a row's end.

```ts
export type DrawnTrailing = TextBlock | BadgeBlock | IconBlock | ProgressBlock | DrawnSwitch | DrawnIconButton | DrawnButton;
```

Refers to [TextBlock](/docs/develop/reference/songstress/#type-TextBlock), [BadgeBlock](/docs/develop/reference/songstress/#type-BadgeBlock), [IconBlock](/docs/develop/reference/songstress/#type-IconBlock), [ProgressBlock](/docs/develop/reference/songstress/#type-ProgressBlock), [DrawnSwitch](/docs/develop/reference/ui/#type-DrawnSwitch), [DrawnIconButton](/docs/develop/reference/ui/#type-DrawnIconButton), [DrawnButton](/docs/develop/reference/ui/#type-DrawnButton).

### DrawnTree

A tree screen, its nodes as an app draws them.

```ts
export type DrawnTree = Omit<TreeScreen, 'nodes' | 'empty'> & {
    nodes: DrawnTreeItem[];
    empty?: DrawnEmptyState;
};
```

Refers to [TreeScreen](/docs/develop/reference/songstress/#type-TreeScreen), [DrawnTreeItem](/docs/develop/reference/ui/#type-DrawnTreeItem), [DrawnEmptyState](/docs/develop/reference/ui/#type-DrawnEmptyState).

### DrawnTreeBlock

A tree block, its nodes as an app draws them.

```ts
export type DrawnTreeBlock = Omit<TreeBlock, 'nodes' | 'onExpand'> & {
    nodes: DrawnTreeItem[];
    onExpand?: Handled;
};
```

Refers to [TreeBlock](/docs/develop/reference/songstress/#type-TreeBlock), [DrawnTreeItem](/docs/develop/reference/ui/#type-DrawnTreeItem), [Handled](/docs/develop/reference/ui/#type-Handled).

### DrawnTreeItem

What a tree holds at one level: nodes, songs, and what an app does not know.

```ts
export type DrawnTreeItem = DrawnNode | SongRow | UnknownNode;
```

Refers to [DrawnNode](/docs/develop/reference/ui/#type-DrawnNode), [SongRow](/docs/develop/reference/songstress/#type-SongRow), [UnknownNode](/docs/develop/reference/ui/#type-UnknownNode).

### EMPHASES

How much a button asks to be seen.

```ts
export declare const EMPHASES: readonly Emphasis[];
```

Refers to [Emphasis](/docs/develop/reference/songstress/#type-Emphasis).

### Empty

The app's "nothing here": an `empty` node. Its button is `buttonTitle`
and `onPress`.

```ts
export declare const Empty: import("./types").SdkComponent<EmptyProps>;
```

Example:

```tsx
import { Empty } from 'songstress/ui'

const none = <Empty title="Nothing played yet" text="Play a song to the end, and it shows here." icon="music" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [EmptyProps](/docs/develop/reference/ui/#type-EmptyProps).

### EmptyProps

An `Empty`'s props: its button is `buttonTitle` and `onPress`.

| Field | Type | Description |
|---|---|---|
| `buttonTitle?` | `string \| undefined` | The button's label. |
| `onPress?` | `Handler<void> \| undefined` | What the button does. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title` | `string` | What it says. |
| `text?` | `string \| undefined` | A sentence more. |
| `icon?` | `IconName \| undefined` | An icon from Songstress's icon set. Left out, "list". |

Refers to [EmptyBlock](/docs/develop/reference/songstress/#type-EmptyBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Glyph

An icon, by name, from Songstress's icon set: an `icon` node.

```ts
export declare const Glyph: import("./types").SdkComponent<GlyphProps>;
```

Example:

```tsx
import { Glyph } from 'songstress/ui'

const mark = <Glyph name="headphones" tone="accent" size="small" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [GlyphProps](/docs/develop/reference/ui/#type-GlyphProps).

### GlyphProps

A `Glyph`'s props.

```ts
export type GlyphProps = Own<IconBlock>;
```

Refers to [IconBlock](/docs/develop/reference/songstress/#type-IconBlock).

### Grid

Blocks in columns: a `grid` node.

```ts
export declare const Grid: import("./types").SdkComponent<GridProps>;
```

Example:

```tsx
import { Box, Grid, Text } from 'songstress/ui'

const totals = (
  <Grid columns={2} gap="small">
    <Box variant="card"><Text style="label">Plays</Text><Text style="title">42</Text></Box>
    <Box variant="card"><Text style="label">Hours</Text><Text style="title">3</Text></Box>
  </Grid>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [GridProps](/docs/develop/reference/ui/#type-GridProps).

### GridProps

A `Grid`'s props.

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | What it holds, row by row. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `columns?` | `"auto" \| 2 \| 3 \| 4 \| 5 \| 6 \| undefined` | How many columns, or as many as fit (`"auto"`). A number is the most: at a phone's width a grid shows two. Left out, "auto". |
| `gap?` | `Space \| undefined` | Room between its cells. Left out, "medium". |
| `padding?` | `Space \| undefined` | Room inside it. Left out, "none". |

Refers to [GridBlock](/docs/develop/reference/songstress/#type-GridBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### HStack

Blocks beside one another, going on to a new line when they do not fit
(`wrap`): a `stack` node with `direction: "horizontal"`.

```ts
export declare const HStack: import("./types").SdkComponent<StackProps>;
```

Example:

```tsx
import { Badge, Glyph, HStack, Spacer, Text } from 'songstress/ui'

const row = (
  <HStack gap="small" align="center">
    <Glyph name="headphones" />
    <Text>Listening now</Text>
    <Spacer />
    <Badge tone="accent">Live</Badge>
  </HStack>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [StackProps](/docs/develop/reference/ui/#type-StackProps).

### Handled

What a control does, as an app reads it: an action, a function of the
extension's client code, or a question before either.

```ts
export type Handled = Action | HandlerRef | HandledConfirm;
```

Refers to [Action](/docs/develop/reference/songstress/#type-Action), [HandlerRef](/docs/develop/reference/ui/#type-HandlerRef), [HandledConfirm](/docs/develop/reference/ui/#type-HandledConfirm).

### HandledButton

A button of a banner or an empty state: a title and what it does.

| Field | Type | Description |
|---|---|---|
| `title` | `string` | The button's label. |
| `action` | `Handled` | What choosing it does. |

Refers to [Handled](/docs/develop/reference/ui/#type-Handled).

### HandledConfirm

A question first, then a handler: what `confirmed` writes around a
function.

| Field | Type | Description |
|---|---|---|
| `action` | `Handled` | What happens on yes. |
| `type` | `"confirm"` | Always `"confirm"`: which kind this is. |
| `title` | `string` | What is asked. |
| `message?` | `string \| undefined` | A sentence more. |
| `confirm?` | `string \| undefined` | The word on the button that agrees. |
| `destructive?` | `boolean \| undefined` | Yes is drawn as a destructive choice. |

Refers to [ConfirmAction](/docs/develop/reference/songstress/#type-ConfirmAction), [Handled](/docs/develop/reference/ui/#type-Handled).

### Handler

What a control does: an action anywhere, a function in client code only.

```ts
export type Handler<Payload = void> = Action | HandlerFunction<Payload>;
```

Refers to [Action](/docs/develop/reference/songstress/#type-Action), [HandlerFunction](/docs/develop/reference/ui/#type-HandlerFunction).

### HandlerFunction

A function of the extension's client code: called in its worker when the
person presses, types or slides. It may answer an action, which the app
then carries out as it carries out a command's outcome.

```ts
export type HandlerFunction<Payload = void> = (payload: Payload) => Awaitable<Action | void>;
```

Refers to [Awaitable](/docs/develop/reference/songstress/#type-Awaitable), [Action](/docs/develop/reference/songstress/#type-Action).

### HandlerRef

A function of the extension's client code, by the id its mount gave it.
Written by the SDK's runtime alone; an app sends it back to that mount, as
an event, when the person uses the control.

| Field | Type | Description |
|---|---|---|
| `$handler` | `number` | The function's id in its mount: a whole number from 1. |

### ICON_NAMES

Every name Songstress's apps draw with a glyph of their own, in order. A
name outside the set is still allowed, and is drawn as the extension mark.

```ts
export declare const ICON_NAMES: readonly [
    "add",
    "album",
    "artist",
    "calendar",
    "chart",
    "check",
    "clock",
    "close",
    "cloud",
    "copy",
    "download",
    "edit",
    "extension",
    "external",
    "filter",
    "flame",
    "folder",
    "globe",
    "headphones",
    "heart",
    "image",
    "info",
    "key",
    "library",
    "link",
    "list",
    "lock",
    "lyrics",
    "mic",
    "music",
    "notification",
    "pause",
    "people",
    "person",
    "play",
    "playlist",
    "queue",
    "radio",
    "refresh",
    "remove",
    "search",
    "server",
    "settings",
    "share",
    "shuffle",
    "sparkles",
    "star",
    "sync",
    "tag",
    "timer",
    "trash",
    "warning"
];
```

Example:

```ts
import { ICON_NAMES } from 'songstress/ui'

ICON_NAMES.includes('heart') // true
```

### IconButton

A button that shows an icon alone: an `icon-button` node, `onPress` its
`action`.

```ts
export declare const IconButton: import("./types").SdkComponent<IconButtonProps>;
```

Example:

```tsx
import { IconButton } from 'songstress/ui'

const reload = <IconButton icon="refresh" label="Look again" onPress={{ type: 'refresh' }} />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [IconButtonProps](/docs/develop/reference/ui/#type-IconButtonProps).

### IconButtonProps

An `IconButton`'s props.

| Field | Type | Description |
|---|---|---|
| `onPress` | `Handler<void>` | What pressing it does. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `icon` | `IconName` | An icon from Songstress's icon set. |
| `label` | `string` | What it does, for people who do not see the icon; also its tooltip. |
| `emphasis?` | `Emphasis \| undefined` | How much it asks to be seen. Left out, "quiet". |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be chosen. |
| `busy?` | `boolean \| undefined` | Work it started is going on. |

Refers to [IconButtonBlock](/docs/develop/reference/songstress/#type-IconButtonBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Image

A picture: an `image` node, a cover of the library, an address the app
fetches through the server, or one of the package's own images.

```ts
export declare const Image: import("./types").SdkComponent<ImageProps>;
```

Example:

```tsx
import { Image } from 'songstress/ui'

// An image the package carries, by its path in the package.
const header = <Image source={{ asset: 'images/header.png' }} description="The radio's logo" shape="wide" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ImageProps](/docs/develop/reference/ui/#type-ImageProps).

### ImageProps

An `Image`'s props.

```ts
export type ImageProps = Own<ImageBlock>;
```

Refers to [ImageBlock](/docs/develop/reference/songstress/#type-ImageBlock).

### JUSTIFIES

How a stack's children share the room along it.

```ts
export declare const JUSTIFIES: readonly ('start' | 'center' | 'end' | 'between')[];
```

### LibraryItem

One of Songstress's own rows and cards, named by library id.

```ts
export type LibraryItem = SongRow | AlbumCard | ArtistCard | PlaylistCard;
```

Refers to [SongRow](/docs/develop/reference/songstress/#type-SongRow), [AlbumCard](/docs/develop/reference/songstress/#type-AlbumCard), [ArtistCard](/docs/develop/reference/songstress/#type-ArtistCard), [PlaylistCard](/docs/develop/reference/songstress/#type-PlaylistCard).

### LibraryItemProps

The props of a `SongItem`, an `AlbumItem`, an `ArtistItem` or a
`PlaylistItem`: something of the library, by its id.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Its library id. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

Refers to [Placement](/docs/develop/reference/ui/#type-Placement).

### List

Rows, as a block: a `list` node, its rows its children. Its empty state
is `emptyTitle`, `emptyText` and `emptyIcon`.

```ts
export declare const List: import("./types").SdkComponent<ListProps>;
```

Example:

```tsx
import { List, SongItem } from 'songstress/ui'

const songIds = ['s1', 's2', 's3']
const recent = (
  <List title="Played lately" emptyTitle="Nothing played yet" emptyIcon="music">
    {songIds.map((id) => <SongItem key={id} id={id} />)}
  </List>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ListProps](/docs/develop/reference/ui/#type-ListProps).

### ListItem

A row of a `List`: a `row` node, `onPress` its `action`.

```ts
export declare const ListItem: import("./types").SdkComponent<ListItemProps>;
```

Example:

```tsx
import { Badge, List, ListItem } from 'songstress/ui'

const stations = (
  <List>
    <ListItem id="night" title="Night radio" subtitle="Slow songs, after ten" icon="radio" trailing={<Badge>New</Badge>} onPress={{ type: 'navigate', to: { page: 'night' } }} />
  </List>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ListItemProps](/docs/develop/reference/ui/#type-ListItemProps).

### ListItemProps

A `ListItem`'s props: a `row` node.

| Field | Type | Description |
|---|---|---|
| `onPress?` | `Handler<void> \| undefined` | What pressing it does. |
| `leading?` | `UiNode` | What stands at its start: one `Glyph`, `Image`, `Cover` or `Sprite`. |
| `trailing?` | `UiNode` | What stands at its end: one `Text`, `Badge`, `Glyph`, `Progress`, `Switch`, `IconButton` or `Button`. |
| `badge?` | `UiNode` | A short word at its end: one `Badge`. |
| `menu?` | `UiNode` | More to do with it: `MenuOption` elements. |
| `id` | `string` | Unique among the rows of its list. |
| `title` | `string` | Its title. |
| `subtitle?` | `string \| undefined` | A line under the title. |
| `icon?` | `IconName \| undefined` | An icon from Songstress's icon set. |
| `image?` | `ImageSource \| undefined` | A picture beside it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be chosen. |

Refers to [Row](/docs/develop/reference/songstress/#type-Row).

### ListProps

A `List`'s props: its rows are its children (`ListItem`, `SongItem`, or
hand-written rows).

| Field | Type | Description |
|---|---|---|
| `emptyTitle?` | `string \| undefined` | What it says with no rows. Left out, "Nothing here yet". |
| `emptyText?` | `string \| undefined` | A sentence more, with no rows. |
| `emptyIcon?` | `IconName \| undefined` | An icon, with no rows. |
| `children?` | `UiNode` | Its rows. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title?` | `string \| undefined` | A heading over the rows. |

Refers to [ListBlock](/docs/develop/reference/songstress/#type-ListBlock), [IconName](/docs/develop/reference/songstress/#type-IconName), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### MOUNT_ID_LENGTH

The longest mount id: `"<kind>:<id>#<count>"`, made by the app.

```ts
export declare const MOUNT_ID_LENGTH = 80;
```

### MOUNT_INTERVAL

The least time between two of a text field's or a slider's events while
the person types or drags, in milliseconds; and between two renders of
one bundle.

```ts
export declare const MOUNT_INTERVAL = 33;
```

### MOUNT_LIMIT

The most targets one extension's client code holds mounted at once.

```ts
export declare const MOUNT_LIMIT = 16;
```

### MOUNT_PUSH

The bridge member a mount pushes a newer tree, an acknowledgement or an
error through. It is the bridge's, not the API's: no extension calls it by
name, and the server refuses any member that starts with `$`.

```ts
export declare const MOUNT_PUSH = "$ui.render";
```

### MediaCard

A card of the extension's own: a `card` node, `onPress` its `action`.

```ts
export declare const MediaCard: import("./types").SdkComponent<MediaCardProps>;
```

Example:

```tsx
import { MediaCard, Shelf } from 'songstress/ui'

const mixes = (
  <Shelf title="Mixes">
    <MediaCard id="night" title="Night radio" subtitle="Slow songs, after ten" image={{ asset: 'images/night.png' }} onPress={{ type: 'toast', message: 'Starting' }} />
  </Shelf>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [MediaCardProps](/docs/develop/reference/ui/#type-MediaCardProps).

### MediaCardProps

A `MediaCard`'s props: a `card` node.

| Field | Type | Description |
|---|---|---|
| `onPress?` | `Handler<void> \| undefined` | What pressing it does. |
| `menu?` | `UiNode` | Its menu: `MenuOption` elements. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `id` | `string` | Unique among the cards beside it. |
| `title` | `string` | Its title. |
| `subtitle?` | `string \| undefined` | A line under the title. |
| `image?` | `ImageSource \| undefined` | Its picture. |

Refers to [Card](/docs/develop/reference/songstress/#type-Card), [Handler](/docs/develop/reference/ui/#type-Handler), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Menu

A button that opens a menu: a `menu` node, its entries its `MenuOption`
children.

```ts
export declare const Menu: import("./types").SdkComponent<MenuProps>;
```

Example:

```tsx
import { Menu, MenuOption } from 'songstress/ui'

const more = (
  <Menu title="More" icon="settings">
    <MenuOption title="Look again" icon="refresh" onSelect={{ type: 'refresh' }} />
    <MenuOption title="Say hello" onSelect={() => ({ type: 'toast', message: 'Hello' })} />
  </Menu>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [MenuProps](/docs/develop/reference/ui/#type-MenuProps).

### MenuOption

A menu item: one entry of a `Menu`, or of a `ListItem`'s, a
`TreeItem`'s or a `MediaCard`'s menu. `onSelect` is what choosing it does.

```ts
export declare const MenuOption: import("./types").SdkComponent<MenuOptionProps>;
```

Example:

```tsx
import { confirmed, Menu, MenuOption } from 'songstress/ui'

const more = (
  <Menu title="More">
    <MenuOption title="Forget every play" icon="trash" destructive onSelect={confirmed({ title: 'Forget every play?' }, { type: 'invoke', command: 'forget' })} />
  </Menu>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [MenuOptionProps](/docs/develop/reference/ui/#type-MenuOptionProps).

### MenuOptionProps

A `MenuOption`'s props.

| Field | Type | Description |
|---|---|---|
| `onSelect` | `Handler<void>` | What choosing it does. |
| `title` | `string` | Its label. |
| `icon?` | `IconName \| undefined` | An icon from Songstress's icon set. |
| `destructive?` | `boolean \| undefined` | It deletes or cannot be undone: drawn as such. |

Refers to [MenuEntry](/docs/develop/reference/songstress/#type-MenuEntry), [Handler](/docs/develop/reference/ui/#type-Handler).

### MenuProps

A `Menu`'s props: its entries are its children, each a `MenuOption`.

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | Its entries: `MenuOption` elements. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title` | `string` | The menu button's label. |
| `icon?` | `IconName \| undefined` | The menu button's icon. |

Refers to [MenuBlock](/docs/develop/reference/songstress/#type-MenuBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### MountError

Why a mount's render failed, as it says it: each part cut at 2,000
characters.

| Field | Type | Description |
|---|---|---|
| `message` | `string` | What went wrong. |
| `stack?` | `string \| undefined` | Where, in the extension's code. |

### MountSession

What the app asks a mount, as the second argument of the target's
renderer: to mount it, to render it for a new context, to run a control's
function, to draw a canvas's frame, or to take it down.

```ts
export type MountSession = {
    mount: string;
    op: 'mount' | 'context' | 'unmount';
} | {
    mount: string;
    op: 'event';
    handler: number;
    payload: unknown;
    seq: number;
} | {
    mount: string;
    op: 'tick';
    canvas: number;
    tick: number;
    frame: CanvasFrame;
};
```

Refers to [mount](/docs/develop/reference/testing/#type-mount), [CanvasFrame](/docs/develop/reference/ui/#type-CanvasFrame).

### MountUpdate

An answer or a push of a mount, as `readUpdate` reads it. A tree is still
text: the app reads it with the reader of the target's kind when it draws
it.

```ts
export type MountUpdate = {
    kind: 'render';
    mount?: string;
    n: number;
    ack: number;
    tree: string;
} | {
    kind: 'ack';
    mount?: string;
    ack: number;
} | {
    kind: 'error';
    mount?: string;
    error: MountError;
} | {
    kind: 'handled';
    handled: boolean;
    action: Action | null;
} | {
    kind: 'gone';
} | {
    kind: 'done';
} | {
    kind: 'plain';
    value: unknown;
} | {
    kind: 'refused';
    reason: Refusal;
};
```

Refers to [mount](/docs/develop/reference/testing/#type-mount), [MountError](/docs/develop/reference/ui/#type-MountError), [Action](/docs/develop/reference/songstress/#type-Action), [Refusal](/docs/develop/reference/ui/#type-Refusal).

### Placement

What every component takes beside its own props: how it takes its
parent's room. Its name among its siblings is the JSX `key`.

```ts
export type Placement = Omit<Placed, 'key'>;
```

Refers to [Placed](/docs/develop/reference/songstress/#type-Placed).

### PlayButton

The app's own Play button, for songs, an album, an artist or a playlist:
a `play-button` node.

```ts
export declare const PlayButton: import("./types").SdkComponent<PlayButtonProps>;
```

Example:

```tsx
import { PlayButton } from 'songstress/ui'

const play = <PlayButton what={{ albumId: 'al-1' }} title="Play the album" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [PlayButtonProps](/docs/develop/reference/ui/#type-PlayButtonProps).

### PlayButtonProps

A `PlayButton`'s props.

```ts
export type PlayButtonProps = Own<PlayButtonBlock>;
```

Refers to [PlayButtonBlock](/docs/develop/reference/songstress/#type-PlayButtonBlock).

### PlaylistItem

A playlist of the library: a `playlist` node, a card of a `Shelf` (a
`List` takes rows and songs alone).

```ts
export declare const PlaylistItem: import("./types").SdkComponent<LibraryItemProps>;
```

Example:

```tsx
import { PlaylistItem, Shelf } from 'songstress/ui'

const playlists = (
  <Shelf title="Your playlists">
    <PlaylistItem id="pl-1" />
  </Shelf>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [LibraryItemProps](/docs/develop/reference/ui/#type-LibraryItemProps).

### Progress

How far something has got, as a bar or a ring: a `progress` node.

```ts
export declare const Progress: import("./types").SdkComponent<ProgressProps>;
```

Example:

```tsx
import { Progress } from 'songstress/ui'

const imported = <Progress value={0.4} label="40 of 100 songs" />
const going = <Progress variant="ring" label="Looking" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ProgressProps](/docs/develop/reference/ui/#type-ProgressProps).

### ProgressProps

A `Progress`'s props.

```ts
export type ProgressProps = Own<ProgressBlock>;
```

Refers to [ProgressBlock](/docs/develop/reference/songstress/#type-ProgressBlock).

### ProseText

Prose: paragraphs, lists and emphasis in the manifest's prose format, a
`prose` node. Its blocks are `blocks`, or its children's text a block a
line, as the format has it: a paragraph, a heading or a list item is one
line, and a blank line is nothing.

```ts
export declare const ProseText: import("./types").SdkComponent<ProseTextProps>;
```

Example:

```tsx
import { ProseText } from 'songstress/ui'

const about = <ProseText blocks={['Counts each song you play to the end.', 'Nothing leaves your server.']} />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ProseTextProps](/docs/develop/reference/ui/#type-ProseTextProps).

### ProseTextProps

A `ProseText`'s props: its blocks are `blocks`, or its children's text
a block a line, as the prose format has it (a list item on a line of its
own is a list item; a blank line is no block).

| Field | Type | Description |
|---|---|---|
| `blocks?` | `string[] \| undefined` | The blocks: paragraphs, headings, list items. |
| `children?` | `UiNode` | The blocks, as one text with each on a line of its own. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

Refers to [ProseTextBlock](/docs/develop/reference/songstress/#type-ProseTextBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Refusal

Why a tree is not drawn at all: it is over one of `UI_CAPS`, or it is
not a tree.

```ts
export type Refusal = 'too-large' | 'unreadable';
```

### SIZES

The steps of size.

```ts
export declare const SIZES: readonly Size[];
```

Refers to [Size](/docs/develop/reference/songstress/#type-Size).

### SPACES

The steps of room, between things (`gap`) or inside one (`padding`).

```ts
export declare const SPACES: readonly Space[];
```

Refers to [Space](/docs/develop/reference/songstress/#type-Space).

### STORED_FILE_TYPES

What a stored file is, by the ending of its name.

```ts
export declare const STORED_FILE_TYPES: Readonly<Record<string, StoredType>>;
```

Refers to [StoredType](/docs/develop/reference/songstress/#type-StoredType).

### SURFACE_CAPS

What a state holds and how often it may change, at most. The server holds
the server entry's writes to them and an app holds client code's; an app
reads what it is handed with them again.

```ts
export declare const SURFACE_CAPS: {
    readonly bytes: 16384;
    readonly badge: 9999;
    readonly contextText: 100;
    readonly statusBytes: 4096;
    readonly deviceWrites: 10;
    readonly deviceBurst: 20;
    readonly memberWrites: 10;
    readonly memberBurst: 20;
    readonly wideWrites: 1;
    readonly wideBurst: 5;
    readonly pushes: 4;
};
```

Example:

```ts
import { SURFACE_CAPS } from 'songstress/ui/reader'

// A badge over the cap is refused: say "99+" yourself if you count more.
const badge = Math.min(4200, SURFACE_CAPS.badge)
```

### SdkComponent

One of Songstress's components. On the server none of their props takes
a function (`songstress/ui/server`'s JSX); an author's own component keeps
its function props there.

```ts
export type SdkComponent<Props> = ((props: Props) => UiElement) & {
    readonly [sdk]: true;
};
```

Refers to [UiElement](/docs/develop/reference/ui/#type-UiElement).

### SearchField

The app's search field: a `search-field` node, told what it holds.

```ts
export declare const SearchField: import("./types").SdkComponent<SearchFieldProps>;
```

Example:

```tsx
import { SearchField, useState } from 'songstress/ui'

function Find() {
  const [term, setTerm] = useState('')
  return <SearchField placeholder="Search your plays" value={term} onChange={setTerm} />
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SearchFieldProps](/docs/develop/reference/ui/#type-SearchFieldProps).

### SearchFieldProps

A `SearchField`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<string> \| undefined` | Told what it holds as the person types. |
| `onSubmit?` | `Handler<string> \| undefined` | Told what it holds when the person submits it. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `value` | `string` | What it holds. |
| `label?` | `string \| undefined` | What it searches, said to screen readers. Left out, "Search". |
| `placeholder?` | `string \| undefined` | The hint while it is empty. Left out, "Search". |

Refers to [SearchFieldBlock](/docs/develop/reference/songstress/#type-SearchFieldBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Section

Blocks under a heading: a `section` node.

```ts
export declare const Section: import("./types").SdkComponent<SectionProps>;
```

Example:

```tsx
import { Section, Text } from 'songstress/ui'

const today = (
  <Section title="Today" footer="Counted on this device.">
    <Text>3 songs started</Text>
  </Section>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SectionProps](/docs/develop/reference/ui/#type-SectionProps).

### SectionProps

A `Section`'s props.

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | What it holds. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title?` | `string \| undefined` | The section's heading. |
| `footer?` | `string \| undefined` | A line of help under the section. |

Refers to [SectionBlock](/docs/develop/reference/songstress/#type-SectionBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Segmented

One of a few, side by side: a `segmented` node, told the option's
`value`.

```ts
export declare const Segmented: import("./types").SdkComponent<SegmentedProps>;
```

Example:

```tsx
import { Segmented, useState } from 'songstress/ui'

function Span() {
  const [span, setSpan] = useState('week')
  return (
    <Segmented
      label="Over"
      options={[{ value: 'week', title: 'Week' }, { value: 'year', title: 'Year' }]}
      value={span}
      onChange={setSpan}
    />
  )
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SegmentedProps](/docs/develop/reference/ui/#type-SegmentedProps).

### SegmentedProps

A `Segmented`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<string> \| undefined` | Told the `value` of the option chosen. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `options` | `{ value: string; title: string; }[]` | The choices, two to five; one whose `value` or `title` repeats an earlier one's is left out. A title is at most 40 characters. |
| `value` | `string` | The `value` of the option chosen. |

Refers to [SegmentedBlock](/docs/develop/reference/songstress/#type-SegmentedBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Select

One of a list, in a menu: a `select` node, told the option's `value`.

```ts
export declare const Select: import("./types").SdkComponent<SelectProps>;
```

Example:

```tsx
import { Select, useState } from 'songstress/ui'

const ORDERS = [
  { value: 'recent', title: 'Most recent' },
  { value: 'plays', title: 'Most played' },
]

function Order() {
  const [order, setOrder] = useState('recent')
  return <Select label="Sort by" options={ORDERS} value={order} onChange={setOrder} />
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SelectProps](/docs/develop/reference/ui/#type-SelectProps).

### SelectProps

A `Select`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<string> \| undefined` | Told the `value` of the option chosen. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `help?` | `string \| undefined` | A line of help under it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `options` | `{ value: string; title: string; }[]` | The choices, at most 100. |
| `value?` | `string \| undefined` | The `value` of the option chosen. Left out, nothing is chosen. |
| `placeholder?` | `string \| undefined` | What it says while nothing is chosen. Left out, "Choose one". |

Refers to [SelectBlock](/docs/develop/reference/songstress/#type-SelectBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### Shelf

A row of cards that scrolls sideways: a `shelf` node, its cards its
children.

```ts
export declare const Shelf: import("./types").SdkComponent<ShelfProps>;
```

Example:

```tsx
import { MediaCard, Shelf } from 'songstress/ui'

const mixes = (
  <Shelf title="Mixes">
    <MediaCard id="night" title="Night radio" image={{ asset: 'images/night.png' }} onPress={{ type: 'navigate', to: { page: 'night' } }} />
    <MediaCard id="morning" title="Morning" image={{ asset: 'images/morning.png' }} onPress={{ type: 'navigate', to: { page: 'morning' } }} />
  </Shelf>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [ShelfProps](/docs/develop/reference/ui/#type-ShelfProps).

### ShelfProps

A `Shelf`'s props: its cards are its children (`MediaCard`, `SongItem`,
`AlbumItem`, `ArtistItem`, `PlaylistItem`).

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | Its cards, side by side. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `title` | `string` | The shelf's heading. |

Refers to [ShelfBlock](/docs/develop/reference/songstress/#type-ShelfBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### SignedImage

A picture as the server hands it over: an address on the web comes with
the server's signature (`sig`), the one its image route asks for, so the
route fetches only what one of the extension's trees named; one of the
extension's files with the digest of the file it found for the member
looking (`sha256`).

```ts
export type SignedImage = ImageSource & {
    sig?: string;
    sha256?: string;
};
```

Refers to [ImageSource](/docs/develop/reference/songstress/#type-ImageSource).

### Skeleton

The app's placeholder while something loads: a `skeleton` node.

```ts
export declare const Skeleton: import("./types").SdkComponent<SkeletonProps>;
```

Example:

```tsx
import { Skeleton } from 'songstress/ui'

const loading = <Skeleton shape="row" count={3} />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SkeletonProps](/docs/develop/reference/ui/#type-SkeletonProps).

### SkeletonProps

A `Skeleton`'s props.

```ts
export type SkeletonProps = Own<SkeletonBlock>;
```

Refers to [SkeletonBlock](/docs/develop/reference/songstress/#type-SkeletonBlock).

### Slider

A number in a range: a `slider` node, told a number.

```ts
export declare const Slider: import("./types").SdkComponent<SliderProps>;
```

Example:

```tsx
import { Slider, useState } from 'songstress/ui'

function Fade() {
  const [seconds, setSeconds] = useState(4)
  return <Slider label="Fade" value={seconds} minimum={0} maximum={12} step={1} onChange={setSeconds} />
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SliderProps](/docs/develop/reference/ui/#type-SliderProps).

### SliderProps

A `Slider`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<number> \| undefined` | Told where it now stands. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `help?` | `string \| undefined` | A line of help under it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `value` | `number` | Where it stands, held between `minimum` and `maximum`. |
| `minimum` | `number` | Its lowest value. Each of a slider's numbers is one a 32-bit float carries, as the phones hold it: a slider with a number past that, or with bounds a float makes one, is left out. |
| `maximum` | `number` | Its highest value, above `minimum`. |
| `step?` | `number \| undefined` | How far one move goes, above 0 and no longer than the range (else it is left out, as is a step a float makes nothing). Left out, the app picks one: a hundredth of the range rounded down to a power of ten, never more than 1. Any count of steps is kept: an app draws a tick for each only when there are few. |

Refers to [SliderBlock](/docs/develop/reference/songstress/#type-SliderBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### SongItem

A song of the library, drawn as Songstress draws it: a `song` node.

```ts
export declare const SongItem: import("./types").SdkComponent<LibraryItemProps>;
```

Example:

```tsx
import { List, SongItem } from 'songstress/ui'

const songIds = ['s1', 's2']
const recent = <List title="Played lately">{songIds.map((id) => <SongItem key={id} id={id} />)}</List>
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [LibraryItemProps](/docs/develop/reference/ui/#type-LibraryItemProps).

### Spacer

Room between blocks: a `spacer` node.

```ts
export declare const Spacer: import("./types").SdkComponent<SpacerProps>;
```

Example:

```tsx
import { HStack, Spacer, Text } from 'songstress/ui'

// In an HStack, a Spacer takes the room left: the count goes to the far end.
const line = (
  <HStack>
    <Text>So What</Text>
    <Spacer />
    <Text tone="muted">12 plays</Text>
  </HStack>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SpacerProps](/docs/develop/reference/ui/#type-SpacerProps).

### SpacerProps

A `Spacer`'s props.

```ts
export type SpacerProps = Own<SpacerBlock>;
```

Refers to [SpacerBlock](/docs/develop/reference/songstress/#type-SpacerBlock).

### Sprite

One row of an image of frames, played: a `sprite` node.

```ts
export declare const Sprite: import("./types").SdkComponent<SpriteProps>;
```

Example:

```tsx
import { Sprite } from 'songstress/ui'

// Eight frames of 32 points in a row of the package's own image, twelve a second.
const bars = <Sprite source={{ asset: 'images/bars.png' }} frameWidth={32} frameHeight={32} frames={8} rate={12} loop description="Bars that move" />
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SpriteProps](/docs/develop/reference/ui/#type-SpriteProps).

### SpriteProps

A `Sprite`'s props.

```ts
export type SpriteProps = Own<SpriteBlock>;
```

Refers to [SpriteBlock](/docs/develop/reference/songstress/#type-SpriteBlock).

### SpriteRun

One animation of a sprite, ready to draw: the image's grid, the row, how
many of its frames, and how long one pass of them takes.

| Field | Type | Description |
|---|---|---|
| `columns` | `number` | Frames across the image. |
| `rows` | `number` | Rows down the image. |
| `row` | `number` | The row played, from 0. |
| `frames` | `number` | How many of the row's frames, from its left. |
| `durationMs` | `number` | One pass of those frames, in milliseconds. |
| `frameMs?` | `number[] \| undefined` | Each frame's own duration, in milliseconds, when the sprite gives them: `durationMs` is their sum. Left out, every frame lasts the same. |
| `loop` | `boolean` | Whether it plays again from its first frame. |

### Stack

Blocks under one another: a `stack` node.

```ts
export declare const Stack: import("./types").SdkComponent<StackProps>;
```

Example:

```tsx
import { Stack, Text } from 'songstress/ui'

const header = (
  <Stack gap="xsmall">
    <Text style="heading">Played lately</Text>
    <Text tone="muted">12 songs this week</Text>
  </Stack>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [StackProps](/docs/develop/reference/ui/#type-StackProps).

### StackProps

A `Stack`'s or an `HStack`'s props.

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | What it holds, in order. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `gap?` | `Space \| undefined` | Room between its children. Left out, "medium". |
| `padding?` | `Space \| undefined` | Room inside it, around its children. Left out, "none". |
| `align?` | `"center" \| "end" \| "start" \| "stretch" \| undefined` | How its children line up across it. |
| `justify?` | `"between" \| "center" \| "end" \| "start" \| undefined` | How its children share the room along it. Left out, "start". |
| `wrap?` | `boolean \| undefined` | Whether a horizontal stack's children go on to a new line when they do not fit. Left out, true. |

Refers to [StackBlock](/docs/develop/reference/songstress/#type-StackBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### SurfaceDeclared

What one extension declares, which a state is held to.

| Field | Type | Description |
|---|---|---|
| `sidebar` | `readonly string[]` | The ids of `contributes.sidebar`'s entries. |
| `context` | `readonly { key: string; type: ContextKey['type']; }[]` | `contributes.context`'s keys and their types. |
| `status` | `readonly string[]` | The ids of `contributes.status`. |
| `overlays` | `readonly string[]` | The ids of `contributes.overlays`. |
| `assets?` | `readonly AssetSize[] \| undefined` | The package's images, which a status item's sprite is held to. |

Refers to [ContextKey](/docs/develop/reference/manifest/#type-ContextKey), [AssetSize](/docs/develop/reference/ui/#type-AssetSize).

### SurfaceState

What code set of one extension's surfaces, as an app reads it.

| Field | Type | Description |
|---|---|---|
| `badges` | `Record<string, number \| "dot">` | A sidebar entry's badge, by the entry's id: a count from 1 to 9999, or a dot. |
| `context` | `Record<string, string \| number \| boolean>` | A context key's value, by its key (read as `ctx.<key>`). |
| `status` | `Record<string, DrawnStatus>` | What a status item shows in place of its renderer's answer, by its id. |
| `overlays` | `Record<string, boolean>` | Code's word on an overlay, by its id: shown (true) or hidden (false). |

Refers to [DrawnStatus](/docs/develop/reference/ui/#type-DrawnStatus).

### Switch

On or off, as a switch: a `switch` node, told a boolean.

```ts
export declare const Switch: import("./types").SdkComponent<SwitchProps>;
```

Example:

```tsx
import { Switch, useState } from 'songstress/ui'

function Loud() {
  const [loud, setLoud] = useState(false)
  return <Switch label="Loud" help="Plays the next song louder." value={loud} onChange={setLoud} />
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [SwitchProps](/docs/develop/reference/ui/#type-SwitchProps).

### SwitchProps

A `Switch`'s props.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<boolean> \| undefined` | Told whether it is now on. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `help?` | `string \| undefined` | A line of help under it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `value` | `boolean` | Whether it is on. |

Refers to [SwitchBlock](/docs/develop/reference/songstress/#type-SwitchBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### TONES

Colour by what it means; the theme decides the colour itself.

```ts
export declare const TONES: readonly Tone[];
```

Refers to [Tone](/docs/develop/reference/songstress/#type-Tone).

### Tab

One tab of a `Tabs`: its id, its title on the switcher, and its blocks.

```ts
export declare const Tab: import("./types").SdkComponent<TabProps>;
```

Example:

```tsx
import { Tab, Tabs, Text } from 'songstress/ui'

const totals = (
  <Tabs>
    <Tab id="week" title="This week" icon="calendar"><Text>42 plays</Text></Tab>
    <Tab id="year" title="This year"><Text>1,204 plays</Text></Tab>
  </Tabs>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TabProps](/docs/develop/reference/ui/#type-TabProps).

### TabProps

A `Tab`'s props: one tab of a `Tabs`.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Unique in its `Tabs`, at most 40 characters. |
| `title` | `string` | Its title on the switcher, at most 40 characters. |
| `icon?` | `IconName \| undefined` | An icon from Songstress's icon set. |
| `children?` | `UiNode` | What it shows. |

Refers to [IconName](/docs/develop/reference/songstress/#type-IconName), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Table

Rows of cells under column headings: a `table` node.

```ts
export declare const Table: import("./types").SdkComponent<TableProps>;
```

Example:

```tsx
import { Table } from 'songstress/ui'

const top = (
  <Table
    columns={[{ id: 'song', title: 'Song' }, { id: 'plays', title: 'Plays', align: 'end' }]}
    rows={[{ id: 's1', cells: ['So What', 12] }, { id: 's2', cells: ['Blue in Green', 9] }]}
  />
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TableProps](/docs/develop/reference/ui/#type-TableProps).

### TableProps

A `Table`'s props.

| Field | Type | Description |
|---|---|---|
| `rows` | `TableRow[]` | The rows, at most 200. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `columns` | `{ id: string; title: string; align?: 'start' \| 'end'; }[]` | The columns, one to eight. |
| `empty?` | `EmptyState \| undefined` | What it shows when it holds no rows. Left out, "Nothing here yet". |

Refers to [TableBlock](/docs/develop/reference/songstress/#type-TableBlock), [TableRow](/docs/develop/reference/ui/#type-TableRow).

### TableRow

A row of a `Table`.

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Unique in the table. |
| `cells` | `(string \| number \| TableCell)[]` | One cell a column; a string or a number is a `text` cell. |
| `onPress?` | `Handler<void> \| undefined` | What pressing the row does. |

Refers to [TableCell](/docs/develop/reference/songstress/#type-TableCell), [Handler](/docs/develop/reference/ui/#type-Handler).

### Tabs

One of several groups of blocks, under a switcher: a `tabs` node, its
tabs its `Tab` children.

```ts
export declare const Tabs: import("./types").SdkComponent<TabsProps>;
```

Example:

```tsx
import { Tab, Tabs, Text, useState } from 'songstress/ui'

function Totals() {
  const [tab, setTab] = useState('week')
  return (
    <Tabs value={tab} onSelect={setTab}>
      <Tab id="week" title="This week"><Text>42 plays</Text></Tab>
      <Tab id="year" title="This year"><Text>1,204 plays</Text></Tab>
    </Tabs>
  )
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TabsProps](/docs/develop/reference/ui/#type-TabsProps).

### TabsProps

A `Tabs`'s props: its tabs are its children, each a `Tab`.

| Field | Type | Description |
|---|---|---|
| `onSelect?` | `Handler<string> \| undefined` | Told the `id` of the tab the person chose. |
| `children?` | `UiNode` | Its tabs: `Tab` elements. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `value?` | `string \| undefined` | The `id` of the tab shown. Left out, the first. |

Refers to [TabsBlock](/docs/develop/reference/songstress/#type-TabsBlock), [Handler](/docs/develop/reference/ui/#type-Handler), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Text

Words, in one of six styles: a `text` node. Its words are its children,
or `text`.

```ts
export declare const Text: import("./types").SdkComponent<TextProps>;
```

Example:

```tsx
import { Text } from 'songstress/ui'

const title = <Text style="title">Played lately</Text>
const note = <Text tone="muted" lines={2}>{`${12} songs, the last one an hour ago`}</Text>
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TextProps](/docs/develop/reference/ui/#type-TextProps).

### TextInput

A line of text, or several: a `text-field` node, told what it holds.

```ts
export declare const TextInput: import("./types").SdkComponent<TextInputProps>;
```

Example:

```tsx
import { TextInput, useState } from 'songstress/ui'

function MixName() {
  const [name, setName] = useState('')
  return (
    <TextInput
      label="Name"
      placeholder="A name for the mix"
      value={name}
      onChange={setName}
      onSubmit={(value) => ({ type: 'toast', message: `Saved ${value}` })}
    />
  )
}
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TextInputProps](/docs/develop/reference/ui/#type-TextInputProps).

### TextInputProps

A `TextInput`'s props: the `text-field` node.

| Field | Type | Description |
|---|---|---|
| `onChange?` | `Handler<string> \| undefined` | Told what it holds as the person types. |
| `onSubmit?` | `Handler<string> \| undefined` | Told what it holds when the person presses Return in a single line. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `label` | `string` | What it sets, said beside it. |
| `help?` | `string \| undefined` | A line of help under it. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be used. |
| `value` | `string` | What it holds. |
| `placeholder?` | `string \| undefined` | The hint while it is empty. |
| `multiline?` | `boolean \| undefined` | Several lines. |
| `maxLength?` | `number \| undefined` | The most characters it takes, from 1 to 2,000. |

Refers to [TextFieldBlock](/docs/develop/reference/songstress/#type-TextFieldBlock), [Handler](/docs/develop/reference/ui/#type-Handler).

### TextProps

A `Text`'s props: its words are its children joined, or `text`.

| Field | Type | Description |
|---|---|---|
| `text?` | `string \| undefined` | The words, when there are no children. |
| `children?` | `UiNode` | The words. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |
| `style?` | `"body" \| "caption" \| "code" \| "heading" \| "label" \| "title" \| undefined` | Left out, "body". `label` is a control's label; `code` is text in a monospace face, shown as written. |
| `tone?` | `Tone \| undefined` | Their colour, by meaning. |
| `lines?` | `number \| undefined` | Cut to this many lines, from 1 to 6. Left out, all of it shows. |

Refers to [TextBlock](/docs/develop/reference/songstress/#type-TextBlock), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### Tree

Nodes that hold nodes, as a block: a `tree` node, its top nodes its
children. A node's `open` is how it stands at first: the app keeps what the
person opens and closes, and tells `onExpand`.

```ts
export declare const Tree: import("./types").SdkComponent<TreeProps>;
```

Example:

```tsx
import { Tree, TreeItem } from 'songstress/ui'

// 2026 stands open at first; a tap closes it, and the handler is told.
const years = (
  <Tree onExpand={({ id, open }) => console.log(id, open)}>
    <TreeItem id="2026" title="2026" open>
      <TreeItem id="2026-11" title="November" subtitle="42 plays" />
    </TreeItem>
  </Tree>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TreeProps](/docs/develop/reference/ui/#type-TreeProps).

### TreeItem

A node of a `Tree`: a `node` node, `onPress` its `action`, the nodes
under it its children.

```ts
export declare const TreeItem: import("./types").SdkComponent<TreeItemProps>;
```

Example:

```tsx
import { Tree, TreeItem } from 'songstress/ui'

// A node whose nodes come later: `expandable`, and the tree's onExpand loads them.
const folders = (
  <Tree onExpand={{ type: 'refresh' }}>
    <TreeItem id="jazz" title="Jazz" icon="folder" expandable />
  </Tree>
)
```

Refers to [SdkComponent](/docs/develop/reference/ui/#type-SdkComponent), [TreeItemProps](/docs/develop/reference/ui/#type-TreeItemProps).

### TreeItemProps

A `TreeItem`'s props: a tree's `node`; its children are the nodes under
it (`TreeItem`, `SongItem`).

| Field | Type | Description |
|---|---|---|
| `children?` | `UiNode` | The nodes under it. |
| `onPress?` | `Handler<void> \| undefined` | What pressing it does. |
| `leading?` | `UiNode` | What stands at its start: one `Glyph`, `Image`, `Cover` or `Sprite`. |
| `trailing?` | `UiNode` | What stands at its end: one `Text`, `Badge`, `Glyph`, `Progress`, `Switch`, `IconButton` or `Button`. |
| `badge?` | `UiNode` | A short word at its end: one `Badge`. |
| `menu?` | `UiNode` | More to do with it: `MenuOption` elements. |
| `id` | `string` | Unique in the tree. |
| `title` | `string` | Its title. |
| `subtitle?` | `string \| undefined` | A line under the title. |
| `icon?` | `IconName \| undefined` | An icon from Songstress's icon set. |
| `image?` | `ImageSource \| undefined` | A picture beside it. |
| `expandable?` | `boolean \| undefined` | It has nodes under it that are not given now: when the person opens it, the page is rendered again with its id in `RenderContext.node`, and the answer's `nodes` are drawn under it. Left out when `children` is given. |
| `open?` | `boolean \| undefined` | Open at first, on the web and the desktop; then the app keeps what the person opens and closes. A phone opens a node with nodes under it as a page of its own. |
| `disabled?` | `boolean \| undefined` | Shown, but it cannot be chosen. |

Refers to [TreeNode](/docs/develop/reference/songstress/#type-TreeNode), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### TreeProps

A `Tree`'s props: its top nodes are its children (`TreeItem`, `SongItem`).

| Field | Type | Description |
|---|---|---|
| `onExpand?` | `Handler<{ id: string; open: boolean; }> \| undefined` | Told `{ id, open }` when the person opens or closes a node. The app keeps what the person chose: a node's `open` is how it stands at first, and a later tree's `open` does not take the choice back. |
| `children?` | `UiNode` | Its top nodes. |
| `grow?` | `boolean \| undefined` | In a horizontal stack, it takes the room left over. Elsewhere it does nothing. |
| `width?` | `Width \| undefined` | Across its parent, or as wide as what it holds. Left out, the block's own way. |

Refers to [TreeBlock](/docs/develop/reference/songstress/#type-TreeBlock), [Handler](/docs/develop/reference/ui/#type-Handler), [UiNode](/docs/develop/reference/ui/#type-UiNode).

### TreeRead

A tree as an app read it: the tree it draws, or why it draws none.

```ts
export type TreeRead<Tree> = {
    ok: true;
    tree: Tree;
} | {
    ok: false;
    reason: Refusal;
};
```

Refers to [Tree](/docs/develop/reference/ui/#type-Tree), [Refusal](/docs/develop/reference/ui/#type-Refusal).

### UI_CAPS

What an app draws of one tree, at most (SPEC.md section 10: "the apps cap a
tree's size, depth and number of rows ... and do not draw a tree over a
cap"). A tree over a count is refused whole; a text over its length is cut.

```ts
export declare const UI_CAPS: {
    readonly nodes: 1500;
    readonly depth: 16;
    readonly items: 200;
    readonly sections: 30;
    readonly menu: 10;
    readonly fields: 50;
    readonly options: 100;
    readonly buttons: 2;
    readonly status: 24;
    readonly shelf: 30;
    readonly title: 120;
    readonly text: 2000;
    readonly handlers: 300;
    readonly bytes: 262144;
    readonly tabs: 6;
    readonly columns: 8;
    readonly segments: 5;
    readonly prose: 16;
    readonly lines: 6;
    readonly key: 64;
    readonly canvases: 2;
    readonly canvasSide: 720;
    readonly spriteFrames: 64;
    readonly spriteSide: 256;
    readonly spriteRate: 30;
    readonly spriteFrameMinMs: 16;
    readonly spriteFrameMaxMs: 10000;
    readonly overlayNodes: 60;
};
```

Example:

```ts
import { UI_CAPS } from 'songstress/ui'

declare const songs: { id: string; title: string }[]

// One answer of a list holds at most UI_CAPS.items rows: the rest come by `nextCursor`.
const rows = songs.slice(0, UI_CAPS.items).map((song) => ({ type: 'row' as const, id: song.id, title: song.title }))
```

### UiElement

What a component of `songstress/ui` makes: an element of a tree. Opaque:
nothing but a component makes one. A renderer may answer one in place of a
hand-written tree.

| Field | Type | Description |
|---|---|---|
| `__@element@76431` | `true` |  |

### UiNode

What a component holds as children, and what one may answer: an
element, text, a hand-written node, nothing, or a list of these.

```ts
export type UiNode = UiElement | Block | Row | Card | TreeNode | string | number | boolean | null | undefined | readonly UiNode[];
```

Refers to [UiElement](/docs/develop/reference/ui/#type-UiElement), [Block](/docs/develop/reference/songstress/#type-Block), [Row](/docs/develop/reference/songstress/#type-Row), [Card](/docs/develop/reference/songstress/#type-Card), [TreeNode](/docs/develop/reference/songstress/#type-TreeNode).

### UnknownNode

A node the reader does not know, by the `type` it came with: an app draws
it as "needs a newer app".

| Field | Type | Description |
|---|---|---|
| `type` | `"unknown"` |  |
| `name` | `string` | The `type` the node came with. |

### VIEW_CAPS

What an in-app view may be, and do, at most.

```ts
export declare const VIEW_CAPS: {
    readonly fileBytes: number;
    readonly elements: 4000;
    readonly styleChars: 131072;
    readonly frames: 4;
    readonly patchOps: 200;
    readonly patchChars: 65536;
    readonly patchesPerSecond: 120;
    readonly textChars: 10000;
    readonly classChars: 1000;
    readonly pictures: 12;
    readonly picturesPerSecond: 4;
    readonly eventsPerSecond: 240;
    readonly canvases: 4;
    readonly canvasSide: 1440;
    readonly canvasPixels: 1166400;
    readonly canvasTicks: 60;
    readonly viewTicks: 120;
    readonly canvasFramesPerSecond: 130;
    readonly canvasMessagesPerSecond: 20;
    readonly postBytes: 16384;
    readonly postsPerSecond: 30;
    readonly slowFrameMs: 50;
    readonly slowWindowMs: 2000;
    readonly slowBudgetMs: 667;
    readonly opensPerMinute: 4;
};
```

Example:

```ts
import { VIEW_CAPS } from 'songstress/ui/reader'

// A list a view keeps in its markup stays well under the app's element cap.
const rows = Math.min(500, VIEW_CAPS.elements / 4)
```

### VIEW_IMAGE

What a view's picture may name, as the frame's script and the app read it
(`readViewImage`): a cover of one of these kinds of the library by its id
(letters and digits, as the server makes them), or one of the package's
own images by its path. A picture of any other shape stops the view's code.

```ts
export declare const VIEW_IMAGE: {
    readonly covers: readonly [
        "song",
        "album",
        "artist",
        "playlist"
    ];
    readonly id: RegExp;
    readonly asset: RegExp;
    readonly assetChars: 200;
};
```

Example:

```ts
import { VIEW_IMAGE } from 'songstress/ui/reader'

console.log(VIEW_IMAGE.id.test('4uLU6hMCjMI75M1A2tKUQC'), VIEW_IMAGE.id.test('https://example.com/a.png')) // true false
```

### VIEW_MARKUP

The markup an app keeps of an in-app view: these elements and attributes
(and any `aria-` or `data-` attribute); an `input` of these types; an
`img` whose `src` is a `data:` address of these picture types. Everything
else is taken out before the view is drawn: every script, link, frame,
`on…` attribute, address and `autofocus`. Every field is given
`autocomplete="off"`.

```ts
export declare const VIEW_MARKUP: {
    readonly elements: readonly [
        "div",
        "span",
        "p",
        "h1",
        "h2",
        "h3",
        "h4",
        "h5",
        "h6",
        "ul",
        "ol",
        "li",
        "dl",
        "dt",
        "dd",
        "section",
        "article",
        "header",
        "footer",
        "main",
        "nav",
        "aside",
        "figure",
        "figcaption",
        "blockquote",
        "pre",
        "code",
        "em",
        "strong",
        "b",
        "i",
        "u",
        "s",
        "small",
        "sub",
        "sup",
        "mark",
        "br",
        "hr",
        "table",
        "caption",
        "colgroup",
        "col",
        "thead",
        "tbody",
        "tfoot",
        "tr",
        "th",
        "td",
        "style",
        "canvas",
        "img",
        "form",
        "button",
        "input",
        "select",
        "option",
        "optgroup",
        "textarea",
        "label",
        "fieldset",
        "legend",
        "progress",
        "meter",
        "output",
        "details",
        "summary"
    ];
    readonly attributes: readonly [
        "id",
        "class",
        "style",
        "title",
        "lang",
        "dir",
        "hidden",
        "tabindex",
        "role",
        "alt",
        "width",
        "height",
        "for",
        "name",
        "type",
        "value",
        "placeholder",
        "checked",
        "disabled",
        "readonly",
        "required",
        "min",
        "max",
        "step",
        "multiple",
        "selected",
        "rows",
        "cols",
        "maxlength",
        "minlength",
        "open",
        "colspan",
        "rowspan",
        "scope",
        "src"
    ];
    readonly attributePrefixes: readonly [
        "aria-",
        "data-"
    ];
    readonly inputTypes: readonly [
        "text",
        "search",
        "number",
        "range",
        "checkbox",
        "radio",
        "color",
        "date",
        "time",
        "email",
        "tel",
        "url",
        "button",
        "submit",
        "reset"
    ];
    readonly pictureTypes: readonly [
        "image/png",
        "image/jpeg",
        "image/webp"
    ];
};
```

Example:

```ts
import { VIEW_MARKUP } from 'songstress/ui/reader'

const kept = (tag: string) => (VIEW_MARKUP.elements as readonly string[]).includes(tag)
console.log(kept('canvas'), kept('script')) // true false
```

### VIEW_STYLE

What no in-app view's style may hold, in a `style` element or attribute,
as the app and the frame's script read each (`viewStyleRefused`):
`text-security`, with any prefix (`-webkit-text-security`), however it is
written (in capitals, with CSS escapes, between comments). It draws what a
person types as a password field's dots, and a view never dresses a field
as a password box: a page of an extension's that asks for a password is
what the frame exists to prevent. A view whose style holds it is not drawn.
The word is refused as a name of its own wherever it stands, so a class of
that exact name is refused too; `--text-security-hint` or `.no-text-security`
is not.

```ts
export declare const VIEW_STYLE: {
    readonly escape: RegExp;
    readonly refused: RegExp;
};
```

Example:

```ts
import { VIEW_STYLE } from 'songstress/ui/reader'

console.log(VIEW_STYLE.refused.test('input { -webkit-text-security: disc }')) // true
```

### VIEW_TOKENS

The CSS variables an in-app view is handed, each `--songstress-` and a
token of the theme that is on (dots as dashes), with the app's font, its
monospace font, its corner radius and its focus ring: so a view's own CSS
can look like the app with `var(--songstress-text)`. The document's root
also carries the class `dark` or `light`, and `reduced-motion` while the
person asks for less motion.

```ts
export declare const VIEW_TOKENS: readonly [
    "--songstress-background",
    "--songstress-surface",
    "--songstress-surface-raised",
    "--songstress-surface-hover",
    "--songstress-border",
    "--songstress-text",
    "--songstress-text-muted",
    "--songstress-text-faint",
    "--songstress-accent",
    "--songstress-accent-fill",
    "--songstress-accent-fill-pressed",
    "--songstress-accent-on-fill",
    "--songstress-success",
    "--songstress-warning",
    "--songstress-danger",
    "--songstress-info",
    "--songstress-font",
    "--songstress-font-mono",
    "--songstress-radius",
    "--songstress-focus"
];
```

Example:

```ts
import { VIEW_TOKENS } from 'songstress/ui/reader'

const css = `button { background: var(${VIEW_TOKENS[0]}) }`
```

Refers to [songstress](/docs/develop/reference/songstress/#type-songstress), [on](/docs/develop/reference/view/#type-on).

### ViewFrameMessage

What the frame's script hands a view's worker, on the worker's own
channel (not the bridge's text): the start, an event, and a canvas's tick,
a frame wanted of the canvas whose element has that id.

```ts
export type ViewFrameMessage = ViewStart | {
    t: 'event';
    event: ViewEvent;
} | {
    t: 'tick';
    canvas: string;
    tick: number;
    frame: {
        width: number;
        height: number;
        pixelRatio: number;
        time: number;
    };
};
```

Refers to [ViewStart](/docs/develop/reference/ui/#type-ViewStart), [ViewEvent](/docs/develop/reference/view/#type-ViewEvent).

### ViewPatchOp

One change of a patch: an element, by its id, and what of it changes.

```ts
export type ViewPatchOp = [
    id: string,
    field: 'text' | 'class',
    value: string
] | [
    id: string,
    field: 'hidden',
    value: boolean
] | [
    id: string,
    field: 'value',
    value: string | number | boolean
] | [
    id: string,
    field: 'image',
    value: ViewImage | null
];
```

Refers to [ViewImage](/docs/develop/reference/view/#type-ViewImage).

### ViewPatchRead

A patch as the frame's script reads it: the changes to apply, or why it
refuses the patch (and, with it, stops the worker).

```ts
export type ViewPatchRead = {
    ok: true;
    ops: ViewPatchOp[];
} | {
    ok: false;
    why: string;
};
```

Refers to [ViewPatchOp](/docs/develop/reference/ui/#type-ViewPatchOp).

### ViewStart

What the frame tells a view's code once, before any event: which view,
opened with what, at what size, in which theme, and whether it may draw on
a canvas here. Changes come after as events (`resize`, `theme`, `motion`).

| Field | Type | Description |
|---|---|---|
| `t` | `"view"` |  |
| `view` | `string` |  |
| `params` | `Record<string, string>` |  |
| `size` | `{ width: number; height: number; }` |  |
| `theme` | `ViewTheme` |  |
| `reducedMotion` | `boolean` |  |
| `canvas` | `boolean` |  |

Refers to [ViewTheme](/docs/develop/reference/view/#type-ViewTheme).

### ViewTreeNode

A node of a view's file as an HTML parser builds it, in what the browser's DOM and a parser's own tree (parse5's)
both give: so the app and `songstress check` read one file alike (`viewWeight`). An element has a `tagName`; a
text holds its characters in `nodeValue` (the DOM) or `value` (parse5); an element's attributes are its
`attributes` (the DOM) or `attrs` (parse5).

| Field | Type | Description |
|---|---|---|
| `nodeName` | `string` |  |
| `tagName?` | `string \| undefined` |  |
| `childNodes?` | `ArrayLike<ViewTreeNode> \| undefined` |  |
| `nodeValue?` | `string \| null \| undefined` |  |
| `value?` | `unknown` |  |
| `attributes?` | `ArrayLike<{ readonly name: string; readonly value: string; }> \| undefined` |  |
| `attrs?` | `ArrayLike<{ readonly name: string; readonly value: string; }> \| undefined` |  |

### ViewWeight

What an app holds a view's file to, read from the file as parsed (`viewWeight`).

| Field | Type | Description |
|---|---|---|
| `elements` | `number` | Every element of its body, and each `style` element of its head: held to `VIEW_CAPS.elements`. |
| `styleChars` | `number` | The characters of those `style` elements and of their `style` attributes: held to `VIEW_CAPS.styleChars`. |
| `passwordStyle` | `boolean` | Whether one of those holds what `VIEW_STYLE` refuses: then the view is not drawn. |

### ViewWorkerMessage

What a view's worker hands the frame's script, on the same channel: a
patch, a canvas it draws on (or no longer does), and a frame drawn for a
tick, as a bitmap. Anything else stops the worker.

```ts
export type ViewWorkerMessage = {
    t: 'patch';
    ops: ViewPatchOp[];
} | {
    t: 'canvas';
    id: string;
    context: '2d' | 'webgl2';
    motion: 'decorative' | 'essential';
    pointer: boolean;
} | {
    t: 'canvas';
    id: string;
    off: true;
} | {
    t: 'frame';
    canvas: string;
    tick: number;
    bitmap: unknown;
};
```

Refers to [ViewPatchOp](/docs/develop/reference/ui/#type-ViewPatchOp).

### WIDTHS

Across its parent, or as wide as what it holds.

```ts
export declare const WIDTHS: readonly Width[];
```

Refers to [Width](/docs/develop/reference/songstress/#type-Width).

### confirmed

Asks first, then calls `then`, a function of client code, when the person
agrees: a `confirm` action around a handler of its own.
Asks first, then does `then`, an action, when the person agrees: a
`ConfirmAction`, itself an action, so it is a handler in a server file
(`songstress/ui/server`) too.
Asks first, then runs `then` when the person agrees: a handler that is an
action or a function of client code.

```ts
export declare function confirmed<Payload = void>(question: {
    title: string;
    message?: string;
    confirm?: string;
    destructive?: boolean;
}, then: HandlerFunction<Payload>): Handler<Payload>;
export declare function confirmed(question: {
    title: string;
    message?: string;
    confirm?: string;
    destructive?: boolean;
}, then: Action): ConfirmAction;
export declare function confirmed<Payload = void>(question: {
    title: string;
    message?: string;
    confirm?: string;
    destructive?: boolean;
}, then: Handler<Payload>): Handler<Payload>;
```

| Parameter | Type | Description |
|---|---|---|
| `question` | `{ title: string; message?: string; confirm?: string; destructive?: boolean; }` | What is asked: its `title`, a `message`, the word on the button that agrees (`confirm`), and whether yes is `destructive`. |
| `then` | `HandlerFunction<Payload>` | What runs on yes. |

Returns `Handler<Payload>;
export declare function confirmed(question: {
    title: string;
    message?: string;
    confirm?: string;
    destructive?: boolean;
}, then: Action): ConfirmAction;
export declare function confirmed<Payload = void>(question: {
    title: string;
    message?: string;
    confirm?: string;
    destructive?: boolean;
}, then: Handler<Payload>): Handler<Payload>`.

Example:

```tsx
import { Button, confirmed, useState } from 'songstress/ui'

function Reset() {
  const [count, setCount] = useState(3)
  return <Button title={`Start again from ${count}`} onPress={confirmed({ title: 'Start again from 0?' }, () => setCount(0))} />
}
```

Refers to [HandlerFunction](/docs/develop/reference/ui/#type-HandlerFunction), [Handler](/docs/develop/reference/ui/#type-Handler), [Action](/docs/develop/reference/songstress/#type-Action), [ConfirmAction](/docs/develop/reference/songstress/#type-ConfirmAction).

### controlValue

What a control shows: what the person did, from the moment its event was
sent until the mount has handled that event (an `ack` at or above its
`seq`), and the tree's value from then on. So a tree that left the worker
before the person's last keystroke never takes a letter away, and a
handler that refuses a change still has the last word.

```ts
export declare function controlValue<Value>(local: Value | undefined, tree: Value, lastSent: number, ack: number): Value;
```

| Parameter | Type | Description |
|---|---|---|
| `local` | `Value \| undefined` | What the person did, or undefined when they have done nothing yet. |
| `tree` | `Value` | The value the newest tree holds. |
| `lastSent` | `number` | The `seq` of the last event this control sent (0 for none). |
| `ack` | `number` | The newest `ack` the mount sent. |

Returns `Value`.

Example:

```ts
import { controlValue } from 'songstress/ui/reader'

controlValue('abc', 'ab', 7, 6) // 'abc': event 7 is not handled yet
controlValue('abc', 'ab', 7, 7) // 'ab': handled, and the handler kept "ab"
```

### handledOf

What a control does, as an app reads it from a drawn tree: an action, a
function of the extension's client code by the id its mount gave it
(`{ $handler: n }`, which the app sends back to that mount as an event),
or a `confirm` around either; null when it is neither. A server-rendered
tree never holds a handler reference: the server's reader drops one.

```ts
export declare function handledOf(value: unknown): Handled | null;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the tree holds where a handler stands. |

Returns `Handled | null`.

Example:

```ts
import { handledOf } from 'songstress/ui/reader'

handledOf({ $handler: 4 }) // { $handler: 4 }
handledOf({ type: 'toast', message: 'Saved' }) // the action, as readAction reads it
handledOf({ $handler: 1.5 }) // null
```

Refers to [Handled](/docs/develop/reference/ui/#type-Handled).

### imageFileName

The name of a stored image (PNG, JPEG or WebP), else "": what a tree may
name as `{ file }`.

```ts
export declare function imageFileName(value: unknown): string;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | Any JSON value. |

Returns `string`.

Example:

```ts
import { imageFileName } from 'songstress/ui'

imageFileName('pets/prince.webp') // 'pets/prince.webp'
imageFileName('pets/pet.json') // ''
```

### isKnownIcon

Whether `name` is one of the set's names, which an app draws as its own
glyph; any other is drawn as the extension mark.

```ts
export declare function isKnownIcon(name: unknown): name is KnownIconName;
```

| Parameter | Type | Description |
|---|---|---|
| `name` | `unknown` |  |

Returns `name is KnownIconName`.

Example:

```ts
import { isKnownIcon } from 'songstress/ui'

isKnownIcon('heart') // true
isKnownIcon('unicorn') // false: drawn as the extension mark
```

Refers to [KnownIconName](/docs/develop/reference/songstress/#type-KnownIconName).

### isWebAddress

Whether `value` is an address an app follows or fetches for a tree: http
or https, with a host, no spaces, and 2,000 characters at most. An
`openUrl` action or an image with any other address is left out.

```ts
export declare function isWebAddress(value: unknown): value is string;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | The address. |

Returns `value is string`.

Example:

```ts
import { isWebAddress } from 'songstress/ui'

isWebAddress('https://example.com/album/1') // true
isWebAddress('ftp://example.com/album/1') // false
```

### listOf

`value` when it is an array, else `[]`.

```ts
export declare const listOf: (value: unknown) => unknown[];
```

Example:

```ts
import { listOf } from 'songstress/ui'

listOf([1, 2]).length // 2
listOf({ length: 2 }).length // 0
```

### mergeSurfaceState

Layers of one extension's state laid one over another, key by key: a later
layer's value stands over an earlier one's. An app lays every member's,
then the member's, then this device's.

```ts
export declare function mergeSurfaceState(...layers: SurfaceState[]): SurfaceState;
```

| Parameter | Type | Description |
|---|---|---|
| `...layers` | `SurfaceState[]` | The layers, the lowest first. |

Returns `SurfaceState`.

Example:

```ts
import { mergeSurfaceState } from 'songstress/ui/reader'

const empty = { badges: {}, context: {}, status: {}, overlays: {} }
const merged = mergeSurfaceState({ ...empty, badges: { inbox: 2 } }, { ...empty, badges: { inbox: 'dot' } })
// merged.badges.inbox === 'dot'
```

Refers to [SurfaceState](/docs/develop/reference/ui/#type-SurfaceState).

### numberOf

`value` when it is a finite number, else `null`.

```ts
export declare const numberOf: (value: unknown) => number | null;
```

Example:

```ts
import { numberOf } from 'songstress/ui'

numberOf(3.5) // 3.5
numberOf('3.5') // null
```

### objectOf

`value` when it is a plain object, else `{}`.

```ts
export declare const objectOf: (value: unknown) => Record<string, unknown>;
```

Example:

```ts
import { objectOf } from 'songstress/ui'

objectOf({ id: 'a' }).id // 'a'
objectOf(['a']).id // undefined: a list is no object
```

### readAction

What a tap does, as an app reads an action an extension handed it (a
command's outcome, a button's, a row's): null when it is no action an app
carries out. A question (a confirm, a pick, an input, a notice) may lead to
one more, and no further.

```ts
export declare function readAction(value: unknown): Action | null;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | The action, as the extension wrote it. |

Returns `Action | null`.

Example:

```ts
import { readAction } from 'songstress/ui'

console.log(readAction({ type: 'toast', message: 'Saved' })) // { type: 'toast', message: 'Saved' }
console.log(readAction({ type: 'teleport' })) // null
```

Refers to [Action](/docs/develop/reference/songstress/#type-Action).

### readOverlay

An overlay, as an app reads what its renderer answered: read as a panel is,
held to `UI_CAPS.overlayNodes` nodes. `tree` is null when it has nothing to
show now.

```ts
export declare function readOverlay(value: unknown, assets?: readonly AssetSize[]): TreeRead<DrawnPanel | null>;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the renderer answered. |
| `assets?` | `readonly AssetSize[]` | The package's images and their sizes, as for `readScreen`. |

Returns `TreeRead<DrawnPanel | null>`.

Example:

```ts
import { readOverlay } from 'songstress/ui'

const read = readOverlay({ children: [{ type: 'text', text: 'Asleep' }] })
console.log(read.ok ? read.tree?.children.length : read.reason) // 1
```

Refers to [AssetSize](/docs/develop/reference/ui/#type-AssetSize), [TreeRead](/docs/develop/reference/ui/#type-TreeRead), [DrawnPanel](/docs/develop/reference/ui/#type-DrawnPanel).

### readPanel

A panel, as an app reads what an extension's renderer answered; `tree` is
null when the panel has nothing to show here and is left out (nothing, or
nothing readable). Only a panel over one of `UI_CAPS` is refused.

```ts
export declare function readPanel(value: unknown, assets?: readonly AssetSize[]): TreeRead<DrawnPanel | null>;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the renderer answered. |
| `assets?` | `readonly AssetSize[]` | The package's images and their sizes, as for `readScreen`. |

Returns `TreeRead<DrawnPanel | null>`.

Example:

```ts
import { readPanel } from 'songstress/ui'

const read = readPanel({ children: [{ type: 'text', text: 'Played 12 times this week' }] })
console.log(read.ok ? read.tree?.children.length : read.reason) // 1
```

Refers to [AssetSize](/docs/develop/reference/ui/#type-AssetSize), [TreeRead](/docs/develop/reference/ui/#type-TreeRead), [DrawnPanel](/docs/develop/reference/ui/#type-DrawnPanel).

### readScreen

A page, as an app reads what an extension's renderer answered: `ok` with
the tree it draws, or why it draws none (`too-large`: over one of
`UI_CAPS`; `unreadable`: not a screen). A node it does not know is kept as
`{ type: 'unknown' }`, drawn as "needs a newer app"; a part an extension
may not say is left out.

```ts
export declare function readScreen(value: unknown, assets?: readonly AssetSize[]): TreeRead<DrawnScreen>;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the renderer answered. |
| `assets?` | `readonly AssetSize[]` | The package's images and their sizes, from the extension's entry in the server's contributions list: with them, a sprite whose frames do not fit its image is left out. |

Returns `TreeRead<DrawnScreen>`.

Example:

```ts
import { readScreen } from 'songstress/ui'

const page = { type: 'list', sections: [{ items: [{ type: 'row', id: 'a', title: 'Blue in Green' }] }] }
const read = readScreen(page)
// Kept whole: every app draws this page as written.
console.log(read.ok && JSON.stringify(read.tree) === JSON.stringify(page))
```

Refers to [AssetSize](/docs/develop/reference/ui/#type-AssetSize), [TreeRead](/docs/develop/reference/ui/#type-TreeRead), [DrawnScreen](/docs/develop/reference/ui/#type-DrawnScreen).

### readStatus

A status item, as an app reads what its renderer answered or code set;
null when it has nothing to say now (nothing, or neither words, an icon nor
a sprite). Its words are cut to `UI_CAPS.status` characters, its progress
held between 0 and 1; its sprite is read as a sprite block is.

```ts
export declare function readStatus(value: unknown, assets?: readonly AssetSize[]): DrawnStatus | null;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the renderer answered. |
| `assets?` | `readonly AssetSize[]` | The package's images and their sizes: with them, a sprite whose frames do not fit its image is left out. |

Returns `DrawnStatus | null`.

Example:

```ts
import { readStatus } from 'songstress/ui'

console.log(readStatus({ text: 'Synced', icon: 'sync', progress: 1.5 })) // { text: 'Synced', icon: 'sync', progress: 1 }
```

Refers to [AssetSize](/docs/develop/reference/ui/#type-AssetSize), [DrawnStatus](/docs/develop/reference/ui/#type-DrawnStatus).

### readSurfaceState

One layer of an extension's state, as an app reads what it was handed (the
server's answer, a push, or client code's own writes): each badge, key,
status item and overlay the extension declares, read by its rules; anything
else left out. A text is checked against `SURFACE_CAPS.bytes` before it is
parsed; one over it, or one that is not JSON, reads as an empty state.

```ts
export declare function readSurfaceState(value: unknown, declared: SurfaceDeclared): SurfaceState;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | The state, as JSON text or as parsed JSON. |
| `declared` | `SurfaceDeclared` | What the extension declares. |

Returns `SurfaceState`.

Example:

```ts
import { readSurfaceState } from 'songstress/ui/reader'

const declared = { sidebar: ['inbox'], context: [{ key: 'asleep', type: 'boolean' as const }], status: [], overlays: ['pet'] }
const state = readSurfaceState({ badges: { inbox: 3, other: 1 }, context: { asleep: 'yes' }, overlays: { pet: false } }, declared)
// { badges: { inbox: 3 }, context: {}, status: {}, overlays: { pet: false } }
```

Refers to [SurfaceDeclared](/docs/develop/reference/ui/#type-SurfaceDeclared), [SurfaceState](/docs/develop/reference/ui/#type-SurfaceState).

### readUpdate

An answer of a mount (to a `mount`, `context`, `event`, `tick` or
`unmount`) or a push through `MOUNT_PUSH`, read field by field. Anything
without `$mount: 1` is `plain`: the tree itself, from a bundle that holds
no mount (built before API 0.1.12, or one whose renderer answers a
hand-written tree), drawn as it is drawn today. A count that is not a
whole number, a mount id that is not one, or a tree longer than
`UI_CAPS.bytes` is `refused`. Whether an `n` rose and an `ack` is one the
app sent is the app's to check, against what it holds of that mount.

```ts
export declare function readUpdate(value: unknown): MountUpdate;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the renderer answered, or the push's one argument. |

Returns `MountUpdate`.

Example:

```ts
import { readUpdate } from 'songstress/ui/reader'

readUpdate({ $mount: 1, n: 1, ack: 0, tree: '{"type":"detail","children":[]}' })
// { kind: 'render', n: 1, ack: 0, tree: '{"type":"detail","children":[]}' }
readUpdate({ type: 'detail', children: [] }) // { kind: 'plain', value: … }: an older bundle's tree
```

Refers to [MountUpdate](/docs/develop/reference/ui/#type-MountUpdate).

### readViewImage

A view's picture as the frame's script and the app read it: a cover of
the library (one of `VIEW_IMAGE.covers`, by a library id) or one of the
package's images (a plain path in the package); `null`, no picture; and
`undefined` for anything else, which names no address the app would load.

```ts
export declare function readViewImage(value: unknown): ViewImage | null | undefined;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | The `image` change's value. |

Returns `ViewImage | null | undefined`.

Example:

```ts
import { readViewImage } from 'songstress/ui/reader'

console.log(readViewImage({ cover: 'album', id: '4uLU6hMCjMI75M1A2tKUQC' })) // { cover: 'album', id: '4uLU6hMCjMI75M1A2tKUQC' }
console.log(readViewImage({ cover: 'coverArt', id: 'https://example.com/a.png' })) // undefined
```

Refers to [ViewImage](/docs/develop/reference/view/#type-ViewImage).

### readViewPatch

A patch as the frame's script reads what a view's worker posted: its
changes, or why it is refused whole (more than `VIEW_CAPS.patchOps`
changes, more than `VIEW_CAPS.patchChars` characters counted as
`viewOpChars` counts them, or one change of another shape).

```ts
export declare function readViewPatch(value: unknown): ViewPatchRead;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | What the worker posted. |

Returns `ViewPatchRead`.

Example:

```ts
import { readViewPatch } from 'songstress/ui/reader'

console.log(readViewPatch({ t: 'patch', ops: [['count', 'text', '3']] }).ok) // true
console.log(readViewPatch({ t: 'patch', ops: [['link', 'href', 'https://example.com']] }).ok) // false
```

Refers to [ViewPatchRead](/docs/develop/reference/ui/#type-ViewPatchRead).

### spriteRuns

A sprite's first animation and the one that follows it (`then`, which
plays at the sprite's own rate when it names none), or null when its frames
do not fit its image: more frames than the image has across, or a row
below its last.

```ts
export declare function spriteRuns(sprite: SpriteBlock, asset: {
    width: number;
    height: number;
}): {
    first: SpriteRun;
    then?: SpriteRun;
} | null;
```

| Parameter | Type | Description |
|---|---|---|
| `sprite` | `SpriteBlock` | The sprite, as the reader kept it. |
| `asset` | `{ width: number; height: number; }` | Its image's size in pixels, from the extension's list of assets. |

Returns `{
    first: SpriteRun;
    then?: SpriteRun;
} | null`.

Example:

```ts
import { spriteRuns } from 'songstress/ui/reader'

const sprite = { type: 'sprite' as const, source: { asset: 'assets/pet.webp' }, frameWidth: 192, frameHeight: 208, frames: 6, row: 1, loop: false, then: { row: 0, frames: 6 } }
const runs = spriteRuns(sprite, { width: 1536, height: 1872 })
// runs?.first: row 1, 6 frames over 750 ms, once; runs?.then: row 0, again and again
```

Refers to [SpriteBlock](/docs/develop/reference/songstress/#type-SpriteBlock), [SpriteRun](/docs/develop/reference/ui/#type-SpriteRun).

### storedFileType

What a stored file of this name is, or null for a name the store refuses:
1 to 128 characters, up to three folders, ending in one of
`STORED_FILE_TYPES`' endings.

```ts
export declare function storedFileType(name: unknown): StoredType | null;
```

| Parameter | Type | Description |
|---|---|---|
| `name` | `unknown` | The file's name. |

Returns `StoredType | null`.

Example:

```ts
import { storedFileType } from 'songstress/ui'

storedFileType('pets/prince.webp') // 'image/webp'
storedFileType('../secret.png') // null
```

Refers to [StoredType](/docs/develop/reference/songstress/#type-StoredType).

### stringsOf

The strings in `value` when it is an array, else `[]`.

```ts
export declare const stringsOf: (value: unknown) => string[];
```

Example:

```ts
import { stringsOf } from 'songstress/ui'

stringsOf(['a', 1, 'b']) // ['a', 'b']
```

### textOf

`value` when it is a string, else `""`.

```ts
export declare const textOf: (value: unknown) => string;
```

Example:

```ts
import { textOf } from 'songstress/ui'

textOf('Blue in Green') // 'Blue in Green'
textOf(42) // ''
```

### uploadFolder

An upload's folder: up to three parts joined by `/` (a `/` at its end is
dropped), "" for none, null for one the store would refuse.

```ts
export declare function uploadFolder(value: unknown): string | null;
```

| Parameter | Type | Description |
|---|---|---|
| `value` | `unknown` | Any JSON value. |

Returns `string | null`.

Example:

```ts
import { uploadFolder } from 'songstress/ui'

uploadFolder('pets/') // 'pets'
uploadFolder('Pets') // null
```

### useAsync

What an async function answered for these deps: `loading` until it does,
then `data` (or `error`). An answer for deps that have since changed, or
that comes once the component is gone, is ignored. In one pass it holds
`loading: true`: a server renderer awaits what it needs before it answers.

```ts
export declare function useAsync<Data>(load: () => Promise<Data>, deps: readonly unknown[]): AsyncState<Data>;
```

| Parameter | Type | Description |
|---|---|---|
| `load` | `() => Promise<Data>` | Asks for the data. |
| `deps` | `readonly unknown[]` | What it depends on: it asks again when one changes. |

Returns `AsyncState<Data>`.

Example:

```tsx
import { Skeleton, Text, useAsync } from 'songstress/ui'
import { songstress } from 'songstress/client'

export function Synced() {
  const at = useAsync(() => songstress.storage.get<string>('synced-at'), [])
  if (at.loading) return <Skeleton />
  return <Text>{at.data ? `Synced ${at.data}` : 'Not synced yet'}</Text>
}
```

Refers to [AsyncState](/docs/develop/reference/ui/#type-AsyncState).

### useCallback

The same function while its deps hold, for a component that compares it.

```ts
export declare function useCallback<Fn extends (...args: never[]) => unknown>(fn: Fn, deps: readonly unknown[]): Fn;
```

Example:

```tsx
import { Switch, useCallback, useState } from 'songstress/ui'

export function Loud() {
  const [loud, setLoud] = useState(false)
  const toggle = useCallback((on: boolean) => setLoud(on), [])
  return <Switch label="Loud" value={loud} onChange={toggle} />
}
```

### useEffect

Work done after the tree is handed over: a timer, a listener. The function
it answers cleans up, before the effect runs again (when a dep changes)
and when the component goes. It never runs in one pass.

```ts
export declare function useEffect(effect: () => void | (() => void), deps?: readonly unknown[]): void;
```

| Parameter | Type | Description |
|---|---|---|
| `effect` | `() => void \| (() => void)` | The work; it may answer its clean-up. |
| `deps?` | `readonly unknown[]` | What it depends on: it runs again when one changes. Left out, after every render. |

Returns `void`.

Example:

```tsx
import { Text, useEffect, useState } from 'songstress/ui'

export function Clock() {
  const [now, setNow] = useState(() => new Date())
  useEffect(() => {
    const timer = setInterval(() => setNow(new Date()), 1000)
    return () => clearInterval(timer)
  }, [])
  return <Text>{now.toISOString().slice(11, 19)}</Text>
}
```

### useMemo

A value worked out again only when one of its deps changes.

```ts
export declare function useMemo<Value>(make: () => Value, deps: readonly unknown[]): Value;
```

| Parameter | Type | Description |
|---|---|---|
| `make` | `() => Value` | Works the value out. |
| `deps` | `readonly unknown[]` | What it depends on. |

Returns `Value`.

Example:

```tsx
import { Text, useMemo } from 'songstress/ui'

export function Total({ minutes }: { minutes: number[] }) {
  const total = useMemo(() => minutes.reduce((sum, each) => sum + each, 0), [minutes])
  return <Text>{`${total} minutes in all`}</Text>
}
```

### usePlayer

This device's player, kept current: what `player.getState` answers, then
the state each player hook hands over. Undefined until it is known, and
always for an extension without the `listening.read` permission. A hook
the manifest does not list under `hooks.client` is never delivered: list
`onPlay`, `onPause`, `onTrackChange`, `onSeek`, `onProgress` and
`onVolumeChange` as the component needs them.

```ts
export declare function usePlayer(): PlayerState | undefined;
```

Returns `PlayerState | undefined`.

Example:

```tsx
import { Text, usePlayer } from 'songstress/ui'

// The manifest asks for listening.read and lists onTrackChange under hooks.client.
export function NowPlaying() {
  const player = usePlayer()
  return <Text>{player?.song ? `Playing ${player.song.title}` : 'Nothing playing'}</Text>
}
```

Refers to [PlayerState](/docs/develop/reference/songstress/#type-PlayerState).

### useReducer

State changed by a reducer: the next state from the state and a change.

```ts
export declare function useReducer<State, Change>(reducer: (state: State, change: Change) => State, initial: State): [
    State,
    (change: Change) => void
];
```

| Parameter | Type | Description |
|---|---|---|
| `reducer` | `(state: State, change: Change) => State` | What each change makes of the state. |
| `initial` | `State` | The first state. |

Returns `[
    State,
    (change: Change) => void
]`.

Example:

```tsx
import { Button, Text, Stack, useReducer } from 'songstress/ui'

type Change = 'more' | 'reset'
const count = (state: number, change: Change) => (change === 'more' ? state + 1 : 0)

export function Tally() {
  const [state, change] = useReducer(count, 0)
  return (
    <Stack>
      <Text>{String(state)}</Text>
      <Button title="More" onPress={() => change('more')} />
      <Button title="Reset" emphasis="quiet" onPress={() => change('reset')} />
    </Stack>
  )
}
```

### useRef

One object kept for the component's life: changing `current` renders
nothing.

```ts
export declare function useRef<Value>(initial: Value): {
    current: Value;
};
```

| Parameter | Type | Description |
|---|---|---|
| `initial` | `Value` | Its first `current`. |

Returns `{
    current: Value;
}`.

Example:

```tsx
import { Button, useRef } from 'songstress/ui'

export function Presses() {
  const presses = useRef(0)
  return <Button title="Press" onPress={() => void (presses.current += 1)} />
}
```

### useSetting

One of the extension's settings, kept current: undefined until it is read,
then its value, and each change to it after.

```ts
export declare function useSetting<Value extends SettingValue = SettingValue>(key: string): Value | undefined;
```

| Parameter | Type | Description |
|---|---|---|
| `key` | `string` | The setting's key, as the manifest declares it. |

Returns `Value | undefined`.

Example:

```tsx
import { Text, useSetting } from 'songstress/ui'

export function Greeting() {
  const name = useSetting<string>('name')
  return <Text>{`Hello, ${name ?? 'you'}`}</Text>
}
```

Refers to [SettingValue](/docs/develop/reference/songstress/#type-SettingValue).

### useState

State of a component, kept between its renders: a change renders it again.

```ts
export declare function useState<State>(initial: State | (() => State)): [
    State,
    (next: State | ((was: State) => State)) => void
];
```

| Parameter | Type | Description |
|---|---|---|
| `initial` | `State \| (() => State)` | Its first value, or a function that makes it. |

Returns `[
    State,
    (next: State | ((was: State) => State)) => void
]`.

Example:

```tsx
import { Button, Text, Stack, useState } from 'songstress/ui'

export function Counter() {
  const [count, setCount] = useState(0)
  return (
    <Stack>
      <Text>{`Pressed ${count} times`}</Text>
      <Button title="Add" onPress={() => setCount((was) => was + 1)} />
    </Stack>
  )
}
```

### useStored

State kept in the extension's store (JSON), under `key`, for the member: `initial`
until it is read (`loading` says when), the stored value after. `set`
shows the new value at once and writes it; a write that fails is logged.
It needs the `storage` permission.

```ts
export declare function useStored<Value = JsonValue>(key: string, initial: Value): [
    value: Value,
    set: (next: Value | ((was: Value) => Value)) => void,
    loading: boolean
];
```

| Parameter | Type | Description |
|---|---|---|
| `key` | `string` | Where it is kept. |
| `initial` | `Value` | What it holds before it is read, and when nothing is kept. |

Returns `[
    value: Value,
    set: (next: Value | ((was: Value) => Value)) => void,
    loading: boolean
]`.

Example:

```tsx
import { Switch, useStored } from 'songstress/ui'

export function Loud() {
  const [loud, setLoud, loading] = useStored('loud', false)
  return <Switch label="Loud" value={loud} disabled={loading} onChange={setLoud} />
}
```

Refers to [JsonValue](/docs/develop/reference/songstress/#type-JsonValue).

### viewOpChars

What one change counts toward a patch's `VIEW_CAPS.patchChars`, as the
frame counts it (its count is the contract): the element's id, and the
text the change carries (a text, a class or a value that is text; a
picture's kind and id, or its path).

```ts
export declare function viewOpChars(op: ViewPatchOp): number;
```

| Parameter | Type | Description |
|---|---|---|
| `op` | `ViewPatchOp` | One change of a patch. |

Returns `number`.

Example:

```ts
import { viewOpChars } from 'songstress/ui/reader'

console.log(viewOpChars(['count', 'text', '3 plays'])) // 12
```

Refers to [ViewPatchOp](/docs/develop/reference/ui/#type-ViewPatchOp).

### viewStyleRefused

Whether a view's style holds what `VIEW_STYLE` refuses: its escapes read,
in lower case. The app refuses the view (it is not drawn), the frame's
script ends it, and `songstress check` warns `VIEW_TEXT_SECURITY`.

```ts
export declare function viewStyleRefused(css: string): boolean;
```

| Parameter | Type | Description |
|---|---|---|
| `css` | `string` | The text of one `style` element or attribute, as the HTML parser hands it on. |

Returns `boolean`.

Example:

```ts
import { viewStyleRefused } from 'songstress/ui/reader'

console.log(viewStyleRefused('#pin { -webkit-text-\\73 ecurity: disc }'), viewStyleRefused('p { color: red }')) // true false
```

### viewStyleUnescaped

A view's style with its CSS escapes read, as an engine reads them (a code
point that is none, U+FFFD): the text every rule of `VIEW_STYLE`, and the
app's reading of a style's pictures, is held to.

```ts
export declare function viewStyleUnescaped(css: string): string;
```

| Parameter | Type | Description |
|---|---|---|
| `css` | `string` | The text of one `style` element or attribute, as the HTML parser hands it on. |

Returns `string`.

Example:

```ts
import { viewStyleUnescaped } from 'songstress/ui/reader'

console.log(viewStyleUnescaped('p { background: url(d\\61 ta:image/png;base64,AA) }')) // p { background: url(data:image/png;base64,AA) }
```

### viewWeight

What an app holds an in-app view's file to, read from the file as a browser parses it: its elements (every element
of its body, its scripts among them, and each `style` element of its head; a table's implied `tbody` counts, and
a `<` in a sheet, a comment or an attribute does not), its characters of style, and whether its style dresses a
field as a password box (`viewStyleRefused`). The app and `songstress check` and `build` count by this, the app
on its own parser's document, the command on parse5's, so a file the one takes the other takes.

```ts
export declare function viewWeight(document: ViewTreeNode): ViewWeight;
```

| Parameter | Type | Description |
|---|---|---|
| `document` | `ViewTreeNode` | The view's file, parsed: the DOM's `Document`, or parse5's `parse(file, { scriptingEnabled: false })`. |

Returns `ViewWeight`.

Example:

```ts
import { viewWeight } from 'songstress/ui/reader'

// In a page: viewWeight(new DOMParser().parseFromString(file, 'text/html')). By hand, `<p style="color: red">`:
const p = { nodeName: 'P', tagName: 'P', attributes: [{ name: 'style', value: 'color: red' }] }
const html = { nodeName: 'HTML', tagName: 'HTML', childNodes: [{ nodeName: 'HEAD', tagName: 'HEAD' }, { nodeName: 'BODY', tagName: 'BODY', childNodes: [p] }] }
console.log(viewWeight({ nodeName: '#document', childNodes: [html] })) // { elements: 1, styleChars: 10, passwordStyle: false }
```

Refers to [ViewTreeNode](/docs/develop/reference/ui/#type-ViewTreeNode), [ViewWeight](/docs/develop/reference/ui/#type-ViewWeight).

### withValue

The action a control's handler runs on the server, with the value the
person chose in it: an `invoke` is handed the value as `input.value` (an
`input` that is an object gains it, any other becomes `{ value }`), and a
`confirm` around an `invoke` hands it on to that `invoke`. Any other action
runs as written, without the value. The server refuses an input of more
than 8 KiB, as for any action.

```ts
export declare function withValue(action: Action, value: unknown): Action;
```

| Parameter | Type | Description |
|---|---|---|
| `action` | `Action` | The control's `onChange`, `onSubmit`, `onSelect` or `onExpand`. |
| `value` | `unknown` | What the control now holds (section 3 of SPEC.md's declared interface). |

Returns `Action`.

Example:

```ts
import { withValue } from 'songstress/ui/reader'

withValue({ type: 'invoke', command: 'set', input: { key: 'loud' } }, true)
// { type: 'invoke', command: 'set', input: { key: 'loud', value: true } }
```

Refers to [Action](/docs/develop/reference/songstress/#type-Action).
