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