@affectively/dash 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,26 +11,103 @@ export declare class HybridProvider extends Observable<string> {
11
11
  private wt;
12
12
  private connected;
13
13
  private url;
14
+ private activeRelayUrl;
14
15
  private roomName;
15
16
  awareness: awarenessProtocol.Awareness;
16
17
  private writer;
17
18
  private highFrequencyMode;
19
+ private connectionState;
20
+ private reconnectAttempts;
21
+ private readonly maxReconnectDelay;
22
+ private readonly baseReconnectDelay;
23
+ private reconnectTimeout;
24
+ private relayDiscovery;
25
+ private discoveredRelayUrls;
26
+ private relayDiscoveryCursor;
27
+ private lastRelayDiscoveryAt;
28
+ private relayHealth;
29
+ private relayPerformance;
30
+ private compressionEngine;
31
+ private adaptiveCompression;
32
+ private batchTiming;
33
+ private outboundQueue;
34
+ private outboundQueueBytes;
35
+ private batchFlushTimeout;
36
+ private flushingBatch;
37
+ private lastCompressionRatio;
38
+ private relayPrivacy;
39
+ private roomCryptoKey;
40
+ private roomCryptoKeyReady;
41
+ private localCapabilitiesBitmask;
42
+ private peerCapabilities;
43
+ private protocolVersion;
44
+ private lastCapabilityAdvertisedAt;
18
45
  private aeonConfig;
19
46
  private deltaAdapter;
20
47
  private presenceAdapter;
21
48
  private offlineAdapter;
22
- constructor(url: string, roomName: string, doc: Y.Doc, { awareness, aeonConfig, }?: {
49
+ constructor(url: string, roomName: string, doc: Y.Doc, { awareness, aeonConfig, relayDiscovery, relayPerformance, relayPrivacy, }?: {
23
50
  awareness?: awarenessProtocol.Awareness;
24
51
  aeonConfig?: AeonConfig;
52
+ relayDiscovery?: RelayDiscoveryConfig;
53
+ relayPerformance?: RelayPerformanceConfig;
54
+ relayPrivacy?: RelayPrivacyConfig;
25
55
  });
26
56
  private connect;
27
57
  private connectWebSocket;
58
+ /**
59
+ * Schedule reconnection with exponential backoff + jitter
60
+ * Prevents thundering herd on network flapping
61
+ */
62
+ private scheduleReconnect;
63
+ private seedAdaptiveNetworkProfile;
64
+ private initializeRoomCryptoKey;
65
+ private getRoomCryptoKey;
66
+ private computeLocalCapabilities;
67
+ private getKnownRemoteClientIds;
68
+ private isCapabilityEnabled;
69
+ private capabilityListFromBitmask;
70
+ private sendCapabilitiesAdvertisement;
71
+ private reconcilePeerCapabilities;
28
72
  private getAuthToken;
73
+ private resolveRelayUrl;
74
+ private discoverRelayUrls;
75
+ private fetchRelayCandidates;
76
+ private rankRelayUrls;
77
+ private scoreRelay;
78
+ private recordRelaySuccess;
79
+ private recordRelayFailure;
29
80
  enterHighFrequencyMode(): Promise<void>;
30
81
  private sendSyncStep1;
82
+ /**
83
+ * Read loop for WebTransport with dynamic buffer sizing
84
+ * Handles payloads larger than initial buffer
85
+ */
31
86
  private readLoop;
87
+ /**
88
+ * Handle incoming message with protocol validation
89
+ * Never silently ignores malformed messages
90
+ */
32
91
  private handleMessage;
92
+ /**
93
+ * Send message with error handling and offline queue fallback
94
+ * Never fails silently - either sends, queues, or throws
95
+ */
33
96
  private send;
97
+ private enqueueOutbound;
98
+ private scheduleBatchFlush;
99
+ private flushOutboundQueue;
100
+ private encodeBatchFrame;
101
+ private applyOutboundPipeline;
102
+ private maybeCompressPayload;
103
+ private decompressPayload;
104
+ private maybeEncryptPayload;
105
+ private decryptPayload;
106
+ private sendSingleFrame;
107
+ /**
108
+ * Queue message for offline sync
109
+ */
110
+ private queueForOffline;
34
111
  private onDocUpdate;
35
112
  private onAwarenessUpdate;
36
113
  destroy(): void;
@@ -61,6 +138,11 @@ export declare class HybridProvider extends Observable<string> {
61
138
  * Get comprehensive connection status
62
139
  */
63
140
  getConnectionStatus(): ConnectionStatus;
141
+ /**
142
+ * Force immediate reconnection (resets backoff)
143
+ * Use when user explicitly requests reconnect
144
+ */
145
+ forceReconnect(): void;
64
146
  /**
65
147
  * Get all awareness states from connected peers
66
148
  */
@@ -96,18 +178,66 @@ export declare class HybridProvider extends Observable<string> {
96
178
  }
97
179
  export interface ConnectionStatus {
98
180
  connected: boolean;
181
+ connectionState: 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
99
182
  roomName: string;
100
183
  url: string;
184
+ reconnectAttempts: number;
101
185
  websocket: {
102
186
  state: 'connecting' | 'open' | 'closing' | 'closed';
103
187
  connected: boolean;
188
+ bufferedAmount: number;
104
189
  };
105
190
  webTransport: {
106
191
  connected: boolean;
107
192
  highFrequencyMode: boolean;
108
193
  };
194
+ discovery: {
195
+ enabled: boolean;
196
+ knownRelays: number;
197
+ lastDiscoveryAt: number | null;
198
+ targetPeerId: string;
199
+ };
200
+ performance: {
201
+ batching: boolean;
202
+ adaptiveCompression: boolean;
203
+ activeBatching: boolean;
204
+ activeCompression: boolean;
205
+ queuedFrames: number;
206
+ lastCompressionRatio: number | null;
207
+ };
208
+ privacy: {
209
+ enabled: boolean;
210
+ keyLoaded: boolean;
211
+ activeEncryption: boolean;
212
+ };
213
+ protocol: {
214
+ version: number;
215
+ localCapabilities: string[];
216
+ knownPeers: number;
217
+ };
109
218
  transport: 'WebSocket' | 'WebTransport';
110
219
  }
220
+ export interface RelayDiscoveryConfig {
221
+ enabled?: boolean;
222
+ bootstrapUrls?: string[];
223
+ discoveryPath?: string;
224
+ refreshIntervalMs?: number;
225
+ requestTimeoutMs?: number;
226
+ maxCandidates?: number;
227
+ dhtQueryEnabled?: boolean;
228
+ targetPeerId?: string;
229
+ }
230
+ export interface RelayPerformanceConfig {
231
+ enableAdaptiveCompression?: boolean;
232
+ enableBatching?: boolean;
233
+ compressionThresholdBytes?: number;
234
+ maxBatchDelayMs?: number;
235
+ maxBatchSizeBytes?: number;
236
+ }
237
+ export interface RelayPrivacyConfig {
238
+ enabled?: boolean;
239
+ roomKey?: string | Uint8Array;
240
+ }
111
241
  export interface AwarenessState {
112
242
  clientId: number;
113
243
  state: Record<string, unknown>;
@@ -169,4 +299,9 @@ export interface AeonStatus {
169
299
  away: number;
170
300
  offline: number;
171
301
  } | null;
302
+ compression: {
303
+ averageCompressionMs: number;
304
+ averageRatio: number;
305
+ networkCondition: 'fast' | 'normal' | 'slow' | 'offline';
306
+ } | null;
172
307
  }