@signalwire/js 3.19.0 → 3.19.1

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.js CHANGED
@@ -752,7 +752,7 @@ var memberPositionWorker = function* memberPositionWorker2(options) {
752
752
  var import_core9 = require("@signalwire/core");
753
753
  var childMemberJoinedWorker = function* (options) {
754
754
  (0, import_core9.getLogger)().trace("childMemberJoinedWorker started");
755
- const { channels, instance, initialState } = options;
755
+ const { channels, instance, initialState, onDone, onFail } = options;
756
756
  const { swEventChannel } = channels;
757
757
  const { parentId } = initialState;
758
758
  if (!parentId) {
@@ -766,16 +766,22 @@ var childMemberJoinedWorker = function* (options) {
766
766
  });
767
767
  const { member } = action.payload;
768
768
  if (member == null ? void 0 : member.parent_id) {
769
- instance._attachListeners(member.id);
770
- instance.applyEmitterTransforms();
771
- const parent = yield import_core9.sagaEffects.select(import_core9.componentSelectors.getComponent, member.parent_id);
769
+ const byId = yield import_core9.sagaEffects.select(import_core9.componentSelectors.getComponentsById);
770
+ const parent = Object.values(byId).find((row) => {
771
+ return "memberId" in row && row.memberId === member.parent_id;
772
+ });
772
773
  if (parent) {
774
+ instance._attachListeners(member.id);
775
+ instance.applyEmitterTransforms();
773
776
  yield import_core9.sagaEffects.put(import_core9.componentActions.upsert({
774
777
  id: instance.callId,
775
778
  roomId: action.payload.room_id,
776
779
  roomSessionId: action.payload.room_session_id,
777
780
  memberId: member.id
778
781
  }));
782
+ onDone == null ? void 0 : onDone();
783
+ } else {
784
+ onFail == null ? void 0 : onFail({ error: new Error("Unknown parent_id") });
779
785
  }
780
786
  }
781
787
  (0, import_core9.getLogger)().trace("childMemberJoinedWorker ended");
@@ -982,61 +988,65 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
982
988
  }
983
989
  startScreenShare() {
984
990
  return __async(this, arguments, function* (opts = {}) {
985
- var _a;
986
- const {
987
- autoJoin = true,
988
- audio = false,
989
- video = true,
990
- layout,
991
- positions
992
- } = opts;
993
- const displayStream = yield (0, import_webrtc4.getDisplayMedia)({
994
- audio: audio === true ? SCREENSHARE_AUDIO_CONSTRAINTS : audio,
995
- video
996
- });
997
- const options = __spreadProps(__spreadValues({}, this.options), {
998
- screenShare: true,
999
- recoverCall: false,
1000
- localStream: displayStream,
1001
- remoteStream: void 0,
1002
- userVariables: __spreadProps(__spreadValues({}, ((_a = this.options) == null ? void 0 : _a.userVariables) || {}), {
1003
- memberCallId: this.callId,
1004
- memberId: this.memberId
1005
- }),
1006
- layout,
1007
- positions
1008
- });
1009
- const screenShare = (0, import_core10.connect)({
1010
- store: this.store,
1011
- Component: RoomSessionScreenShareAPI
1012
- })(options);
1013
- displayStream.getVideoTracks().forEach((t) => {
1014
- t.addEventListener("ended", () => {
1015
- if (screenShare && screenShare.active) {
1016
- screenShare.leave();
1017
- }
991
+ return new Promise((resolve, reject) => __async(this, null, function* () {
992
+ var _a;
993
+ const {
994
+ autoJoin = true,
995
+ audio = false,
996
+ video = true,
997
+ layout,
998
+ positions
999
+ } = opts;
1000
+ const displayStream = yield (0, import_webrtc4.getDisplayMedia)({
1001
+ audio: audio === true ? SCREENSHARE_AUDIO_CONSTRAINTS : audio,
1002
+ video
1018
1003
  });
1019
- });
1020
- screenShare.once("destroy", () => {
1021
- screenShare.emit("room.left");
1022
- this._screenShareList.delete(screenShare);
1023
- });
1024
- try {
1025
- screenShare.runWorker("childMemberJoinedWorker", {
1026
- worker: childMemberJoinedWorker,
1027
- initialState: {
1028
- parentId: this.memberId
1029
- }
1004
+ const options = __spreadProps(__spreadValues({}, this.options), {
1005
+ screenShare: true,
1006
+ recoverCall: false,
1007
+ localStream: displayStream,
1008
+ remoteStream: void 0,
1009
+ userVariables: __spreadProps(__spreadValues({}, ((_a = this.options) == null ? void 0 : _a.userVariables) || {}), {
1010
+ memberCallId: this.callId,
1011
+ memberId: this.memberId
1012
+ }),
1013
+ layout,
1014
+ positions
1015
+ });
1016
+ const screenShare = (0, import_core10.connect)({
1017
+ store: this.store,
1018
+ Component: RoomSessionScreenShareAPI
1019
+ })(options);
1020
+ displayStream.getVideoTracks().forEach((t) => {
1021
+ t.addEventListener("ended", () => {
1022
+ if (screenShare && screenShare.active) {
1023
+ screenShare.leave();
1024
+ }
1025
+ });
1026
+ });
1027
+ screenShare.once("destroy", () => {
1028
+ screenShare.emit("room.left");
1029
+ this._screenShareList.delete(screenShare);
1030
1030
  });
1031
- this._screenShareList.add(screenShare);
1032
- if (autoJoin) {
1033
- yield screenShare.join();
1031
+ try {
1032
+ screenShare.runWorker("childMemberJoinedWorker", {
1033
+ worker: childMemberJoinedWorker,
1034
+ onDone: () => resolve(screenShare),
1035
+ onFail: reject,
1036
+ initialState: {
1037
+ parentId: this.memberId
1038
+ }
1039
+ });
1040
+ this._screenShareList.add(screenShare);
1041
+ if (autoJoin) {
1042
+ return yield screenShare.join();
1043
+ }
1044
+ return resolve(screenShare);
1045
+ } catch (error) {
1046
+ this.logger.error("ScreenShare Error", error);
1047
+ reject(error);
1034
1048
  }
1035
- return screenShare;
1036
- } catch (error) {
1037
- this.logger.error("ScreenShare Error", error);
1038
- throw error;
1039
- }
1049
+ }));
1040
1050
  });
1041
1051
  }
1042
1052
  addCamera(opts = {}) {
@@ -1055,47 +1065,51 @@ var RoomSessionConnection = class extends import_webrtc4.BaseConnection {
1055
1065
  }
1056
1066
  addDevice() {
1057
1067
  return __async(this, arguments, function* (opts = {}) {
1058
- var _a;
1059
- const { autoJoin = true, audio = false, video = false } = opts;
1060
- if (!audio && !video) {
1061
- throw new TypeError("At least one of `audio` or `video` must be requested.");
1062
- }
1063
- const options = __spreadProps(__spreadValues({}, this.options), {
1064
- localStream: void 0,
1065
- remoteStream: void 0,
1066
- audio,
1067
- video,
1068
- additionalDevice: true,
1069
- recoverCall: false,
1070
- userVariables: __spreadProps(__spreadValues({}, ((_a = this.options) == null ? void 0 : _a.userVariables) || {}), {
1071
- memberCallId: this.callId,
1072
- memberId: this.memberId
1073
- })
1074
- });
1075
- const roomDevice = (0, import_core10.connect)({
1076
- store: this.store,
1077
- Component: RoomSessionDeviceAPI
1078
- })(options);
1079
- roomDevice.once("destroy", () => {
1080
- roomDevice.emit("room.left");
1081
- this._deviceList.delete(roomDevice);
1082
- });
1083
- try {
1084
- roomDevice.runWorker("childMemberJoinedWorker", {
1085
- worker: childMemberJoinedWorker,
1086
- initialState: {
1087
- parentId: this.memberId
1088
- }
1068
+ return new Promise((resolve, reject) => __async(this, null, function* () {
1069
+ var _a;
1070
+ const { autoJoin = true, audio = false, video = false } = opts;
1071
+ if (!audio && !video) {
1072
+ throw new TypeError("At least one of `audio` or `video` must be requested.");
1073
+ }
1074
+ const options = __spreadProps(__spreadValues({}, this.options), {
1075
+ localStream: void 0,
1076
+ remoteStream: void 0,
1077
+ audio,
1078
+ video,
1079
+ additionalDevice: true,
1080
+ recoverCall: false,
1081
+ userVariables: __spreadProps(__spreadValues({}, ((_a = this.options) == null ? void 0 : _a.userVariables) || {}), {
1082
+ memberCallId: this.callId,
1083
+ memberId: this.memberId
1084
+ })
1089
1085
  });
1090
- this._deviceList.add(roomDevice);
1091
- if (autoJoin) {
1092
- yield roomDevice.join();
1086
+ const roomDevice = (0, import_core10.connect)({
1087
+ store: this.store,
1088
+ Component: RoomSessionDeviceAPI
1089
+ })(options);
1090
+ roomDevice.once("destroy", () => {
1091
+ roomDevice.emit("room.left");
1092
+ this._deviceList.delete(roomDevice);
1093
+ });
1094
+ try {
1095
+ roomDevice.runWorker("childMemberJoinedWorker", {
1096
+ worker: childMemberJoinedWorker,
1097
+ onDone: () => resolve(roomDevice),
1098
+ onFail: reject,
1099
+ initialState: {
1100
+ parentId: this.memberId
1101
+ }
1102
+ });
1103
+ this._deviceList.add(roomDevice);
1104
+ if (autoJoin) {
1105
+ return yield roomDevice.join();
1106
+ }
1107
+ return resolve(roomDevice);
1108
+ } catch (error) {
1109
+ this.logger.error("RoomDevice Error", error);
1110
+ reject(error);
1093
1111
  }
1094
- return roomDevice;
1095
- } catch (error) {
1096
- this.logger.error("RoomDevice Error", error);
1097
- throw error;
1098
- }
1112
+ }));
1099
1113
  });
1100
1114
  }
1101
1115
  join() {
@@ -1379,7 +1393,7 @@ var JWTSession = class extends import_core14.BaseJWTSession {
1379
1393
  this.options = options;
1380
1394
  __publicField(this, "WebSocketConstructor", WebSocket);
1381
1395
  __publicField(this, "CloseEventConstructor", CloseEvent);
1382
- __publicField(this, "agent", "@signalwire/js/browser/3.19.0");
1396
+ __publicField(this, "agent", "@signalwire/js/browser/3.19.1");
1383
1397
  }
1384
1398
  get allowReattach() {
1385
1399
  var _a;
@@ -1968,6 +1982,9 @@ var RoomSession = function(roomOptions) {
1968
1982
  reattachManager.destroy();
1969
1983
  client.disconnect();
1970
1984
  });
1985
+ client.once("session.disconnected", () => {
1986
+ room.destroy();
1987
+ });
1971
1988
  const join = (params) => {
1972
1989
  return new Promise((resolve, reject) => __async(this, null, function* () {
1973
1990
  var _a2, _b;