stream-chat 4.4.3 → 4.5.0-beta.0
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/README.md +4 -13
- package/dist/browser.es.js +1571 -1071
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1571 -1071
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1571 -1071
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1571 -1071
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +18 -39
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +42 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +6 -6
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +94 -80
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +12 -2
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +277 -674
- package/src/client_state.ts +2 -2
- package/src/connection.ts +143 -394
- package/src/connection_fallback.ts +205 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +15 -23
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +268 -504
- package/src/utils.ts +39 -19
- package/CHANGELOG.md +0 -844
package/src/utils.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import {
|
|
3
|
-
AscDesc,
|
|
4
|
-
LiteralStringForUnion,
|
|
5
|
-
OwnUserBase,
|
|
6
|
-
OwnUserResponse,
|
|
7
|
-
UnknownType,
|
|
8
|
-
UserResponse,
|
|
9
|
-
} from './types';
|
|
2
|
+
import { AscDesc, LiteralStringForUnion, OwnUserBase, OwnUserResponse, UR, UserResponse } from './types';
|
|
10
3
|
|
|
11
4
|
/**
|
|
12
5
|
* logChatPromiseExecution - utility function for logging the execution of a promise..
|
|
@@ -42,8 +35,7 @@ function isReadableStream(obj: unknown): obj is NodeJS.ReadStream {
|
|
|
42
35
|
return (
|
|
43
36
|
obj !== null &&
|
|
44
37
|
typeof obj === 'object' &&
|
|
45
|
-
((obj as NodeJS.ReadStream).readable ||
|
|
46
|
-
typeof (obj as NodeJS.ReadStream)._read === 'function')
|
|
38
|
+
((obj as NodeJS.ReadStream).readable || typeof (obj as NodeJS.ReadStream)._read === 'function')
|
|
47
39
|
);
|
|
48
40
|
}
|
|
49
41
|
|
|
@@ -63,16 +55,13 @@ function isFileWebAPI(uri: unknown): uri is File {
|
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
export function isOwnUser<
|
|
66
|
-
ChannelType extends
|
|
58
|
+
ChannelType extends UR = UR,
|
|
67
59
|
CommandType extends string = LiteralStringForUnion,
|
|
68
|
-
UserType extends
|
|
60
|
+
UserType extends UR = UR
|
|
69
61
|
>(
|
|
70
62
|
user?: OwnUserResponse<ChannelType, CommandType, UserType> | UserResponse<UserType>,
|
|
71
63
|
): user is OwnUserResponse<ChannelType, CommandType, UserType> {
|
|
72
|
-
return (
|
|
73
|
-
(user as OwnUserResponse<ChannelType, CommandType, UserType>)?.total_unread_count !==
|
|
74
|
-
undefined
|
|
75
|
-
);
|
|
64
|
+
return (user as OwnUserResponse<ChannelType, CommandType, UserType>)?.total_unread_count !== undefined;
|
|
76
65
|
}
|
|
77
66
|
|
|
78
67
|
export function isOwnUserBaseProperty(property: string) {
|
|
@@ -113,9 +102,7 @@ export function addFileToFormData(
|
|
|
113
102
|
|
|
114
103
|
return data;
|
|
115
104
|
}
|
|
116
|
-
export function normalizeQuerySort<T extends Record<string, AscDesc | undefined>>(
|
|
117
|
-
sort: T | T[],
|
|
118
|
-
) {
|
|
105
|
+
export function normalizeQuerySort<T extends Record<string, AscDesc | undefined>>(sort: T | T[]) {
|
|
119
106
|
const sortFields: Array<{ direction: AscDesc; field: keyof T }> = [];
|
|
120
107
|
const sortArr = Array.isArray(sort) ? sort : [sort];
|
|
121
108
|
for (const item of sortArr) {
|
|
@@ -216,3 +203,36 @@ export function convertErrorToJson(err: Error) {
|
|
|
216
203
|
|
|
217
204
|
return jsonObj;
|
|
218
205
|
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* isOnline safely return the navigator.online value
|
|
209
|
+
* if navigator is not in global object, it always return true
|
|
210
|
+
*/
|
|
211
|
+
export function isOnline() {
|
|
212
|
+
const nav =
|
|
213
|
+
typeof navigator !== 'undefined'
|
|
214
|
+
? navigator
|
|
215
|
+
: typeof window !== 'undefined' && window.navigator
|
|
216
|
+
? window.navigator
|
|
217
|
+
: undefined;
|
|
218
|
+
|
|
219
|
+
if (!nav) return true;
|
|
220
|
+
return nav.onLine;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
225
|
+
*/
|
|
226
|
+
export function addConnectionEventListeners(cb: (e: Event) => void) {
|
|
227
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
228
|
+
window.addEventListener('offline', cb);
|
|
229
|
+
window.addEventListener('online', cb);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function removeConnectionEventListeners(cb: (e: Event) => void) {
|
|
234
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
235
|
+
window.removeEventListener('offline', cb);
|
|
236
|
+
window.removeEventListener('online', cb);
|
|
237
|
+
}
|
|
238
|
+
}
|