# Decoder Worker

TypeScript source: `dai-connection/decoder.worker.ts`

## Types

### DecoderWorkerInput

Source: `dai-connection/decoder.worker.ts:46`

Message sent to the decoder worker for service response parsing.

#### Members

| Name | Type | Description |
| --- | --- | --- |
| `data` | `DataView` | Raw response bytes. |
| `kind` | `"pipeline" | "json"` | Response payload kind. |
| `name?` | `string` | Optional service or topic name associated with the response. |

### DecoderWorkerOutput

Source: `dai-connection/decoder.worker.ts:64`

```ts
{ name?: string } & { data: RawPipelinePayload; kind: "pipeline" } | { data: RawPipelineStatePayload; kind: "pipeline" } | { data: Record<string, string>; kind: "json" }
```

Message emitted by the decoder worker after parsing a service response.

#### Members

| Name | Type | Description |
| --- | --- | --- |
| `name?` | `string` |  |
| `data` | `RawPipelinePayload` |  |
| `kind` | `"pipeline"` |  |
| `data` | `RawPipelineStatePayload` |  |
| `kind` | `"pipeline"` |  |
| `data` | `Record<string, string>` |  |
| `kind` | `"json"` |  |

## Functions

### decodeServiceMessage

Source: `dai-connection/decoder.worker.ts:12`

```ts
(response: DataView<ArrayBufferLike> | null) => any
```

Decodes a backend service response from UTF-8 JSON.

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `response` | `DataView<ArrayBufferLike> | null` | Raw binary response returned by the visualizer connection. |

#### Returns

Parsed JSON payload, or `null` when the response is empty or invalid.
