updateState

abstract fun updateState(previewId: String, fields: List<PreviewLabField<*>>, events: List<PreviewLabEvent>, captureScreenshot: suspend () -> ImageBitmap?, onUpdateField: (label: String, serializedValue: String) -> Boolean, onClearEvents: () -> Unit)

Called when the PreviewLab state changes. Implementations should update MCP resources accordingly.

Parameters

previewId

Unique identifier for this PreviewLab instance

fields

Current list of fields in PreviewLab

events

Current list of events in PreviewLab

captureScreenshot

Function to capture a screenshot of the preview content

onUpdateField

Callback to update a field's value by label

onClearEvents

Callback to clear all events