> Development branch documentation · commit 327c05c78d2f528e4f4a679fcc7a77d9aa161f48
> Package versions: @zenfg/webgpu 0.1.0, @zenfg/snapshot 0.1.0, @zenfg/inspector 0.1.0, zenfg 0.1.0, zenfg-snapshot 0.1.0
> Source: https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L80

[ZenFG TypeScript API](/zenfg/docs/api/index.md) / [inspector](/zenfg/docs/api/inspector/index.md) / [root](/zenfg/docs/api/inspector/root/index.md) / FrameGraphInspector

# Class: FrameGraphInspector

Defined in: [inspector/src/FrameGraphInspector.ts:80](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L80)

Browser lifecycle controller for one embeddable FrameGraph inspector.

## Remarks

The constructor creates, but does not append, [dom](#dom). Use
[mountFrameGraphInspector](/zenfg/docs/api/inspector/root/functions/mountFrameGraphInspector.md) for the common append-and-return workflow.
Async capture, import, and clipboard failures are reported in the UI. Call
[destroy](#destroy) when the controller is no longer needed.

## Example

```ts
const inspector = new FrameGraphInspector({ captureSnapshot: capture });
document.body.append(inspector.dom);
// Later:
inspector.destroy();
```

## Constructors

### Constructor

> **new FrameGraphInspector**(`options?`): `FrameGraphInspector`

Defined in: [inspector/src/FrameGraphInspector.ts:143](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L143)

Creates a detached inspector UI.

#### Parameters

##### options?

[`FrameGraphInspectorOptions`](/zenfg/docs/api/inspector/root/type-aliases/FrameGraphInspectorOptions.md) = `{}`

#### Returns

`FrameGraphInspector`

#### Throws

If a configured numeric limit is not a non-negative safe integer,
or if browser DOM globals are unavailable.

## Properties

### dom

> `readonly` **dom**: `HTMLElement`

Defined in: [inspector/src/FrameGraphInspector.ts:82](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L82)

Root element owned by this inspector instance.

## Methods

### captureSnapshot()

> **captureSnapshot**(): `Promise`\<`void`\>

Defined in: [inspector/src/FrameGraphInspector.ts:276](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L276)

Requests and displays a live snapshot from the configured provider.

#### Returns

`Promise`\<`void`\>

#### Remarks

Concurrent requests are coalesced. Provider errors, invalid
snapshots, and an unavailable provider are displayed in the inspector and
do not reject the returned promise.

***

### copySnapshotJson()

> **copySnapshotJson**(): `Promise`\<`void`\>

Defined in: [inspector/src/FrameGraphInspector.ts:412](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L412)

Copies the displayed snapshot as pretty-printed canonical JSON.

#### Returns

`Promise`\<`void`\>

#### Remarks

Clipboard failures are shown in the UI and do not reject the
returned promise. A legacy `document.execCommand` fallback is used when the
async Clipboard API is unavailable.

***

### destroy()

> **destroy**(): `void`

Defined in: [inspector/src/FrameGraphInspector.ts:472](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L472)

Idempotently cancels pending UI results, releases graph resources, and
removes the inspector workbench. Do not reuse the controller afterward.

#### Returns

`void`

***

### downloadSnapshot()

> **downloadSnapshot**(): `void`

Defined in: [inspector/src/FrameGraphInspector.ts:394](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L394)

Downloads the displayed snapshot as pretty-printed canonical JSON.

#### Returns

`void`

***

### getSnapshot()

> **getSnapshot**(): [`FrameGraphSnapshotV1`](/zenfg/docs/api/snapshot/root/type-aliases/FrameGraphSnapshotV1.md) \| `undefined`

Defined in: [inspector/src/FrameGraphInspector.ts:331](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L331)

Returns the currently displayed canonical snapshot, if any.

#### Returns

[`FrameGraphSnapshotV1`](/zenfg/docs/api/snapshot/root/type-aliases/FrameGraphSnapshotV1.md) \| `undefined`

***

### importSnapshot()

> **importSnapshot**(`file`): `Promise`\<`void`\>

Defined in: [inspector/src/FrameGraphInspector.ts:341](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L341)

Reads, migrates, validates, and displays a snapshot JSON file.

#### Parameters

##### file

`File`

#### Returns

`Promise`\<`void`\>

#### Remarks

Files above `maxImportBytes`, read failures, invalid JSON, and
validation failures are displayed in the UI and do not reject the promise.

***

### refreshTheme()

> **refreshTheme**(): `void`

Defined in: [inspector/src/FrameGraphInspector.ts:240](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L240)

Re-read final CSS values after external CSS changes and refresh graph and legend.
Does not write theme variables, recapture, fit, or rebuild the component.

#### Returns

`void`

***

### setCaptureSnapshotProvider()

> **setCaptureSnapshotProvider**(`provider`): `void`

Defined in: [inspector/src/FrameGraphInspector.ts:256](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L256)

Replaces or removes the live-capture provider.

#### Parameters

##### provider

((`request`) => [`FrameGraphSnapshotV1`](/zenfg/docs/api/snapshot/root/type-aliases/FrameGraphSnapshotV1.md) \| `Promise`\<[`FrameGraphSnapshotV1`](/zenfg/docs/api/snapshot/root/type-aliases/FrameGraphSnapshotV1.md) \| `undefined`\> \| `undefined`) \| `undefined`

#### Returns

`void`

#### Remarks

Installing a provider may immediately begin an asynchronous
capture when no snapshot is displayed. Replacing or removing a provider
invalidates its pending capture results without cancelling the provider
promise. An already displayed snapshot and any pending import are preserved.

***

### setSnapshot()

> **setSnapshot**(`snapshot`): `void`

Defined in: [inspector/src/FrameGraphInspector.ts:320](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L320)

Validates and synchronously displays a programmatic Snapshot 1.2 value.

#### Parameters

##### snapshot

[`FrameGraphSnapshotV1`](/zenfg/docs/api/snapshot/root/type-aliases/FrameGraphSnapshotV1.md)

#### Returns

`void`

#### Throws

[FrameGraphSnapshotValidationError](/zenfg/docs/api/snapshot/root/classes/FrameGraphSnapshotValidationError.md) if `snapshot` is invalid.

***

### setTheme()

> **setTheme**(`theme`): `void`

Defined in: [inspector/src/FrameGraphInspector.ts:231](https://github.com/uinosoft/zenfg/blob/327c05c78d2f528e4f4a679fcc7a77d9aa161f48/packages/inspector/src/FrameGraphInspector.ts#L231)

Replace API-applied variables on this instance, then synchronize graph styles.
Pass null to restore host CSS and defaults. Does not change capture or interaction state.

#### Parameters

##### theme

[`InspectorTheme`](/zenfg/docs/api/inspector/theme/interfaces/InspectorTheme.md) \| `null`

#### Returns

`void`
