# WebUI.Page — client runtime

Runs inside the game process. Reads and presentation are local; anything that changes shared state has to go through the server.

9 functions.

## destroy

```lua
WebUI.Page.destroy()
```

`SHARED` — Available without a live game instance.

Destroys the surface.

Destroys this resource-owned browser surface, removes all of its Lua event handlers and invalidates the page handle. Resource teardown performs the same cleanup automatically.

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6472) as `LuaWebPageDestroy`.

## hide

```lua
WebUI.Page.hide()
```

`SHARED` — Available without a live game instance.

Hides the surface.

Makes the owned browser surface invisible without destroying its document or handlers. Visibility is client-local and can be restored with `show()`.

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6474) as `LuaWebPageVisibility`.

## id

```lua
WebUI.Page.id()
```

`SHARED` — Available without a live game instance.

Numeric id of the surface.

Returns the opaque client-local surface id for diagnostics and host integration. It is not a network id and must not be persisted across page destruction or resource reload.

Returns: `integer`

Registered in `ResourceHost.cpp` (line 6471) as `LuaWebPageId`.

## off

```lua
WebUI.Page.off(event, handler)
```

`SHARED` — Available without a live game instance.

Removes a handler registered with `on`.

Removes one WebUI callback id previously returned by `page:on`. The id must belong to this page and the current resource generation.

| Parameter | Type | Required | Default |
|---|---|---|---|
| `event` | `string` | required | — |
| `handler` | `function` | required | — |

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6478) as `LuaWebPageOff`.

## on

```lua
WebUI.Page.on(event, handler)
```

`SHARED` — Available without a live game instance.

Listens for an event the page raised with `CyberM.emit`.

Registers a Lua callback for an event emitted by this page's JavaScript bridge. Event names and handler counts are bounded, and the registration is automatically removed with the page or resource generation.

| Parameter | Type | Required | Default |
|---|---|---|---|
| `event` | `string` | required | — |
| `handler` | `function` | required | — |

Returns: `handler id`

Registered in `ResourceHost.cpp` (line 6477) as `LuaWebPageOn`.

## reply

```lua
WebUI.Page.reply(request, ok, [payload])
```

`SHARED` — Available without a live game instance.

Answers an `invoke` call made by the page.

Completes a pending JavaScript request identified by its request id with a JSON-serializable Lua value. Request ids are page-local and invalid or unsupported payloads are rejected.

| Parameter | Type | Required | Default |
|---|---|---|---|
| `request` | `integer` | required | — |
| `ok` | `boolean` | required | — |
| `payload` | `table` | optional | — |

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6479) as `LuaWebPageReply`.

## send

```lua
WebUI.Page.send(event, [payload])
```

`SHARED` — Available without a live game instance.

Sends an event to the page.

Sends a named event and JSON-serializable payload from Lua to this page's JavaScript runtime. This is local UI IPC, not a network event, and both event names and payloads are bounded.

| Parameter | Type | Required | Default |
|---|---|---|---|
| `event` | `string` | required | — |
| `payload` | `table` | optional | — |

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6476) as `LuaWebPageSend`.

## setFocus

```lua
WebUI.Page.setFocus(focused, [cursor], [keyboard])
```

`SHARED` — Available without a live game instance.

Gives the surface focus, cursor and keyboard separately.

Keyboard capture is asked for separately so a page can take the mouse without depriving the game of the movement keys.

| Parameter | Type | Required | Default |
|---|---|---|---|
| `focused` | `boolean` | required | — |
| `cursor` | `boolean` | optional | — |
| `keyboard` | `boolean` | optional | — |

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6475) as `LuaWebPageFocus`.

## show

```lua
WebUI.Page.show()
```

`SHARED` — Available without a live game instance.

Shows the surface.

Avoid calling this right after `create` — see the race described in `CyberM.webui.create`.

Returns: `boolean`

Registered in `ResourceHost.cpp` (line 6473) as `LuaWebPageVisibility`.

