mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 06:42:03 +00:00
Resolves merge conflicts: - apps/server/src/routes/terminal/common.ts: Keep randomBytes import, use @automaker/utils for createLogger - apps/ui/eslint.config.mjs: Use main's explicit globals list with XMLHttpRequest and MediaQueryListEvent additions - apps/ui/src/components/views/terminal-view.tsx: Keep our terminal improvements (killAllSessions, beforeunload, better error handling) - apps/ui/src/config/terminal-themes.ts: Keep our search highlight colors for all themes - apps/ui/src/store/app-store.ts: Keep our terminal settings persistence improvements (merge function) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
887 B
TypeScript
37 lines
887 B
TypeScript
/**
|
|
* Event emitter for streaming events to WebSocket clients
|
|
*/
|
|
|
|
import type { EventType, EventCallback } from '@automaker/types';
|
|
|
|
// Re-export event types from shared package
|
|
export type { EventType, EventCallback };
|
|
|
|
export interface EventEmitter {
|
|
emit: (type: EventType, payload: unknown) => void;
|
|
subscribe: (callback: EventCallback) => () => void;
|
|
}
|
|
|
|
export function createEventEmitter(): EventEmitter {
|
|
const subscribers = new Set<EventCallback>();
|
|
|
|
return {
|
|
emit(type: EventType, payload: unknown) {
|
|
for (const callback of subscribers) {
|
|
try {
|
|
callback(type, payload);
|
|
} catch (error) {
|
|
console.error('Error in event subscriber:', error);
|
|
}
|
|
}
|
|
},
|
|
|
|
subscribe(callback: EventCallback) {
|
|
subscribers.add(callback);
|
|
return () => {
|
|
subscribers.delete(callback);
|
|
};
|
|
},
|
|
};
|
|
}
|