@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.d.mts CHANGED
@@ -1262,6 +1262,23 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1262
1262
  channel(type: string, id: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
1263
1263
  getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1264
1264
  getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1265
+ /**
1266
+ * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
1267
+ * Consumers can customize the `name` field. `members` and `public` fields are constrained.
1268
+ *
1269
+ * @param name - The custom name for the meeting channel.
1270
+ * @returns A promise that resolves to the created `Channel` object.
1271
+ */
1272
+ createMeetingChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1273
+ /**
1274
+ * Joins a `meeting` channel.
1275
+ * It queries/watches the channel to see if caller is already a member.
1276
+ * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
1277
+ *
1278
+ * @param channelId - The ID of the meeting channel to join.
1279
+ * @returns A promise that resolves to the joined `Channel` object.
1280
+ */
1281
+ joinMeetingChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1265
1282
  _normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
1266
1283
  getUserAgent(): string;
1267
1284
  setUserAgent(userAgent: string): void;
package/dist/index.d.ts CHANGED
@@ -1262,6 +1262,23 @@ declare class ErmisChat<ErmisChatGenerics extends ExtendableGenerics = DefaultGe
1262
1262
  channel(type: string, id: string, custom?: ChannelData<ErmisChatGenerics>): Channel<ErmisChatGenerics>;
1263
1263
  getChannelById: (channelType: string, channelID: string | undefined, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1264
1264
  getChannel: (channelType: string, custom: ChannelData<ErmisChatGenerics>) => Channel<ErmisChatGenerics>;
1265
+ /**
1266
+ * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
1267
+ * Consumers can customize the `name` field. `members` and `public` fields are constrained.
1268
+ *
1269
+ * @param name - The custom name for the meeting channel.
1270
+ * @returns A promise that resolves to the created `Channel` object.
1271
+ */
1272
+ createMeetingChannel(name?: string): Promise<Channel<ErmisChatGenerics>>;
1273
+ /**
1274
+ * Joins a `meeting` channel.
1275
+ * It queries/watches the channel to see if caller is already a member.
1276
+ * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
1277
+ *
1278
+ * @param channelId - The ID of the meeting channel to join.
1279
+ * @returns A promise that resolves to the joined `Channel` object.
1280
+ */
1281
+ joinMeetingChannel(channelId: string): Promise<Channel<ErmisChatGenerics>>;
1265
1282
  _normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
1266
1283
  getUserAgent(): string;
1267
1284
  setUserAgent(userAgent: string): void;
package/dist/index.mjs CHANGED
@@ -936,10 +936,9 @@ var Channel = class {
936
936
  };
937
937
  this.state.addMessageSorted(optimisticMessage);
938
938
  try {
939
- return await this.getClient().post(
940
- this._channelURL() + "/message",
941
- { message: { ...message } }
942
- );
939
+ return await this.getClient().post(this._channelURL() + "/message", {
940
+ message: { ...message }
941
+ });
943
942
  } catch (error) {
944
943
  const isOfflineError = !error.response || error.code === "ERR_NETWORK" || error.isWSFailure || !this.getClient().wsConnection?.isHealthy;
945
944
  const statusToSet = isOfflineError ? "failed_offline" : "error";
@@ -964,10 +963,9 @@ var Channel = class {
964
963
  messagePayload.show_in_channel = stateMsg.show_in_channel;
965
964
  }
966
965
  try {
967
- return await this.getClient().post(
968
- this._channelURL() + "/message",
969
- { message: messagePayload }
970
- );
966
+ return await this.getClient().post(this._channelURL() + "/message", {
967
+ message: messagePayload
968
+ });
971
969
  } catch (error) {
972
970
  const isOfflineError = !error.response || error.code === "ERR_NETWORK" || error.isWSFailure || !this.getClient().wsConnection?.isHealthy;
973
971
  this.state.updateMessageStatus(messageId, isOfflineError ? "failed_offline" : "error");
@@ -1034,9 +1032,7 @@ var Channel = class {
1034
1032
  return file;
1035
1033
  });
1036
1034
  const uploadResults = await Promise.allSettled(
1037
- processedFiles.map(
1038
- (file) => this.sendFile(file, file.name, file.type)
1039
- )
1035
+ processedFiles.map((file) => this.sendFile(file, file.name, file.type))
1040
1036
  );
1041
1037
  const thumbUrls = /* @__PURE__ */ new Map();
1042
1038
  const thumbPromises = [];
@@ -1048,11 +1044,7 @@ var Channel = class {
1048
1044
  try {
1049
1045
  const thumbBlob = await this.getThumbBlobVideo(files[i]);
1050
1046
  if (thumbBlob) {
1051
- const thumbFile = new File(
1052
- [thumbBlob],
1053
- `thumb_${processedFiles[i].name}.jpg`,
1054
- { type: "image/jpeg" }
1055
- );
1047
+ const thumbFile = new File([thumbBlob], `thumb_${processedFiles[i].name}.jpg`, { type: "image/jpeg" });
1056
1048
  const thumbResp = await this.sendFile(thumbFile, thumbFile.name, "image/jpeg");
1057
1049
  thumbUrls.set(i, thumbResp.file);
1058
1050
  }
@@ -1070,9 +1062,7 @@ var Channel = class {
1070
1062
  const uploadedUrl = result.value.file;
1071
1063
  const thumbUrl = thumbUrls.get(i);
1072
1064
  const voiceMeta = options?.voiceMetadata?.get(i);
1073
- attachments.push(
1074
- buildAttachmentPayload(processedFiles[i], uploadedUrl, thumbUrl, voiceMeta)
1075
- );
1065
+ attachments.push(buildAttachmentPayload(processedFiles[i], uploadedUrl, thumbUrl, voiceMeta));
1076
1066
  } else {
1077
1067
  failedFiles.push({
1078
1068
  file: files[i],
@@ -1420,7 +1410,7 @@ var Channel = class {
1420
1410
  if (this.id) {
1421
1411
  queryURL += `/${this.id}`;
1422
1412
  } else {
1423
- if (this.type === "team") {
1413
+ if (this.type === "team" || this.type === "meeting") {
1424
1414
  const uuid = randomId();
1425
1415
  this.id = `${project_id}:${uuid}`;
1426
1416
  queryURL += `/${this.id}`;
@@ -3711,6 +3701,47 @@ var ErmisChat = class _ErmisChat {
3711
3701
  this.activeChannels[channel.cid] = channel;
3712
3702
  return channel;
3713
3703
  };
3704
+ /**
3705
+ * Creates an interactive `meeting` Channel locally, and immediately creates it on the server.
3706
+ * Consumers can customize the `name` field. `members` and `public` fields are constrained.
3707
+ *
3708
+ * @param name - The custom name for the meeting channel.
3709
+ * @returns A promise that resolves to the created `Channel` object.
3710
+ */
3711
+ async createMeetingChannel(name) {
3712
+ if (!this.userID) {
3713
+ throw Error("Call connectUser before creating a channel");
3714
+ }
3715
+ const payload = {
3716
+ name: name || `Meeting Public - ${(/* @__PURE__ */ new Date()).toISOString()}`,
3717
+ members: [this.userID],
3718
+ public: true
3719
+ };
3720
+ const meetingChannel = this.channel("meeting", payload);
3721
+ await meetingChannel.create();
3722
+ return meetingChannel;
3723
+ }
3724
+ /**
3725
+ * Joins a `meeting` channel.
3726
+ * It queries/watches the channel to see if caller is already a member.
3727
+ * If not, it accepts the invite to join the channel, then watches it again to reflect changes.
3728
+ *
3729
+ * @param channelId - The ID of the meeting channel to join.
3730
+ * @returns A promise that resolves to the joined `Channel` object.
3731
+ */
3732
+ async joinMeetingChannel(channelId) {
3733
+ if (!this.userID) {
3734
+ throw Error("Call connectUser before joining a channel");
3735
+ }
3736
+ const meetingChannel = this.channel("meeting", channelId);
3737
+ await meetingChannel.watch();
3738
+ const isMember = meetingChannel.state.members && meetingChannel.state.members[this.userID];
3739
+ if (!isMember) {
3740
+ await meetingChannel.acceptInvite("join");
3741
+ await meetingChannel.watch();
3742
+ }
3743
+ return meetingChannel;
3744
+ }
3714
3745
  _normalizeExpiration(timeoutOrExpirationDate) {
3715
3746
  let pinExpires = null;
3716
3747
  if (typeof timeoutOrExpirationDate === "number") {
@@ -3725,7 +3756,7 @@ var ErmisChat = class _ErmisChat {
3725
3756
  return pinExpires;
3726
3757
  }
3727
3758
  getUserAgent() {
3728
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.4"}`;
3759
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
3729
3760
  }
3730
3761
  setUserAgent(userAgent) {
3731
3762
  this.userAgent = userAgent;
@@ -5248,7 +5279,7 @@ async function __wbg_init(module_or_path) {
5248
5279
  }
5249
5280
  }
5250
5281
  if (typeof module_or_path === "undefined") {
5251
- module_or_path = new URL("ermis_call_node_wasm_bg.wasm", import.meta.url);
5282
+ module_or_path = "/ermis_call_node_wasm_bg.wasm";
5252
5283
  }
5253
5284
  const imports = __wbg_get_imports();
5254
5285
  if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
@@ -7084,7 +7115,7 @@ var ErmisAuthProvider = class {
7084
7115
  return data;
7085
7116
  }
7086
7117
  getUserAgent() {
7087
- return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.4"}`;
7118
+ return this.userAgent || `ermis-chat-sdk-javascript-client-${this.node ? "node" : "browser"}-${"1.0.6"}`;
7088
7119
  }
7089
7120
  setUserAgent(userAgent) {
7090
7121
  this.userAgent = userAgent;