react-jssip-kit 0.5.0 → 0.5.2
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 +8 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +417 -99
- package/dist/index.d.ts +417 -99
- package/dist/index.js +8 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,99 +1,418 @@
|
|
|
1
|
-
import * as jssip_lib_UA from 'jssip/lib/UA';
|
|
2
|
-
import { RTCSessionEvent, IncomingRTCSessionEvent, UAEventMap, UAConfiguration, CallOptions } from 'jssip/lib/UA';
|
|
3
|
-
export { CallOptions, RTCSessionEvent, UAEventMap } from 'jssip/lib/UA';
|
|
4
|
-
import * as jssip_lib_RTCSession from 'jssip/lib/RTCSession';
|
|
5
|
-
import { RTCSessionEventMap, DTFMOptions as DTFMOptions$1, AnswerOptions, TerminateOptions, RTCSession, ReferOptions } from 'jssip/lib/RTCSession';
|
|
6
|
-
export { AnswerOptions, RTCSession, RTCSessionEventMap, ReferOptions, TerminateOptions } from 'jssip/lib/RTCSession';
|
|
7
1
|
import { UA } from 'jssip';
|
|
8
2
|
export { WebSocketInterface } from 'jssip';
|
|
9
3
|
import * as react from 'react';
|
|
10
4
|
import react__default from 'react';
|
|
11
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
12
6
|
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
type Originator = "local" | "remote" | "system";
|
|
8
|
+
type SessionDirection = "incoming" | "outgoing";
|
|
9
|
+
|
|
10
|
+
interface SIPURI {
|
|
11
|
+
user: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface NameAddrHeader {
|
|
15
|
+
uri: SIPURI;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface IncomingRequest {
|
|
19
|
+
body?: string | { toString(): string };
|
|
20
|
+
from: NameAddrHeader;
|
|
21
|
+
to: NameAddrHeader;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface OutgoingRequest {
|
|
25
|
+
body?: string | { toString(): string };
|
|
26
|
+
from: NameAddrHeader;
|
|
27
|
+
to: NameAddrHeader;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface IncomingResponse {
|
|
31
|
+
status_code?: number;
|
|
32
|
+
reason_phrase?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface ExtraHeaders {
|
|
36
|
+
extraHeaders?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface AnswerOptions extends ExtraHeaders {
|
|
40
|
+
mediaConstraints?: MediaStreamConstraints;
|
|
41
|
+
mediaStream?: MediaStream;
|
|
42
|
+
pcConfig?: RTCConfiguration;
|
|
43
|
+
rtcConstraints?: object;
|
|
44
|
+
rtcAnswerConstraints?: RTCOfferOptions;
|
|
45
|
+
rtcOfferConstraints?: RTCOfferOptions;
|
|
46
|
+
sessionTimersExpires?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface RejectOptions extends ExtraHeaders {
|
|
50
|
+
status_code?: number;
|
|
51
|
+
reason_phrase?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface TerminateOptions extends RejectOptions {
|
|
55
|
+
body?: string;
|
|
56
|
+
cause?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface ReferOptions extends ExtraHeaders {
|
|
60
|
+
eventHandlers?: Record<string, unknown>;
|
|
61
|
+
replaces?: RTCSession;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface DTFMOptions extends ExtraHeaders {
|
|
65
|
+
duration?: number;
|
|
66
|
+
interToneGap?: number;
|
|
67
|
+
transportType?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface HoldOptions extends ExtraHeaders {
|
|
71
|
+
useUpdate?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface MediaStreamTypes {
|
|
75
|
+
audio?: boolean;
|
|
76
|
+
video?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface DTMF {
|
|
80
|
+
tone: string;
|
|
81
|
+
duration: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface Info {
|
|
85
|
+
contentType: string;
|
|
86
|
+
body: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface PeerConnectionEvent {
|
|
90
|
+
peerconnection: RTCPeerConnection;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface ConnectingEvent {
|
|
94
|
+
request: IncomingRequest | OutgoingRequest;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface SendingEvent {
|
|
98
|
+
request: OutgoingRequest;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface IncomingEvent {
|
|
102
|
+
originator: Originator;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
interface OutgoingEvent {
|
|
106
|
+
originator: Originator;
|
|
107
|
+
response?: IncomingResponse;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface IncomingAckEvent {
|
|
111
|
+
originator: Originator;
|
|
112
|
+
ack: IncomingRequest;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface OutgoingAckEvent {
|
|
116
|
+
originator: Originator;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface EndEvent {
|
|
120
|
+
originator: Originator;
|
|
121
|
+
message?: IncomingRequest | IncomingResponse;
|
|
122
|
+
cause?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface IncomingDTMFEvent {
|
|
126
|
+
originator: Originator;
|
|
127
|
+
dtmf: DTMF;
|
|
128
|
+
request?: IncomingRequest;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface OutgoingDTMFEvent {
|
|
132
|
+
originator: Originator;
|
|
133
|
+
dtmf: DTMF;
|
|
134
|
+
request?: OutgoingRequest;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface IncomingInfoEvent {
|
|
138
|
+
originator: Originator;
|
|
139
|
+
info: Info;
|
|
140
|
+
request?: IncomingRequest;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface OutgoingInfoEvent {
|
|
144
|
+
originator: Originator;
|
|
145
|
+
info: Info;
|
|
146
|
+
request?: OutgoingRequest;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface HoldEvent {
|
|
150
|
+
originator: Originator;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface ReInviteEvent {
|
|
154
|
+
request?: IncomingRequest;
|
|
155
|
+
callback?: VoidFunction;
|
|
156
|
+
reject?: (options?: RejectOptions) => void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface ReferEvent {
|
|
160
|
+
request?: IncomingRequest;
|
|
161
|
+
accept?: () => void;
|
|
162
|
+
reject?: VoidFunction;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface SDPEvent {
|
|
166
|
+
originator: Originator;
|
|
167
|
+
type: string;
|
|
168
|
+
sdp: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface IceCandidateEvent {
|
|
172
|
+
candidate: RTCIceCandidate;
|
|
173
|
+
ready: VoidFunction;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface IncomingRTCSessionEvent {
|
|
177
|
+
originator: "remote";
|
|
178
|
+
session: RTCSession;
|
|
179
|
+
request: IncomingRequest;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface OutgoingRTCSessionEvent {
|
|
183
|
+
originator: "local";
|
|
184
|
+
session: RTCSession;
|
|
185
|
+
request: OutgoingRequest;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type RTCSessionEvent = IncomingRTCSessionEvent | OutgoingRTCSessionEvent;
|
|
189
|
+
|
|
190
|
+
type RTCSessionEventMap = {
|
|
191
|
+
peerconnection: (event: PeerConnectionEvent) => void;
|
|
192
|
+
connecting: (event: ConnectingEvent) => void;
|
|
193
|
+
sending: (event: SendingEvent) => void;
|
|
194
|
+
progress: (event: IncomingEvent | OutgoingEvent) => void;
|
|
195
|
+
accepted: (event: IncomingEvent | OutgoingEvent) => void;
|
|
196
|
+
confirmed: (event: IncomingAckEvent | OutgoingAckEvent) => void;
|
|
197
|
+
ended: (event: EndEvent) => void;
|
|
198
|
+
failed: (event: EndEvent) => void;
|
|
199
|
+
newDTMF: (event: IncomingDTMFEvent | OutgoingDTMFEvent) => void;
|
|
200
|
+
newInfo: (event: IncomingInfoEvent | OutgoingInfoEvent) => void;
|
|
201
|
+
hold: (event: HoldEvent) => void;
|
|
202
|
+
unhold: (event: HoldEvent) => void;
|
|
203
|
+
muted: (event: MediaStreamTypes) => void;
|
|
204
|
+
unmuted: (event: MediaStreamTypes) => void;
|
|
205
|
+
reinvite: (event: ReInviteEvent) => void;
|
|
206
|
+
update: (event: ReInviteEvent) => void;
|
|
207
|
+
refer: (event: ReferEvent) => void;
|
|
208
|
+
replaces: (event: ReferEvent) => void;
|
|
209
|
+
sdp: (event: SDPEvent) => void;
|
|
210
|
+
icecandidate: (event: IceCandidateEvent) => void;
|
|
211
|
+
getusermediafailed: (error: unknown) => void;
|
|
212
|
+
"peerconnection:createofferfailed": (error: unknown) => void;
|
|
213
|
+
"peerconnection:createanswerfailed": (error: unknown) => void;
|
|
214
|
+
"peerconnection:setlocaldescriptionfailed": (error: unknown) => void;
|
|
215
|
+
"peerconnection:setremotedescriptionfailed": (error: unknown) => void;
|
|
25
216
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
217
|
+
|
|
218
|
+
interface RTCSession {
|
|
219
|
+
id: string;
|
|
220
|
+
direction: SessionDirection;
|
|
221
|
+
connection?: RTCPeerConnection;
|
|
222
|
+
answer(options?: AnswerOptions): void;
|
|
223
|
+
terminate(options?: TerminateOptions): void;
|
|
224
|
+
mute(options?: MediaStreamTypes): void;
|
|
225
|
+
unmute(options?: MediaStreamTypes): void;
|
|
226
|
+
hold(options?: HoldOptions, done?: VoidFunction): boolean;
|
|
227
|
+
unhold(options?: HoldOptions, done?: VoidFunction): boolean;
|
|
228
|
+
sendDTMF(tones: string | number, options?: DTFMOptions): void;
|
|
229
|
+
refer(target: string | RTCSession, options?: ReferOptions): void;
|
|
230
|
+
on<K extends keyof RTCSessionEventMap>(
|
|
231
|
+
type: K,
|
|
232
|
+
listener: RTCSessionEventMap[K]
|
|
233
|
+
): this;
|
|
234
|
+
off<K extends keyof RTCSessionEventMap>(
|
|
235
|
+
type: K,
|
|
236
|
+
listener: RTCSessionEventMap[K]
|
|
237
|
+
): this;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
interface UAConfiguration {
|
|
241
|
+
sockets: unknown | unknown[];
|
|
242
|
+
uri: string;
|
|
243
|
+
password?: string;
|
|
244
|
+
[key: string]: unknown;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface CallOptions extends AnswerOptions {
|
|
248
|
+
eventHandlers?: Partial<RTCSessionEventMap>;
|
|
249
|
+
anonymous?: boolean;
|
|
250
|
+
fromUserName?: string;
|
|
251
|
+
fromDisplayName?: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface ConnectingUAEvent {
|
|
255
|
+
socket: unknown;
|
|
256
|
+
attempts: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface ConnectedEvent {
|
|
260
|
+
socket: unknown;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
interface DisconnectEvent {
|
|
264
|
+
socket: unknown;
|
|
265
|
+
error: boolean;
|
|
266
|
+
code?: number;
|
|
267
|
+
reason?: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
interface RegisteredEvent {
|
|
271
|
+
response: IncomingResponse;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
interface UnRegisteredEvent {
|
|
275
|
+
response: IncomingResponse;
|
|
276
|
+
cause?: string;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
interface IncomingMessageEvent {
|
|
280
|
+
originator: Originator;
|
|
281
|
+
message: unknown;
|
|
282
|
+
request: IncomingRequest;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface OutgoingMessageEvent {
|
|
286
|
+
originator: Originator;
|
|
287
|
+
message: unknown;
|
|
288
|
+
request: OutgoingRequest;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
interface IncomingOptionsEvent {
|
|
292
|
+
originator: Originator;
|
|
293
|
+
request: IncomingRequest;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface OutgoingOptionsEvent {
|
|
297
|
+
originator: Originator;
|
|
298
|
+
request: OutgoingRequest;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
type UAEventMap = {
|
|
302
|
+
connecting: (event: ConnectingUAEvent) => void;
|
|
303
|
+
connected: (event: ConnectedEvent) => void;
|
|
304
|
+
disconnected: (event: DisconnectEvent) => void;
|
|
305
|
+
registered: (event: RegisteredEvent) => void;
|
|
306
|
+
unregistered: (event: UnRegisteredEvent) => void;
|
|
307
|
+
registrationFailed: (event: UnRegisteredEvent) => void;
|
|
308
|
+
registrationExpiring: () => void;
|
|
309
|
+
newRTCSession: (event: RTCSessionEvent) => void;
|
|
310
|
+
newMessage: (event: IncomingMessageEvent | OutgoingMessageEvent) => void;
|
|
311
|
+
sipEvent: (event: { event: unknown; request: IncomingRequest }) => void;
|
|
312
|
+
newOptions: (event: IncomingOptionsEvent | OutgoingOptionsEvent) => void;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
type UAExtraEvents = {
|
|
316
|
+
error: { cause: string; code?: string; raw?: any; message?: string };
|
|
317
|
+
missed: IncomingRTCSessionEvent;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
type UAEventName = keyof UAEventMap | keyof UAExtraEvents;
|
|
321
|
+
type SessionEventName = keyof RTCSessionEventMap;
|
|
322
|
+
|
|
323
|
+
declare const JsSIPEventName: {
|
|
324
|
+
readonly connecting: "connecting";
|
|
325
|
+
readonly connected: "connected";
|
|
326
|
+
readonly disconnected: "disconnected";
|
|
327
|
+
readonly registered: "registered";
|
|
328
|
+
readonly unregistered: "unregistered";
|
|
329
|
+
readonly registrationFailed: "registrationFailed";
|
|
330
|
+
readonly registrationExpiring: "registrationExpiring";
|
|
331
|
+
readonly newRTCSession: "newRTCSession";
|
|
332
|
+
readonly newMessage: "newMessage";
|
|
333
|
+
readonly sipEvent: "sipEvent";
|
|
334
|
+
readonly newOptions: "newOptions";
|
|
335
|
+
readonly peerconnection: "peerconnection";
|
|
336
|
+
readonly sending: "sending";
|
|
337
|
+
readonly progress: "progress";
|
|
338
|
+
readonly accepted: "accepted";
|
|
339
|
+
readonly confirmed: "confirmed";
|
|
340
|
+
readonly ended: "ended";
|
|
341
|
+
readonly failed: "failed";
|
|
342
|
+
readonly newDTMF: "newDTMF";
|
|
343
|
+
readonly newInfo: "newInfo";
|
|
344
|
+
readonly hold: "hold";
|
|
345
|
+
readonly unhold: "unhold";
|
|
346
|
+
readonly muted: "muted";
|
|
347
|
+
readonly unmuted: "unmuted";
|
|
348
|
+
readonly reinvite: "reinvite";
|
|
349
|
+
readonly update: "update";
|
|
350
|
+
readonly refer: "refer";
|
|
351
|
+
readonly replaces: "replaces";
|
|
352
|
+
readonly sdp: "sdp";
|
|
353
|
+
readonly error: "error";
|
|
354
|
+
readonly icecandidate: "icecandidate";
|
|
355
|
+
readonly getusermediafailed: "getusermediafailed";
|
|
356
|
+
readonly "peerconnection:createofferfailed": "peerconnection:createofferfailed";
|
|
357
|
+
readonly "peerconnection:createanswerfailed": "peerconnection:createanswerfailed";
|
|
358
|
+
readonly "peerconnection:setlocaldescriptionfailed": "peerconnection:setlocaldescriptionfailed";
|
|
359
|
+
readonly "peerconnection:setremotedescriptionfailed": "peerconnection:setremotedescriptionfailed";
|
|
360
|
+
readonly missed: "missed";
|
|
361
|
+
};
|
|
362
|
+
type JsSIPEventName = UAEventName | SessionEventName;
|
|
363
|
+
|
|
364
|
+
type UAEventPayload<K extends UAEventName> = K extends keyof UAEventMap
|
|
365
|
+
? Parameters<UAEventMap[K]>[0]
|
|
366
|
+
: K extends keyof UAExtraEvents
|
|
367
|
+
? UAExtraEvents[K]
|
|
368
|
+
: never;
|
|
369
|
+
|
|
370
|
+
type SessionEventPayload<K extends SessionEventName> =
|
|
371
|
+
K extends keyof RTCSessionEventMap ? Parameters<RTCSessionEventMap[K]>[0] : never;
|
|
372
|
+
|
|
373
|
+
type JsSIPEventPayload<K extends JsSIPEventName> = K extends UAEventName
|
|
374
|
+
? UAEventPayload<K>
|
|
375
|
+
: K extends SessionEventName
|
|
376
|
+
? SessionEventPayload<K>
|
|
377
|
+
: never;
|
|
378
|
+
|
|
379
|
+
type JsSIPEventHandler<K extends JsSIPEventName> = (
|
|
380
|
+
payload?: JsSIPEventPayload<K>
|
|
381
|
+
) => void;
|
|
382
|
+
|
|
383
|
+
type SipEventHandlers = {
|
|
384
|
+
[K in JsSIPEventName]?: JsSIPEventHandler<K>;
|
|
385
|
+
};
|
|
386
|
+
|
|
72
387
|
interface SipEventManager {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
388
|
+
onUA: <K extends UAEventName>(
|
|
389
|
+
event: K,
|
|
390
|
+
handler: (payload?: UAEventPayload<K>) => void
|
|
391
|
+
) => () => void;
|
|
392
|
+
onSession: <K extends SessionEventName>(
|
|
393
|
+
sessionId: string,
|
|
394
|
+
event: K,
|
|
395
|
+
handler: (payload?: SessionEventPayload<K>) => void
|
|
396
|
+
) => () => void;
|
|
77
397
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
pendingMediaTtlMs?: number;
|
|
398
|
+
|
|
399
|
+
type JsSIPEventMap = {
|
|
400
|
+
[K in JsSIPEventName]: JsSIPEventPayload<K>;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
type SipConfiguration = Omit<UAConfiguration, "password" | "uri"> & {
|
|
404
|
+
/**
|
|
405
|
+
* Enable JsSIP debug logging. If string, treated as debug pattern.
|
|
406
|
+
*/
|
|
407
|
+
debug?: boolean | string;
|
|
408
|
+
/**
|
|
409
|
+
* Maximum allowed concurrent sessions. Additional sessions are rejected.
|
|
410
|
+
*/
|
|
411
|
+
maxSessionCount?: number;
|
|
412
|
+
/**
|
|
413
|
+
* Milliseconds to keep enqueued outgoing media before dropping. Defaults to 30000.
|
|
414
|
+
*/
|
|
415
|
+
pendingMediaTtlMs?: number;
|
|
97
416
|
};
|
|
98
417
|
|
|
99
418
|
type StartOpts = {
|
|
@@ -274,19 +593,19 @@ declare const SipContext: react.Context<SipContextType | null>;
|
|
|
274
593
|
declare function useSipState(): SipState;
|
|
275
594
|
|
|
276
595
|
declare function useSipActions(): {
|
|
277
|
-
call: (target: string, callOptions?:
|
|
278
|
-
answer: (sessionId: string, options?:
|
|
279
|
-
hangup: (sessionId: string, options?:
|
|
596
|
+
call: (target: string, callOptions?: CallOptions | undefined) => void;
|
|
597
|
+
answer: (sessionId: string, options?: AnswerOptions | undefined) => boolean;
|
|
598
|
+
hangup: (sessionId: string, options?: TerminateOptions | undefined) => boolean;
|
|
280
599
|
toggleMute: (sessionId?: string | undefined) => boolean;
|
|
281
600
|
toggleHold: (sessionId?: string | undefined) => boolean;
|
|
282
|
-
sendDTMF: (sessionId: string, tones: string | number, options?:
|
|
283
|
-
transfer: (sessionId: string, target: string |
|
|
284
|
-
attendedTransfer: (sessionId: string, otherSession:
|
|
285
|
-
getSession: (sessionId: string) =>
|
|
601
|
+
sendDTMF: (sessionId: string, tones: string | number, options?: DTFMOptions | undefined) => boolean;
|
|
602
|
+
transfer: (sessionId: string, target: string | RTCSession, options?: ReferOptions | undefined) => boolean;
|
|
603
|
+
attendedTransfer: (sessionId: string, otherSession: RTCSession) => boolean;
|
|
604
|
+
getSession: (sessionId: string) => RTCSession | null;
|
|
286
605
|
getSessionIds: () => string[];
|
|
287
606
|
getSessions: () => {
|
|
288
607
|
id: string;
|
|
289
|
-
session:
|
|
608
|
+
session: RTCSession;
|
|
290
609
|
}[];
|
|
291
610
|
setSessionMedia: (sessionId: string, stream: MediaStream) => void;
|
|
292
611
|
switchCamera: (sessionId: string, track: MediaStreamTrack) => false | Promise<boolean>;
|
|
@@ -298,9 +617,8 @@ declare function useSip(): SipContextType;
|
|
|
298
617
|
|
|
299
618
|
declare function useSipSessions(): Pick<SipState, "sessions">;
|
|
300
619
|
|
|
301
|
-
|
|
302
|
-
declare function
|
|
303
|
-
declare function useSipSessionEvent<K extends EventName>(sessionId: string | null | undefined, event: K, handler?: (payload?: JsSIPEventMap[K]) => void): void;
|
|
620
|
+
declare function useSipEvent<K extends UAEventName>(event: K, handler?: (payload?: UAEventPayload<K>) => void): void;
|
|
621
|
+
declare function useSipSessionEvent<K extends SessionEventName>(sessionId: string | null | undefined, event: K, handler?: (payload?: SessionEventPayload<K>) => void): void;
|
|
304
622
|
|
|
305
623
|
declare function CallPlayer({ sessionId }: {
|
|
306
624
|
sessionId?: string;
|
|
@@ -312,4 +630,4 @@ declare function SipProvider({ client, children, sipEventManager, }: {
|
|
|
312
630
|
children: react__default.ReactNode;
|
|
313
631
|
}): react_jsx_runtime.JSX.Element;
|
|
314
632
|
|
|
315
|
-
export { CallDirection, CallDirection as CallDirectionType, CallPlayer, CallStatus, CallStatus as CallStatusType, type DTFMOptions, type JsSIPEventMap, JsSIPEventName, type SipConfiguration, SipContext, type SipContextType, type SipEventHandlers, type SipEventManager, SipProvider, type SipSessionState, type SipState, SipStatus, SipStatus as SipStatusType, createSipClientInstance, createSipEventManager, useSip, useSipActions, useSipEvent, useSipSessionEvent, useSipSessions, useSipState };
|
|
633
|
+
export { type AnswerOptions, CallDirection, CallDirection as CallDirectionType, type CallOptions, CallPlayer, CallStatus, CallStatus as CallStatusType, type DTFMOptions, type JsSIPEventMap, JsSIPEventName, type RTCSession, type RTCSessionEvent, type RTCSessionEventMap, type ReferOptions, type SessionEventName, type SessionEventPayload, type SipConfiguration, SipContext, type SipContextType, type SipEventHandlers, type SipEventManager, SipProvider, type SipSessionState, type SipState, SipStatus, SipStatus as SipStatusType, type TerminateOptions, type UAEventMap, type UAEventName, type UAEventPayload, createSipClientInstance, createSipEventManager, useSip, useSipActions, useSipEvent, useSipSessionEvent, useSipSessions, useSipState };
|
package/dist/index.js
CHANGED
|
@@ -1041,19 +1041,12 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1041
1041
|
});
|
|
1042
1042
|
}
|
|
1043
1043
|
cleanupSession(sessionId, session) {
|
|
1044
|
-
const existingSession = this.sessionManager.getSession(sessionId);
|
|
1045
|
-
this.emit("sessionCleanup", { sessionId, session: existingSession });
|
|
1046
1044
|
const targetSession = session ?? this.sessionManager.getSession(sessionId) ?? this.sessionManager.getRtc(sessionId)?.currentSession;
|
|
1047
1045
|
this.detachSessionHandlers(sessionId, targetSession);
|
|
1048
1046
|
this.sessionManager.cleanupSession(sessionId);
|
|
1049
1047
|
removeSessionState(this.stateStore, sessionId);
|
|
1050
1048
|
}
|
|
1051
1049
|
cleanupAllSessions() {
|
|
1052
|
-
const ids = this.sessionManager.getSessionIds();
|
|
1053
|
-
ids.forEach((id) => {
|
|
1054
|
-
const s = this.sessionManager.getSession(id);
|
|
1055
|
-
this.emit("sessionCleanup", { sessionId: id, session: s });
|
|
1056
|
-
});
|
|
1057
1050
|
this.sessionManager.cleanupAllSessions();
|
|
1058
1051
|
this.sessionHandlers.clear();
|
|
1059
1052
|
this.stateStore.setState({
|
|
@@ -1285,71 +1278,17 @@ function createSipClientInstance(options) {
|
|
|
1285
1278
|
return new SipClient(options);
|
|
1286
1279
|
}
|
|
1287
1280
|
function createSipEventManager(client) {
|
|
1288
|
-
const sessionEventNames = /* @__PURE__ */ new Set([
|
|
1289
|
-
"peerconnection",
|
|
1290
|
-
"connecting",
|
|
1291
|
-
"sending",
|
|
1292
|
-
"progress",
|
|
1293
|
-
"accepted",
|
|
1294
|
-
"confirmed",
|
|
1295
|
-
"ended",
|
|
1296
|
-
"failed",
|
|
1297
|
-
"newDTMF",
|
|
1298
|
-
"newInfo",
|
|
1299
|
-
"hold",
|
|
1300
|
-
"unhold",
|
|
1301
|
-
"muted",
|
|
1302
|
-
"unmuted",
|
|
1303
|
-
"reinvite",
|
|
1304
|
-
"update",
|
|
1305
|
-
"refer",
|
|
1306
|
-
"replaces",
|
|
1307
|
-
"sdp",
|
|
1308
|
-
"icecandidate",
|
|
1309
|
-
"getusermediafailed",
|
|
1310
|
-
"peerconnection:createofferfailed",
|
|
1311
|
-
"peerconnection:createanswerfailed",
|
|
1312
|
-
"peerconnection:setlocaldescriptionfailed",
|
|
1313
|
-
"peerconnection:setremotedescriptionfailed"
|
|
1314
|
-
]);
|
|
1315
1281
|
return {
|
|
1316
|
-
|
|
1282
|
+
onUA(event, handler) {
|
|
1317
1283
|
return client.on(event, handler);
|
|
1318
1284
|
},
|
|
1319
1285
|
onSession(sessionId, event, handler) {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
}
|
|
1327
|
-
return client.on(event, (payload) => {
|
|
1328
|
-
const id = payload?.session?.id ?? payload?.sessionId ?? payload?.data?.session?.id ?? payload?.data?.id;
|
|
1329
|
-
if (id && String(id) === sessionId) {
|
|
1330
|
-
handler(payload);
|
|
1331
|
-
}
|
|
1332
|
-
});
|
|
1333
|
-
},
|
|
1334
|
-
bind(handlers) {
|
|
1335
|
-
const offs = [];
|
|
1336
|
-
Object.keys(handlers).forEach((event) => {
|
|
1337
|
-
const handler = handlers[event];
|
|
1338
|
-
if (handler) {
|
|
1339
|
-
offs.push(client.on(event, handler));
|
|
1340
|
-
}
|
|
1341
|
-
});
|
|
1342
|
-
return () => offs.forEach((off) => off());
|
|
1343
|
-
},
|
|
1344
|
-
bindSession(sessionId, handlers) {
|
|
1345
|
-
const offs = [];
|
|
1346
|
-
Object.keys(handlers).forEach((event) => {
|
|
1347
|
-
const handler = handlers[event];
|
|
1348
|
-
if (handler) {
|
|
1349
|
-
offs.push(this.onSession(sessionId, event, handler));
|
|
1350
|
-
}
|
|
1351
|
-
});
|
|
1352
|
-
return () => offs.forEach((off) => off());
|
|
1286
|
+
const session = client.getSession(sessionId);
|
|
1287
|
+
if (!session)
|
|
1288
|
+
return () => {
|
|
1289
|
+
};
|
|
1290
|
+
session.on(event, handler);
|
|
1291
|
+
return () => session.off(event, handler);
|
|
1353
1292
|
}
|
|
1354
1293
|
};
|
|
1355
1294
|
}
|
|
@@ -1405,7 +1344,7 @@ function useSipEvent(event, handler) {
|
|
|
1405
1344
|
useEffect(() => {
|
|
1406
1345
|
if (!handler)
|
|
1407
1346
|
return;
|
|
1408
|
-
return sipEventManager.
|
|
1347
|
+
return sipEventManager.onUA(event, handler);
|
|
1409
1348
|
}, [event, handler, sipEventManager]);
|
|
1410
1349
|
}
|
|
1411
1350
|
function useSipSessionEvent(sessionId, event, handler) {
|