Search documentation of Plushie

# Plushie.Event.Diagnostic (Plushie v0.7.2)

Copy Markdown View Source

Typed diagnostic variants emitted by the renderer.

The renderer's `plushie-core::Diagnostic` enum enumerates every diagnostic the renderer can emit (tree normalization warnings, prop validation, font cap, panic guards, transport violations). Each variant arrives on the wire as a map with a discriminator (`"kind": "..."`) and variant-specific fields. `decode!/1` dispatches on that discriminator to one of the structs defined here so app authors pattern match on a typed struct rather than a raw map.

Decoded diagnostics are delivered through `Plushie.Event.DiagnosticMessage`, which carries the session ID, severity level, and the typed diagnostic. Apps typically match both:

    def update(model, %DiagnosticMessage{diagnostic: %FontFamilyNotFound{family: f}}) do
      Logger.warning("font missing: #{f}")
      model
    end

## Unknown variants

The decoder raises `ArgumentError` on an unrecognised `kind`. A new renderer variant requires an SDK update; silently dropping unknown diagnostics would hide host/renderer version skew that the runtime needs to see.

## Summary

### Types

t()

Any typed diagnostic variant struct.

### Functions

decode!(payload)

Decode a typed diagnostic from a wire payload map.

known_kinds()

List of wire-level kind strings this SDK version decodes.

## Types

# t()

    @type t() ::
      Plushie.Event.Diagnostic.DuplicateId.t()
      | Plushie.Event.Diagnostic.EmptyId.t()
      | Plushie.Event.Diagnostic.MultipleTopLevelWindows.t()
      | Plushie.Event.Diagnostic.UnknownWindow.t()
      | Plushie.Event.Diagnostic.UnrecognizedWidgetPlaceholder.t()
      | Plushie.Event.Diagnostic.TreeDepthExceeded.t()
      | Plushie.Event.Diagnostic.TooManyDuplicates.t()
      | Plushie.Event.Diagnostic.WidgetIdInvalid.t()
      | Plushie.Event.Diagnostic.MissingAccessibleName.t()
      | Plushie.Event.Diagnostic.A11yRefUnresolved.t()
      | Plushie.Event.Diagnostic.PropRangeExceeded.t()
      | Plushie.Event.Diagnostic.PropTypeMismatch.t()
      | Plushie.Event.Diagnostic.PropUnknown.t()
      | Plushie.Event.Diagnostic.ContentLengthExceeded.t()
      | Plushie.Event.Diagnostic.FontCacheCapExceeded.t()
      | Plushie.Event.Diagnostic.FontCapExceeded.t()
      | Plushie.Event.Diagnostic.FontFamilyNotFound.t()
      | Plushie.Event.Diagnostic.InvalidSettings.t()
      | Plushie.Event.Diagnostic.RequiredWidgetsMissing.t()
      | Plushie.Event.Diagnostic.WidgetPanic.t()
      | Plushie.Event.Diagnostic.SvgParseError.t()
      | Plushie.Event.Diagnostic.SvgDecodeTimeout.t()
      | Plushie.Event.Diagnostic.DashCacheCapExceeded.t()
      | Plushie.Event.Diagnostic.EmitterCoalesceCapExceeded.t()
      | Plushie.Event.Diagnostic.WidgetIdTypeCollision.t()
      | Plushie.Event.Diagnostic.ViewPanicked.t()
      | Plushie.Event.Diagnostic.UpdatePanicked.t()
      | Plushie.Event.Diagnostic.UnknownMessageType.t()
      | Plushie.Event.Diagnostic.DispatchLoopExceeded.t()
      | Plushie.Event.Diagnostic.BufferOverflow.t()

Any typed diagnostic variant struct.

## Functions

# decode!(payload)

    @spec decode!(map()) :: t()

Decode a typed diagnostic from a wire payload map.

The payload is the value of the `diagnostic` field on the top-level `diagnostic` wire message: a map containing `"kind"` plus variant- specific fields.

Raises `ArgumentError` on an unknown `kind`.

# known_kinds()

    @spec known_kinds() :: [String.t()]

List of wire-level kind strings this SDK version decodes.

Useful for test assertions that the SDK's typed-variant coverage matches the renderer's enum.