@signalwire/js 1.4.2-rc.1 → 1.5.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.
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import logger from '../util/logger';
11
- import { getUserMedia, getMediaConstraints, sdpStereoHack, sdpBitrateHack } from './helpers';
11
+ import { getUserMedia, getMediaConstraints, sdpStereoHack, sdpBitrateHack, } from './helpers';
12
12
  import { SwEvent } from '../util/constants';
13
13
  import { PeerType } from './constants';
14
- import { attachMediaStream, muteMediaElement, sdpToJsonHack, RTCPeerConnection, streamIsValid } from '../util/webrtc';
14
+ import { attachMediaStream, muteMediaElement, sdpToJsonHack, RTCPeerConnection, streamIsValid, } from './WebRTC';
15
15
  import { isFunction } from '../util/helpers';
16
16
  import { trigger } from '../services/Handler';
17
17
  import { filterIceServers } from './helpers';
@@ -23,7 +23,10 @@ export default class Peer {
23
23
  this.onSdpReadyTwice = null;
24
24
  this._negotiating = false;
25
25
  logger.info('New Peer with type:', this.type, 'Options:', this.options);
26
- this._constraints = { offerToReceiveAudio: true, offerToReceiveVideo: true };
26
+ this._constraints = {
27
+ offerToReceiveAudio: true,
28
+ offerToReceiveVideo: true,
29
+ };
27
30
  this._sdpReady = this._sdpReady.bind(this);
28
31
  this._init();
29
32
  }
@@ -45,7 +48,7 @@ export default class Peer {
45
48
  _init() {
46
49
  return __awaiter(this, void 0, void 0, function* () {
47
50
  this.instance = RTCPeerConnection(this._config());
48
- this.instance.onsignalingstatechange = event => {
51
+ this.instance.onsignalingstatechange = (event) => {
49
52
  switch (this.instance.signalingState) {
50
53
  case 'stable':
51
54
  break;
@@ -56,22 +59,24 @@ export default class Peer {
56
59
  this._negotiating = true;
57
60
  }
58
61
  };
59
- this.instance.onnegotiationneeded = event => {
62
+ this.instance.onnegotiationneeded = (event) => {
60
63
  if (this._negotiating) {
61
64
  logger.debug('Skip twice onnegotiationneeded..');
62
65
  return;
63
66
  }
64
67
  this.startNegotiation();
65
68
  };
66
- this.options.localStream = yield this._retrieveLocalStream()
67
- .catch(error => {
69
+ this.options.localStream = yield this._retrieveLocalStream().catch((error) => {
68
70
  trigger(SwEvent.MediaError, error, this.options.id);
69
71
  return null;
70
72
  });
71
73
  const { localElement, localStream = null, screenShare = false } = this.options;
72
74
  if (streamIsValid(localStream)) {
73
75
  if (typeof this.instance.addTrack === 'function') {
74
- localStream.getTracks().forEach(t => this.instance.addTrack(t, localStream));
76
+ const tracks = localStream.getTracks();
77
+ for (const track of tracks) {
78
+ yield this.instance.addTrack(track, localStream);
79
+ }
75
80
  }
76
81
  else {
77
82
  this.instance.addStream(localStream);
@@ -90,10 +95,11 @@ export default class Peer {
90
95
  if (!this._isOffer()) {
91
96
  return;
92
97
  }
93
- this.instance.createOffer(this._constraints)
98
+ this.instance
99
+ .createOffer(this._constraints)
94
100
  .then(this._setLocalDescription.bind(this))
95
101
  .then(this._sdpReady)
96
- .catch(error => logger.error('Peer _createOffer error:', error));
102
+ .catch((error) => logger.error('Peer _createOffer error:', error));
97
103
  }
98
104
  _createAnswer() {
99
105
  if (!this._isAnswer()) {
@@ -101,12 +107,16 @@ export default class Peer {
101
107
  }
102
108
  const { remoteSdp, useStereo } = this.options;
103
109
  const sdp = useStereo ? sdpStereoHack(remoteSdp) : remoteSdp;
104
- const sessionDescr = sdpToJsonHack({ sdp, type: PeerType.Offer });
105
- this.instance.setRemoteDescription(sessionDescr)
110
+ const sessionDescr = sdpToJsonHack({
111
+ sdp,
112
+ type: PeerType.Offer,
113
+ });
114
+ this.instance
115
+ .setRemoteDescription(sessionDescr)
106
116
  .then(() => this.instance.createAnswer())
107
117
  .then(this._setLocalDescription.bind(this))
108
118
  .then(this._sdpReady)
109
- .catch(error => logger.error('Peer _createAnswer error:', error));
119
+ .catch((error) => logger.error('Peer _createAnswer error:', error));
110
120
  }
111
121
  _setLocalDescription(sessionDescription) {
112
122
  const { useStereo, googleMaxBitrate, googleMinBitrate, googleStartBitrate } = this.options;
@@ -132,7 +142,7 @@ export default class Peer {
132
142
  const remoteVideo = sdp ? sdpHasVideo(sdp) : false;
133
143
  const sharedConstraints = {
134
144
  audio: localAudio && remoteAudio,
135
- video: localVideo && remoteVideo
145
+ video: localVideo && remoteVideo,
136
146
  };
137
147
  return sharedConstraints;
138
148
  }
@@ -146,7 +156,10 @@ export default class Peer {
146
156
  if (this._isAnswer()) {
147
157
  const { remoteSdp, useStereo } = this.options;
148
158
  const sdp = useStereo ? sdpStereoHack(remoteSdp) : remoteSdp;
149
- const sessionDescr = sdpToJsonHack({ sdp, type: PeerType.Offer });
159
+ const sessionDescr = sdpToJsonHack({
160
+ sdp,
161
+ type: PeerType.Offer,
162
+ });
150
163
  sharedConstraints = this._getSharedConstraints(localConstraints, sessionDescr.sdp);
151
164
  }
152
165
  return getUserMedia(sharedConstraints);
@@ -159,8 +172,10 @@ export default class Peer {
159
172
  return this.type === PeerType.Answer;
160
173
  }
161
174
  _config() {
162
- const { iceServers = [], iceTransportPolicy = 'all', disableUdpIceServers = false } = this.options;
163
- const filteredIceServers = filterIceServers(iceServers, { disableUdpIceServers });
175
+ const { iceServers = [], iceTransportPolicy = 'all', disableUdpIceServers = false, } = this.options;
176
+ const filteredIceServers = filterIceServers(iceServers, {
177
+ disableUdpIceServers,
178
+ });
164
179
  const config = {
165
180
  iceTransportPolicy,
166
181
  sdpSemantics: 'unified-plan',
@@ -171,14 +186,17 @@ export default class Peer {
171
186
  return config;
172
187
  }
173
188
  _getSenderByKind(kind) {
174
- if (this.instance) {
175
- return this.instance.getSenders().find(({ track }) => (track && track.kind === kind));
176
- }
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ if (this.instance) {
191
+ const senders = yield this.instance.getSenders();
192
+ return senders.find(({ track }) => track && track.kind === kind);
193
+ }
194
+ });
177
195
  }
178
196
  applyMediaConstraints(kind, constraints) {
179
197
  return __awaiter(this, void 0, void 0, function* () {
180
198
  try {
181
- const sender = this._getSenderByKind(kind);
199
+ const sender = yield this._getSenderByKind(kind);
182
200
  if (!sender || !sender.track) {
183
201
  return logger.info('No sender to apply constraints', kind, constraints);
184
202
  }
@@ -0,0 +1,51 @@
1
+ import * as WebRTC from '../util/webrtc';
2
+ export interface IWebRTCOverridesManager {
3
+ RTCPeerConnection: (params: any) => RTCPeerConnection;
4
+ getUserMedia: typeof WebRTC.getUserMedia;
5
+ getDisplayMedia: typeof WebRTC.getDisplayMedia;
6
+ enumerateDevices: typeof WebRTC.enumerateDevices;
7
+ getSupportedConstraints: typeof WebRTC.getSupportedConstraints;
8
+ attachMediaStream: typeof WebRTC.attachMediaStream;
9
+ streamIsValid: typeof WebRTC.streamIsValid;
10
+ }
11
+ export declare class WebRTCOverridesManager implements IWebRTCOverridesManager {
12
+ private constructor();
13
+ private static _instance;
14
+ private _RTCPeerConnection;
15
+ private _getUserMedia;
16
+ private _getDisplayMedia;
17
+ private _enumerateDevices;
18
+ private _getSupportedConstraints;
19
+ private _attachMediaStream;
20
+ private _streamIsValid;
21
+ static getInstance(): WebRTCOverridesManager;
22
+ get RTCPeerConnection(): (params: any) => RTCPeerConnection;
23
+ set RTCPeerConnection(value: (params: any) => RTCPeerConnection);
24
+ get getUserMedia(): typeof WebRTC.getUserMedia;
25
+ set getUserMedia(value: typeof WebRTC.getUserMedia);
26
+ get getDisplayMedia(): (constraints: MediaStreamConstraints) => Promise<MediaStream>;
27
+ set getDisplayMedia(value: (constraints: MediaStreamConstraints) => Promise<MediaStream>);
28
+ get enumerateDevices(): () => Promise<MediaDeviceInfo[]>;
29
+ set enumerateDevices(value: () => Promise<MediaDeviceInfo[]>);
30
+ get getSupportedConstraints(): () => MediaTrackSupportedConstraints;
31
+ set getSupportedConstraints(value: () => MediaTrackSupportedConstraints);
32
+ set attachMediaStream(value: (tag: any, stream: MediaStream) => void);
33
+ get attachMediaStream(): (tag: any, stream: MediaStream) => void;
34
+ set streamIsValid(value: (stream: MediaStream) => boolean);
35
+ get streamIsValid(): (stream: MediaStream) => boolean;
36
+ }
37
+ declare const RTCPeerConnection: (params: any) => RTCPeerConnection;
38
+ declare const getUserMedia: (params: any) => Promise<MediaStream>;
39
+ declare const getDisplayMedia: (params: any) => Promise<MediaStream>;
40
+ declare const enumerateDevices: () => Promise<MediaDeviceInfo[]>;
41
+ declare const getSupportedConstraints: () => MediaTrackSupportedConstraints;
42
+ declare const streamIsValid: (stream: any) => boolean;
43
+ declare const attachMediaStream: (tag: any, stream: MediaStream) => void;
44
+ declare const detachMediaStream: (tag: any) => void;
45
+ declare const muteMediaElement: (tag: any) => void;
46
+ declare const unmuteMediaElement: (tag: any) => void;
47
+ declare const toggleMuteMediaElement: (tag: any) => void;
48
+ declare const setMediaElementSinkId: (tag: any, deviceId: string) => Promise<boolean>;
49
+ declare const sdpToJsonHack: (sdp: any) => any;
50
+ declare const stopStream: (stream: MediaStream) => void;
51
+ export { RTCPeerConnection, getUserMedia, getDisplayMedia, enumerateDevices, getSupportedConstraints, streamIsValid, attachMediaStream, detachMediaStream, sdpToJsonHack, stopStream, muteMediaElement, unmuteMediaElement, toggleMuteMediaElement, setMediaElementSinkId, };
@@ -0,0 +1,91 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { normalizeAsyncAPIs } from '../util/helpers';
11
+ import * as WebRTC from '../util/webrtc';
12
+ export class WebRTCOverridesManager {
13
+ constructor() { }
14
+ static getInstance() {
15
+ if (!this._instance) {
16
+ this._instance = new WebRTCOverridesManager();
17
+ }
18
+ return this._instance;
19
+ }
20
+ get RTCPeerConnection() {
21
+ return (params) => {
22
+ var _a;
23
+ const peerConnectionBuilder = (_a = this._RTCPeerConnection) !== null && _a !== void 0 ? _a : WebRTC.RTCPeerConnection;
24
+ const peerConnectionInstance = peerConnectionBuilder(params);
25
+ return normalizeAsyncAPIs(peerConnectionInstance, [
26
+ 'addTrack',
27
+ 'getSender',
28
+ ]);
29
+ };
30
+ }
31
+ set RTCPeerConnection(value) {
32
+ this._RTCPeerConnection = value;
33
+ }
34
+ get getUserMedia() {
35
+ var _a;
36
+ return (_a = this._getUserMedia) !== null && _a !== void 0 ? _a : WebRTC.getUserMedia;
37
+ }
38
+ set getUserMedia(value) {
39
+ this._getUserMedia = value;
40
+ }
41
+ get getDisplayMedia() {
42
+ var _a;
43
+ return (_a = this._getDisplayMedia) !== null && _a !== void 0 ? _a : WebRTC.getDisplayMedia;
44
+ }
45
+ set getDisplayMedia(value) {
46
+ this._getDisplayMedia = value;
47
+ }
48
+ get enumerateDevices() {
49
+ var _a;
50
+ return (_a = this._enumerateDevices) !== null && _a !== void 0 ? _a : WebRTC.enumerateDevices;
51
+ }
52
+ set enumerateDevices(value) {
53
+ this._enumerateDevices = value;
54
+ }
55
+ get getSupportedConstraints() {
56
+ var _a;
57
+ return (_a = this._getSupportedConstraints) !== null && _a !== void 0 ? _a : WebRTC.getSupportedConstraints;
58
+ }
59
+ set getSupportedConstraints(value) {
60
+ this._getSupportedConstraints = value;
61
+ }
62
+ set attachMediaStream(value) {
63
+ this._attachMediaStream = value;
64
+ }
65
+ get attachMediaStream() {
66
+ var _a;
67
+ return (_a = this._attachMediaStream) !== null && _a !== void 0 ? _a : WebRTC.attachMediaStream;
68
+ }
69
+ set streamIsValid(value) {
70
+ this._streamIsValid = value;
71
+ }
72
+ get streamIsValid() {
73
+ var _a;
74
+ return (_a = this._streamIsValid) !== null && _a !== void 0 ? _a : WebRTC.streamIsValid;
75
+ }
76
+ }
77
+ const RTCPeerConnection = (params) => WebRTCOverridesManager.getInstance().RTCPeerConnection(params);
78
+ const getUserMedia = (params) => WebRTCOverridesManager.getInstance().getUserMedia(params);
79
+ const getDisplayMedia = (params) => WebRTCOverridesManager.getInstance().getDisplayMedia(params);
80
+ const enumerateDevices = () => WebRTCOverridesManager.getInstance().enumerateDevices();
81
+ const getSupportedConstraints = () => WebRTCOverridesManager.getInstance().getSupportedConstraints();
82
+ const streamIsValid = (stream) => WebRTCOverridesManager.getInstance().streamIsValid(stream);
83
+ const attachMediaStream = (tag, stream) => WebRTCOverridesManager.getInstance().attachMediaStream(tag, stream);
84
+ const detachMediaStream = (tag) => WebRTC.detachMediaStream(tag);
85
+ const muteMediaElement = (tag) => WebRTC.muteMediaElement(tag);
86
+ const unmuteMediaElement = (tag) => WebRTC.unmuteMediaElement(tag);
87
+ const toggleMuteMediaElement = (tag) => WebRTC.toggleMuteMediaElement(tag);
88
+ const setMediaElementSinkId = (tag, deviceId) => __awaiter(void 0, void 0, void 0, function* () { return WebRTC.setMediaElementSinkId(tag, deviceId); });
89
+ const sdpToJsonHack = (sdp) => WebRTC.sdpToJsonHack(sdp);
90
+ const stopStream = (stream) => WebRTC.stopStream(stream);
91
+ export { RTCPeerConnection, getUserMedia, getDisplayMedia, enumerateDevices, getSupportedConstraints, streamIsValid, attachMediaStream, detachMediaStream, sdpToJsonHack, stopStream, muteMediaElement, unmuteMediaElement, toggleMuteMediaElement, setMediaElementSinkId, };
@@ -30,4 +30,4 @@ interface FilterIceServersOptions {
30
30
  declare const filterIceServers: (servers: RTCIceServer[], options?: FilterIceServersOptions) => RTCIceServer[];
31
31
  declare const sdpHasAudio: (sdp?: string) => boolean;
32
32
  declare const sdpHasVideo: (sdp?: string) => boolean;
33
- export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, filterIceServers, sdpHasAudio, sdpHasVideo };
33
+ export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, filterIceServers, sdpHasAudio, sdpHasVideo, };
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import logger from '../util/logger';
11
- import * as WebRTC from '../util/webrtc';
11
+ import * as WebRTC from './WebRTC';
12
12
  import { isDefined } from '../util/helpers';
13
13
  import { DeviceType } from './constants';
14
14
  const getUserMedia = (constraints) => __awaiter(void 0, void 0, void 0, function* () {
@@ -28,15 +28,16 @@ const getUserMedia = (constraints) => __awaiter(void 0, void 0, void 0, function
28
28
  const _constraintsByKind = (kind = null) => {
29
29
  return {
30
30
  audio: !kind || kind === DeviceType.AudioIn,
31
- video: !kind || kind === DeviceType.Video
31
+ video: !kind || kind === DeviceType.Video,
32
32
  };
33
33
  };
34
34
  const getDevices = (kind = null, fullList = false) => __awaiter(void 0, void 0, void 0, function* () {
35
- let devices = yield WebRTC.enumerateDevices().catch(error => []);
35
+ let devices = yield WebRTC.enumerateDevices().catch((error) => []);
36
36
  if (kind) {
37
37
  devices = devices.filter((d) => d.kind === kind);
38
38
  }
39
- const valid = devices.length && devices.every((d) => (d.deviceId && d.label));
39
+ const valid = devices.length &&
40
+ devices.every((d) => d.deviceId && d.label);
40
41
  if (!valid) {
41
42
  const stream = yield WebRTC.getUserMedia(_constraintsByKind(kind));
42
43
  WebRTC.stopStream(stream);
@@ -59,14 +60,23 @@ const getDevices = (kind = null, fullList = false) => __awaiter(void 0, void 0,
59
60
  });
60
61
  return devices;
61
62
  });
62
- const resolutionList = [[320, 240], [640, 360], [640, 480], [1280, 720], [1920, 1080]];
63
+ const resolutionList = [
64
+ [320, 240],
65
+ [640, 360],
66
+ [640, 480],
67
+ [1280, 720],
68
+ [1920, 1080],
69
+ ];
63
70
  const scanResolutions = (deviceId) => __awaiter(void 0, void 0, void 0, function* () {
64
71
  const supported = [];
65
- const stream = yield getUserMedia({ video: { deviceId: { exact: deviceId } } });
72
+ const stream = yield getUserMedia({
73
+ video: { deviceId: { exact: deviceId } },
74
+ });
66
75
  const videoTrack = stream.getVideoTracks()[0];
67
76
  for (let i = 0; i < resolutionList.length; i++) {
68
77
  const [width, height] = resolutionList[i];
69
- const success = yield videoTrack.applyConstraints({ width: { exact: width }, height: { exact: height } })
78
+ const success = yield videoTrack
79
+ .applyConstraints({ width: { exact: width }, height: { exact: height } })
70
80
  .then(() => true)
71
81
  .catch(() => false);
72
82
  if (success) {
@@ -80,7 +90,7 @@ const getMediaConstraints = (options) => __awaiter(void 0, void 0, void 0, funct
80
90
  let { audio = true, micId } = options;
81
91
  const { micLabel = '' } = options;
82
92
  if (micId) {
83
- micId = yield assureDeviceId(micId, micLabel, DeviceType.AudioIn).catch(error => null);
93
+ micId = yield assureDeviceId(micId, micLabel, DeviceType.AudioIn).catch((error) => null);
84
94
  if (micId) {
85
95
  if (typeof audio === 'boolean') {
86
96
  audio = {};
@@ -91,7 +101,7 @@ const getMediaConstraints = (options) => __awaiter(void 0, void 0, void 0, funct
91
101
  let { video = false, camId } = options;
92
102
  const { camLabel = '' } = options;
93
103
  if (camId) {
94
- camId = yield assureDeviceId(camId, camLabel, DeviceType.Video).catch(error => null);
104
+ camId = yield assureDeviceId(camId, camLabel, DeviceType.Video).catch((error) => null);
95
105
  if (camId) {
96
106
  if (typeof video === 'boolean') {
97
107
  video = {};
@@ -113,8 +123,10 @@ const assureDeviceId = (id, label, kind) => __awaiter(void 0, void 0, void 0, fu
113
123
  });
114
124
  const removeUnsupportedConstraints = (constraints) => {
115
125
  const supported = WebRTC.getSupportedConstraints();
116
- Object.keys(constraints).map(key => {
117
- if (!supported.hasOwnProperty(key) || constraints[key] === null || constraints[key] === undefined) {
126
+ Object.keys(constraints).map((key) => {
127
+ if (!supported.hasOwnProperty(key) ||
128
+ constraints[key] === null ||
129
+ constraints[key] === undefined) {
118
130
  delete constraints[key];
119
131
  }
120
132
  });
@@ -122,7 +134,7 @@ const removeUnsupportedConstraints = (constraints) => {
122
134
  const checkDeviceIdConstraints = (id, label, kind, constraints) => __awaiter(void 0, void 0, void 0, function* () {
123
135
  const { deviceId } = constraints;
124
136
  if (!isDefined(deviceId) && (id || label)) {
125
- const deviceId = yield assureDeviceId(id, label, kind).catch(error => null);
137
+ const deviceId = yield assureDeviceId(id, label, kind).catch((error) => null);
126
138
  if (deviceId) {
127
139
  constraints.deviceId = { exact: deviceId };
128
140
  }
@@ -132,7 +144,7 @@ const checkDeviceIdConstraints = (id, label, kind, constraints) => __awaiter(voi
132
144
  const sdpStereoHack = (sdp) => {
133
145
  const endOfLine = '\r\n';
134
146
  const sdpLines = sdp.split(endOfLine);
135
- const opusIndex = sdpLines.findIndex(s => /^a=rtpmap/.test(s) && /opus\/48000/.test(s));
147
+ const opusIndex = sdpLines.findIndex((s) => /^a=rtpmap/.test(s) && /opus\/48000/.test(s));
136
148
  if (opusIndex < 0) {
137
149
  return sdp;
138
150
  }
@@ -143,7 +155,7 @@ const sdpStereoHack = (sdp) => {
143
155
  };
144
156
  const opusPayload = getCodecPayloadType(sdpLines[opusIndex]);
145
157
  const pattern = new RegExp(`a=fmtp:${opusPayload}`);
146
- const fmtpLineIndex = sdpLines.findIndex(s => pattern.test(s));
158
+ const fmtpLineIndex = sdpLines.findIndex((s) => pattern.test(s));
147
159
  if (fmtpLineIndex >= 0) {
148
160
  if (!/stereo=1;/.test(sdpLines[fmtpLineIndex])) {
149
161
  sdpLines[fmtpLineIndex] += '; stereo=1; sprop-stereo=1';
@@ -168,7 +180,7 @@ const sdpMediaOrderHack = (answer, localOffer) => {
168
180
  const answerAudioIndex = answerLines.findIndex(_isAudioLine);
169
181
  const answerVideoIndex = answerLines.findIndex(_isVideoLine);
170
182
  const audioLines = answerLines.slice(answerAudioIndex, answerVideoIndex);
171
- const videoLines = answerLines.slice(answerVideoIndex, (answerLines.length - 1));
183
+ const videoLines = answerLines.slice(answerVideoIndex, answerLines.length - 1);
172
184
  const beginLines = answerLines.slice(0, answerAudioIndex);
173
185
  return [...beginLines, ...videoLines, ...audioLines, ''].join(endOfLine);
174
186
  };
@@ -185,9 +197,11 @@ const destructSubscribeResponse = (response) => {
185
197
  alreadySubscribed: [],
186
198
  unauthorized: [],
187
199
  unsubscribed: [],
188
- notSubscribed: []
200
+ notSubscribed: [],
189
201
  };
190
- Object.keys(tmp).forEach(k => { tmp[k] = response[`${k}Channels`] || []; });
202
+ Object.keys(tmp).forEach((k) => {
203
+ tmp[k] = response[`${k}Channels`] || [];
204
+ });
191
205
  return tmp;
192
206
  };
193
207
  const enableAudioTracks = (stream) => {
@@ -258,13 +272,15 @@ const filterIceServers = (servers, options = { disableUdpIceServers: false }) =>
258
272
  const filterNonTransportTCP = (urls) => {
259
273
  const transportParam = 'transport=tcp';
260
274
  if (urls instanceof Array) {
261
- return urls.filter(url => url.includes(transportParam));
275
+ return urls.filter((url) => url.includes(transportParam));
262
276
  }
263
277
  else {
264
278
  return urls.includes(transportParam) ? urls : '';
265
279
  }
266
280
  };
267
- return servers.map(server => (Object.assign(Object.assign({}, server), { urls: disableUdpIceServers ? filterNonTransportTCP(server.urls) : server.urls })));
281
+ return servers.map((server) => (Object.assign(Object.assign({}, server), { urls: disableUdpIceServers
282
+ ? filterNonTransportTCP(server.urls)
283
+ : server.urls })));
268
284
  };
269
285
  const sdpHasAudio = (sdp = '') => {
270
286
  return /m=audio/.test(sdp);
@@ -272,4 +288,4 @@ const sdpHasAudio = (sdp = '') => {
272
288
  const sdpHasVideo = (sdp = '') => {
273
289
  return /m=video/.test(sdp);
274
290
  };
275
- export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, filterIceServers, sdpHasAudio, sdpHasVideo };
291
+ export { getUserMedia, getDevices, scanResolutions, getMediaConstraints, assureDeviceId, removeUnsupportedConstraints, checkDeviceIdConstraints, sdpStereoHack, sdpMediaOrderHack, sdpBitrateHack, checkSubscribeResponse, destructSubscribeResponse, enableAudioTracks, disableAudioTracks, toggleAudioTracks, enableVideoTracks, disableVideoTracks, toggleVideoTracks, filterIceServers, sdpHasAudio, sdpHasVideo, };
@@ -1,6 +1,6 @@
1
1
  import Relay from './src/SignalWire';
2
2
  import Verto from './src/Verto';
3
3
  import CantinaAuth from '../common/src/webrtc/CantinaAuth';
4
- export declare const VERSION = "1.4.2-rc.1";
4
+ export declare const VERSION = "1.5.0";
5
5
  export { Relay, Verto, CantinaAuth };
6
6
  export * from '../common/src/util/interfaces';
@@ -2,7 +2,7 @@ import Relay from './src/SignalWire';
2
2
  import Verto from './src/Verto';
3
3
  import { setAgentName } from '../common/src/messages/blade/Connect';
4
4
  import CantinaAuth from '../common/src/webrtc/CantinaAuth';
5
- export const VERSION = '1.4.2-rc.1';
5
+ export const VERSION = '1.5.0';
6
6
  setAgentName(`JavaScript SDK/${VERSION}`);
7
7
  export { Relay, Verto, CantinaAuth };
8
8
  export * from '../common/src/util/interfaces';
@@ -15,11 +15,17 @@ export default class SignalWire extends BrowserSession {
15
15
  execute(message) {
16
16
  let msg = message;
17
17
  if (message instanceof BaseRequest) {
18
- const params = { message: message.request };
18
+ const params = {
19
+ message: message.request,
20
+ };
19
21
  if (message.targetNodeId) {
20
22
  params.node_id = message.targetNodeId;
21
23
  }
22
- msg = new Execute({ protocol: this.relayProtocol, method: 'message', params });
24
+ msg = new Execute({
25
+ protocol: this.relayProtocol,
26
+ method: 'message',
27
+ params,
28
+ });
23
29
  }
24
30
  return super.execute(msg);
25
31
  }