---
url: /en-us/standard/type.md
---
The main file consists of MessagePack objects one after another; each top-level object is called a **block**. The first field of a block, `type` (item 0 of the array in the Header), is the Type ID, which the reader uses to determine the kind of block.

## Type ID

| Type ID (uint16) | Block | MessagePack type | Minimum level requiring reader support |
| --- | --- | --- | --- |
| `0` | [Header](blocks/header) | Array | Core |
| `1` | [Header Extension](blocks/headerextension) | Map | Core |
| `2` | [Canvas](blocks/canvas) | Map | Core |
| `3` | [Ink](blocks/ink) | Map | Core |
| `4` | [Media](blocks/media) | Map | Standard |
| `5` | [Shape](blocks/shape) | Map | Core |
| `6` | [Clear](blocks/clear) | Map | Inkeys extension |

[Device](blocks/device) is a nested Map in the Header Extension registry; it has no Type ID and never appears as a top-level block.

Type IDs `7` and above are reserved for future versions, and UInk defines no private Type IDs: app-private data is written in each block's `extra` (TYPE-4). A writer must not write an unregistered Type ID; a reader that meets one skips it according to TYPE-9.

::: warning `type` and `inkType`
The `type` of an Ink block is always `3`; the kind of pen (erase, normal pen, highlighter…) is distinguished by `inkType` inside the block. There is no separate Eraser block, and there is no `penType` field.
:::

## Writing rules

* **TYPE-1** A writer must use the exact MessagePack type and bit width declared in the field table. For example, `uint16` must not be written as a positive fixint, and `float32` must not be written as float64.
* **TYPE-2** The Header must also follow its fixed array layout; see [Header Block](blocks/header).
* **TYPE-3** When saving again, numeric values accepted tolerantly during reading must be normalized to the type declared in the field table.
* **TYPE-4** App-private fields must be placed in the `extra` of the Map they belong to and must not be written as unregistered top-level keys.

## Reading rules

* **TYPE-5** A numeric field may tolerantly accept other MessagePack numeric encodings, but all of the following must hold: both the source value and the target are numeric (`bool` is not numeric); the conversion does not change the value (an integer target requires the source value to be an integer, a floating-point target requires the value to be exactly representable); the converted value passes the field's own range check.
* **TYPE-6** `bool`, `string`, Array and Map must not be replaced by other types.
* **TYPE-7** When any known key appears more than once in the same Map, the whole block containing that Map is invalid.
* **TYPE-8** A reader must ignore unknown keys, and unknown keys must not change the meaning of known fields.
* **TYPE-9** When a reader meets an unknown Type ID and the object can be decoded completely, the reader must skip it and continue reading the next block; it must not reject the whole file because of it. When the end of the object cannot be determined, stop reading according to the [crash recovery rules](incremental#crash-recovery). Content blocks of future versions may occupy `contentId` numbers, so a reader must not reject a file because `contentId` is not consecutive; the drawing order still follows the object stream order.
* **TYPE-10** When a reader meets a registered block beyond its level (for example, a reader below Standard meets Media), it handles the block as described in the "Fallback" section of that block's page.

## Private values

Values `128` and above of each enum field are private values, defined by each app itself. UInk provides no global vendor namespace and has no `vendorId`; only apps that have agreed on the same meaning in advance can interoperate. When a reader meets an unknown private value, it handles it according to the fallback rules of the corresponding field.

## Saving files with unknown content

* **TYPE-11** UInk does not require writers to preserve unknown blocks or keys as they are.
* **TYPE-12** A file that the app created itself, and whose content it has confirmed it fully understands, may be overwritten directly. A file that was imported from outside, or that contains content the reader does not recognize or support, should by default be saved as a new file; the original file may be overwritten only after the user explicitly confirms that content may be lost.
