@ermis-network/ermis-chat-sdk 1.0.2 → 1.0.3
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/bin/init-call.js +52 -0
- package/dist/index.browser.cjs +164 -92
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.full-bundle.min.js +15 -15
- package/dist/index.browser.full-bundle.min.js.map +1 -1
- package/dist/index.browser.mjs +163 -92
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.cjs +164 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +26 -7
- package/dist/index.d.ts +26 -7
- package/dist/index.mjs +163 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
- package/public/call_incoming.mp3 +0 -0
- package/public/call_outgoing.mp3 +0 -0
- package/public/ermis_call_node_wasm_bg.wasm +0 -0
- package/src/ermis_call_node.ts +77 -47
- package/src/index.ts +2 -1
- package/src/signal_message.ts +121 -71
package/dist/index.d.mts
CHANGED
|
@@ -1281,6 +1281,7 @@ declare class ErmisCallNode<ErmisChatGenerics extends ExtendableGenerics = Defau
|
|
|
1281
1281
|
private getAvailableDevices;
|
|
1282
1282
|
private getMediaConstraints;
|
|
1283
1283
|
startLocalStream(): Promise<MediaStream | null | undefined>;
|
|
1284
|
+
private applyLocalStream;
|
|
1284
1285
|
private setConnectionMessage;
|
|
1285
1286
|
private setCallStatus;
|
|
1286
1287
|
private setUserInfo;
|
|
@@ -1456,15 +1457,33 @@ declare const createForwardMessagePayload: <ErmisChatGenerics extends Extendable
|
|
|
1456
1457
|
declare function parseSystemMessage(value: string, userMap: Record<string, string>): string;
|
|
1457
1458
|
|
|
1458
1459
|
/**
|
|
1459
|
-
*
|
|
1460
|
+
* Call type constants for signal messages.
|
|
1461
|
+
*/
|
|
1462
|
+
declare const CallType: {
|
|
1463
|
+
readonly AUDIO: "audio";
|
|
1464
|
+
readonly VIDEO: "video";
|
|
1465
|
+
};
|
|
1466
|
+
type CallTypeValue = (typeof CallType)[keyof typeof CallType];
|
|
1467
|
+
/**
|
|
1468
|
+
* Result of parsing a signal message.
|
|
1469
|
+
*/
|
|
1470
|
+
interface SignalMessageResult {
|
|
1471
|
+
text: string;
|
|
1472
|
+
duration: string;
|
|
1473
|
+
callType: CallTypeValue | '';
|
|
1474
|
+
color: string;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Parse a raw signal message string into a structured object
|
|
1478
|
+
* containing text, duration, call type, and color.
|
|
1460
1479
|
*
|
|
1461
1480
|
* Signal messages represent call events. The raw format is:
|
|
1462
|
-
* `"<formatId> <
|
|
1481
|
+
* `"<formatId> <callerId> [<enderId> <duration>]"`
|
|
1463
1482
|
*
|
|
1464
|
-
* @param value
|
|
1465
|
-
* @param
|
|
1466
|
-
* @returns
|
|
1483
|
+
* @param value - Raw signal message string from the server
|
|
1484
|
+
* @param myUserId - The current user's ID (from client.userID)
|
|
1485
|
+
* @returns Parsed signal message object, or null if input is empty
|
|
1467
1486
|
*/
|
|
1468
|
-
declare function parseSignalMessage(value: string,
|
|
1487
|
+
declare function parseSignalMessage(value: string, myUserId: string): SignalMessageResult | null;
|
|
1469
1488
|
|
|
1470
|
-
export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type DefaultGenerics, EVENT_MAP, type EditMessage, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
|
|
1489
|
+
export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type DefaultGenerics, EVENT_MAP, type EditMessage, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1281,6 +1281,7 @@ declare class ErmisCallNode<ErmisChatGenerics extends ExtendableGenerics = Defau
|
|
|
1281
1281
|
private getAvailableDevices;
|
|
1282
1282
|
private getMediaConstraints;
|
|
1283
1283
|
startLocalStream(): Promise<MediaStream | null | undefined>;
|
|
1284
|
+
private applyLocalStream;
|
|
1284
1285
|
private setConnectionMessage;
|
|
1285
1286
|
private setCallStatus;
|
|
1286
1287
|
private setUserInfo;
|
|
@@ -1456,15 +1457,33 @@ declare const createForwardMessagePayload: <ErmisChatGenerics extends Extendable
|
|
|
1456
1457
|
declare function parseSystemMessage(value: string, userMap: Record<string, string>): string;
|
|
1457
1458
|
|
|
1458
1459
|
/**
|
|
1459
|
-
*
|
|
1460
|
+
* Call type constants for signal messages.
|
|
1461
|
+
*/
|
|
1462
|
+
declare const CallType: {
|
|
1463
|
+
readonly AUDIO: "audio";
|
|
1464
|
+
readonly VIDEO: "video";
|
|
1465
|
+
};
|
|
1466
|
+
type CallTypeValue = (typeof CallType)[keyof typeof CallType];
|
|
1467
|
+
/**
|
|
1468
|
+
* Result of parsing a signal message.
|
|
1469
|
+
*/
|
|
1470
|
+
interface SignalMessageResult {
|
|
1471
|
+
text: string;
|
|
1472
|
+
duration: string;
|
|
1473
|
+
callType: CallTypeValue | '';
|
|
1474
|
+
color: string;
|
|
1475
|
+
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Parse a raw signal message string into a structured object
|
|
1478
|
+
* containing text, duration, call type, and color.
|
|
1460
1479
|
*
|
|
1461
1480
|
* Signal messages represent call events. The raw format is:
|
|
1462
|
-
* `"<formatId> <
|
|
1481
|
+
* `"<formatId> <callerId> [<enderId> <duration>]"`
|
|
1463
1482
|
*
|
|
1464
|
-
* @param value
|
|
1465
|
-
* @param
|
|
1466
|
-
* @returns
|
|
1483
|
+
* @param value - Raw signal message string from the server
|
|
1484
|
+
* @param myUserId - The current user's ID (from client.userID)
|
|
1485
|
+
* @returns Parsed signal message object, or null if input is empty
|
|
1467
1486
|
*/
|
|
1468
|
-
declare function parseSignalMessage(value: string,
|
|
1487
|
+
declare function parseSignalMessage(value: string, myUserId: string): SignalMessageResult | null;
|
|
1469
1488
|
|
|
1470
|
-
export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type DefaultGenerics, EVENT_MAP, type EditMessage, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
|
|
1489
|
+
export { type APIErrorResponse, type APIResponse, type AscDesc, type Attachment, type AttachmentResponse, type AudioConfig, CallAction, type CallEventData, type CallEventType, CallStatus, CallType, type CallTypeValue, Channel, type ChannelAPIResponse, type ChannelData, type ChannelFilters, type ChannelMemberResponse, type ChannelMembership, type ChannelQueryOptions, type ChannelResponse, type ChannelSort, ChannelState, type ChannelStateOptions, ClientState, type ConnectAPIResponse, type ConnectionOpen, type Contact, type ContactResponse, type ContactResult, type DefaultGenerics, EVENT_MAP, type EditMessage, ErmisAuthProvider, ErmisCallNode, ErmisChat, type ErmisChatOptions, ErrorFromResponse, type Event$1 as Event, type EventHandler, type EventTypes, type ExtendableGenerics, FRAME_TYPE, type FormatMessageResponse, type ForwardMessage, type IMediaReceiverEvents, type INodeCall, type LiteralStringForUnion, type LogLevel, type Logger, type Message, type MessageBase, type MessageLabel, type MessageResponse, type MessageResponseBase, type MessageSetType, type Metadata, type PollMessage, type QueryChannelAPIResponse, type QueryChannelsAPIResponse, type Reaction, type ReactionAPIResponse, type ReactionResponse, type ReadResponse, type Role, type SendFileAPIResponse, type SendMessageAPIResponse, type SignalData, type SignalMessageResult, StableWSConnection, TokenManager, type TransceiverState, type UR, type UpdateChannelAPIResponse, type UserCallInfo, type UserResponse, type UsersResponse, type VideoConfig, type VoiceRecordingMeta, buildAttachmentPayload, chatCodes, createForwardMessagePayload, formatMessage, getAttachmentCategory, isHeicFile, isVideoFile, logChatPromiseExecution, normalizeFileName, parseSignalMessage, parseSystemMessage };
|
package/dist/index.mjs
CHANGED
|
@@ -3605,7 +3605,7 @@ var ErmisChat = class _ErmisChat {
|
|
|
3605
3605
|
return pinExpires;
|
|
3606
3606
|
}
|
|
3607
3607
|
getUserAgent() {
|
|
3608
|
-
return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.
|
|
3608
|
+
return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.3"}`;
|
|
3609
3609
|
}
|
|
3610
3610
|
setUserAgent(userAgent) {
|
|
3611
3611
|
this.userAgent = userAgent;
|
|
@@ -6314,21 +6314,38 @@ var ErmisCallNode = class {
|
|
|
6314
6314
|
const mediaConstraints = await this.getMediaConstraints();
|
|
6315
6315
|
try {
|
|
6316
6316
|
const stream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6317
|
+
return this.applyLocalStream(stream);
|
|
6318
|
+
} catch (error) {
|
|
6319
|
+
console.warn("Error getting user media:", error?.message);
|
|
6320
|
+
if (this.callType === "video" && mediaConstraints.video) {
|
|
6321
|
+
try {
|
|
6322
|
+
const audioOnlyStream = await navigator.mediaDevices.getUserMedia({
|
|
6323
|
+
audio: mediaConstraints.audio,
|
|
6324
|
+
video: false
|
|
6325
|
+
});
|
|
6326
|
+
this.setConnectionMessage("Camera not available, using audio only");
|
|
6327
|
+
return this.applyLocalStream(audioOnlyStream);
|
|
6328
|
+
} catch {
|
|
6329
|
+
}
|
|
6321
6330
|
}
|
|
6322
|
-
if (this.
|
|
6323
|
-
this.
|
|
6331
|
+
if (typeof this.onError === "function") {
|
|
6332
|
+
this.onError("No microphone or camera found. Please check your device.");
|
|
6324
6333
|
}
|
|
6325
|
-
this.localStream = stream;
|
|
6326
|
-
return stream;
|
|
6327
|
-
} catch (error) {
|
|
6328
|
-
console.error("Error getting user media:", error);
|
|
6329
6334
|
return null;
|
|
6330
6335
|
}
|
|
6331
6336
|
}
|
|
6337
|
+
applyLocalStream(stream) {
|
|
6338
|
+
if (this.callStatus === "ended" /* ENDED */) {
|
|
6339
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
6340
|
+
this.destroy();
|
|
6341
|
+
return;
|
|
6342
|
+
}
|
|
6343
|
+
if (this.onLocalStream) {
|
|
6344
|
+
this.onLocalStream(stream);
|
|
6345
|
+
}
|
|
6346
|
+
this.localStream = stream;
|
|
6347
|
+
return stream;
|
|
6348
|
+
}
|
|
6332
6349
|
setConnectionMessage(message) {
|
|
6333
6350
|
if (typeof this.onConnectionMessageChange === "function") {
|
|
6334
6351
|
this.onConnectionMessageChange(message);
|
|
@@ -6373,20 +6390,10 @@ var ErmisCallNode = class {
|
|
|
6373
6390
|
this.isDestroyed = false;
|
|
6374
6391
|
this.callStatus = "";
|
|
6375
6392
|
this.callType = is_video ? "video" : "audio";
|
|
6376
|
-
await this.startLocalStream();
|
|
6377
|
-
if (this.callStatus === "ended" /* ENDED */) return;
|
|
6378
6393
|
this.setUserInfo(cid, eventUserId);
|
|
6379
6394
|
this.setCallStatus("ringing" /* RINGING */);
|
|
6380
6395
|
this.cid = cid || "";
|
|
6381
6396
|
this.metadata = metadata || {};
|
|
6382
|
-
console.log("----metadata---", metadata);
|
|
6383
|
-
if (eventUserId !== this.userID) {
|
|
6384
|
-
await this.initialize();
|
|
6385
|
-
}
|
|
6386
|
-
if (this.localStream && this.mediaSender && this.mediaReceiver) {
|
|
6387
|
-
this.mediaSender?.initEncoders(this.localStream);
|
|
6388
|
-
this.mediaReceiver?.initDecoders(this.callType);
|
|
6389
|
-
}
|
|
6390
6397
|
if (typeof this.onCallEvent === "function") {
|
|
6391
6398
|
this.onCallEvent({
|
|
6392
6399
|
type: eventUserId !== this.userID ? "incoming" : "outgoing",
|
|
@@ -6397,6 +6404,15 @@ var ErmisCallNode = class {
|
|
|
6397
6404
|
metadata: this.metadata
|
|
6398
6405
|
});
|
|
6399
6406
|
}
|
|
6407
|
+
await this.startLocalStream();
|
|
6408
|
+
if (this.callStatus === "ended" /* ENDED */) return;
|
|
6409
|
+
if (eventUserId !== this.userID) {
|
|
6410
|
+
await this.initialize();
|
|
6411
|
+
}
|
|
6412
|
+
if (this.localStream && this.mediaSender && this.mediaReceiver) {
|
|
6413
|
+
this.mediaSender?.initEncoders(this.localStream);
|
|
6414
|
+
this.mediaReceiver?.initDecoders(this.callType);
|
|
6415
|
+
}
|
|
6400
6416
|
if (eventUserId === this.userID) {
|
|
6401
6417
|
if (this.missCallTimeout) clearTimeout(this.missCallTimeout);
|
|
6402
6418
|
this.missCallTimeout = setTimeout(async () => {
|
|
@@ -6657,21 +6673,30 @@ var ErmisCallNode = class {
|
|
|
6657
6673
|
}
|
|
6658
6674
|
async stopScreenShare() {
|
|
6659
6675
|
const mediaConstraints = await this.getMediaConstraints();
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6676
|
+
try {
|
|
6677
|
+
const cameraStream = await navigator.mediaDevices.getUserMedia({
|
|
6678
|
+
video: mediaConstraints.video,
|
|
6679
|
+
audio: false
|
|
6680
|
+
});
|
|
6681
|
+
const cameraTrack = cameraStream.getVideoTracks()[0];
|
|
6682
|
+
if (this.localStream) {
|
|
6683
|
+
this.localStream.getVideoTracks().forEach((track) => {
|
|
6684
|
+
track.stop();
|
|
6685
|
+
this.localStream?.removeTrack(track);
|
|
6686
|
+
});
|
|
6687
|
+
this.localStream.addTrack(cameraTrack);
|
|
6688
|
+
} else {
|
|
6689
|
+
this.localStream = cameraStream;
|
|
6690
|
+
}
|
|
6691
|
+
if (this.onLocalStream) {
|
|
6692
|
+
this.onLocalStream(this.localStream);
|
|
6693
|
+
this.mediaSender?.replaceVideoTrack(this.localStream.getVideoTracks()[0]);
|
|
6694
|
+
}
|
|
6695
|
+
if (typeof this.onScreenShareChange === "function") {
|
|
6696
|
+
this.onScreenShareChange(false);
|
|
6697
|
+
}
|
|
6698
|
+
} catch (error) {
|
|
6699
|
+
console.error("Error stopping screen share and reverting to camera:", error);
|
|
6675
6700
|
}
|
|
6676
6701
|
}
|
|
6677
6702
|
async toggleMic(enabled) {
|
|
@@ -6939,7 +6964,7 @@ var ErmisAuthProvider = class {
|
|
|
6939
6964
|
return data;
|
|
6940
6965
|
}
|
|
6941
6966
|
getUserAgent() {
|
|
6942
|
-
return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.
|
|
6967
|
+
return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.3"}`;
|
|
6943
6968
|
}
|
|
6944
6969
|
setUserAgent(userAgent) {
|
|
6945
6970
|
this.userAgent = userAgent;
|
|
@@ -7172,70 +7197,116 @@ function parseSystemMessage(value, userMap) {
|
|
|
7172
7197
|
}
|
|
7173
7198
|
|
|
7174
7199
|
// src/signal_message.ts
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7200
|
+
var CallType = {
|
|
7201
|
+
AUDIO: "audio",
|
|
7202
|
+
VIDEO: "video"
|
|
7203
|
+
};
|
|
7204
|
+
function formatDuration(durationMs) {
|
|
7205
|
+
if (!durationMs) return "";
|
|
7206
|
+
const ms = parseInt(durationMs, 10);
|
|
7207
|
+
if (isNaN(ms) || ms <= 0) return "";
|
|
7208
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
7209
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
7210
|
+
const seconds = totalSeconds % 60;
|
|
7211
|
+
return `${minutes} min, ${seconds} sec`;
|
|
7184
7212
|
}
|
|
7185
|
-
function parseSignalMessage(value,
|
|
7186
|
-
if (!value || typeof value !== "string") return
|
|
7213
|
+
function parseSignalMessage(value, myUserId) {
|
|
7214
|
+
if (!value || typeof value !== "string") return null;
|
|
7187
7215
|
const trimmed = value.trim();
|
|
7188
|
-
if (!trimmed) return
|
|
7216
|
+
if (!trimmed) return null;
|
|
7189
7217
|
const parts = trimmed.split(" ");
|
|
7190
|
-
const
|
|
7191
|
-
const
|
|
7192
|
-
const
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
case
|
|
7209
|
-
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
case
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7218
|
+
const number = parseInt(parts[0], 10);
|
|
7219
|
+
const callerId = parts[1] ?? "";
|
|
7220
|
+
const isMe = myUserId === callerId;
|
|
7221
|
+
let enderId = "";
|
|
7222
|
+
let duration = "";
|
|
7223
|
+
let callType = "";
|
|
7224
|
+
let color = "";
|
|
7225
|
+
if (number === 3 || number === 6) {
|
|
7226
|
+
enderId = parts[2] ?? "";
|
|
7227
|
+
duration = parts[3] === "0" ? "" : parts[3] ?? "";
|
|
7228
|
+
}
|
|
7229
|
+
let text;
|
|
7230
|
+
switch (number) {
|
|
7231
|
+
case 1:
|
|
7232
|
+
text = isMe ? "Calling..." : "Incoming audio call...";
|
|
7233
|
+
callType = CallType.AUDIO;
|
|
7234
|
+
color = "#54D62C";
|
|
7235
|
+
break;
|
|
7236
|
+
case 2:
|
|
7237
|
+
text = isMe ? "Outgoing audio call" : "You missed audio call";
|
|
7238
|
+
callType = CallType.AUDIO;
|
|
7239
|
+
color = "#FF4842";
|
|
7240
|
+
break;
|
|
7241
|
+
case 3:
|
|
7242
|
+
if (duration) {
|
|
7243
|
+
text = isMe ? "Outgoing audio call" : "Incoming audio call";
|
|
7244
|
+
color = "#54D62C";
|
|
7245
|
+
} else {
|
|
7246
|
+
if (enderId === myUserId) {
|
|
7247
|
+
text = "You cancel audio call";
|
|
7248
|
+
} else {
|
|
7249
|
+
text = "You missed audio call";
|
|
7250
|
+
}
|
|
7251
|
+
color = "#FF4842";
|
|
7252
|
+
}
|
|
7253
|
+
callType = CallType.AUDIO;
|
|
7254
|
+
break;
|
|
7255
|
+
case 4:
|
|
7256
|
+
text = isMe ? "Calling..." : "Incoming video call...";
|
|
7257
|
+
callType = CallType.VIDEO;
|
|
7258
|
+
color = "#54D62C";
|
|
7259
|
+
break;
|
|
7260
|
+
case 5:
|
|
7261
|
+
text = isMe ? "Outgoing video call" : "You missed video call";
|
|
7262
|
+
callType = CallType.VIDEO;
|
|
7263
|
+
color = "#FF4842";
|
|
7264
|
+
break;
|
|
7265
|
+
case 6:
|
|
7266
|
+
if (duration) {
|
|
7267
|
+
text = isMe ? "Outgoing video call" : "Incoming video call";
|
|
7268
|
+
color = "#54D62C";
|
|
7269
|
+
} else {
|
|
7270
|
+
if (enderId === myUserId) {
|
|
7271
|
+
text = "You cancel video call";
|
|
7272
|
+
} else {
|
|
7273
|
+
text = "You missed video call";
|
|
7274
|
+
}
|
|
7275
|
+
color = "#FF4842";
|
|
7276
|
+
}
|
|
7277
|
+
callType = CallType.VIDEO;
|
|
7278
|
+
break;
|
|
7279
|
+
case 7:
|
|
7280
|
+
text = isMe ? "Recipient rejected audio call" : "You rejected audio call";
|
|
7281
|
+
callType = CallType.AUDIO;
|
|
7282
|
+
color = "#FF4842";
|
|
7283
|
+
break;
|
|
7284
|
+
case 8:
|
|
7285
|
+
text = isMe ? "Recipient rejected video call" : "You rejected video call";
|
|
7286
|
+
callType = CallType.VIDEO;
|
|
7287
|
+
color = "#FF4842";
|
|
7288
|
+
break;
|
|
7289
|
+
case 9:
|
|
7290
|
+
text = isMe ? "Recipient was busy" : "You missed audio call";
|
|
7291
|
+
callType = CallType.AUDIO;
|
|
7292
|
+
color = "#FF4842";
|
|
7293
|
+
break;
|
|
7294
|
+
case 10:
|
|
7295
|
+
text = isMe ? "Recipient was busy" : "You missed video call";
|
|
7296
|
+
callType = CallType.VIDEO;
|
|
7297
|
+
color = "#FF4842";
|
|
7298
|
+
break;
|
|
7232
7299
|
default:
|
|
7233
|
-
|
|
7300
|
+
text = trimmed;
|
|
7301
|
+
callType = "";
|
|
7302
|
+
color = "";
|
|
7234
7303
|
}
|
|
7304
|
+
return { text, duration: formatDuration(duration), callType, color };
|
|
7235
7305
|
}
|
|
7236
7306
|
export {
|
|
7237
7307
|
CallAction,
|
|
7238
7308
|
CallStatus,
|
|
7309
|
+
CallType,
|
|
7239
7310
|
Channel,
|
|
7240
7311
|
ChannelState,
|
|
7241
7312
|
ClientState,
|