import { WidgetData } from './widget'; import { WindowData } from './window'; export interface ProtocolCreateWidgetPerformer { kind: 'create-widget', id: string, parentId: string, name: string | null, data: Partial }; export interface ProtocolCreateWindowPerformer { kind: 'create-window', id: string, name: string | null, data: Partial }; export interface ProtocolDestroyPerformer { kind: 'destroy', id: string, reason: string | null, }; export interface ProtocolAnnihilatePerformer { // Destroys everything. Mwahahaha! >:3 kind: 'annihilate', reason: string | null, }; export interface ProtocolSetPerformer { kind: 'set', id: string, keys: string[], value: any }; export interface ProtocolEmitUpPerformer { kind: 'emit-up', id: string, event: string, args: any[] }; export interface ProtocolEmitDownPerformer { kind: 'emit-down', id: string, event: string, args: any[] }; export interface ProtocolEmitPerformer { kind: 'emit', id: string, event: string, args: any[] }; export type ProtocolPerformer = ( ProtocolCreateWidgetPerformer | ProtocolCreateWindowPerformer | ProtocolDestroyPerformer | ProtocolSetPerformer | ProtocolEmitUpPerformer | ProtocolEmitDownPerformer | ProtocolEmitPerformer | ProtocolAnnihilatePerformer ); export interface ProtocolListQuery { kind: 'list', }; export interface ProtocolNameQuery { kind: 'name', id: string, }; export interface ProtocolDataQuery { kind: 'data', id: string, keys: string[], }; export type ProtocolQuery = ( ProtocolNameQuery | ProtocolDataQuery ); export interface ProtocolQueryCall { id: string; type: 'query'; call: ProtocolQuery; }; export interface ProtocolPerformerCall { id: string; type: 'perform'; call: ProtocolPerformer; }; export type ProtocolCall = ( ProtocolQueryCall | ProtocolPerformerCall ); // RESPONSE STATA // export interface ProtocolStatus { type: number; id: string; reason?: string; } export interface ProtocolResponse { callId: string; status: ProtocolStatus; result?: any; } export interface ProtocolEvent { type: 'event', event: string, at: string, origin: string, args: any[] } export function makeResponse(this: ProtocolCall, status: ProtocolStatus, result?: any) { return { callId: this.id, status: status, result: result } }