/**
 * Remote UI Protocol Types
 */

import type { Patch } from "../engine.js";

export type RemoteMessage =
  | InitialTreeMessage
  | PatchMessage
  | StateUpdateMessage
  | DispatchActionMessage;

export interface InitialTreeMessage {
  type: "initialTree";
  module: string;
  state: any;
  patches: Patch[];
  revision: number;
}

export interface PatchMessage {
  type: "patch";
  module: string;
  patches: Patch[];
  revision: number;
}

export interface StateUpdateMessage {
  type: "stateUpdate";
  module: string;
  state: any;
  revision: number;
}

export interface DispatchActionMessage {
  type: "dispatchAction";
  module: string;
  action: string;
  payload?: any;
}

export interface RemoteClient {
  id: string;
  socket: any;
  connectedAt: Date;
}

export interface RemoteServerConfig {
  port?: number;
  hostname?: string;
}
