documentation improvement

This commit is contained in:
2026-03-23 01:05:28 +01:00
parent 971a5afb8b
commit 0467a7b612
13 changed files with 145 additions and 120 deletions

View File

@@ -3,11 +3,12 @@
# Toju / Zoracord # Toju / Zoracord
Desktop chat app with three parts: Desktop chat app with four parts:
- `src/` Angular client - `src/` Angular client
- `electron/` desktop shell, IPC, and local database - `electron/` desktop shell, IPC, and local database
- `server/` directory server, join request API, and websocket events - `server/` directory server, join request API, and websocket events
- `website/` Toju website served at toju.app
## Install ## Install
@@ -59,3 +60,60 @@ Inside `server/`:
# Images # Images
<img src="./website/src/images/screenshots/gif.png" width="700" height="400"> <img src="./website/src/images/screenshots/gif.png" width="700" height="400">
<img src="./website/src/images/screenshots/screenshare_gaming.png" width="700" height="400"> <img src="./website/src/images/screenshots/screenshare_gaming.png" width="700" height="400">
## Main Toju app Structure
| Path | Description |
|------|-------------|
| `src/app/` | Main application root |
| `src/app/core/` | Core utilities, services, models |
| `src/app/domains/` | Domain-driven modules |
| `src/app/features/` | UI feature modules |
| `src/app/infrastructure/` | Low-level infrastructure (DB, realtime, etc.) |
| `src/app/shared/` | Shared UI components |
| `src/app/shared-kernel/` | Shared domain contracts & models |
| `src/app/store/` | Global state management |
| `src/assets/` | Static assets |
| `src/environments/` | Environment configs |
---
### Domains
| Path | Link |
|------|------|
| Attachment | [app/domains/attachment/README.md](src/app/domains/attachment/README.md) |
| Auth | [app/domains/auth/README.md](src/app/domains/auth/README.md) |
| Chat | [app/domains/chat/README.md](src/app/domains/chat/README.md) |
| Screen Share | [app/domains/screen-share/README.md](src/app/domains/screen-share/README.md) |
| Server Directory | [app/domains/server-directory/README.md](src/app/domains/server-directory/README.md) |
| Voice Connection | [app/domains/voice-connection/README.md](src/app/domains/voice-connection/README.md) |
| Voice Session | [app/domains/voice-session/README.md](src/app/domains/voice-session/README.md) |
| Domains Root | [app/domains/README.md](src/app/domains/README.md) |
---
### Infrastructure
| Path | Link |
|------|------|
| Persistence | [src/app/infrastructure/persistence/README.md](src/app/infrastructure/persistence/README.md) |
| Realtime | [src/app/infrastructure/realtime/README.md](src/app/infrastructure/realtime/README.md) |
---
### Shared Kernel
| Path | Link |
|------|------|
| Shared Kernel | [src/app/shared-kernel/README.md](src/app/shared-kernel/README.md) |
---
### Entry Points
| File | Link |
|------|------|
| Main | [main.ts](src/main.ts) |
| Index HTML | [index.html](src/index.html) |
| App Root | [app/app.ts](src/app/app.ts) |

View File

@@ -10,7 +10,6 @@
* instead of this file. * instead of this file.
*/ */
// ── shared-kernel re-exports ────────────────────────────────────────
export type { export type {
User, User,
UserStatus, UserStatus,
@@ -50,5 +49,4 @@ export type {
ChatAttachmentMeta ChatAttachmentMeta
} from '../../shared-kernel'; } from '../../shared-kernel';
// ── domain re-exports ───────────────────────────────────────────────
export type { ServerInfo } from '../../domains/server-directory'; export type { ServerInfo } from '../../domains/server-directory';

View File

@@ -54,15 +54,15 @@ graph TD
Persistence --> Store Persistence --> Store
Storage --> Helpers[attachment-storage.helpers] Storage --> Helpers[attachment-storage.helpers]
click Facade "application/attachment.facade.ts" "Thin entry point" click Facade "application/attachment.facade.ts" "Thin entry point" _blank
click Manager "application/attachment-manager.service.ts" "Orchestrates lifecycle" click Manager "application/attachment-manager.service.ts" "Orchestrates lifecycle" _blank
click Transfer "application/attachment-transfer.service.ts" "P2P file transfer protocol" click Transfer "application/attachment-transfer.service.ts" "P2P file transfer protocol" _blank
click Transport "application/attachment-transfer-transport.service.ts" "Base64 encode/decode, chunked streaming" click Transport "application/attachment-transfer-transport.service.ts" "Base64 encode/decode, chunked streaming" _blank
click Persistence "application/attachment-persistence.service.ts" "DB + filesystem persistence" click Persistence "application/attachment-persistence.service.ts" "DB + filesystem persistence" _blank
click Store "application/attachment-runtime.store.ts" "In-memory signal-based state" click Store "application/attachment-runtime.store.ts" "In-memory signal-based state" _blank
click Storage "infrastructure/attachment-storage.service.ts" "Electron filesystem access" click Storage "infrastructure/attachment-storage.service.ts" "Electron filesystem access" _blank
click Helpers "infrastructure/attachment-storage.helpers.ts" "Path helpers" click Helpers "infrastructure/attachment-storage.helpers.ts" "Path helpers" _blank
click Logic "domain/attachment.logic.ts" "Pure decision functions" click Logic "domain/attachment.logic.ts" "Pure decision functions" _blank
``` ```
## File transfer protocol ## File transfer protocol

View File

@@ -36,11 +36,11 @@ graph TD
Auth --> SD Auth --> SD
Login --> Store Login --> Store
click Auth "application/auth.service.ts" "HTTP login/register" click Auth "application/auth.service.ts" "HTTP login/register" _blank
click Login "feature/login/" "Login form" click Login "feature/login/" "Login form" _blank
click Register "feature/register/" "Registration form" click Register "feature/register/" "Registration form" _blank
click UserBar "feature/user-bar/" "Current user display" click UserBar "feature/user-bar/" "Current user display" _blank
click SD "../server-directory/application/server-directory.facade.ts" "Resolves API URL" click SD "../server-directory/application/server-directory.facade.ts" "Resolves API URL" _blank
``` ```
## Login flow ## Login flow

View File

@@ -54,14 +54,14 @@ graph TD
List --> Item List --> Item
Item --> Overlays Item --> Overlays
click Chat "feature/chat-messages/chat-messages.component.ts" "Root chat view" click Chat "feature/chat-messages/chat-messages.component.ts" "Root chat view" _blank
click List "feature/chat-messages/components/message-list/" "Paginated message list" click List "feature/chat-messages/components/message-list/" "Paginated message list" _blank
click Composer "feature/chat-messages/components/message-composer/" "Markdown toolbar + send" click Composer "feature/chat-messages/components/message-composer/" "Markdown toolbar + send" _blank
click Overlays "feature/chat-messages/components/message-overlays/" "Context menus, reaction picker" click Overlays "feature/chat-messages/components/message-overlays/" "Context menus, reaction picker" _blank
click Item "feature/chat-messages/components/message-item/" "Single message bubble" click Item "feature/chat-messages/components/message-item/" "Single message bubble" _blank
click GIF "feature/klipy-gif-picker/" "GIF search panel" click GIF "feature/klipy-gif-picker/" "GIF search panel" _blank
click Typing "feature/typing-indicator/" "Typing indicator" click Typing "feature/typing-indicator/" "Typing indicator" _blank
click Users "feature/user-list/" "Online user sidebar" click Users "feature/user-list/" "Online user sidebar" _blank
``` ```
## Message lifecycle ## Message lifecycle
@@ -122,9 +122,9 @@ graph LR
Klipy --> SD Klipy --> SD
Klipy --> API Klipy --> API
click Picker "feature/klipy-gif-picker/" "GIF search panel" click Picker "feature/klipy-gif-picker/" "GIF search panel" _blank
click Klipy "application/klipy.service.ts" "GIF search via KLIPY API" click Klipy "application/klipy.service.ts" "GIF search via KLIPY API" _blank
click SD "../server-directory/application/server-directory.facade.ts" "Resolves API base URL" click SD "../server-directory/application/server-directory.facade.ts" "Resolves API base URL" _blank
``` ```
## Domain rules ## Domain rules

View File

@@ -44,14 +44,14 @@ graph TD
Workspace --> Tile Workspace --> Tile
Picker --> Config Picker --> Config
click SSF "application/screen-share.facade.ts" "Proxy to RealtimeSessionFacade" click SSF "application/screen-share.facade.ts" "Proxy to RealtimeSessionFacade" _blank
click Picker "application/screen-share-source-picker.service.ts" "Electron source picker" click Picker "application/screen-share-source-picker.service.ts" "Electron source picker" _blank
click RSF "../../infrastructure/realtime/realtime-session.service.ts" "Low-level WebRTC composition root" click RSF "../../infrastructure/realtime/realtime-session.service.ts" "Low-level WebRTC composition root" _blank
click Viewer "feature/screen-share-viewer/screen-share-viewer.component.ts" "Single-stream player" click Viewer "feature/screen-share-viewer/screen-share-viewer.component.ts" "Single-stream player" _blank
click Workspace "feature/screen-share-workspace/screen-share-workspace.component.ts" "Multi-stream workspace" click Workspace "feature/screen-share-workspace/screen-share-workspace.component.ts" "Multi-stream workspace" _blank
click Tile "feature/screen-share-workspace/screen-share-stream-tile.component.ts" "Stream tile" click Tile "feature/screen-share-workspace/screen-share-stream-tile.component.ts" "Stream tile" _blank
click Playback "feature/screen-share-workspace/screen-share-playback.service.ts" "Per-user volume state" click Playback "feature/screen-share-workspace/screen-share-playback.service.ts" "Per-user volume state" _blank
click Config "domain/screen-share.config.ts" "Quality presets" click Config "domain/screen-share.config.ts" "Quality presets" _blank
``` ```
## Starting a screen share ## Starting a screen share

View File

@@ -53,14 +53,14 @@ graph TD
State --> Defaults State --> Defaults
Health --> Compat Health --> Compat
click Facade "application/server-directory.facade.ts" "High-level API" click Facade "application/server-directory.facade.ts" "High-level API" _blank
click State "application/server-endpoint-state.service.ts" "Signal-based endpoint state" click State "application/server-endpoint-state.service.ts" "Signal-based endpoint state" _blank
click API "infrastructure/server-directory-api.service.ts" "HTTP client for server API" click API "infrastructure/server-directory-api.service.ts" "HTTP client for server API" _blank
click Health "infrastructure/server-endpoint-health.service.ts" "Health probe" click Health "infrastructure/server-endpoint-health.service.ts" "Health probe" _blank
click Compat "infrastructure/server-endpoint-compatibility.service.ts" "Version compatibility" click Compat "infrastructure/server-endpoint-compatibility.service.ts" "Version compatibility" _blank
click Storage "infrastructure/server-endpoint-storage.service.ts" "localStorage persistence" click Storage "infrastructure/server-endpoint-storage.service.ts" "localStorage persistence" _blank
click Defaults "domain/server-endpoint-defaults.ts" "Default endpoint templates" click Defaults "domain/server-endpoint-defaults.ts" "Default endpoint templates" _blank
click Models "domain/server-directory.models.ts" "Domain types" click Models "domain/server-directory.models.ts" "Domain types" _blank
``` ```
## Endpoint lifecycle ## Endpoint lifecycle

View File

@@ -31,11 +31,11 @@ graph TD
VAS --> VCF VAS --> VCF
VPS --> VCF VPS --> VCF
click VCF "application/voice-connection.facade.ts" "Proxy to RealtimeSessionFacade" click VCF "application/voice-connection.facade.ts" "Proxy to RealtimeSessionFacade" _blank
click VAS "application/voice-activity.service.ts" "RMS-based speaking detection" click VAS "application/voice-activity.service.ts" "RMS-based speaking detection" _blank
click VPS "application/voice-playback.service.ts" "Per-peer GainNode volume chain" click VPS "application/voice-playback.service.ts" "Per-peer GainNode volume chain" _blank
click RSF "../../infrastructure/realtime/realtime-session.service.ts" "Low-level WebRTC composition root" click RSF "../../infrastructure/realtime/realtime-session.service.ts" "Low-level WebRTC composition root" _blank
click Models "domain/voice-connection.models.ts" "Re-exported types" click Models "domain/voice-connection.models.ts" "Re-exported types" _blank
``` ```
## Voice connection facade ## Voice connection facade
@@ -63,8 +63,8 @@ graph LR
RMS -- yes --> Speaking[speakingSignal = true] RMS -- yes --> Speaking[speakingSignal = true]
RMS -- no, 8 frames --> Silent[speakingSignal = false] RMS -- no, 8 frames --> Silent[speakingSignal = false]
click Stream "application/voice-activity.service.ts" "VoiceActivityService.trackStream()" click Stream "application/voice-activity.service.ts" "VoiceActivityService.trackStream()" _blank
click Poll "application/voice-activity.service.ts" "VoiceActivityService.poll()" click Poll "application/voice-activity.service.ts" "VoiceActivityService.poll()" _blank
``` ```
| Parameter | Value | | Parameter | Value |
@@ -88,8 +88,8 @@ graph LR
Gain --> Dest[MediaStreamAudioDestinationNode] Gain --> Dest[MediaStreamAudioDestinationNode]
Dest --> Audio[HTMLAudioElement<br/>.play] Dest --> Audio[HTMLAudioElement<br/>.play]
click Remote "application/voice-playback.service.ts" "VoicePlaybackService.setupPeer()" click Remote "application/voice-playback.service.ts" "VoicePlaybackService.setupPeer()" _blank
click Gain "application/voice-playback.service.ts" "VoicePlaybackService.setUserVolume()" click Gain "application/voice-playback.service.ts" "VoicePlaybackService.setUserVolume()" _blank
``` ```
Volume per peer is stored in localStorage and restored on reconnect. The range is 0% to 200% (gain values 0.0 to 2.0). When the user deafens, all gain nodes are set to zero; undeafening restores the previous values. Volume per peer is stored in localStorage and restored on reconnect. The range is 0% to 200% (gain values 0.0 to 2.0). When the user deafens, all gain nodes are set to zero; undeafening restores the previous values.

View File

@@ -47,12 +47,12 @@ graph TD
VSF --> Store VSF --> Store
VWS --> VSF VWS --> VSF
click VSF "application/voice-session.facade.ts" "Tracks active voice session" click VSF "application/voice-session.facade.ts" "Tracks active voice session" _blank
click VWS "application/voice-workspace.service.ts" "Workspace mode and focused stream" click VWS "application/voice-workspace.service.ts" "Workspace mode and focused stream" _blank
click VSS "infrastructure/voice-settings.storage.ts" "localStorage persistence for audio settings" click VSS "infrastructure/voice-settings.storage.ts" "localStorage persistence for audio settings" _blank
click Logic "domain/voice-session.logic.ts" "Pure helper functions" click Logic "domain/voice-session.logic.ts" "Pure helper functions" _blank
click VC "feature/voice-controls/" "Full voice control panel" click VC "feature/voice-controls/" "Full voice control panel" _blank
click FC "feature/floating-voice-controls/" "Minimal floating overlay" click FC "feature/floating-voice-controls/" "Minimal floating overlay" _blank
``` ```
## Session lifecycle ## Session lifecycle

View File

@@ -23,9 +23,9 @@ graph TD
Decision -- Electron --> IPC[ElectronDatabaseService<br/>IPC to main process] Decision -- Electron --> IPC[ElectronDatabaseService<br/>IPC to main process]
IPC --> Main[Electron main process<br/>TypeORM + SQLite] IPC --> Main[Electron main process<br/>TypeORM + SQLite]
click Facade "database.service.ts" "DatabaseService - platform-agnostic facade" click Facade "database.service.ts" "DatabaseService - platform-agnostic facade" _blank
click IDB "browser-database.service.ts" "IndexedDB backend for web" click IDB "browser-database.service.ts" "IndexedDB backend for web" _blank
click IPC "electron-database.service.ts" "IPC client for Electron" click IPC "electron-database.service.ts" "IPC client for Electron" _blank
``` ```
`DatabaseService` is an `@Injectable({ providedIn: 'root' })` that injects both backends and delegates every call to whichever one matches the current platform. Consumers never import a backend directly. `DatabaseService` is an `@Injectable({ providedIn: 'root' })` that injects both backends and delegates every call to whichever one matches the current platform. Consumers never import a backend directly.

View File

@@ -87,28 +87,28 @@ graph TD
SSM --> ElectronCap[Electron capture] SSM --> ElectronCap[Electron capture]
SSM --> LinuxCap[Linux audio routing] SSM --> LinuxCap[Linux audio routing]
click WS "realtime-session.service.ts" "WebRTCService - composition root" click WS "realtime-session.service.ts" "WebRTCService - composition root" _blank
click SC "signaling/signaling-transport-handler.ts" "Routes messages to the right WebSocket" click SC "signaling/signaling-transport-handler.ts" "Routes messages to the right WebSocket" _blank
click PCM "peer-connection-manager/peer-connection.manager.ts" "Owns all RTCPeerConnection instances" click PCM "peer-connection-manager/peer-connection.manager.ts" "Owns all RTCPeerConnection instances" _blank
click MM "media/media.manager.ts" "getUserMedia, mute, deafen, gain pipeline" click MM "media/media.manager.ts" "getUserMedia, mute, deafen, gain pipeline" _blank
click SSM "media/screen-share.manager.ts" "Screen capture and per-peer distribution" click SSM "media/screen-share.manager.ts" "Screen capture and per-peer distribution" _blank
click State "state/webrtc-state-controller.ts" "Angular Signals for connection state" click State "state/webrtc-state-controller.ts" "Angular Signals for connection state" _blank
click VSC "media/voice-session-controller.ts" "Higher-level voice session wrapper" click VSC "media/voice-session-controller.ts" "Higher-level voice session wrapper" _blank
click PMF "streams/peer-media-facade.ts" "Unified API over peers, media, screen share" click PMF "streams/peer-media-facade.ts" "Unified API over peers, media, screen share" _blank
click RSSRC "streams/remote-screen-share-request-controller.ts" "On-demand screen share delivery" click RSSRC "streams/remote-screen-share-request-controller.ts" "On-demand screen share delivery" _blank
click SM1 "signaling/signaling.manager.ts" "One WebSocket per signaling URL" click SM1 "signaling/signaling.manager.ts" "One WebSocket per signaling URL" _blank
click SM2 "signaling/signaling.manager.ts" "One WebSocket per signaling URL" click SM2 "signaling/signaling.manager.ts" "One WebSocket per signaling URL" _blank
click Coord "signaling/server-signaling-coordinator.ts" "Maps peers/servers to signaling URLs" click Coord "signaling/server-signaling-coordinator.ts" "Maps peers/servers to signaling URLs" _blank
click Conn "peer-connection-manager/connection/create-peer-connection.ts" "RTCPeerConnection factory" click Conn "peer-connection-manager/connection/create-peer-connection.ts" "RTCPeerConnection factory" _blank
click Neg "peer-connection-manager/connection/negotiation.ts" "Offer/answer/ICE with collision handling" click Neg "peer-connection-manager/connection/negotiation.ts" "Offer/answer/ICE with collision handling" _blank
click DC "peer-connection-manager/messaging/data-channel.ts" "Ordered data channel for chat + control" click DC "peer-connection-manager/messaging/data-channel.ts" "Ordered data channel for chat + control" _blank
click Ping "peer-connection-manager/messaging/ping.ts" "Latency measurement via PING/PONG" click Ping "peer-connection-manager/messaging/ping.ts" "Latency measurement via PING/PONG" _blank
click Rec "peer-connection-manager/recovery/peer-recovery.ts" "Disconnect grace period + reconnect loop" click Rec "peer-connection-manager/recovery/peer-recovery.ts" "Disconnect grace period + reconnect loop" _blank
click RS "peer-connection-manager/streams/remote-streams.ts" "Classifies incoming tracks" click RS "peer-connection-manager/streams/remote-streams.ts" "Classifies incoming tracks" _blank
click NR "media/noise-reduction.manager.ts" "RNNoise AudioWorklet graph" click NR "media/noise-reduction.manager.ts" "RNNoise AudioWorklet graph" _blank
click BrowserCap "media/screen-share-platforms/browser-screen-share.capture.ts" "Standard getDisplayMedia" click BrowserCap "media/screen-share-platforms/browser-screen-share.capture.ts" "Standard getDisplayMedia" _blank
click ElectronCap "media/screen-share-platforms/desktop-electron-screen-share.capture.ts" "Electron source picker" click ElectronCap "media/screen-share-platforms/desktop-electron-screen-share.capture.ts" "Electron source picker" _blank
click LinuxCap "media/screen-share-platforms/linux-electron-screen-share.capture.ts" "PulseAudio/PipeWire routing" click LinuxCap "media/screen-share-platforms/linux-electron-screen-share.capture.ts" "PulseAudio/PipeWire routing" _blank
``` ```
## Signaling (WebSocket) ## Signaling (WebSocket)
@@ -222,11 +222,11 @@ graph LR
GainNode --> Out GainNode --> Out
Out --> Peers[replaceTrack on<br/>all peer audio senders] Out --> Peers[replaceTrack on<br/>all peer audio senders]
click Mic "media/media.manager.ts" "MediaManager.enableVoice()" click Mic "media/media.manager.ts" "MediaManager.enableVoice()" _blank
click Worklet "media/noise-reduction.manager.ts" "NoiseReductionManager.enable()" click Worklet "media/noise-reduction.manager.ts" "NoiseReductionManager.enable()" _blank
click GainNode "media/media.manager.ts" "MediaManager.applyInputGainToCurrentStream()" click GainNode "media/media.manager.ts" "MediaManager.applyInputGainToCurrentStream()" _blank
click Out "media/media.manager.ts" "MediaManager.localMediaStream" click Out "media/media.manager.ts" "MediaManager.localMediaStream" _blank
click Peers "media/media.manager.ts" "MediaManager.bindLocalTracksToAllPeers()" click Peers "media/media.manager.ts" "MediaManager.bindLocalTracksToAllPeers()" _blank
``` ```
`MediaManager` grabs the mic with `getUserMedia`, optionally pipes it through the RNNoise AudioWorklet for noise reduction (48 kHz, loaded from `rnnoise-worklet.js`), optionally runs it through a `GainNode` for input volume control, and then pushes the resulting stream to every connected peer via `replaceTrack`. `MediaManager` grabs the mic with `getUserMedia`, optionally pipes it through the RNNoise AudioWorklet for noise reduction (48 kHz, loaded from `rnnoise-worklet.js`), optionally runs it through a `GainNode` for input volume control, and then pushes the resulting stream to every connected peer via `replaceTrack`.

View File

@@ -47,8 +47,6 @@ export class NoiseReductionManager {
constructor(private readonly logger: WebRTCLogger) {} constructor(private readonly logger: WebRTCLogger) {}
// ─── Public API ──────────────────────────────────────────────────
/** Whether noise reduction is currently active. */ /** Whether noise reduction is currently active. */
get isEnabled(): boolean { get isEnabled(): boolean {
return this._isEnabled; return this._isEnabled;
@@ -138,8 +136,6 @@ export class NoiseReductionManager {
this.workletLoaded = false; this.workletLoaded = false;
} }
// ─── Internals ───────────────────────────────────────────────────
/** /**
* Build the AudioWorklet processing graph: * Build the AudioWorklet processing graph:
* rawStream → source → workletNode → destination * rawStream → source → workletNode → destination

View File

@@ -10,8 +10,6 @@ import type { VoiceState } from './voice-state.models';
import type { BanEntry } from './moderation.models'; import type { BanEntry } from './moderation.models';
import type { ChatAttachmentAnnouncement, ChatAttachmentMeta } from './attachment-contracts'; import type { ChatAttachmentAnnouncement, ChatAttachmentMeta } from './attachment-contracts';
// ── Inventory item (data structure, not an event) ───────────────────
export interface ChatInventoryItem { export interface ChatInventoryItem {
id: string; id: string;
ts: number; ts: number;
@@ -19,7 +17,6 @@ export interface ChatInventoryItem {
ac?: number; ac?: number;
} }
// ── Base ────────────────────────────────────────────────────────────
// Every field that appears on any event is kept optional here so that // Every field that appears on any event is kept optional here so that
// code which accesses `event.roomId` etc. without narrowing first // code which accesses `event.roomId` etc. without narrowing first
// still compiles. Individual event interfaces below then make the // still compiles. Individual event interfaces below then make the
@@ -74,8 +71,6 @@ export interface ChatEventBase {
expiresAt?: number; expiresAt?: number;
} }
// ── Messaging ───────────────────────────────────────────────────────
export interface ChatMessageEvent extends ChatEventBase { export interface ChatMessageEvent extends ChatEventBase {
type: 'message' | 'chat-message'; type: 'message' | 'chat-message';
message: Message; message: Message;
@@ -93,8 +88,6 @@ export interface MessageDeletedEvent extends ChatEventBase {
messageId: string; messageId: string;
} }
// ── Reactions ───────────────────────────────────────────────────────
export interface ReactionAddedEvent extends ChatEventBase { export interface ReactionAddedEvent extends ChatEventBase {
type: 'reaction' | 'reaction-added'; type: 'reaction' | 'reaction-added';
messageId: string; messageId: string;
@@ -108,8 +101,6 @@ export interface ReactionRemovedEvent extends ChatEventBase {
emoji: string; emoji: string;
} }
// ── File transfer ───────────────────────────────────────────────────
export interface FileAnnounceChatEvent extends ChatEventBase { export interface FileAnnounceChatEvent extends ChatEventBase {
type: 'file-announce'; type: 'file-announce';
messageId: string; messageId: string;
@@ -143,8 +134,6 @@ export interface FileNotFoundChatEvent extends ChatEventBase {
fileId: string; fileId: string;
} }
// ── Sync protocol ───────────────────────────────────────────────────
export interface ChatInventoryRequestEvent extends ChatEventBase { export interface ChatInventoryRequestEvent extends ChatEventBase {
type: 'chat-inventory-request'; type: 'chat-inventory-request';
roomId: string; roomId: string;
@@ -184,8 +173,6 @@ export interface ChatSyncFullEvent extends ChatEventBase {
messages: Message[]; messages: Message[];
} }
// ── Room management ─────────────────────────────────────────────────
export interface RoomDeletedEvent extends ChatEventBase { export interface RoomDeletedEvent extends ChatEventBase {
type: 'room-deleted'; type: 'room-deleted';
roomId: string; roomId: string;
@@ -212,8 +199,6 @@ export interface HostChangeEvent extends ChatEventBase {
previousHostOderId: string; previousHostOderId: string;
} }
// ── Voice & screen state ────────────────────────────────────────────
export interface VoiceStateEvent extends ChatEventBase { export interface VoiceStateEvent extends ChatEventBase {
type: 'voice-state'; type: 'voice-state';
voiceState: Partial<VoiceState>; voiceState: Partial<VoiceState>;
@@ -240,8 +225,6 @@ export interface ScreenShareStopEvent extends ChatEventBase {
type: 'screen-share-stop'; type: 'screen-share-stop';
} }
// ── Server icon ─────────────────────────────────────────────────────
export interface ServerIconSummaryEvent extends ChatEventBase { export interface ServerIconSummaryEvent extends ChatEventBase {
type: 'server-icon-summary'; type: 'server-icon-summary';
roomId: string; roomId: string;
@@ -267,8 +250,6 @@ export interface ServerIconUpdateEvent extends ChatEventBase {
iconUpdatedAt: number; iconUpdatedAt: number;
} }
// ── Server state ────────────────────────────────────────────────────
export interface ServerStateRequestEvent extends ChatEventBase { export interface ServerStateRequestEvent extends ChatEventBase {
type: 'server-state-request'; type: 'server-state-request';
roomId: string; roomId: string;
@@ -280,8 +261,6 @@ export interface ServerStateFullEvent extends ChatEventBase {
room: Partial<Room>; room: Partial<Room>;
} }
// ── Member roster ───────────────────────────────────────────────────
export interface MemberRosterRequestEvent extends ChatEventBase { export interface MemberRosterRequestEvent extends ChatEventBase {
type: 'member-roster-request'; type: 'member-roster-request';
roomId: string; roomId: string;
@@ -302,8 +281,6 @@ export interface RoleChangeEvent extends ChatEventBase {
type: 'role-change'; type: 'role-change';
} }
// ── Moderation ──────────────────────────────────────────────────────
export interface KickEvent extends ChatEventBase { export interface KickEvent extends ChatEventBase {
type: 'kick'; type: 'kick';
} }
@@ -316,16 +293,12 @@ export interface UnbanEvent extends ChatEventBase {
type: 'unban'; type: 'unban';
} }
// ── Channel ─────────────────────────────────────────────────────────
export interface ChannelsUpdateEvent extends ChatEventBase { export interface ChannelsUpdateEvent extends ChatEventBase {
type: 'channels-update'; type: 'channels-update';
roomId: string; roomId: string;
channels: Channel[]; channels: Channel[];
} }
// ── Discriminated union ─────────────────────────────────────────────
/** Discriminated union of all P2P chat events. Narrow via `event.type`. */ /** Discriminated union of all P2P chat events. Narrow via `event.type`. */
export type ChatEvent = export type ChatEvent =
| ChatMessageEvent | ChatMessageEvent