import type { CompilerEvent, CompilerEventPayload, CompilerEventType } from './types.ts'; const VALID_EVENT_TYPES = new Set(['change', 'log', 'progress', 'state', 'all', 'file']); export class EventUtil { static isCompilerEventType = (value: string): value is CompilerEventType => VALID_EVENT_TYPES.has(value as CompilerEventType); static isCompilerEvent = (value: unknown): value is CompilerEvent => typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string' && EventUtil.isCompilerEventType(value.type); static sendEvent>(type: K, payload: T): void { process.connected && process.send!({ type, payload }, undefined, undefined, () => {}); } }