> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# WhiteBoard

本页面介绍 Lynx DevTool 支持的 `WhiteBoard` CDP domain。



:::warning 实验性参考
此生成的参考文档仍在完善中。

- CDP events 尚未包含。
- 部分 Lynx 扩展已列出，但尚未提供详细文档。
- 方法说明尚未根据实现自动校验，可能不完整或不准确。

在依赖本参考前，请根据实现及所链接的 upstream CDP reference 验证实际行为。
:::

## 概览

- 作用域：`instance`
- CDP domain：Lynx 专有

## Lynx 扩展

### `WhiteBoard.clear`

Clears all global WhiteBoard shared-data entries.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_white_board_agent.cc`

###### 参数

无参数。

###### 返回字段

无返回字段。

###### 事件

- WhiteBoard.onSharedDataCleared

###### 备注

- Requires WhiteBoard.enable first. If the delegate is disabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to the TASM executor when available, otherwise to the JavaScript debugger.
- If neither backend task runner is available, the mediator does not dispatch the request and no explicit CDP response is sent.
- Returns an empty result object on success.
- Returns a CDP error with code -32000 and message Failed to clear shared data! when the WhiteBoard instance is unavailable.
- On success, enabled delegates receive WhiteBoard.onSharedDataCleared without params.
- If no WhiteBoard inspector delegate is attached, the current handler does not send an explicit CDP response.

###### 示例

**Clear shared data**

Request:

```json
{
  "id": 8,
  "method": "WhiteBoard.clear"
}
```

Response:

```json
{
  "id": 8,
  "result": {}
}
```

**Shared-data cleared notification**

Response:

```json
{
  "method": "WhiteBoard.onSharedDataCleared"
}
```

### `WhiteBoard.disable`

Disables WhiteBoard shared-data inspection for the current target.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_white_board_agent.cc`

###### 参数

无参数。

###### 返回字段

无返回字段。

###### 备注

- Dispatches through LynxDevToolMediator to the TASM executor when available, otherwise to the JavaScript debugger.
- If neither backend task runner is available, the mediator does not dispatch the request and no explicit CDP response is sent.
- Sets the WhiteBoard inspector delegate enabled flag to false.
- Returns an empty result object.
- After disable succeeds, WhiteBoard data methods that require an enabled delegate return no explicit CDP response.
- If no WhiteBoard inspector delegate is attached, the current handler does not send an explicit CDP response.

###### 示例

**Disable WhiteBoard inspection**

Request:

```json
{
  "id": 2,
  "method": "WhiteBoard.disable"
}
```

Response:

```json
{
  "id": 2,
  "result": {}
}
```

### `WhiteBoard.enable`

Enables WhiteBoard shared-data inspection for the current target.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_white_board_agent.cc`

###### 参数

无参数。

###### 返回字段

无返回字段。

###### 备注

- Dispatches through LynxDevToolMediator to the TASM executor when available, otherwise to the JavaScript debugger.
- If neither backend task runner is available, the mediator does not dispatch the request and no explicit CDP response is sent.
- Sets the WhiteBoard inspector delegate enabled flag to true.
- Returns an empty result object.
- After enable succeeds, WhiteBoard shared-data change events can be delivered to this target.
- If no WhiteBoard inspector delegate is attached, the current handler does not send an explicit CDP response.

###### 示例

**Enable WhiteBoard inspection**

Request:

```json
{
  "id": 1,
  "method": "WhiteBoard.enable"
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

### `WhiteBoard.getSharedData`

Returns all global WhiteBoard shared-data entries.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_white_board_agent.cc`

###### 参数

无参数。

###### 返回字段

| Name              | Type     | Description                                             |
| ----------------- | -------- | ------------------------------------------------------- |
| `entries`         | `array`  | Shared-data entries currently stored in the WhiteBoard. |
| `entries[].key`   | `string` | Shared-data key.                                        |
| `entries[].value` | `string` | JSON text for the shared-data value.                    |

###### 备注

- Requires WhiteBoard.enable first. If the delegate is disabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to the TASM executor when available, otherwise to the JavaScript debugger.
- If neither backend task runner is available, the mediator does not dispatch the request and no explicit CDP response is sent.
- The native implementation does not read request params.
- Values are returned as serialized JSON text strings.
- Returns a CDP error with code -32000 and message Failed to get shared data! when the WhiteBoard instance is unavailable.
- If no WhiteBoard inspector delegate is attached, the current handler does not send an explicit CDP response.

###### 示例

**Get all shared data**

Request:

```json
{
  "id": 5,
  "method": "WhiteBoard.getSharedData"
}
```

Response:

```json
{
  "id": 5,
  "result": {
    "entries": [
      {
        "key": "userName",
        "value": "\"Ada\""
      },
      {
        "key": "count",
        "value": "3"
      }
    ]
  }
}
```

### `WhiteBoard.removeSharedData`

Removes one global WhiteBoard shared-data entry.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_white_board_agent.cc`

###### 参数

| Name  | Type     | Required | Description                |
| ----- | -------- | -------- | -------------------------- |
| `key` | `string` | Yes      | Shared-data key to remove. |

###### 返回字段

无返回字段。

###### 事件

- WhiteBoard.onSharedDataRemoved

###### 备注

- Requires WhiteBoard.enable first. If the delegate is disabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to the TASM executor when available, otherwise to the JavaScript debugger.
- If neither backend task runner is available, the mediator does not dispatch the request and no explicit CDP response is sent.
- Returns an empty result object when the key exists and is removed.
- Returns a CDP error with code -32602 and message The key does not exist! when the key is not present.
- Returns a CDP error with code -32000 and message Failed to remove shared data! when the WhiteBoard instance is unavailable.
- On success, enabled delegates receive WhiteBoard.onSharedDataRemoved with params.key.
- If no WhiteBoard inspector delegate is attached, the current handler does not send an explicit CDP response.

###### 示例

**Remove one shared-data entry**

Request:

```json
{
  "id": 6,
  "method": "WhiteBoard.removeSharedData",
  "params": {
    "key": "userName"
  }
}
```

Response:

```json
{
  "id": 6,
  "result": {}
}
```

**Shared-data removed notification**

Response:

```json
{
  "method": "WhiteBoard.onSharedDataRemoved",
  "params": {
    "key": "userName"
  }
}
```

**Missing key**

Request:

```json
{
  "id": 7,
  "method": "WhiteBoard.removeSharedData",
  "params": {
    "key": "missing"
  }
}
```

Response:

```json
{
  "id": 7,
  "error": {
    "code": -32602,
    "message": "The key does not exist!"
  }
}
```

### `WhiteBoard.setSharedData`

Writes one global WhiteBoard shared-data entry.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_white_board_agent.cc`

###### 参数

| Name    | Type     | Required | Description                          |
| ------- | -------- | -------- | ------------------------------------ |
| `key`   | `string` | Yes      | Shared-data key to create or update. |
| `value` | `string` | Yes      | JSON text for the shared-data value. |

###### 返回字段

无返回字段。

###### 事件

- WhiteBoard.onSharedDataAdded
- WhiteBoard.onSharedDataUpdated

###### 备注

- Requires WhiteBoard.enable first. If the delegate is disabled, the current handler returns without sending a CDP response.
- Dispatches through LynxDevToolMediator to the TASM executor when available, otherwise to the JavaScript debugger.
- If neither backend task runner is available, the mediator does not dispatch the request and no explicit CDP response is sent.
- The value param must be a string containing valid JSON text. For a string value, include the JSON string quotes inside the value text.
- Returns an empty result object on success.
- Returns a CDP error with code -32602 and message The value must be a valid JSON string! when value cannot be parsed as JSON.
- Returns a CDP error with code -32000 and message Failed to set shared data! when the WhiteBoard instance is unavailable.
- The shared-data store emits WhiteBoard.onSharedDataAdded for a new key and WhiteBoard.onSharedDataUpdated for an existing key.
- The add event params contain key and value. The update event params contain key and newValue.
- If no WhiteBoard inspector delegate is attached, the current handler does not send an explicit CDP response.

###### 示例

**Set a string value**

Request:

```json
{
  "id": 3,
  "method": "WhiteBoard.setSharedData",
  "params": {
    "key": "userName",
    "value": "\"Ada\""
  }
}
```

Response:

```json
{
  "id": 3,
  "result": {}
}
```

**Shared-data added notification**

Response:

```json
{
  "method": "WhiteBoard.onSharedDataAdded",
  "params": {
    "key": "userName",
    "value": "\"Ada\""
  }
}
```

**Invalid JSON value**

Request:

```json
{
  "id": 4,
  "method": "WhiteBoard.setSharedData",
  "params": {
    "key": "userName",
    "value": "Ada"
  }
}
```

Response:

```json
{
  "id": 4,
  "error": {
    "code": -32602,
    "message": "The value must be a valid JSON string!"
  }
}
```

