@ermis-network/ermis-chat-sdk 1.0.4 → 1.0.6

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/dist/index.cjs CHANGED
@@ -996,10 +996,9 @@ var Channel = class {
996
996
  };
997
997
  this.state.addMessageSorted(optimisticMessage);
998
998
  try {
999
- return await this.getClient().post(
1000
- this._channelURL() + "/message",
1001
- { message: { ...message } }
1002
- );
999
+ return await this.getClient().post(this._channelURL() + "/message", {
1000
+ message: { ...message }
1001
+ });
1003
1002
  } catch (error) {
1004
1003
  const isOfflineError = !error.response || error.code === "ERR_NETWORK" || error.isWSFailure || !this.getClient().wsConnection?.isHealthy;
1005
1004
  const statusToSet = isOfflineError ? "failed_offline" : "error";
@@ -1024,10 +1023,9 @@ var Channel = class {
1024
1023
  messagePayload.show_in_channel = stateMsg.show_in_channel;
1025
1024
  }
1026
1025
  try {
1027
- return await this.getClient().post(
1028
- this._channelURL() + "/message",
1029
- { message: messagePayload }
1030
- );
1026
+ return await this.getClient().post(this._channelURL() + "/message", {
1027
+ message: messagePayload
1028
+ });
1031
1029
  } catch (error) {
1032
1030
  const isOfflineError = !error.response || error.code === "ERR_NETWORK" || error.isWSFailure || !this.getClient().wsConnection?.isHealthy;
1033
1031
  this.state.updateMessageStatus(messageId, isOfflineError ? "failed_offline" : "error");
@@ -1094,9 +1092,7 @@ var Channel = class {
1094
1092
  return file;
1095
1093
  });
1096
1094
  const uploadResults = await Promise.allSettled(
1097
- processedFiles.map(
1098
- (file) => this.sendFile(file, file.name, file.type)
1099
- )
1095
+ processedFiles.map((file) => this.sendFile(file, file.name, file.type))
1100
1096
  );
1101
1097
  const thumbUrls = /* @__PURE__ */ new Map();
1102
1098
  const thumbPromises = [];
@@ -1108,11 +1104,7 @@ var Channel = class {
1108
1104
  try {
1109
1105
  const thumbBlob = await this.getThumbBlobVideo(files[i]);
1110
1106
  if (thumbBlob) {
1111
- const thumbFile = new File(
1112
- [thumbBlob],
1113
- `thumb_${processedFiles[i].name}.jpg`,
1114
- { type: "image/jpeg" }
1115
- );
1107
+ const thumbFile = new File([thumbBlob], `thumb_${processedFiles[i].name}.jpg`, { type: "image/jpeg" });
1116
1108
  const thumbResp = await this.sendFile(thumbFile, thumbFile.name, "image/jpeg");
1117
1109
  thumbUrls.set(i, thumbResp.file);
1118
1110
  }
@@ -1130,9 +1122,7 @@ var Channel = class {
1130
1122
  const uploadedUrl = result.value.file;
1131
1123
  const thumbUrl = thumbUrls.get(i);
1132
1124
  const voiceMeta = options?.voiceMetadata?.get(i);
1133
- attachments.push(
1134
- buildAttachmentPayload(processedFiles[i], uploadedUrl, thumbUrl, voiceMeta)
1135
- );
1125
+ attachments.push(buildAttachmentPayload(processedFiles[i], uploadedUrl, thumbUrl, voiceMeta));
1136
1126
  } else {
1137
1127
  failedFiles.push({
1138
1128
  file: files[i],
@@ -1480,7 +1470,7 @@ var Channel = class {
1480
1470
  if (this.id) {
1481
1471
  queryURL += `/${this.id}`;
1482
1472
  } else {
1483
- if (this.type === "team") {
1473
+ if (this.type === "team" || this.type === "meeting") {
1484
1474
  const uuid = randomId();
1485
1475
  this.id = `${project_id}:${uuid}`;
1486
1476
  queryURL += `/${this.id}`;
@@ -3771,6 +3761,47 @@ var ErmisChat = class _ErmisChat {
3771
3761
  this.activeChannels[channel.cid] = channel;
3772
3762
  return channel;
3773
3763
  };
3764
+ /**
3765
+ * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
3766
+ * Consumers can customize the `name` field. `members` and `public` fields are constrained.
3767
+ *
3768
+ * @param name - The custom name for the meeting channel.
3769
+ * @returns A promise that resolves to the created `Channel` object.
3770
+ */
3771
+ async createMeetingChannel(name) {
3772
+ if (!this.userID) {
3773
+ throw Error("Call connectUser before creating a channel");
3774
+ }
3775
+ const payload = {
3776
+ name: name || `Meeting Public - ${(/* @__PURE__ */ new Date()).toISOString()}`,
3777
+ members: [this.userID],
3778
+ public: true
3779
+ };
3780
+ const meetingChannel = this.channel("meeting", payload);
3781
+ await meetingChannel.create();
3782
+ return meetingChannel;
3783
+ }
3784
+ /**
3785
+ * Joins a `meeting` channel.
3786
+ * It queries/watches the channel to see if caller is already a member.
3787
+ * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
3788
+ *
3789
+ * @param channelId - The ID of the meeting channel to join.
3790
+ * @returns A promise that resolves to the joined `Channel` object.
3791
+ */
3792
+ async joinMeetingChannel(channelId) {
3793
+ if (!this.userID) {
3794
+ throw Error("Call connectUser before joining a channel");
3795
+ }
3796
+ const meetingChannel = this.channel("meeting", channelId);
3797
+ await meetingChannel.watch();
3798
+ const isMember = meetingChannel.state.members && meetingChannel.state.members[this.userID];
3799
+ if (!isMember) {
3800
+ await meetingChannel.acceptInvite("join");
3801
+ await meetingChannel.watch();
3802
+ }
3803
+ return meetingChannel;
3804
+ }
3774
3805
  _normalizeExpiration(timeoutOrExpirationDate) {
3775
3806
  let pinExpires = null;
3776
3807
  if (typeof timeoutOrExpirationDate === "number") {
@@ -3785,7 +3816,7 @@ var ErmisChat = class _ErmisChat {
3785
3816
  return pinExpires;
3786
3817
  }
3787
3818
  getUserAgent() {
3788
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.4"}`;
3819
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
3789
3820
  }
3790
3821
  setUserAgent(userAgent) {
3791
3822
  this.userAgent = userAgent;
@@ -3901,7 +3932,6 @@ var EVENT_MAP = {
3901
3932
  };
3902
3933
 
3903
3934
  // src/wasm/ermis_call_node_wasm.js
3904
- var import_meta = {};
3905
3935
  var wasm;
3906
3936
  var cachedUint8ArrayMemory0 = null;
3907
3937
  function getUint8ArrayMemory0() {
@@ -5309,7 +5339,7 @@ async function __wbg_init(module_or_path) {
5309
5339
  }
5310
5340
  }
5311
5341
  if (typeof module_or_path === "undefined") {
5312
- module_or_path = new URL("ermis_call_node_wasm_bg.wasm", import_meta.url);
5342
+ module_or_path = "/ermis_call_node_wasm_bg.wasm";
5313
5343
  }
5314
5344
  const imports = __wbg_get_imports();
5315
5345
  if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
@@ -7145,7 +7175,7 @@ var ErmisAuthProvider = class {
7145
7175
  return data;
7146
7176
  }
7147
7177
  getUserAgent() {
7148
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.4"}`;
7178
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
7149
7179
  }
7150
7180
  setUserAgent(userAgent) {
7151
7181
  this.userAgent = userAgent;