@nice2dev/ui-communication 1.0.8 → 1.0.11

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.
@@ -0,0 +1,369 @@
1
+ /**
2
+ * @file Nice2Dev Communication Controls
3
+ * @description Video conferencing, screen sharing, whiteboard, chat
4
+ */
5
+ export interface VideoConferenceConfig {
6
+ /** Room ID */
7
+ roomId: string;
8
+ /** User info */
9
+ user: {
10
+ id: string;
11
+ name: string;
12
+ avatar?: string;
13
+ };
14
+ /** ICE servers for WebRTC */
15
+ iceServers?: RTCIceServer[];
16
+ /** Signaling server URL */
17
+ signalingUrl: string;
18
+ /** Enable audio */
19
+ audio?: boolean;
20
+ /** Enable video */
21
+ video?: boolean;
22
+ /** Max participants */
23
+ maxParticipants?: number;
24
+ }
25
+ export interface Participant {
26
+ id: string;
27
+ name: string;
28
+ avatar?: string;
29
+ stream?: MediaStream;
30
+ audioEnabled: boolean;
31
+ videoEnabled: boolean;
32
+ isScreenSharing: boolean;
33
+ isSpeaking: boolean;
34
+ }
35
+ export interface VideoConferenceState {
36
+ isConnected: boolean;
37
+ participants: Participant[];
38
+ localStream: MediaStream | null;
39
+ screenStream: MediaStream | null;
40
+ audioEnabled: boolean;
41
+ videoEnabled: boolean;
42
+ isScreenSharing: boolean;
43
+ }
44
+ /**
45
+ * Hook for video conferencing
46
+ */
47
+ export declare function useVideoConference(_config: VideoConferenceConfig): {
48
+ state: VideoConferenceState;
49
+ join: () => Promise<void>;
50
+ leave: () => void;
51
+ toggleAudio: () => void;
52
+ toggleVideo: () => void;
53
+ startScreenShare: () => Promise<void>;
54
+ stopScreenShare: () => void;
55
+ onParticipantJoined: (_callback: (participant: Participant) => void) => void;
56
+ onParticipantLeft: (_callback: (participantId: string) => void) => void;
57
+ onStreamUpdated: (_callback: (participantId: string, stream: MediaStream) => void) => void;
58
+ };
59
+ export interface ScreenShareConfig {
60
+ /** Enable audio capture */
61
+ withAudio?: boolean;
62
+ /** Video quality */
63
+ quality?: 'low' | 'medium' | 'high' | 'hd';
64
+ /** Preferred display surface */
65
+ displaySurface?: 'monitor' | 'window' | 'application' | 'browser';
66
+ }
67
+ export interface ScreenAnnotation {
68
+ id: string;
69
+ type: 'drawing' | 'text' | 'arrow' | 'rectangle' | 'highlight';
70
+ data: unknown;
71
+ color: string;
72
+ userId: string;
73
+ }
74
+ /**
75
+ * Hook for screen sharing with annotation
76
+ */
77
+ export declare function useScreenShare(_config?: ScreenShareConfig): {
78
+ stream: MediaStream | null;
79
+ isSharing: boolean;
80
+ annotations: ScreenAnnotation[];
81
+ startSharing: () => Promise<{
82
+ stream: MediaStream | null;
83
+ }>;
84
+ stopSharing: () => void;
85
+ addAnnotation: (_annotation: Omit<ScreenAnnotation, "id">) => void;
86
+ removeAnnotation: (_id: string) => void;
87
+ clearAnnotations: () => void;
88
+ enableRemoteControl: () => void;
89
+ disableRemoteControl: () => void;
90
+ };
91
+ export interface WhiteboardConfig {
92
+ /** Board ID for collaboration */
93
+ boardId: string;
94
+ /** User info */
95
+ user: {
96
+ id: string;
97
+ name: string;
98
+ color: string;
99
+ };
100
+ /** Collaboration server URL */
101
+ serverUrl?: string;
102
+ /** Board dimensions */
103
+ width?: number;
104
+ height?: number;
105
+ }
106
+ export interface WhiteboardElement {
107
+ id: string;
108
+ type: 'path' | 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'text' | 'image' | 'sticky';
109
+ x: number;
110
+ y: number;
111
+ width?: number;
112
+ height?: number;
113
+ points?: {
114
+ x: number;
115
+ y: number;
116
+ }[];
117
+ fill?: string;
118
+ stroke?: string;
119
+ strokeWidth?: number;
120
+ text?: string;
121
+ fontSize?: number;
122
+ imageUrl?: string;
123
+ rotation?: number;
124
+ opacity?: number;
125
+ locked?: boolean;
126
+ userId: string;
127
+ }
128
+ export interface WhiteboardTool {
129
+ type: 'select' | 'pen' | 'highlighter' | 'eraser' | 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'text' | 'sticky' | 'image' | 'pan' | 'laser';
130
+ color?: string;
131
+ strokeWidth?: number;
132
+ fontSize?: number;
133
+ }
134
+ /**
135
+ * Hook for collaborative whiteboard
136
+ */
137
+ export declare function useWhiteboard(_config: WhiteboardConfig): {
138
+ elements: WhiteboardElement[];
139
+ selectedIds: string[];
140
+ currentTool: WhiteboardTool;
141
+ zoom: number;
142
+ pan: {
143
+ x: number;
144
+ y: number;
145
+ };
146
+ collaborators: {
147
+ id: string;
148
+ name: string;
149
+ color: string;
150
+ cursor?: {
151
+ x: number;
152
+ y: number;
153
+ };
154
+ }[];
155
+ addElement: (_element: Omit<WhiteboardElement, "id" | "userId">) => void;
156
+ updateElement: (_id: string, _updates: Partial<WhiteboardElement>) => void;
157
+ deleteElements: (_ids: string[]) => void;
158
+ selectElements: (_ids: string[]) => void;
159
+ setTool: (_tool: WhiteboardTool) => void;
160
+ setZoom: (_zoom: number) => void;
161
+ setPan: (_pan: {
162
+ x: number;
163
+ y: number;
164
+ }) => void;
165
+ undo: () => void;
166
+ redo: () => void;
167
+ canUndo: boolean;
168
+ canRedo: boolean;
169
+ exportAsImage: () => Promise<string>;
170
+ exportAsSvg: () => string;
171
+ exportAsJson: () => object;
172
+ importFromJson: (_data: object) => void;
173
+ };
174
+ export interface ChatRoomConfig {
175
+ /** Room ID */
176
+ roomId: string;
177
+ /** User info */
178
+ user: {
179
+ id: string;
180
+ name: string;
181
+ avatar?: string;
182
+ };
183
+ /** Server URL */
184
+ serverUrl: string;
185
+ /** Enable file sharing */
186
+ enableFiles?: boolean;
187
+ /** Enable threads */
188
+ enableThreads?: boolean;
189
+ /** Enable reactions */
190
+ enableReactions?: boolean;
191
+ }
192
+ export interface ChatMessage {
193
+ id: string;
194
+ content: string;
195
+ type: 'text' | 'file' | 'image' | 'system';
196
+ userId: string;
197
+ userName: string;
198
+ userAvatar?: string;
199
+ timestamp: Date;
200
+ threadId?: string;
201
+ replyTo?: string;
202
+ reactions?: {
203
+ emoji: string;
204
+ userIds: string[];
205
+ }[];
206
+ file?: {
207
+ name: string;
208
+ url: string;
209
+ size: number;
210
+ type: string;
211
+ };
212
+ edited?: boolean;
213
+ deleted?: boolean;
214
+ }
215
+ export interface ChatThread {
216
+ id: string;
217
+ parentMessageId: string;
218
+ messages: ChatMessage[];
219
+ participantIds: string[];
220
+ }
221
+ /**
222
+ * Hook for chat room
223
+ */
224
+ export declare function useChatRoom(_config: ChatRoomConfig): {
225
+ messages: ChatMessage[];
226
+ threads: ChatThread[];
227
+ participants: {
228
+ id: string;
229
+ name: string;
230
+ avatar?: string;
231
+ isOnline: boolean;
232
+ }[];
233
+ isTyping: {
234
+ userId: string;
235
+ userName: string;
236
+ }[];
237
+ unreadCount: number;
238
+ sendMessage: (_content: string, _options?: {
239
+ threadId?: string;
240
+ replyTo?: string;
241
+ }) => Promise<void>;
242
+ editMessage: (_messageId: string, _content: string) => Promise<void>;
243
+ deleteMessage: (_messageId: string) => Promise<void>;
244
+ addReaction: (_messageId: string, _emoji: string) => Promise<void>;
245
+ removeReaction: (_messageId: string, _emoji: string) => Promise<void>;
246
+ uploadFile: (_file: File) => Promise<{
247
+ url: string;
248
+ }>;
249
+ setTyping: (_isTyping: boolean) => void;
250
+ markAsRead: () => void;
251
+ startThread: (_messageId: string) => void;
252
+ closeThread: () => void;
253
+ onNewMessage: (_callback: (message: ChatMessage) => void) => () => void;
254
+ onMessageEdited: (_callback: (message: ChatMessage) => void) => () => void;
255
+ onMessageDeleted: (_callback: (messageId: string) => void) => () => void;
256
+ onTypingChange: (_callback: (typing: {
257
+ userId: string;
258
+ userName: string;
259
+ }[]) => void) => () => void;
260
+ };
261
+ export interface NotificationHubConfig {
262
+ /** User ID */
263
+ userId: string;
264
+ /** API base URL */
265
+ apiUrl: string;
266
+ /** Enable push notifications */
267
+ enablePush?: boolean;
268
+ /** Enable in-app notifications */
269
+ enableInApp?: boolean;
270
+ /** Notification preferences */
271
+ preferences?: NotificationPreferences;
272
+ }
273
+ export interface NotificationPreferences {
274
+ email: boolean;
275
+ push: boolean;
276
+ inApp: boolean;
277
+ channels: {
278
+ [channel: string]: {
279
+ email: boolean;
280
+ push: boolean;
281
+ inApp: boolean;
282
+ };
283
+ };
284
+ }
285
+ export interface Notification {
286
+ id: string;
287
+ type: string;
288
+ channel: string;
289
+ title: string;
290
+ body: string;
291
+ data?: Record<string, unknown>;
292
+ read: boolean;
293
+ timestamp: Date;
294
+ expiresAt?: Date;
295
+ actionUrl?: string;
296
+ imageUrl?: string;
297
+ }
298
+ /**
299
+ * Hook for unified notification hub
300
+ */
301
+ export declare function useNotificationHub(_config: NotificationHubConfig): {
302
+ notifications: Notification[];
303
+ unreadCount: number;
304
+ preferences: NotificationPreferences;
305
+ markAsRead: (_notificationId: string) => Promise<void>;
306
+ markAllAsRead: () => Promise<void>;
307
+ deleteNotification: (_notificationId: string) => Promise<void>;
308
+ clearAll: () => Promise<void>;
309
+ updatePreferences: (_preferences: Partial<NotificationPreferences>) => Promise<void>;
310
+ requestPushPermission: () => Promise<boolean>;
311
+ subscribeToPush: () => Promise<void>;
312
+ unsubscribeFromPush: () => Promise<void>;
313
+ subscribe: () => () => void;
314
+ onNotification: (_callback: (notification: Notification) => void) => () => void;
315
+ };
316
+ export interface CommentConfig {
317
+ /** Entity type (e.g., 'document', 'task', 'cell') */
318
+ entityType: string;
319
+ /** Entity ID */
320
+ entityId: string;
321
+ /** User info */
322
+ user: {
323
+ id: string;
324
+ name: string;
325
+ avatar?: string;
326
+ };
327
+ /** API URL */
328
+ apiUrl: string;
329
+ }
330
+ export interface Comment {
331
+ id: string;
332
+ content: string;
333
+ userId: string;
334
+ userName: string;
335
+ userAvatar?: string;
336
+ timestamp: Date;
337
+ edited?: boolean;
338
+ resolved?: boolean;
339
+ position?: {
340
+ startOffset?: number;
341
+ endOffset?: number;
342
+ x?: number;
343
+ y?: number;
344
+ page?: number;
345
+ };
346
+ replies?: Comment[];
347
+ mentions?: string[];
348
+ }
349
+ /**
350
+ * Hook for commenting/annotation system
351
+ */
352
+ export declare function useComments(_config: CommentConfig): {
353
+ comments: Comment[];
354
+ activeCommentId: string | null;
355
+ addComment: (_content: string, _position?: Comment["position"]) => Promise<void>;
356
+ editComment: (_commentId: string, _content: string) => Promise<void>;
357
+ deleteComment: (_commentId: string) => Promise<void>;
358
+ replyToComment: (_commentId: string, _content: string) => Promise<void>;
359
+ resolveComment: (_commentId: string) => Promise<void>;
360
+ unresolveComment: (_commentId: string) => Promise<void>;
361
+ setActiveComment: (_commentId: string | null) => void;
362
+ searchUsers: (_query: string) => Promise<{
363
+ id: string;
364
+ name: string;
365
+ }[]>;
366
+ onCommentAdded: (_callback: (comment: Comment) => void) => () => void;
367
+ onCommentUpdated: (_callback: (comment: Comment) => void) => () => void;
368
+ onCommentDeleted: (_callback: (commentId: string) => void) => () => void;
369
+ };
@@ -1,5 +1,5 @@
1
- import { CallSession, CallType, ChatMessage, CommunicationMode, CommunicationUser, Conversation, IncomingCall, MessageContentType, RTCTransportConfig, TransportType } from '../types/communicationTypes';
2
1
  import { ICommunicationTransport } from '../transport/communicationTransport';
2
+ import { CallSession, CallType, ChatMessage, CommunicationMode, CommunicationUser, Conversation, IncomingCall, MessageContentType, RTCTransportConfig, TransportType } from '../types/communicationTypes';
3
3
 
4
4
  export interface CommunicationState {
5
5
  isConnected: boolean;