/** * Wire-shape types for the events `@lensmcp/react-instrumentation` * publishes. These mirror the schemas in `@lensmcp/protocol-types` * (`RenderAttrs`, `EffectRunAttrs`) but include the identity fields the * apps/react reducer needs to attribute renders to specific component * instances. */ import type { RenderPhase, RenderWhy } from '@lensmcp/protocol-types'; export type { RenderPhase, RenderWhy }; export interface RenderRecord { id: string; parentRenderId?: string; componentInstanceId: string; componentLogicalId: string; componentName: string; page?: string; route?: string; rendererId?: string; phase: RenderPhase; actualDurationMs: number; baseDurationMs: number; startTime: number; commitTime: number; why: RenderWhy[]; } export interface EffectRecord { hookInstanceId: string; hookLogicalId: string; componentInstanceId?: string; depsHash: string; prevDepsHash?: string; durationMs: number; cleanupRan?: boolean; source?: string; } export interface HookRecord { hookInstanceId: string; hookLogicalId: string; componentInstanceId?: string; hookType: 'useMemo' | 'useCallback'; depsHash: string; prevDepsHash?: string; recomputed: boolean; source?: string; } export interface SlotChangeRecord { slotLogicalId: string; slotInstanceId: string; fromComponent?: string; toComponent?: string; componentInstanceId?: string; source?: string; } export interface ComponentMountRecord { logicalId: string; instanceId: string; generation: number; name: string; source?: string; page?: string; route?: string; } /** Anything the lib publishes downstream of the client-runtime. */ export type ReactPublishPayload = { kind: 'render'; render: RenderRecord; } | { kind: 'effect-run'; effect: EffectRecord; } | { kind: 'hook-run'; hook: HookRecord; } | { kind: 'slot-content-changed'; slot: SlotChangeRecord; } | { kind: 'component-mount'; component: ComponentMountRecord; } | { kind: 'component-unmount'; component: ComponentMountRecord; };