# AssetSnapshot

> Canonical Asset panel snapshot holding the registered bundles and the Vite manifest in their typed form.

[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) › AssetSnapshot

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

Canonical Asset panel snapshot holding the registered bundles and the Vite manifest in their typed form.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates an asset snapshot from bundles and an optional Vite manifest. | `AssetSnapshot` |
| [`bundles()`](#method-bundles) | Returns the asset bundles registered during the request. | `AssetSnapshot` |
| [`fromArray()`](#method-fromArray) static | Narrows the persisted asset payload into a typed snapshot. | `AssetSnapshot` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the panel snapshot for JSON serialization. | `AssetSnapshot` |
| [`vite()`](#method-vite) | Returns the Vite manifest snapshot, or `null` when no Vite bridge is registered. | `AssetSnapshot` |

## Method details

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

```php
public function __construct(list<PHPForge\Debug\Panel\Asset\AssetBundleRow> $bundles, PHPForge\Debug\Panel\Asset\ViteManifest|null $vite)
```

Creates an asset snapshot from bundles and an optional Vite manifest.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$bundles` | `list<`[`AssetBundleRow`](/docs/extensions/debug-core/reference/panel/asset/assetbundlerow/index.md)`>` |  |
| `$vite` | [`ViteManifest`](/docs/extensions/debug-core/reference/panel/asset/vitemanifest/index.md)`\|null` |  |

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

```php
public function bundles(): list<PHPForge\Debug\Panel\Asset\AssetBundleRow>
```

Returns the asset bundles registered during the request.

**Returns**

`list<`[`AssetBundleRow`](/docs/extensions/debug-core/reference/panel/asset/assetbundlerow/index.md)`>`: Registered bundles in registration order.

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

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

Narrows the persisted asset payload into a typed snapshot.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted payload, expected to be an object carrying a `bundles` list and a `vite` entry. |
| `$path` | `string` | JSON path of the payload, used to report a malformed capture. |

**Returns**

`self`: Snapshot carrying the registered bundles and the Vite manifest.

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

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

Returns the panel snapshot for JSON serialization.

**Returns**

`array<string, mixed>`

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

```php
public function vite(): PHPForge\Debug\Panel\Asset\ViteManifest|null
```

Returns the Vite manifest snapshot, or `null` when no Vite bridge is registered.

**Returns**

[`ViteManifest`](/docs/extensions/debug-core/reference/panel/asset/vitemanifest/index.md)`|null`