/** * Types for the Remix IDE lifecycle state machine and event guard system. */ export type LifecycleEvent = { type: 'BOOT'; } | { type: 'PLUGINS_REGISTERED'; } | { type: 'PLUGIN_ACTIVATED'; name: string; } | { type: 'PLUGIN_DEACTIVATED'; name: string; } | { type: 'PLUGIN_ACTIVATION_FAILED'; name: string; error: string; } | { type: 'WORKSPACE_INITIALIZED'; } | { type: 'EDITOR_MOUNTED'; } | { type: 'CACHE_READY'; } | { type: 'PROVIDER_CONNECTED'; name: string; } | { type: 'PROVIDER_DISCONNECTED'; name: string; } | { type: 'WORKSPACE_PLUGINS_ACTIVATED'; } | { type: 'APP_LOADED'; } | { type: 'CUSTOM'; id: string; payload?: any; }; /** String identifier for a lifecycle event, used in guard conditions */ export type EventId = string; export interface AppLifecycleContext { activatedPlugins: Set; failedPlugins: Map; readyServices: Set; bootStartedAt: number; currentPhase: string; firedEvents: Set; } export type BootPhase = 'idle' | 'booting' | 'coreReady' | 'servicesReady' | 'uiReady' | 'toolsReady' | 'running' | 'degraded'; export interface AllCondition { kind: 'all'; conditions: Condition[]; } export interface AnyCondition { kind: 'any'; conditions: Condition[]; } export interface SequenceCondition { kind: 'sequence'; conditions: Condition[]; } export interface EventCondition { kind: 'event'; eventId: EventId; } export type Condition = AllCondition | AnyCondition | SequenceCondition | EventCondition; export type ConditionInput = Condition | EventId; export interface GuardRegistration { id: number; condition: Condition; callback: () => void; once: boolean; fired: boolean; } export interface LifecyclePluginMethods { waitFor(condition: SerializedCondition): Promise; has(eventId: string): boolean; getState(): string; getActivatedPlugins(): string[]; getFiredEvents(): string[]; } /** * JSON-safe representation of a Condition for cross-plugin communication. * Plugins pass these via `call('lifecycle', 'waitFor', condition)`. */ export type SerializedCondition = { all: SerializedConditionInput[]; } | { any: SerializedConditionInput[]; } | { sequence: SerializedConditionInput[]; } | string; export type SerializedConditionInput = SerializedCondition; export interface NudgeAction { type: 'toast' | 'modal' | 'hint' | 'widget'; title?: string; message: string; actionLabel?: string; actionTarget?: string; icon?: string; dismissable?: boolean; hintStyle?: 'pulse' | 'glow' | 'badge'; hintColor?: string; widgetColor?: string; widgetBg?: string; } export interface NudgeRule { id: string; condition: ConditionInput; action: NudgeAction; /** true = show once ever (localStorage), 'session' = once per session, false = every time */ showOnce?: boolean | 'session'; priority?: number; enabled?: boolean; } /** JSON-safe nudge rule for API-loaded rules */ export interface SerializedNudgeRule { id: string; condition: SerializedCondition; action: NudgeAction; showOnce?: boolean | 'session'; priority?: number; enabled?: boolean; }