# gizapp/section

what a page's client section (<script client>, the GHTML reference §4) imports. It is browser code only: the section's runtime (app/sys/client.giz, which the generated page imports as `_C`) and the typed giz-surface element. A server module never imports it, and it imports no server module, so a page's client script links alone.

```gizlang
import * as Section from "gizapp/section";
```

## Types

### `SurfaceElement`

```gizlang
class SurfaceElement { el: Client.Element; constructor(el: Client.Element) { this.el = el; } save(key: string, done: (failure: string) => void): void { Client.surfaceSave(this.el, key, done); } load(key: string, done: (found: bool, failure: string) => void): void { Client.surfaceLoad(this.el, key, done); } call(name: string, input: bytes, done: (answer: bytes, failure: string) => void): void { Client.surfaceCall(this.el, name, input, done); } render(name: string, input: bytes, done: (failure: string) => void): void { Client.surfaceRender(this.el, name, input, done); } fullscreen(done: (failure: string) => void): void { Client.surfaceFullscreen(this.el, done); } mute(muted: bool): void { Client.surfaceMute(this.el, muted); } }
```

A giz-surface element of the page, typed: the calls that a page's client section makes on it.

- `el`: `i64`

## Functions

### `constructor`

```gizlang
constructor(el: Client.Element)
```

The giz-surface element EL (surfaceIn finds it).

Effects: fail, read, write, alloc.

### `surfaceIn`

```gizlang
function surfaceIn(el: Client.Element): SurfaceElement
```

The surface element inside the element EL (its first giz-surface), typed.

Effects: fail, read, write, alloc.

## Methods

### `SurfaceElement.save`

```gizlang
save(key: string, done: (failure: string) => void): void
```

Saves the program's snapshot under KEY on this device; DONE gets the reason of a failure, "" for none.

Effects: fail, read.

### `SurfaceElement.load`

```gizlang
load(key: string, done: (found: bool, failure: string) => void): void
```

Loads the snapshot saved under KEY; DONE gets whether there was one.

Effects: fail, read.

### `SurfaceElement.call`

```gizlang
call(name: string, input: bytes, done: (answer: bytes, failure: string) => void): void
```

Calls the program's export NAME with INPUT; DONE gets its answer.

Effects: fail, read.

### `SurfaceElement.render`

```gizlang
render(name: string, input: bytes, done: (failure: string) => void): void
```

Runs the program's render export NAME with INPUT.

Effects: fail, read.

### `SurfaceElement.fullscreen`

```gizlang
fullscreen(done: (failure: string) => void): void
```

Shows the surface's canvas on the whole screen; the request must come from a click.

Effects: fail, read.

### `SurfaceElement.mute`

```gizlang
mute(muted: bool): void
```

Mutes or unmutes the program's sounds (its cues).

Effects: fail, read.

