# ViteChunk

> Typed entry of a Vite build manifest.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Asset](/docs/extensions/debug-core/reference/panel/asset/index.md) › ViteChunk

| final readonly class | `PHPForge\Debug\Panel\Asset\ViteChunk` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelRow`](/docs/extensions/debug-core/reference/storage/panelrow/index.md) |
| Source | [`src/Panel/Asset/ViteChunk.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Asset/ViteChunk.php#L12) |

Typed entry of a Vite build manifest.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-cssCount"></span>`$cssCount` readonly constructor | `int` | Number of CSS files attached to the chunk. | `ViteChunk` |
| <span id="property-file"></span>`$file` readonly constructor | `string` | Built file emitted for the chunk. | `ViteChunk` |
| <span id="property-imports"></span>`$imports` readonly constructor | `int` | Number of chunks this one imports. | `ViteChunk` |
| <span id="property-isEntry"></span>`$isEntry` readonly constructor | `bool` | Whether the chunk is a Vite entry point. | `ViteChunk` |
| <span id="property-name"></span>`$name` readonly constructor | `string` | Chunk name as keyed in the manifest. | `ViteChunk` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a Vite manifest entry with its built file and asset counts. | `ViteChunk` |
| [`fromArray()`](#method-fromArray) static | Narrows one persisted manifest entry into a typed chunk. | `ViteChunk` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the typed row for JSON serialization. | `ViteChunk` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(string $name, string $file, int $cssCount, int $imports, bool $isEntry)
```

Creates a Vite manifest entry with its built file and asset counts.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$name` | `string` |  |
| `$file` | `string` |  |
| `$cssCount` | `int` |  |
| `$imports` | `int` |  |
| `$isEntry` | `bool` |  |

### fromArray() <span id="method-fromArray"></span>

```php
public static function fromArray(mixed $data, string $path): self
```

Narrows one persisted manifest entry into a typed chunk.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted manifest entry, expected to be an object carrying the declared shape. |
| `$path` | `string` | JSON path of the entry, used to report a malformed payload. |

**Returns**

`self`: Chunk carrying every persisted manifest field.

### jsonSerialize() <span id="method-jsonSerialize"></span>

```php
public function jsonSerialize(): array<string, mixed>
```

Returns the typed row for JSON serialization.

**Returns**

`array<string, mixed>`