/** * State Inspector diagnostic panel data provider. * * Produces on-demand snapshots of the runtime store's domain states. * Implements the "Live domain state viewer" and "Raw state mode" from * Devtools / State Inspector. * * All domains are serialized to JSON-safe plain objects at snapshot time. * Maps and Sets are converted to arrays; circular references are replaced * with a sentinel string. */ import type { RuntimeStateSnapshot, DiagnosticPanelIssue } from '../types.js'; import type { HotspotReport } from '../../inspection/state-inspector/types.js'; /** * Minimal interface for a domain state slice used by the inspector. * Each domain registered with the store should conform to this shape. */ export interface InspectableDomain { /** Domain name identifier. */ readonly name: string; /** Retrieve the current domain state as a plain object. */ getState(): Record; /** The revision counter from the domain state. */ getRevision(): number; /** The lastUpdatedAt timestamp from the domain state. */ getLastUpdatedAt(): number; } /** * Hotspot analysis summary for display in the diagnostics panel. * Provides a read-only view of the current selector hotspot report. */ export interface HotspotAnalysisView { /** The full hotspot report, or undefined when no sampler is attached. */ readonly report: HotspotReport | undefined; /** Top churn hotspots (highest calls/sec), up to 5. */ readonly topChurn: HotspotReport['hotspots']; /** Top latency hotspots (highest p95), up to 5. */ readonly topLatency: HotspotReport['hotspots']; /** Whether any churn hotspots are above threshold. */ readonly hasChurnHotspots: boolean; /** Whether any latency hotspots are above threshold. */ readonly hasLatencyHotspots: boolean; /** Panel-level warnings/errors for degraded hotspot collection. */ readonly issues?: readonly DiagnosticPanelIssue[] | undefined; } /** * Callback type for providing an on-demand hotspot report. * Decouples the diagnostics panel from the sampler implementation. */ export type HotspotReportProvider = () => HotspotReport | undefined; /** * StateInspectorPanel, on-demand runtime state snapshot provider. * * Domains are registered at construction time. Call `getSnapshot()` to * capture the current state of all registered domains. * * Optionally accepts a `HotspotReportProvider` callback to surface * selector hotspot analysis. Call `getHotspotAnalysis()` to retrieve * the current view. * * Unlike event-driven panels, this panel does not maintain an internal * buffer, each `getSnapshot()` call produces a fresh snapshot. */ export declare class StateInspectorPanel { private readonly _domains; /** Registered change notification callbacks. */ private readonly _subscribers; /** Optional hotspot report provider. */ private _hotspotProvider; /** * @param domains - Array of domain adapters to inspect. * @param hotspotProvider - Optional provider for selector hotspot reports. */ constructor(domains?: InspectableDomain[], hotspotProvider?: HotspotReportProvider); /** * Register an additional domain for inspection after construction. * * @param domain - Domain adapter to add. */ registerDomain(domain: InspectableDomain): void; /** * Capture a point-in-time snapshot of all registered domains. * Maps and Sets in the state are converted to plain objects/arrays. * * @returns An immutable RuntimeStateSnapshot. */ getSnapshot(): RuntimeStateSnapshot; /** * Attach or replace the hotspot report provider. * * @param provider - Callback returning the current HotspotReport. */ setHotspotProvider(provider: HotspotReportProvider): void; /** * Return a structured hotspot analysis view for the diagnostics UI. * * Produces top-5 churn hotspots (by calls/sec) and top-5 latency * hotspots (by p95) from the current report. Returns an empty view * when no hotspot provider is attached. * * @returns HotspotAnalysisView. */ getHotspotAnalysis(): HotspotAnalysisView; /** * Register a callback invoked when the domain registry changes. * Note: callbacks are NOT invoked on every state mutation, call * `getSnapshot()` on demand to retrieve current state. * * @returns An unsubscribe function. */ subscribe(callback: () => void): () => void; private _notify; } //# sourceMappingURL=state-inspector.d.ts.map