mezon-js 2.10.37 → 2.10.38

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.
@@ -714,12 +714,14 @@ function b64DecodeUnicode(str) {
714
714
  return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
715
715
  }).join(""));
716
716
  }
717
- function safeJSONParse(jsonString) {
717
+ function safeJSONParse(jsonStr) {
718
718
  try {
719
- const parsedData = JSON.parse(jsonString);
719
+ const parsedData = JSON.parse(jsonStr);
720
720
  return parsedData;
721
721
  } catch (error) {
722
- console.error("Error parsing JSON:", jsonString, error);
722
+ if (jsonStr !== "") {
723
+ console.error("Error parsing JSON:", jsonStr, error);
724
+ }
723
725
  return null;
724
726
  }
725
727
  }
@@ -7995,31 +7997,6 @@ var _DefaultSocket = class _DefaultSocket {
7995
7997
  return response.webrtc_signaling_fwd;
7996
7998
  });
7997
7999
  }
7998
- joinPTTChannel(clanId, channelId, dataType, jsonData) {
7999
- return __async(this, null, function* () {
8000
- const response = yield this.send({
8001
- join_ptt_channel: {
8002
- clan_id: clanId,
8003
- channel_id: channelId,
8004
- data_type: dataType,
8005
- json_data: jsonData
8006
- }
8007
- });
8008
- return response.join_ptt_channel;
8009
- });
8010
- }
8011
- talkPTTChannel(clanId, channelId, isTalk) {
8012
- return __async(this, null, function* () {
8013
- const response = yield this.send({
8014
- talk_ptt_channel: {
8015
- clan_id: clanId,
8016
- channel_id: channelId,
8017
- is_talk: isTalk
8018
- }
8019
- });
8020
- return response.talk_ptt_channel;
8021
- });
8022
- }
8023
8000
  pingPong() {
8024
8001
  return __async(this, null, function* () {
8025
8002
  if (!this.adapter.isOpen()) {
@@ -680,12 +680,14 @@ function b64DecodeUnicode(str) {
680
680
  return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
681
681
  }).join(""));
682
682
  }
683
- function safeJSONParse(jsonString) {
683
+ function safeJSONParse(jsonStr) {
684
684
  try {
685
- const parsedData = JSON.parse(jsonString);
685
+ const parsedData = JSON.parse(jsonStr);
686
686
  return parsedData;
687
687
  } catch (error) {
688
- console.error("Error parsing JSON:", jsonString, error);
688
+ if (jsonStr !== "") {
689
+ console.error("Error parsing JSON:", jsonStr, error);
690
+ }
689
691
  return null;
690
692
  }
691
693
  }
@@ -7961,31 +7963,6 @@ var _DefaultSocket = class _DefaultSocket {
7961
7963
  return response.webrtc_signaling_fwd;
7962
7964
  });
7963
7965
  }
7964
- joinPTTChannel(clanId, channelId, dataType, jsonData) {
7965
- return __async(this, null, function* () {
7966
- const response = yield this.send({
7967
- join_ptt_channel: {
7968
- clan_id: clanId,
7969
- channel_id: channelId,
7970
- data_type: dataType,
7971
- json_data: jsonData
7972
- }
7973
- });
7974
- return response.join_ptt_channel;
7975
- });
7976
- }
7977
- talkPTTChannel(clanId, channelId, isTalk) {
7978
- return __async(this, null, function* () {
7979
- const response = yield this.send({
7980
- talk_ptt_channel: {
7981
- clan_id: clanId,
7982
- channel_id: channelId,
7983
- is_talk: isTalk
7984
- }
7985
- });
7986
- return response.talk_ptt_channel;
7987
- });
7988
- }
7989
7966
  pingPong() {
7990
7967
  return __async(this, null, function* () {
7991
7968
  if (!this.adapter.isOpen()) {
package/dist/socket.d.ts CHANGED
@@ -722,8 +722,6 @@ export interface Socket {
722
722
  writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
723
723
  /** send voice leaved */
724
724
  writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
725
- joinPTTChannel(clanId: string, channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
726
- talkPTTChannel(clanId: string, channelId: string, isTalk: boolean): Promise<TalkPTTChannel>;
727
725
  setHeartbeatTimeoutMs(ms: number): void;
728
726
  getHeartbeatTimeoutMs(): number;
729
727
  checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
@@ -890,7 +888,7 @@ export declare class DefaultSocket implements Socket {
890
888
  onjoinpttchannel(join_ptt_channel: JoinPTTChannel): void;
891
889
  ontalkpttchannel(talk_ptt_channel: TalkPTTChannel): void;
892
890
  onsdtopicevent(sd_topic_event: SdTopicEvent): void;
893
- send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping | WebrtcSignalingFwd | IncomingCallPush | MessageButtonClicked | DropdownBoxSelected | JoinPTTChannel | TalkPTTChannel, sendTimeout?: number): Promise<any>;
891
+ send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping | WebrtcSignalingFwd | IncomingCallPush | MessageButtonClicked | DropdownBoxSelected, sendTimeout?: number): Promise<any>;
894
892
  followUsers(userIds: string[]): Promise<Status>;
895
893
  joinClanChat(clan_id: string): Promise<ClanJoin>;
896
894
  follower(): Promise<void>;
@@ -914,8 +912,6 @@ export declare class DefaultSocket implements Socket {
914
912
  makeCallPush(receiver_id: string, json_data: string, channel_id: string, caller_id: string): Promise<IncomingCallPush>;
915
913
  handleDropdownBoxSelected(message_id: string, channel_id: string, selectbox_id: string, sender_id: string, user_id: string, value: Array<string>): Promise<DropdownBoxSelected>;
916
914
  handleMessageButtonClick(message_id: string, channel_id: string, button_id: string, sender_id: string, user_id: string, extra_data: string): Promise<MessageButtonClicked>;
917
- joinPTTChannel(clanId: string, channelId: string, dataType: number, jsonData: string): Promise<JoinPTTChannel>;
918
- talkPTTChannel(clanId: string, channelId: string, isTalk: boolean): Promise<TalkPTTChannel>;
919
915
  private pingPong;
920
916
  }
921
917
  export {};
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export declare function buildFetchOptions(method: string, options: any, bodyJson: string): any;
2
2
  export declare function b64EncodeUnicode(str: string): string;
3
3
  export declare function b64DecodeUnicode(str: string): string;
4
- export declare function safeJSONParse(jsonString: string): any;
4
+ export declare function safeJSONParse(jsonStr: string): any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.10.37",
4
+ "version": "2.10.38",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
package/socket.ts CHANGED
@@ -1102,19 +1102,6 @@ export interface Socket {
1102
1102
  voiceUserId: string
1103
1103
  ): Promise<VoiceLeavedEvent>;
1104
1104
 
1105
- joinPTTChannel(
1106
- clanId: string,
1107
- channelId: string,
1108
- dataType: number,
1109
- jsonData: string
1110
- ): Promise<JoinPTTChannel>;
1111
-
1112
- talkPTTChannel(
1113
- clanId: string,
1114
- channelId: string,
1115
- isTalk: boolean
1116
- ): Promise<TalkPTTChannel>;
1117
-
1118
1105
  /* Set the heartbeat timeout used by the socket to detect if it has lost connectivity to the server. */
1119
1106
  setHeartbeatTimeoutMs(ms: number): void;
1120
1107
 
@@ -1987,9 +1974,7 @@ export class DefaultSocket implements Socket {
1987
1974
  | WebrtcSignalingFwd
1988
1975
  | IncomingCallPush
1989
1976
  | MessageButtonClicked
1990
- | DropdownBoxSelected
1991
- | JoinPTTChannel
1992
- | TalkPTTChannel,
1977
+ | DropdownBoxSelected,
1993
1978
  sendTimeout = DefaultSocket.DefaultSendTimeoutMs
1994
1979
  ): Promise<any> {
1995
1980
  const untypedMessage = message as any;
@@ -2415,38 +2400,6 @@ export class DefaultSocket implements Socket {
2415
2400
  return response.webrtc_signaling_fwd;
2416
2401
  }
2417
2402
 
2418
- async joinPTTChannel(
2419
- clanId: string,
2420
- channelId: string,
2421
- dataType: number,
2422
- jsonData: string
2423
- ): Promise<JoinPTTChannel> {
2424
- const response = await this.send({
2425
- join_ptt_channel: {
2426
- clan_id: clanId,
2427
- channel_id: channelId,
2428
- data_type: dataType,
2429
- json_data: jsonData,
2430
- },
2431
- });
2432
- return response.join_ptt_channel;
2433
- }
2434
-
2435
- async talkPTTChannel(
2436
- clanId: string,
2437
- channelId: string,
2438
- isTalk: boolean
2439
- ): Promise<TalkPTTChannel> {
2440
- const response = await this.send({
2441
- talk_ptt_channel: {
2442
- clan_id: clanId,
2443
- channel_id: channelId,
2444
- is_talk: isTalk,
2445
- },
2446
- });
2447
- return response.talk_ptt_channel;
2448
- }
2449
-
2450
2403
  private async pingPong(): Promise<void> {
2451
2404
  if (!this.adapter.isOpen()) {
2452
2405
  return;
package/utils.ts CHANGED
@@ -48,13 +48,14 @@ export function b64DecodeUnicode(str: string) {
48
48
  }).join(''));
49
49
  }
50
50
 
51
- export function safeJSONParse(jsonString: string) {
51
+ export function safeJSONParse(jsonStr: string) {
52
52
  try {
53
- const parsedData = JSON.parse(jsonString);
54
-
53
+ const parsedData = JSON.parse(jsonStr);
55
54
  return parsedData;
56
55
  } catch (error) {
57
- console.error('Error parsing JSON:', jsonString, error);
56
+ if (jsonStr !== "") {
57
+ console.error('Error parsing JSON:', jsonStr, error);
58
+ }
58
59
  return null; // Handle the error gracefully or throw an exception if necessary
59
60
  }
60
61
  }