@ermis-network/ermis-chat-sdk 1.0.8 → 2.0.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/bin/init-call.js +9 -0
- package/dist/index.browser.cjs +778 -1628
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.full-bundle.min.js +16 -18
- package/dist/index.browser.full-bundle.min.js.map +1 -1
- package/dist/index.browser.mjs +780 -1630
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.cjs +778 -1628
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +173 -40
- package/dist/index.d.ts +173 -40
- package/dist/index.mjs +780 -1630
- package/dist/index.mjs.map +1 -1
- package/dist/wasm_worker.worker.mjs +1596 -0
- package/dist/wasm_worker.worker.mjs.map +1 -0
- package/package.json +2 -2
- package/public/ermis_call_node_wasm_bg.wasm +0 -0
- package/src/channel.ts +117 -44
- package/src/channel_state.ts +6 -1
- package/src/client.ts +198 -56
- package/src/ermis_call_node.ts +123 -55
- package/src/index.ts +2 -1
- package/src/media_stream_receiver.ts +103 -35
- package/src/media_stream_sender.ts +72 -7
- package/src/signal_message.ts +48 -23
- package/src/system_message.ts +169 -27
- package/src/types.ts +13 -0
- package/src/utils.ts +22 -3
- package/src/wasm/ermis_call_node_wasm.d.ts +80 -78
- package/src/wasm/ermis_call_node_wasm.js +1427 -1357
- package/src/wasm_worker.ts +219 -0
- package/src/wasm_worker_proxy.ts +244 -0
package/src/utils.ts
CHANGED
|
@@ -265,12 +265,28 @@ export function addToMessageList<ErmisChatGenerics extends ExtendableGenerics =
|
|
|
265
265
|
// message already exists and not filtered due to timestampChanged, update and return
|
|
266
266
|
if (!timestampChanged && message.id) {
|
|
267
267
|
if (messageArr[left] && message.id === messageArr[left].id) {
|
|
268
|
-
|
|
268
|
+
// Merge properties safely: do not overwrite existing data with undefined
|
|
269
|
+
const existingMessage = messageArr[left];
|
|
270
|
+
const mergedMessage = { ...existingMessage };
|
|
271
|
+
(Object.keys(message) as Array<keyof typeof message>).forEach((key) => {
|
|
272
|
+
if (message[key] !== undefined) {
|
|
273
|
+
(mergedMessage as any)[key] = message[key];
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
messageArr[left] = mergedMessage;
|
|
269
277
|
return [...messageArr];
|
|
270
278
|
}
|
|
271
279
|
|
|
272
280
|
if (messageArr[left - 1] && message.id === messageArr[left - 1].id) {
|
|
273
|
-
|
|
281
|
+
// Merge properties safely: do not overwrite existing data with undefined
|
|
282
|
+
const existingMessage = messageArr[left - 1];
|
|
283
|
+
const mergedMessage = { ...existingMessage };
|
|
284
|
+
(Object.keys(message) as Array<keyof typeof message>).forEach((key) => {
|
|
285
|
+
if (message[key] !== undefined) {
|
|
286
|
+
(mergedMessage as any)[key] = message[key];
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
messageArr[left - 1] = mergedMessage;
|
|
274
290
|
return [...messageArr];
|
|
275
291
|
}
|
|
276
292
|
}
|
|
@@ -421,7 +437,7 @@ export const createPacketWithHeader = (
|
|
|
421
437
|
const jsonString = JSON.stringify(configMsg);
|
|
422
438
|
const encoder = new TextEncoder();
|
|
423
439
|
payload = encoder.encode(jsonString);
|
|
424
|
-
} else if (type === 'connected') {
|
|
440
|
+
} else if (type === 'connected' || type === 'healthCall') {
|
|
425
441
|
HEADER_SIZE = 1;
|
|
426
442
|
payload = new Uint8Array(0);
|
|
427
443
|
} else {
|
|
@@ -456,6 +472,9 @@ export const createPacketWithHeader = (
|
|
|
456
472
|
case 'transciverState':
|
|
457
473
|
typeCode = 7;
|
|
458
474
|
break;
|
|
475
|
+
case 'healthCall':
|
|
476
|
+
typeCode = 11;
|
|
477
|
+
break;
|
|
459
478
|
}
|
|
460
479
|
|
|
461
480
|
// Byte 0: Type code
|
|
@@ -5,58 +5,58 @@
|
|
|
5
5
|
*
|
|
6
6
|
* *This API requires the following crate features to be activated: `ReadableStreamType`*
|
|
7
7
|
*/
|
|
8
|
-
type ReadableStreamType =
|
|
8
|
+
type ReadableStreamType = 'bytes';
|
|
9
9
|
export class ConnectionStats {
|
|
10
10
|
free(): void;
|
|
11
11
|
[Symbol.dispose](): void;
|
|
12
12
|
constructor(connection_type?: string | null, rtt_ms?: number | null, packet_loss?: number | null);
|
|
13
|
+
get connection_type(): string | undefined;
|
|
14
|
+
set connection_type(value: string | null | undefined);
|
|
13
15
|
get rtt_ms(): number | undefined;
|
|
14
16
|
set rtt_ms(value: number | null | undefined);
|
|
15
17
|
get packet_loss(): number | undefined;
|
|
16
18
|
set packet_loss(value: number | null | undefined);
|
|
17
|
-
get connection_type(): string | undefined;
|
|
18
|
-
set connection_type(value: string | null | undefined);
|
|
19
19
|
}
|
|
20
20
|
export class ErmisCall {
|
|
21
21
|
free(): void;
|
|
22
22
|
[Symbol.dispose](): void;
|
|
23
|
-
constructor();
|
|
24
|
-
spawn(relay_urls: any, secret_key?: Uint8Array | null): Promise<void>;
|
|
25
|
-
getLocalEndpointAddr(): Promise<string>;
|
|
26
|
-
connect(addr: string): Promise<void>;
|
|
27
|
-
closeEndpoint(): Promise<void>;
|
|
28
|
-
closeConnection(): void;
|
|
29
|
-
acceptConnection(): Promise<void>;
|
|
30
|
-
sendControlFrame(data: Uint8Array): void;
|
|
31
|
-
sendAudioFrame(data: Uint8Array): void;
|
|
32
|
-
sendFrame(data: Uint8Array): void;
|
|
33
|
-
notifyNewGop(): void;
|
|
34
|
-
recv(): Uint8Array;
|
|
35
23
|
asyncRecv(): Promise<Uint8Array>;
|
|
24
|
+
sendFrame(data: Uint8Array): void;
|
|
36
25
|
beginWithGop(data: Uint8Array): void;
|
|
26
|
+
closeEndpoint(): Promise<void>;
|
|
27
|
+
networkChange(): void;
|
|
28
|
+
notifyNewGop(): void;
|
|
37
29
|
connectionType(): string | undefined;
|
|
38
30
|
roundTripTime(): number | undefined;
|
|
31
|
+
closeConnection(): void;
|
|
32
|
+
sendAudioFrame(data: Uint8Array): void;
|
|
33
|
+
acceptConnection(): Promise<void>;
|
|
34
|
+
sendControlFrame(data: Uint8Array): void;
|
|
39
35
|
currentPacketLoss(): number | undefined;
|
|
40
|
-
|
|
36
|
+
getLocalEndpointAddr(): Promise<string>;
|
|
37
|
+
constructor();
|
|
38
|
+
recv(): Uint8Array;
|
|
39
|
+
spawn(relay_urls: any, secret_key?: Uint8Array | null): Promise<void>;
|
|
40
|
+
connect(addr: string): Promise<void>;
|
|
41
41
|
getStats(): any;
|
|
42
42
|
}
|
|
43
43
|
export class IntoUnderlyingByteSource {
|
|
44
44
|
private constructor();
|
|
45
45
|
free(): void;
|
|
46
46
|
[Symbol.dispose](): void;
|
|
47
|
-
start(controller: ReadableByteStreamController): void;
|
|
48
47
|
pull(controller: ReadableByteStreamController): Promise<any>;
|
|
48
|
+
start(controller: ReadableByteStreamController): void;
|
|
49
49
|
cancel(): void;
|
|
50
|
-
readonly type: ReadableStreamType;
|
|
51
50
|
readonly autoAllocateChunkSize: number;
|
|
51
|
+
readonly type: ReadableStreamType;
|
|
52
52
|
}
|
|
53
53
|
export class IntoUnderlyingSink {
|
|
54
54
|
private constructor();
|
|
55
55
|
free(): void;
|
|
56
56
|
[Symbol.dispose](): void;
|
|
57
|
-
write(chunk: any): Promise<any>;
|
|
58
|
-
close(): Promise<any>;
|
|
59
57
|
abort(reason: any): Promise<any>;
|
|
58
|
+
close(): Promise<any>;
|
|
59
|
+
write(chunk: any): Promise<any>;
|
|
60
60
|
}
|
|
61
61
|
export class IntoUnderlyingSource {
|
|
62
62
|
private constructor();
|
|
@@ -70,61 +70,61 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
70
70
|
|
|
71
71
|
export interface InitOutput {
|
|
72
72
|
readonly memory: WebAssembly.Memory;
|
|
73
|
+
readonly __wbg_connectionstats_free: (a: number, b: number) => void;
|
|
73
74
|
readonly __wbg_ermiscall_free: (a: number, b: number) => void;
|
|
74
|
-
readonly
|
|
75
|
-
readonly
|
|
76
|
-
readonly
|
|
77
|
-
readonly
|
|
78
|
-
readonly
|
|
79
|
-
readonly
|
|
75
|
+
readonly __wbg_get_connectionstats_packet_loss: (a: number, b: number) => void;
|
|
76
|
+
readonly __wbg_get_connectionstats_rtt_ms: (a: number, b: number) => void;
|
|
77
|
+
readonly __wbg_set_connectionstats_packet_loss: (a: number, b: number, c: number) => void;
|
|
78
|
+
readonly __wbg_set_connectionstats_rtt_ms: (a: number, b: number, c: number) => void;
|
|
79
|
+
readonly connectionstats_connection_type: (a: number, b: number) => void;
|
|
80
|
+
readonly connectionstats_new: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
81
|
+
readonly connectionstats_set_connection_type: (a: number, b: number, c: number) => void;
|
|
80
82
|
readonly ermiscall_acceptConnection: (a: number) => number;
|
|
81
|
-
readonly ermiscall_sendControlFrame: (a: number, b: number, c: number, d: number) => void;
|
|
82
|
-
readonly ermiscall_sendAudioFrame: (a: number, b: number, c: number, d: number) => void;
|
|
83
|
-
readonly ermiscall_sendFrame: (a: number, b: number, c: number, d: number) => void;
|
|
84
|
-
readonly ermiscall_notifyNewGop: (a: number, b: number) => void;
|
|
85
|
-
readonly ermiscall_recv: (a: number, b: number) => void;
|
|
86
83
|
readonly ermiscall_asyncRecv: (a: number) => number;
|
|
87
84
|
readonly ermiscall_beginWithGop: (a: number, b: number, c: number, d: number) => void;
|
|
85
|
+
readonly ermiscall_closeConnection: (a: number, b: number) => void;
|
|
86
|
+
readonly ermiscall_closeEndpoint: (a: number) => number;
|
|
87
|
+
readonly ermiscall_connect: (a: number, b: number, c: number) => number;
|
|
88
88
|
readonly ermiscall_connectionType: (a: number, b: number) => void;
|
|
89
|
-
readonly ermiscall_roundTripTime: (a: number, b: number) => void;
|
|
90
89
|
readonly ermiscall_currentPacketLoss: (a: number, b: number) => void;
|
|
91
|
-
readonly
|
|
92
|
-
readonly __wbg_connectionstats_free: (a: number, b: number) => void;
|
|
93
|
-
readonly __wbg_get_connectionstats_rtt_ms: (a: number, b: number) => void;
|
|
94
|
-
readonly __wbg_set_connectionstats_rtt_ms: (a: number, b: number, c: number) => void;
|
|
95
|
-
readonly __wbg_get_connectionstats_packet_loss: (a: number, b: number) => void;
|
|
96
|
-
readonly __wbg_set_connectionstats_packet_loss: (a: number, b: number, c: number) => void;
|
|
97
|
-
readonly connectionstats_new: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
98
|
-
readonly connectionstats_connection_type: (a: number, b: number) => void;
|
|
99
|
-
readonly connectionstats_set_connection_type: (a: number, b: number, c: number) => void;
|
|
90
|
+
readonly ermiscall_getLocalEndpointAddr: (a: number) => number;
|
|
100
91
|
readonly ermiscall_getStats: (a: number, b: number) => void;
|
|
92
|
+
readonly ermiscall_networkChange: (a: number) => void;
|
|
93
|
+
readonly ermiscall_new: () => number;
|
|
94
|
+
readonly ermiscall_notifyNewGop: (a: number, b: number) => void;
|
|
95
|
+
readonly ermiscall_recv: (a: number, b: number) => void;
|
|
96
|
+
readonly ermiscall_roundTripTime: (a: number, b: number) => void;
|
|
97
|
+
readonly ermiscall_sendAudioFrame: (a: number, b: number, c: number, d: number) => void;
|
|
98
|
+
readonly ermiscall_sendControlFrame: (a: number, b: number, c: number, d: number) => void;
|
|
99
|
+
readonly ermiscall_sendFrame: (a: number, b: number, c: number, d: number) => void;
|
|
100
|
+
readonly ermiscall_spawn: (a: number, b: number, c: number, d: number) => number;
|
|
101
101
|
readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
|
|
102
|
-
readonly
|
|
102
|
+
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
103
|
+
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
103
104
|
readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
|
|
104
|
-
readonly intounderlyingbytesource_start: (a: number, b: number) => void;
|
|
105
|
-
readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
|
|
106
105
|
readonly intounderlyingbytesource_cancel: (a: number) => void;
|
|
107
|
-
readonly
|
|
108
|
-
readonly
|
|
109
|
-
readonly
|
|
110
|
-
readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
|
|
111
|
-
readonly intounderlyingsink_write: (a: number, b: number) => number;
|
|
112
|
-
readonly intounderlyingsink_close: (a: number) => number;
|
|
106
|
+
readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
|
|
107
|
+
readonly intounderlyingbytesource_start: (a: number, b: number) => void;
|
|
108
|
+
readonly intounderlyingbytesource_type: (a: number) => number;
|
|
113
109
|
readonly intounderlyingsink_abort: (a: number, b: number) => number;
|
|
110
|
+
readonly intounderlyingsink_close: (a: number) => number;
|
|
111
|
+
readonly intounderlyingsink_write: (a: number, b: number) => number;
|
|
112
|
+
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
113
|
+
readonly intounderlyingsource_pull: (a: number, b: number) => number;
|
|
114
114
|
readonly ring_core_0_17_14__bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
115
|
-
readonly
|
|
116
|
-
readonly
|
|
117
|
-
readonly
|
|
118
|
-
readonly
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
122
|
-
readonly
|
|
123
|
-
readonly
|
|
124
|
-
readonly
|
|
125
|
-
readonly
|
|
126
|
-
readonly
|
|
127
|
-
readonly
|
|
115
|
+
readonly __wasm_bindgen_func_elem_12594: (a: number, b: number) => void;
|
|
116
|
+
readonly __wasm_bindgen_func_elem_12577: (a: number, b: number) => void;
|
|
117
|
+
readonly __wasm_bindgen_func_elem_11460: (a: number, b: number, c: number) => void;
|
|
118
|
+
readonly __wasm_bindgen_func_elem_11415: (a: number, b: number) => void;
|
|
119
|
+
readonly __wasm_bindgen_func_elem_5633: (a: number, b: number) => void;
|
|
120
|
+
readonly __wasm_bindgen_func_elem_5618: (a: number, b: number) => void;
|
|
121
|
+
readonly __wasm_bindgen_func_elem_2279: (a: number, b: number, c: number) => void;
|
|
122
|
+
readonly __wasm_bindgen_func_elem_2072: (a: number, b: number) => void;
|
|
123
|
+
readonly __wasm_bindgen_func_elem_12647: (a: number, b: number, c: number) => void;
|
|
124
|
+
readonly __wasm_bindgen_func_elem_12631: (a: number, b: number) => void;
|
|
125
|
+
readonly __wasm_bindgen_func_elem_6078: (a: number, b: number) => void;
|
|
126
|
+
readonly __wasm_bindgen_func_elem_6067: (a: number, b: number) => void;
|
|
127
|
+
readonly __wasm_bindgen_func_elem_14072: (a: number, b: number, c: number, d: number) => void;
|
|
128
128
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
129
129
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
130
130
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -134,21 +134,23 @@ export interface InitOutput {
|
|
|
134
134
|
|
|
135
135
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
136
136
|
/**
|
|
137
|
-
* Instantiates the given `module`, which can either be bytes or
|
|
138
|
-
* a precompiled `WebAssembly.Module`.
|
|
139
|
-
*
|
|
140
|
-
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
141
|
-
*
|
|
142
|
-
* @returns {InitOutput}
|
|
143
|
-
*/
|
|
137
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
138
|
+
* a precompiled `WebAssembly.Module`.
|
|
139
|
+
*
|
|
140
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
141
|
+
*
|
|
142
|
+
* @returns {InitOutput}
|
|
143
|
+
*/
|
|
144
144
|
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
148
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
149
|
-
*
|
|
150
|
-
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
151
|
-
*
|
|
152
|
-
* @returns {Promise<InitOutput>}
|
|
153
|
-
*/
|
|
154
|
-
export default function __wbg_init
|
|
147
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
148
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
149
|
+
*
|
|
150
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
151
|
+
*
|
|
152
|
+
* @returns {Promise<InitOutput>}
|
|
153
|
+
*/
|
|
154
|
+
export default function __wbg_init(
|
|
155
|
+
module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>,
|
|
156
|
+
): Promise<InitOutput>;
|