# Type Alias: GameWorkerRequest (/pixi-vn/index/type-aliases/GameWorkerRequest)



\> **GameWorkerRequest** = \{ `diff`: `Difference`\[]; `id`: `number`; `state`: `object`; `type`: `"restore-diff"`; } | \{ `after`: `object`; `before`: `object`; `id`: `number`; `type`: `"diff"`; } | \{ `id`: `number`; `type`: `"clone"`; `value`: `object`; } | \{ `id`: `number`; `kind`: `string`; `payload`: `unknown`; `type`: `"custom"`; }

Defined in: [src/worker/interfaces/GameWorkerMessage.ts:13](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/worker/interfaces/GameWorkerMessage.ts#L13)

Message protocol between the main thread and an optional GameWorker-registered
Worker. Kept intentionally small: each request names one unit of work Pixi'VN (or a
third-party library building on it, via `"custom"` - see `registerGameWorkerHandler`) knows
how to hand off, and the worker replies with the same `id` so the caller can match the
response.

This protocol (and everything it carries) only ever deals with plain, structured-clone-safe
data - never PixiJS/canvas/audio objects, which can't leave the main thread.

## Union Members [#union-members]

### Type Literal [#type-literal]

\{ `diff`: `Difference`\[]; `id`: `number`; `state`: `object`; `type`: `"restore-diff"`; }

#### diff [#diff]

\> **diff**: `Difference`\[]

#### id [#id]

\> **id**: `number`

#### state [#state]

\> **state**: `object`

The base state to apply `diff` to (not mutated).

#### type [#type]

\> **type**: `"restore-diff"`

***

### Type Literal [#type-literal-1]

\{ `after`: `object`; `before`: `object`; `id`: `number`; `type`: `"diff"`; }

#### after [#after]

\> **after**: `object`

#### before [#before]

\> **before**: `object`

The two states to compare (neither is mutated).

#### id [#id-1]

\> **id**: `number`

#### type [#type-1]

\> **type**: `"diff"`

***

### Type Literal [#type-literal-2]

\{ `id`: `number`; `type`: `"clone"`; `value`: `object`; }

#### id [#id-2]

\> **id**: `number`

#### type [#type-2]

\> **type**: `"clone"`

#### value [#value]

\> **value**: `object`

The value to deep-clone.

***

### Type Literal [#type-literal-3]

\{ `id`: `number`; `kind`: `string`; `payload`: `unknown`; `type`: `"custom"`; }

#### id [#id-3]

\> **id**: `number`

#### kind [#kind]

\> **kind**: `string`

Identifies which registered handler (see `registerGameWorkerHandler`) should run.

#### payload [#payload]

\> **payload**: `unknown`

#### type [#type-3]

\> **type**: `"custom"`
