@nice2dev/ui-communication 1.0.2

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.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # @nice2dev/ui-communication
2
+
3
+ > Full-featured communication suite for React — chat, DMs, channels, audio/video calls, whiteboard, recordings, E2E encryption.
4
+
5
+ ## Features
6
+
7
+ ### NiceCommunication
8
+
9
+ Main entry-point with 7 modes:
10
+
11
+ | Mode | Description |
12
+ |------|-------------|
13
+ | **bubble** | Floating chat bubble (customer support style) |
14
+ | **chat** | Standalone chat panel |
15
+ | **messenger** | Full messenger with contact list |
16
+ | **workspace** | Teams-style workspace with rail navigation |
17
+ | **call** | Audio/video call UI |
18
+ | **conference** | Multi-participant conference |
19
+ | **whiteboard** | Collaborative whiteboard |
20
+
21
+ ### Components
22
+
23
+ - **NiceTeamsWorkspace** — Teams-style workspace with rail navigation + whiteboard integration
24
+ - **NiceWhiteboard** — Collaborative whiteboard with 15 tools, multi-user cursors, CRDT, layers, zoom/pan, export PNG/SVG
25
+ - **NiceCollaborativeEditor** — Overlay for any editor: cursors, avatars, follow-user, conflict banner, read-only mode
26
+ - **NiceStorageSettings** — Data retention configuration (8 data types) + per-scope encryption + usage bar
27
+ - **NiceRecordingPanel** — Recording management + live timer + audio player + transcript preview (Web Speech API)
28
+
29
+ ### Services
30
+
31
+ - **EncryptionService** — Web Crypto API: AES-GCM-128/256, E2E-ECDH-P384, ECDSA signatures
32
+ - **StorageService** — IndexedDB/localStorage + retention rules (8 data types) + export/import
33
+ - **RecordingService** — MediaRecorder + Web Speech API transcription + export/delete
34
+ - **useWhiteboard** — CRDT hook (undo/redo, auto-save, remote op dedup with vector clock)
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ npm install @nice2dev/ui-communication
40
+ ```
41
+
42
+ ## License
43
+
44
+ MIT © NiceToDev
@@ -0,0 +1,4 @@
1
+ import { NiceCallScreenProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceCallScreen({ session, currentUser, localStream, enableScreenSharing, enableRecording, onEndCall, onMuteAudio, onMuteVideo, onStartScreenShare, onStopScreenShare, onRaiseHand, className, style, id, 'data-testid': testId, }: NiceCallScreenProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NiceCallScreen;
@@ -0,0 +1,4 @@
1
+ import { NiceChannelViewProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceChannelView({ channel, messages, users, currentUser, team, isLoading, hasMore, enableThreads, enableReactions, enableAttachments, onSendMessage, onEditMessage, onDeleteMessage, onReactToMessage, onPinMessage, onLoadMoreMessages, onStartCall, className, style, id, 'data-testid': testId, }: NiceChannelViewProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NiceChannelView;
@@ -0,0 +1,4 @@
1
+ import { NiceChatWindowProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceChatWindow({ conversation, messages, users, currentUser, isLoading, hasMore, showHeader, showUserAvatars, enableReactions, enableThreads, enableAttachments, placeholder, maxMessageLength, onSendMessage, onEditMessage, onDeleteMessage, onReactToMessage, onPinMessage, onLoadMoreMessages, onStartCall, className, style, id, 'data-testid': testId, }: NiceChatWindowProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NiceChatWindow;
@@ -0,0 +1,3 @@
1
+ import { NiceCollaborativeEditorProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceCollaborativeEditor({ editorType, sessionId, currentUser, participants: propParticipants, onOperation, onParticipantJoin, onParticipantLeave, onCursorMove, isReadOnly, showParticipants, showCursors, pendingOperations, conflictCount, className, style, children, 'data-testid': testId, }: NiceCollaborativeEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { NiceCommunicationProps } from '../types/communicationTypes';
2
+
3
+ /**
4
+ * NiceCommunication — the single entry-point component that covers every
5
+ * communication scenario, from a floating chat bubble to a full
6
+ * MS Teams–equivalent workspace, including WebRTC audio/video calls
7
+ * and multi-person video conferences.
8
+ *
9
+ * @example — bubble
10
+ * ```tsx
11
+ * <NiceCommunication mode="bubble" currentUser={me} users={[]} conversations={[conv]}
12
+ * messages={{ [conv.id]: [] }} onSendMessage={handleSend} />
13
+ * ```
14
+ *
15
+ * @example — full workspace
16
+ * ```tsx
17
+ * <NiceCommunication mode="workspace" currentUser={me} users={users} teams={teams}
18
+ * conversations={dms} messages={messages} transport="webrtc"
19
+ * rtcConfig={{ signalingUrl: 'wss://…', iceServers: [{ urls: 'stun:…' }] }}
20
+ * onSendMessage={handleSend} onStartCall={handleCall} />
21
+ * ```
22
+ */
23
+ export declare function NiceCommunication(props: NiceCommunicationProps): import("react/jsx-runtime").JSX.Element;
24
+ export default NiceCommunication;
@@ -0,0 +1,4 @@
1
+ import { NiceMessengerProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceMessenger({ conversations, messages, users, currentUser, activeConversationId, teams, enableGroupConversations, showPresence, enableSearch, onSendMessage, onEditMessage, onDeleteMessage, onReactToMessage, onPinMessage, onLoadMoreMessages, onMarkAsRead, onStartCall, onCreateConversation, className, style, id, 'data-testid': testId, }: NiceMessengerProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NiceMessenger;
@@ -0,0 +1,4 @@
1
+ import { NicePresenceIndicatorProps } from '../types/communicationTypes';
2
+
3
+ export declare function NicePresenceIndicator({ status, size, showLabel, showTooltip, className, style, id, 'data-testid': testId, }: NicePresenceIndicatorProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NicePresenceIndicator;
@@ -0,0 +1,3 @@
1
+ import { NiceRecordingPanelProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceRecordingPanel({ recordings: externalRecordings, onRecordingStart, onRecordingStop, onRecordingPause, onRecordingResume, onRecordingDelete, onRecordingDownload, activeRecordingId, sessionType, className, style, 'data-testid': testId, }: NiceRecordingPanelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { NiceStorageSettingsProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceStorageSettings({ storageConfig, encryptionConfig, onStorageConfigChange, onEncryptionConfigChange, currentUsageBytes, showEncryption, showRetention, showQuota, className, style, 'data-testid': testId, }: NiceStorageSettingsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { NiceTeamsWorkspaceProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceTeamsWorkspace({ currentUser, users, teams, conversations, messages, activeCall, incomingCall, meetings, transport: _transport, rtcConfig: _rtcConfig, enableCalls, enableMeetings, enableScreenSharing, enableWhiteboard, storageConfig, onSendMessage, onEditMessage, onDeleteMessage, onReactToMessage, onPinMessage, onLoadMoreMessages, onMarkAsRead, onStartCall, onAcceptCall, onDeclineCall, onEndCall, onMuteAudio, onMuteVideo, onStartScreenShare, onStopScreenShare, className, style, id, 'data-testid': testId, }: NiceTeamsWorkspaceProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NiceTeamsWorkspace;
@@ -0,0 +1,4 @@
1
+ import { NiceVideoConferenceProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceVideoConference({ session, currentUser, localStream, enableScreenSharing, enableRecording, enableTranscription, enableRaiseHand, maxGridCols, onEndCall, onMuteAudio, onMuteVideo, onStartScreenShare, onStopScreenShare, onRaiseHand, className, style, id, 'data-testid': testId, }: NiceVideoConferenceProps): import("react/jsx-runtime").JSX.Element;
4
+ export default NiceVideoConference;
@@ -0,0 +1,3 @@
1
+ import { NiceWhiteboardProps } from '../types/communicationTypes';
2
+
3
+ export declare function NiceWhiteboard({ session: initialSession, currentUser, onOperation, remoteOperations, readonly, enableLayers, enableExport, enableLaserPointer, enableVectorEditor, enableDiagramEditor, onExport, onSessionUpdate, storageConfig, className, style, 'data-testid': testId, }: NiceWhiteboardProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { CallSession, CallType, ChatMessage, CommunicationMode, CommunicationUser, Conversation, IncomingCall, MessageContentType, RTCTransportConfig, TransportType } from '../types/communicationTypes';
2
+ import { ICommunicationTransport } from '../transport/communicationTransport';
3
+
4
+ export interface CommunicationState {
5
+ isConnected: boolean;
6
+ activeCall: CallSession | null;
7
+ incomingCall: IncomingCall | null;
8
+ localStream: MediaStream | null;
9
+ isMicMuted: boolean;
10
+ isCameraMuted: boolean;
11
+ isScreenSharing: boolean;
12
+ screenStream: MediaStream | null;
13
+ isHandRaised: boolean;
14
+ connectionError: string | null;
15
+ }
16
+ export interface UseCommunicationOptions {
17
+ currentUser: CommunicationUser;
18
+ transport?: TransportType;
19
+ rtcConfig?: RTCTransportConfig;
20
+ signalingUrl?: string;
21
+ autoConnect?: boolean;
22
+ onCallEnded?: (callId: string) => void;
23
+ onIncomingCall?: (call: IncomingCall) => void;
24
+ onStreamAdded?: (participantId: string, stream: MediaStream) => void;
25
+ onStreamRemoved?: (participantId: string) => void;
26
+ onError?: (error: Error) => void;
27
+ }
28
+ export declare function useCommunication(options: UseCommunicationOptions): {
29
+ readonly state: CommunicationState;
30
+ readonly connect: (url: string) => Promise<void>;
31
+ readonly disconnect: () => void;
32
+ readonly startCall: (participantIds: string[], type?: CallType) => Promise<CallSession>;
33
+ readonly acceptCall: () => Promise<void>;
34
+ readonly declineCall: () => void;
35
+ readonly endCall: () => void;
36
+ readonly toggleMic: () => void;
37
+ readonly toggleCamera: () => void;
38
+ readonly startScreenShare: () => Promise<void>;
39
+ readonly stopScreenShare: () => void;
40
+ readonly toggleHand: () => void;
41
+ readonly transport: import('react').MutableRefObject<ICommunicationTransport | null>;
42
+ };
43
+ export declare function buildOptimisticMessage(conversationId: string, authorId: string, content: string, contentType?: MessageContentType): ChatMessage;
44
+ export declare function findConversationPartner(conversation: Conversation, currentUserId: string, users: CommunicationUser[]): CommunicationUser | undefined;
45
+ export declare function getUnreadCount(conversations: Conversation[]): number;
46
+ export declare function getMentionCount(conversations: Conversation[]): number;
47
+ export declare function getDefaultMode(hasTeams: boolean, hasConversations: boolean): CommunicationMode;
@@ -0,0 +1,63 @@
1
+ import { WhiteboardSession, WhiteboardObject, WhiteboardLayer, WhiteboardCollaborator, WhiteboardOperation, WhiteboardToolType, WhiteboardViewport, CommunicationUser, StorageConfig } from '../types/communicationTypes';
2
+
3
+ export interface WhiteboardState {
4
+ session: WhiteboardSession;
5
+ activeTool: WhiteboardToolType;
6
+ selectedObjectIds: string[];
7
+ undoStack: WhiteboardOperation[][];
8
+ redoStack: WhiteboardOperation[][];
9
+ isDrawing: boolean;
10
+ isPanning: boolean;
11
+ isDirty: boolean;
12
+ lastSavedAt?: Date;
13
+ }
14
+ export interface UseWhiteboardOptions {
15
+ session: WhiteboardSession;
16
+ currentUser: CommunicationUser;
17
+ /** Called when a local op should be broadcast to peers */
18
+ onOperation?: (op: WhiteboardOperation) => void;
19
+ /** Remote operation queue from parent */
20
+ remoteOperations?: WhiteboardOperation[];
21
+ readonly?: boolean;
22
+ storageConfig?: StorageConfig;
23
+ /** Auto-save interval in ms (0 = disabled) */
24
+ autoSaveMs?: number;
25
+ }
26
+ export declare function useWhiteboard(opts: UseWhiteboardOptions): {
27
+ session: WhiteboardSession;
28
+ activeTool: WhiteboardToolType;
29
+ selectedObjectIds: string[];
30
+ isDrawing: boolean;
31
+ isPanning: boolean;
32
+ isDirty: boolean;
33
+ lastSavedAt: Date | undefined;
34
+ canUndo: boolean;
35
+ canRedo: boolean;
36
+ collaborators: WhiteboardCollaborator[];
37
+ objects: WhiteboardObject[];
38
+ layers: WhiteboardLayer[];
39
+ viewport: WhiteboardViewport;
40
+ setTool: (tool: WhiteboardToolType) => void;
41
+ addObject: (obj: WhiteboardObject) => void;
42
+ updateObject: (obj: WhiteboardObject) => void;
43
+ deleteObjects: (ids: string[]) => void;
44
+ moveObjects: (moves: Array<{
45
+ id: string;
46
+ x: number;
47
+ y: number;
48
+ }>) => void;
49
+ setSelection: (ids: string[]) => void;
50
+ undo: () => void;
51
+ redo: () => void;
52
+ setViewport: (viewport: WhiteboardViewport) => void;
53
+ broadcastCursor: (x: number, y: number) => void;
54
+ addLayer: (name: string) => void;
55
+ updateLayer: (updates: Partial<WhiteboardLayer> & {
56
+ id: string;
57
+ }) => void;
58
+ deleteLayer: (id: string) => void;
59
+ registerCollaborator: (user: CommunicationUser) => void;
60
+ removeCollaborator: (userId: string) => void;
61
+ saveNow: () => Promise<void>;
62
+ };
63
+ export type UseWhiteboardReturn = ReturnType<typeof useWhiteboard>;