react-jssip-kit 0.3.1 → 0.4.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/CHANGELOG.md +6 -0
- package/dist/index.cjs +41 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -20
- package/dist/index.d.ts +18 -20
- package/dist/index.js +41 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
- Breaking: public client control methods now require an explicit `sessionId` as the first argument (`answer`, `hangup`, mute/hold toggles, DTMF/transfer helpers).
|
|
5
|
+
- Added exports for client-facing types (events, options, RTCSession/UA maps) from the package entrypoint for easier consumption.
|
|
6
|
+
- Allow setting media on a session id before the session object is attached to retain pending streams.
|
|
7
|
+
- When debug is enabled, expose `window.sipState()` and `window.sipSessions()` helpers for quick inspection.
|
|
8
|
+
|
|
3
9
|
## 0.1.1
|
|
4
10
|
- Exported `SipSessionState` from the public entrypoint and aligned demo/imports to the new package name.
|
|
5
11
|
|
package/dist/index.cjs
CHANGED
|
@@ -717,10 +717,6 @@ var SessionManager = class {
|
|
|
717
717
|
const rtc = this.getRtc(sessionId);
|
|
718
718
|
return rtc ? rtc.attendedTransfer(otherSession) : false;
|
|
719
719
|
}
|
|
720
|
-
startScreenShare(sessionId, getDisplayMedia) {
|
|
721
|
-
const rtc = this.getRtc(sessionId);
|
|
722
|
-
return rtc ? rtc.startScreenShare(getDisplayMedia) : false;
|
|
723
|
-
}
|
|
724
720
|
};
|
|
725
721
|
|
|
726
722
|
// src/jssip-lib/sip/sessionLifecycle.ts
|
|
@@ -814,13 +810,19 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
814
810
|
connect(uri, password, config) {
|
|
815
811
|
this.disconnect();
|
|
816
812
|
this.stateStore.setState({ sipStatus: SipStatus.Connecting });
|
|
817
|
-
const {
|
|
813
|
+
const {
|
|
814
|
+
debug: cfgDebug,
|
|
815
|
+
maxSessionCount,
|
|
816
|
+
pendingMediaTtlMs,
|
|
817
|
+
...uaCfg
|
|
818
|
+
} = config;
|
|
818
819
|
this.maxSessionCount = typeof maxSessionCount === "number" ? maxSessionCount : Infinity;
|
|
819
820
|
this.sessionManager.setPendingMediaTtl(pendingMediaTtlMs);
|
|
820
821
|
const debug = this.debugPattern ?? cfgDebug;
|
|
821
822
|
this.userAgent.start(uri, password, uaCfg, { debug });
|
|
822
823
|
this.attachUAHandlers();
|
|
823
824
|
this.attachBeforeUnload();
|
|
825
|
+
this.syncDebugInspector(debug);
|
|
824
826
|
}
|
|
825
827
|
registerUA() {
|
|
826
828
|
this.userAgent.register();
|
|
@@ -847,11 +849,11 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
847
849
|
});
|
|
848
850
|
}
|
|
849
851
|
}
|
|
850
|
-
answer(options = {}) {
|
|
851
|
-
const
|
|
852
|
-
if (!
|
|
852
|
+
answer(sessionId, options = {}) {
|
|
853
|
+
const resolved = this.resolveExistingSessionId(sessionId);
|
|
854
|
+
if (!resolved)
|
|
853
855
|
return false;
|
|
854
|
-
return this.answerSession(
|
|
856
|
+
return this.answerSession(resolved, options);
|
|
855
857
|
}
|
|
856
858
|
hangup(sessionId, options) {
|
|
857
859
|
const resolved = this.resolveExistingSessionId(sessionId);
|
|
@@ -864,21 +866,20 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
864
866
|
ids.forEach((id) => this.hangupSession(id, options));
|
|
865
867
|
return ids.length > 0;
|
|
866
868
|
}
|
|
867
|
-
toggleMute() {
|
|
868
|
-
return this.toggleMuteSession();
|
|
869
|
+
toggleMute(sessionId) {
|
|
870
|
+
return this.toggleMuteSession(sessionId);
|
|
869
871
|
}
|
|
870
|
-
toggleHold() {
|
|
871
|
-
return this.toggleHoldSession();
|
|
872
|
+
toggleHold(sessionId) {
|
|
873
|
+
return this.toggleHoldSession(sessionId);
|
|
872
874
|
}
|
|
873
|
-
sendDTMF(tones, options) {
|
|
874
|
-
|
|
875
|
-
return this.sendDTMFSession(tones, options, sessionId ?? void 0);
|
|
875
|
+
sendDTMF(sessionId, tones, options) {
|
|
876
|
+
return this.sendDTMFSession(sessionId, tones, options);
|
|
876
877
|
}
|
|
877
|
-
transfer(target, options) {
|
|
878
|
-
return this.transferSession(target, options);
|
|
878
|
+
transfer(sessionId, target, options) {
|
|
879
|
+
return this.transferSession(sessionId, target, options);
|
|
879
880
|
}
|
|
880
|
-
attendedTransfer(otherSession) {
|
|
881
|
-
return this.attendedTransferSession(otherSession);
|
|
881
|
+
attendedTransfer(sessionId, otherSession) {
|
|
882
|
+
return this.attendedTransferSession(sessionId, otherSession);
|
|
882
883
|
}
|
|
883
884
|
onChange(fn) {
|
|
884
885
|
return this.stateStore.onChange(fn);
|
|
@@ -897,6 +898,7 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
897
898
|
setDebug(debug) {
|
|
898
899
|
this.debugPattern = debug;
|
|
899
900
|
this.userAgent.setDebug(debug);
|
|
901
|
+
this.syncDebugInspector(debug);
|
|
900
902
|
}
|
|
901
903
|
attachSessionHandlers(sessionId, session) {
|
|
902
904
|
const handlers = this.createSessionHandlersFor(sessionId, session);
|
|
@@ -1040,7 +1042,7 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1040
1042
|
}
|
|
1041
1043
|
return true;
|
|
1042
1044
|
}
|
|
1043
|
-
sendDTMFSession(tones, options
|
|
1045
|
+
sendDTMFSession(sessionId, tones, options) {
|
|
1044
1046
|
const resolved = this.resolveExistingSessionId(sessionId);
|
|
1045
1047
|
if (!resolved)
|
|
1046
1048
|
return false;
|
|
@@ -1049,7 +1051,7 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1049
1051
|
this.sessionManager.sendDTMF(resolved, tones, options);
|
|
1050
1052
|
return true;
|
|
1051
1053
|
}
|
|
1052
|
-
transferSession(target, options
|
|
1054
|
+
transferSession(sessionId, target, options) {
|
|
1053
1055
|
const resolved = this.resolveExistingSessionId(sessionId);
|
|
1054
1056
|
if (!resolved)
|
|
1055
1057
|
return false;
|
|
@@ -1058,7 +1060,7 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1058
1060
|
this.sessionManager.transfer(resolved, target, options);
|
|
1059
1061
|
return true;
|
|
1060
1062
|
}
|
|
1061
|
-
attendedTransferSession(
|
|
1063
|
+
attendedTransferSession(sessionId, otherSession) {
|
|
1062
1064
|
const resolved = this.resolveExistingSessionId(sessionId);
|
|
1063
1065
|
if (!resolved)
|
|
1064
1066
|
return false;
|
|
@@ -1068,8 +1070,6 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1068
1070
|
return true;
|
|
1069
1071
|
}
|
|
1070
1072
|
setSessionMedia(sessionId, stream) {
|
|
1071
|
-
if (!this.sessionExists(sessionId))
|
|
1072
|
-
return;
|
|
1073
1073
|
this.sessionManager.setSessionMedia(sessionId, stream);
|
|
1074
1074
|
}
|
|
1075
1075
|
switchCameraSession(sessionId, track) {
|
|
@@ -1078,11 +1078,6 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1078
1078
|
const rtc = this.sessionManager.getRtc(sessionId);
|
|
1079
1079
|
return rtc ? rtc.switchCamera(track) : false;
|
|
1080
1080
|
}
|
|
1081
|
-
startScreenShareSession(sessionId, getDisplayMedia) {
|
|
1082
|
-
if (!this.sessionExists(sessionId))
|
|
1083
|
-
return false;
|
|
1084
|
-
return this.sessionManager.startScreenShare(sessionId, getDisplayMedia);
|
|
1085
|
-
}
|
|
1086
1081
|
enableVideoSession(sessionId) {
|
|
1087
1082
|
if (!this.sessionExists(sessionId))
|
|
1088
1083
|
return false;
|
|
@@ -1122,6 +1117,22 @@ var SipClient = class extends EventTargetEmitter {
|
|
|
1122
1117
|
window.removeEventListener("beforeunload", this.unloadHandler);
|
|
1123
1118
|
this.unloadHandler = void 0;
|
|
1124
1119
|
}
|
|
1120
|
+
syncDebugInspector(debug) {
|
|
1121
|
+
if (typeof window === "undefined")
|
|
1122
|
+
return;
|
|
1123
|
+
const enabled = Boolean(debug);
|
|
1124
|
+
const win = window;
|
|
1125
|
+
if (enabled) {
|
|
1126
|
+
win.sipState = () => this.stateStore.getState();
|
|
1127
|
+
win.sipSessions = () => this.getSessions();
|
|
1128
|
+
} else {
|
|
1129
|
+
try {
|
|
1130
|
+
delete win.sipState;
|
|
1131
|
+
delete win.sipSessions;
|
|
1132
|
+
} catch {
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1125
1136
|
};
|
|
1126
1137
|
function createSipClientInstance(options) {
|
|
1127
1138
|
return new SipClient(options);
|
|
@@ -1201,7 +1212,6 @@ function useSipActions() {
|
|
|
1201
1212
|
getSessions: () => client.getSessions(),
|
|
1202
1213
|
setSessionMedia: (...args) => client.setSessionMedia(...args),
|
|
1203
1214
|
switchCamera: (...args) => client.switchCameraSession(...args),
|
|
1204
|
-
startScreenShare: (...args) => client.startScreenShareSession(...args),
|
|
1205
1215
|
enableVideo: (...args) => client.enableVideoSession(...args),
|
|
1206
1216
|
disableVideo: (...args) => client.disableVideoSession(...args)
|
|
1207
1217
|
}),
|