@noatgnu/cupcake-mint-chocolate 1.2.9 → 1.2.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.
package/index.d.ts CHANGED
@@ -256,6 +256,7 @@ declare enum SignalType {
256
256
  }
257
257
  interface WebRTCSession extends BaseTimestampedModel {
258
258
  id: string;
259
+ name?: string;
259
260
  sessionType: WebRTCSessionType;
260
261
  sessionStatus: WebRTCSessionStatus;
261
262
  initiatedBy: number;
@@ -263,6 +264,8 @@ interface WebRTCSession extends BaseTimestampedModel {
263
264
  initiatedByDetails?: User;
264
265
  participantsList?: WebRTCPeer[];
265
266
  participantsCount?: number;
267
+ canEdit?: boolean;
268
+ canDelete?: boolean;
266
269
  startedAt: string;
267
270
  endedAt?: string;
268
271
  }
@@ -282,12 +285,19 @@ interface WebRTCPeer extends BaseTimestampedModel {
282
285
  lastSeenAt: string;
283
286
  }
284
287
  interface WebRTCSessionCreate {
288
+ name?: string;
285
289
  sessionType: WebRTCSessionType;
286
290
  ccrvSessionIds?: number[];
287
291
  }
292
+ interface WebRTCSessionUpdate {
293
+ name?: string;
294
+ sessionType?: WebRTCSessionType;
295
+ sessionStatus?: WebRTCSessionStatus;
296
+ }
288
297
  interface WebRTCSessionQueryParams {
289
298
  sessionType?: WebRTCSessionType;
290
299
  sessionStatus?: WebRTCSessionStatus;
300
+ ccrvSessionId?: number;
291
301
  limit?: number;
292
302
  offset?: number;
293
303
  }
@@ -355,6 +365,70 @@ interface PeerConnection {
355
365
  connected: boolean;
356
366
  queuedCandidates: RTCIceCandidate[];
357
367
  }
368
+ interface ChatMessage {
369
+ type: 'chat';
370
+ peerId: string;
371
+ userId: number;
372
+ username: string;
373
+ message: string;
374
+ timestamp: string;
375
+ fileOffer?: FileOfferData;
376
+ }
377
+ interface FileOfferData {
378
+ fileId: string;
379
+ fileName: string;
380
+ fileSize: number;
381
+ fileType: string;
382
+ chunkSize: number;
383
+ totalChunks: number;
384
+ }
385
+ interface FileTransferRequest {
386
+ type: 'file_request';
387
+ fileId: string;
388
+ requesterId: string;
389
+ }
390
+ interface FileTransferAccept {
391
+ type: 'file_accept';
392
+ fileId: string;
393
+ toPeerId: string;
394
+ }
395
+ interface FileChunk {
396
+ type: 'file_chunk';
397
+ fileId: string;
398
+ chunkIndex: number;
399
+ totalChunks: number;
400
+ data: ArrayBuffer;
401
+ isLast: boolean;
402
+ }
403
+ interface FileTransferProgress {
404
+ fileId: string;
405
+ fileName: string;
406
+ fileSize: number;
407
+ chunksReceived: number;
408
+ totalChunks: number;
409
+ bytesReceived: number;
410
+ percentage: number;
411
+ }
412
+ interface FileTransferState {
413
+ fileId: string;
414
+ fileName: string;
415
+ fileSize: number;
416
+ fileType: string;
417
+ file?: File;
418
+ chunks: Map<number, ArrayBuffer>;
419
+ totalChunks: number;
420
+ chunkSize: number;
421
+ sentChunks: number;
422
+ receivedChunks: number;
423
+ status: 'pending' | 'transferring' | 'completed' | 'failed';
424
+ requestedBy: Set<string>;
425
+ streamWriter?: WritableStreamDefaultWriter<Uint8Array>;
426
+ downloadStream?: WritableStream<Uint8Array>;
427
+ }
428
+ interface DataChannelMessage {
429
+ type: 'chat' | 'ping' | 'pong' | 'file_request' | 'file_accept' | 'file_chunk' | 'file_complete' | 'file_cancel';
430
+ data: any;
431
+ }
358
432
 
359
433
  declare class NotificationService extends BaseApiService {
360
434
  /**
@@ -831,14 +905,20 @@ declare class WebRTCService {
831
905
  private peerConnections;
832
906
  private localStream?;
833
907
  private signallingSubscription?;
908
+ private fileTransfers;
909
+ private readonly DEFAULT_CHUNK_SIZE;
834
910
  private _localStreamReady;
835
911
  private _remoteStreams;
836
912
  private _connectionState;
837
913
  private _activePeers;
914
+ private _chatMessages;
915
+ private _fileTransferProgress;
838
916
  localStreamReady$: rxjs.Observable<boolean>;
839
917
  remoteStreams$: rxjs.Observable<Map<string, MediaStream>>;
840
918
  connectionState$: rxjs.Observable<"connecting" | "connected" | "disconnected">;
841
919
  activePeers$: rxjs.Observable<PeerInfo[]>;
920
+ chatMessages$: rxjs.Observable<ChatMessage>;
921
+ fileTransferProgress$: rxjs.Observable<FileTransferProgress>;
842
922
  private defaultConfig;
843
923
  private defaultMediaConstraints;
844
924
  constructor(signalling: WebRTCSignallingService, zone: NgZone);
@@ -856,10 +936,27 @@ declare class WebRTCService {
856
936
  private createPeerConnection;
857
937
  private setupPeerConnectionHandlers;
858
938
  private setupDataChannelHandlers;
939
+ private handleDataChannelMessage;
940
+ sendChatMessage(message: string): void;
941
+ private sendDataChannelMessage;
859
942
  private closePeerConnection;
860
943
  private shouldInitiateConnection;
861
944
  private replaceTracksInAllPeers;
862
945
  private updatePeerState;
946
+ offerFile(file: File): void;
947
+ requestFile(fileId: string): void;
948
+ private handleFileRequest;
949
+ private handleFileAccept;
950
+ private createFileDownloadStream;
951
+ private createStreamSaverFallback;
952
+ private startSendingFile;
953
+ private handleFileChunk;
954
+ private handleFileComplete;
955
+ private handleFileCancel;
956
+ cancelFileTransfer(fileId: string): Promise<void>;
957
+ private arrayBufferToBase64;
958
+ private base64ToArrayBuffer;
959
+ private formatFileSize;
863
960
  get localMediaStream(): MediaStream | undefined;
864
961
  get isConnected(): boolean;
865
962
  get activePeerConnections(): PeerConnection[];
@@ -873,6 +970,7 @@ declare class WebRTCSessionService extends BaseApiService {
873
970
  getSessions(params?: WebRTCSessionQueryParams): Observable<PaginatedResponse$1<WebRTCSession>>;
874
971
  getSession(id: string): Observable<WebRTCSession>;
875
972
  createSession(data: WebRTCSessionCreate): Observable<WebRTCSession>;
973
+ updateSession(id: string, data: WebRTCSessionUpdate): Observable<WebRTCSession>;
876
974
  endSession(id: string): Observable<{
877
975
  message: string;
878
976
  session_id: string;
@@ -883,4 +981,4 @@ declare class WebRTCSessionService extends BaseApiService {
883
981
  }
884
982
 
885
983
  export { CommunicationWebSocketService, CupcakeMintChocolate, DeliveryStatus, DeliveryStatusLabels, MessageService, MessageThreadService, MessageType, MessageTypeLabels, NotificationPriority, NotificationPriorityLabels, NotificationService, NotificationType, NotificationTypeLabels, PeerConnectionState, PeerRole, SignalType, ThreadParticipantService, WebRTCService, WebRTCSessionService, WebRTCSessionStatus, WebRTCSessionType, WebRTCSignallingService };
886
- export type { ApiResponse, BaseTimestampedModel, BulkNotificationActionRequest, ConnectionEstablishedEvent, MarkNotificationReadMessage, MarkNotificationReadRequest, MediaConstraintsConfig, Message, MessageCreateRequest, MessageQueryParams, MessageSearchRequest, MessageThread, MessageThreadCreateRequest, MessageThreadQueryParams, MessageThreadUpdateRequest, MessageUpdateRequest, NewMessageEvent, NewNotificationEvent, Notification, NotificationCreateRequest, NotificationMarkedReadEvent, NotificationQueryParams, NotificationUpdateEvent, NotificationUpdateRequest, PaginatedResponse, PeerConnection, PeerInfo, PingMessage, PongEvent, SubscribeThreadMessage, ThreadParticipant, ThreadParticipantQueryParams, ThreadParticipantRequest, ThreadSearchRequest, ThreadSubscriptionConfirmedEvent, ThreadSubscriptionDeniedEvent, ThreadUnsubscriptionConfirmedEvent, ThreadUpdateEvent, UnsubscribeThreadMessage, UserBasic, WebRTCConfig, WebRTCMessage, WebRTCPeer, WebRTCSession, WebRTCSessionCreate, WebRTCSessionQueryParams, WebRTCSignal, WebSocketIncomingMessage, WebSocketOutgoingMessage };
984
+ export type { ApiResponse, BaseTimestampedModel, BulkNotificationActionRequest, ChatMessage, ConnectionEstablishedEvent, DataChannelMessage, FileChunk, FileOfferData, FileTransferAccept, FileTransferProgress, FileTransferRequest, FileTransferState, MarkNotificationReadMessage, MarkNotificationReadRequest, MediaConstraintsConfig, Message, MessageCreateRequest, MessageQueryParams, MessageSearchRequest, MessageThread, MessageThreadCreateRequest, MessageThreadQueryParams, MessageThreadUpdateRequest, MessageUpdateRequest, NewMessageEvent, NewNotificationEvent, Notification, NotificationCreateRequest, NotificationMarkedReadEvent, NotificationQueryParams, NotificationUpdateEvent, NotificationUpdateRequest, PaginatedResponse, PeerConnection, PeerInfo, PingMessage, PongEvent, SubscribeThreadMessage, ThreadParticipant, ThreadParticipantQueryParams, ThreadParticipantRequest, ThreadSearchRequest, ThreadSubscriptionConfirmedEvent, ThreadSubscriptionDeniedEvent, ThreadUnsubscriptionConfirmedEvent, ThreadUpdateEvent, UnsubscribeThreadMessage, UserBasic, WebRTCConfig, WebRTCMessage, WebRTCPeer, WebRTCSession, WebRTCSessionCreate, WebRTCSessionQueryParams, WebRTCSessionUpdate, WebRTCSignal, WebSocketIncomingMessage, WebSocketOutgoingMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noatgnu/cupcake-mint-chocolate",
3
- "version": "1.2.9",
3
+ "version": "1.2.11",
4
4
  "description": "An extension for cupcake-core that provides additional api and interfaces for managing notifications and messaging.",
5
5
  "author": "Toan Phung",
6
6
  "license": "MIT",