@messagebird/client
Advanced tools
Comparing version 0.15.0-next.2 to 0.15.0-next.2.m.4
@@ -0,1 +1,53 @@ | ||
# [0.15.0-next.6](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.15.0-next.5...v0.15.0-next.6) (2020-03-20) | ||
### Bug Fixes | ||
* add OK ([6ab9d7b](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/6ab9d7b454081f777a10a9d93ae7056e62576ea3)) | ||
* provide whole connection, not rtcSessin ([43a5a69](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/43a5a698638e33d16a6f762a3948c1c339910c35)) | ||
### Features | ||
* add userDevices class ([d2fde7b](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/d2fde7bd2efda5022fdaded4757d90771d9999ea)) | ||
* expose userDevices property publically ([3c6b7cb](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/3c6b7cbcd1f1ec4321470819bf22ba2f4651230c)) | ||
# [0.15.0-next.5](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.15.0-next.4...v0.15.0-next.5) (2020-03-20) | ||
### Bug Fixes | ||
* test ([4de8003](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/4de8003b1d25b51f3ffa06f27f33e1ec86b14e5c)) | ||
# [0.15.0-next.4](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.15.0-next.3...v0.15.0-next.4) (2020-03-20) | ||
### Bug Fixes | ||
* rm debugging ([d401264](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/d40126440a928591817bb9eaa8461b3e84900965)) | ||
# [0.15.0-next.3](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.15.0-next.2...v0.15.0-next.3) (2020-03-20) | ||
### Bug Fixes | ||
* build tests ([ccc30f2](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/ccc30f2cf9a505658560e640c8be83a5966353b1)) | ||
# [0.15.0-next.2](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.15.0-next.1...v0.15.0-next.2) (2020-03-20) | ||
### Bug Fixes | ||
* bump ([835176c](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/835176c9afeafcacd4549a5864c20861cab3e7a8)) | ||
# [0.15.0-next.1](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.14.0...v0.15.0-next.1) (2020-03-19) | ||
### Features | ||
* add header method ([fa63289](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/fa63289c074920020c35bbf83a28b81d1caa27f4)) | ||
* calculate post dial delay ([6afa332](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/6afa3323e6dff81a832a1d5c363595f93ac02ad9)) | ||
* guard against unwanted status codes ([799d7d5](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/799d7d555882e49416a131df2df1fb0d99117c01)) | ||
* new status code ([498fbd5](https://git.messagebird.io/frontend/javascript-webrtc-sdk/commit/498fbd51fe3cc0b56bef3614ea68ba86f1b06cba)) | ||
# [0.14.0](https://git.messagebird.io/frontend/javascript-webrtc-sdk/compare/v0.13.0...v0.14.0) (2020-03-13) | ||
@@ -2,0 +54,0 @@ |
@@ -971,2 +971,191 @@ 'use strict'; | ||
var MediaManager = function MediaManager(connection) { | ||
var _this = this; | ||
_classCallCheck(this, MediaManager); | ||
_defineProperty(this, "eventEmitter", new events.EventEmitter()); | ||
_defineProperty(this, "rtcConnection", void 0); | ||
_defineProperty(this, "_handleDeviceChange", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
var devices; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return _this.get(); | ||
case 2: | ||
devices = _context.sent; | ||
_this.eventEmitter.emit('devicechange', devices); | ||
case 4: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))); | ||
_defineProperty(this, "get", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { | ||
var data, devices; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
data = { | ||
inputs: { | ||
audio: [], | ||
video: [] | ||
}, | ||
outputs: { | ||
audio: [] | ||
} | ||
}; | ||
_context2.prev = 1; | ||
_context2.next = 4; | ||
return navigator.mediaDevices.enumerateDevices(); | ||
case 4: | ||
devices = _context2.sent; | ||
devices.forEach(function (device) { | ||
var _device$kind$split = device.kind.split(/(input|output)/gi), | ||
_device$kind$split2 = _slicedToArray(_device$kind$split, 2), | ||
kind = _device$kind$split2[0], | ||
type = _device$kind$split2[1]; | ||
type === 'input' ? data.inputs[kind].push(device) : data.outputs[kind].push(device); | ||
}); | ||
_context2.next = 10; | ||
break; | ||
case 8: | ||
_context2.prev = 8; | ||
_context2.t0 = _context2["catch"](1); | ||
case 10: | ||
return _context2.abrupt("return", data); | ||
case 11: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, null, [[1, 8]]); | ||
}))); | ||
_defineProperty(this, "on", function (eventName, cb) { | ||
_this.eventEmitter.on(eventName, cb); | ||
}); | ||
_defineProperty(this, "off", function (eventName, cb) { | ||
_this.eventEmitter.off(eventName, cb); | ||
}); | ||
_defineProperty(this, "set", /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(constraints) { | ||
var senders, nextStream, _ref4, _ref5, nextTrack, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, sender; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
if (_this.rtcConnection.streamTargets) { | ||
_context3.next = 2; | ||
break; | ||
} | ||
throw new Error('Unable to set user media source as there are no active streams.'); | ||
case 2: | ||
// Specify the preferred device by ID | ||
senders = _this.rtcConnection.sipRTCSession.connection.getSenders(); | ||
_context3.next = 5; | ||
return navigator.mediaDevices.getUserMedia(constraints); | ||
case 5: | ||
nextStream = _context3.sent; | ||
_context3.next = 8; | ||
return nextStream.getTracks(); | ||
case 8: | ||
_ref4 = _context3.sent; | ||
_ref5 = _slicedToArray(_ref4, 1); | ||
nextTrack = _ref5[0]; | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context3.prev = 14; | ||
_iterator = senders[Symbol.iterator](); | ||
case 16: | ||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { | ||
_context3.next = 24; | ||
break; | ||
} | ||
sender = _step.value; | ||
sender.track.stop(); | ||
_context3.next = 21; | ||
return sender.replaceTrack(nextTrack); | ||
case 21: | ||
_iteratorNormalCompletion = true; | ||
_context3.next = 16; | ||
break; | ||
case 24: | ||
_context3.next = 30; | ||
break; | ||
case 26: | ||
_context3.prev = 26; | ||
_context3.t0 = _context3["catch"](14); | ||
_didIteratorError = true; | ||
_iteratorError = _context3.t0; | ||
case 30: | ||
_context3.prev = 30; | ||
_context3.prev = 31; | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
case 33: | ||
_context3.prev = 33; | ||
if (!_didIteratorError) { | ||
_context3.next = 36; | ||
break; | ||
} | ||
throw _iteratorError; | ||
case 36: | ||
return _context3.finish(33); | ||
case 37: | ||
return _context3.finish(30); | ||
case 38: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, null, [[14, 26, 30, 38], [31,, 33, 37]]); | ||
})); | ||
return function (_x) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}()); | ||
this.rtcConnection = connection; | ||
navigator.mediaDevices.ondevicechange = this._handleDeviceChange; | ||
}; | ||
var DEFAULT_SIP_TO = '00000'; | ||
@@ -1010,2 +1199,4 @@ var OutgoingRTCConnection = /*#__PURE__*/function (_RTCConnection) { | ||
_defineProperty(_assertThisInitialized(_this), "mediaSources", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "handleOutboundSessionAccepted", function () { | ||
@@ -1035,2 +1226,3 @@ if (_this.acceptResolver) { | ||
_this.connectionAttempt = connectionAttempt; | ||
_this.mediaSources = new MediaManager(_assertThisInitialized(_this)); | ||
_this._status = exports.ConnectionStatus.Connecting; // Add a track listener | ||
@@ -1056,3 +1248,3 @@ | ||
if (statusCode !== exports.SipStatusCodes.Ringing && statusCode !== exports.SipStatusCodes.SessionProgress) { | ||
if (statusCode !== exports.SipStatusCodes.Ringing && statusCode !== exports.SipStatusCodes.SessionProgress && statusCode !== exports.SipStatusCodes.Ok) { | ||
return; | ||
@@ -1508,2 +1700,3 @@ } // Clear any existing timeouts that may exist. | ||
exports.InternalError = InternalError; | ||
exports.MediaManager = MediaManager; | ||
exports.NotAcceptableError = NotAcceptableError; | ||
@@ -1510,0 +1703,0 @@ exports.OutgoingRTCConnection = OutgoingRTCConnection; |
import { debug } from 'jssip'; | ||
export { Device } from "./Device.js"; | ||
export * from "./MediaManager.js"; | ||
export { RTCConnection } from "./RTCConnection.js"; | ||
@@ -4,0 +5,0 @@ export { IncomingRTCConnection } from "./IncomingRTCConnection.js"; |
@@ -16,3 +16,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { getTokenHeader, getUserDataHeader, getSDKVersionHeader, getCallIDHeader } from "./headers.js"; | ||
import { FailureCauses } from "./failureCauses.js"; // For now always connect to 00000@webrtc.messagebird.com | ||
import { FailureCauses } from "./failureCauses.js"; | ||
import { MediaManager } from "./MediaManager.js"; // For now always connect to 00000@webrtc.messagebird.com | ||
@@ -57,2 +58,4 @@ var DEFAULT_SIP_TO = '00000'; | ||
_defineProperty(_assertThisInitialized(_this), "mediaSources", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "handleOutboundSessionAccepted", function () { | ||
@@ -82,2 +85,3 @@ if (_this.acceptResolver) { | ||
_this.connectionAttempt = connectionAttempt; | ||
_this.mediaSources = new MediaManager(_assertThisInitialized(_this)); | ||
_this._status = ConnectionStatus.Connecting; // Add a track listener | ||
@@ -103,3 +107,3 @@ | ||
if (statusCode !== SipStatusCodes.Ringing && statusCode !== SipStatusCodes.SessionProgress) { | ||
if (statusCode !== SipStatusCodes.Ringing && statusCode !== SipStatusCodes.SessionProgress && statusCode !== SipStatusCodes.Ok) { | ||
return; | ||
@@ -106,0 +110,0 @@ } // Clear any existing timeouts that may exist. |
@@ -6,2 +6,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
// @ts-nocheck | ||
import { SipStatusCodes, ConnectionStatus } from "./domain.js"; | ||
@@ -8,0 +9,0 @@ import { EventEmitter } from 'events'; |
@@ -26,2 +26,7 @@ /// <reference types="jest" /> | ||
} | ||
export declare class MockRTCPeerConnection implements RTCPeerConnection { | ||
addEventListener: () => void; | ||
getStats(): Promise<RTCStatsReport>; | ||
sendInfo(): void; | ||
} | ||
export declare class RTCSession { | ||
@@ -28,0 +33,0 @@ events: EventEmitter; |
export { Device } from './Device'; | ||
export * from './MediaManager'; | ||
export { RTCConnection } from './RTCConnection'; | ||
@@ -3,0 +4,0 @@ export { IncomingRTCConnection } from './IncomingRTCConnection'; |
import { SessionFailedEventData, SessionEndedEventData } from 'jssip'; | ||
import { RTCConnection } from './RTCConnection'; | ||
import UserAgent from 'UserAgent'; | ||
import { MediaManager } from './MediaManager'; | ||
export interface OutgoingSessionOptions { | ||
@@ -23,2 +24,3 @@ params?: StartConnectionOptions; | ||
private inviteDelayTimeout; | ||
mediaSources: MediaManager; | ||
constructor(ua: UserAgent, { onEnded, params, connectionAttempt, resolvers }: OutgoingSessionOptions); | ||
@@ -25,0 +27,0 @@ pickup({ timeoutMs }?: { |
@@ -9,4 +9,4 @@ /// <reference types="node" /> | ||
protected eventEmitter: EventEmitter; | ||
protected sipRTCSession: SipRTCSession; | ||
private streamTargets; | ||
sipRTCSession: SipRTCSession; | ||
streamTargets: HTMLVideoElement[]; | ||
protected _callId: string; | ||
@@ -35,3 +35,3 @@ private statsTimeout; | ||
handleMute: (muted: boolean) => Promise<boolean>; | ||
sendInfoMessage(message: Object): void; | ||
sendInfoMessage(message: any): void; | ||
private getStatsReport; | ||
@@ -38,0 +38,0 @@ private getAndSendStats; |
@@ -971,2 +971,191 @@ import { WebSocketInterface, UA, debug } from 'jssip'; | ||
var MediaManager = function MediaManager(connection) { | ||
var _this = this; | ||
_classCallCheck(this, MediaManager); | ||
_defineProperty(this, "eventEmitter", new EventEmitter()); | ||
_defineProperty(this, "rtcConnection", void 0); | ||
_defineProperty(this, "_handleDeviceChange", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { | ||
var devices; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return _this.get(); | ||
case 2: | ||
devices = _context.sent; | ||
_this.eventEmitter.emit('devicechange', devices); | ||
case 4: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))); | ||
_defineProperty(this, "get", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { | ||
var data, devices; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
data = { | ||
inputs: { | ||
audio: [], | ||
video: [] | ||
}, | ||
outputs: { | ||
audio: [] | ||
} | ||
}; | ||
_context2.prev = 1; | ||
_context2.next = 4; | ||
return navigator.mediaDevices.enumerateDevices(); | ||
case 4: | ||
devices = _context2.sent; | ||
devices.forEach(function (device) { | ||
var _device$kind$split = device.kind.split(/(input|output)/gi), | ||
_device$kind$split2 = _slicedToArray(_device$kind$split, 2), | ||
kind = _device$kind$split2[0], | ||
type = _device$kind$split2[1]; | ||
type === 'input' ? data.inputs[kind].push(device) : data.outputs[kind].push(device); | ||
}); | ||
_context2.next = 10; | ||
break; | ||
case 8: | ||
_context2.prev = 8; | ||
_context2.t0 = _context2["catch"](1); | ||
case 10: | ||
return _context2.abrupt("return", data); | ||
case 11: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, null, [[1, 8]]); | ||
}))); | ||
_defineProperty(this, "on", function (eventName, cb) { | ||
_this.eventEmitter.on(eventName, cb); | ||
}); | ||
_defineProperty(this, "off", function (eventName, cb) { | ||
_this.eventEmitter.off(eventName, cb); | ||
}); | ||
_defineProperty(this, "set", /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(constraints) { | ||
var senders, nextStream, _ref4, _ref5, nextTrack, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, sender; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
if (_this.rtcConnection.streamTargets) { | ||
_context3.next = 2; | ||
break; | ||
} | ||
throw new Error('Unable to set user media source as there are no active streams.'); | ||
case 2: | ||
// Specify the preferred device by ID | ||
senders = _this.rtcConnection.sipRTCSession.connection.getSenders(); | ||
_context3.next = 5; | ||
return navigator.mediaDevices.getUserMedia(constraints); | ||
case 5: | ||
nextStream = _context3.sent; | ||
_context3.next = 8; | ||
return nextStream.getTracks(); | ||
case 8: | ||
_ref4 = _context3.sent; | ||
_ref5 = _slicedToArray(_ref4, 1); | ||
nextTrack = _ref5[0]; | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context3.prev = 14; | ||
_iterator = senders[Symbol.iterator](); | ||
case 16: | ||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { | ||
_context3.next = 24; | ||
break; | ||
} | ||
sender = _step.value; | ||
sender.track.stop(); | ||
_context3.next = 21; | ||
return sender.replaceTrack(nextTrack); | ||
case 21: | ||
_iteratorNormalCompletion = true; | ||
_context3.next = 16; | ||
break; | ||
case 24: | ||
_context3.next = 30; | ||
break; | ||
case 26: | ||
_context3.prev = 26; | ||
_context3.t0 = _context3["catch"](14); | ||
_didIteratorError = true; | ||
_iteratorError = _context3.t0; | ||
case 30: | ||
_context3.prev = 30; | ||
_context3.prev = 31; | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
case 33: | ||
_context3.prev = 33; | ||
if (!_didIteratorError) { | ||
_context3.next = 36; | ||
break; | ||
} | ||
throw _iteratorError; | ||
case 36: | ||
return _context3.finish(33); | ||
case 37: | ||
return _context3.finish(30); | ||
case 38: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, null, [[14, 26, 30, 38], [31,, 33, 37]]); | ||
})); | ||
return function (_x) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}()); | ||
this.rtcConnection = connection; | ||
navigator.mediaDevices.ondevicechange = this._handleDeviceChange; | ||
}; | ||
var DEFAULT_SIP_TO = '00000'; | ||
@@ -1010,2 +1199,4 @@ var OutgoingRTCConnection = /*#__PURE__*/function (_RTCConnection) { | ||
_defineProperty(_assertThisInitialized(_this), "mediaSources", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "handleOutboundSessionAccepted", function () { | ||
@@ -1035,2 +1226,3 @@ if (_this.acceptResolver) { | ||
_this.connectionAttempt = connectionAttempt; | ||
_this.mediaSources = new MediaManager(_assertThisInitialized(_this)); | ||
_this._status = ConnectionStatus.Connecting; // Add a track listener | ||
@@ -1056,3 +1248,3 @@ | ||
if (statusCode !== SipStatusCodes.Ringing && statusCode !== SipStatusCodes.SessionProgress) { | ||
if (statusCode !== SipStatusCodes.Ringing && statusCode !== SipStatusCodes.SessionProgress && statusCode !== SipStatusCodes.Ok) { | ||
return; | ||
@@ -1503,3 +1695,3 @@ } // Clear any existing timeouts that may exist. | ||
export { BadRequestError, ConnectionStatus, Device, ErrorCodes, ForbiddenError, IncomingRTCConnection, InternalError, NotAcceptableError, OutgoingRTCConnection, RTCConnection, SipStatusCodes, __internalToggleDebugMode }; | ||
export { BadRequestError, ConnectionStatus, Device, ErrorCodes, ForbiddenError, IncomingRTCConnection, InternalError, MediaManager, NotAcceptableError, OutgoingRTCConnection, RTCConnection, SipStatusCodes, __internalToggleDebugMode }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@messagebird/client", | ||
"version": "0.15.0-next.2", | ||
"version": "0.15.0-next.2.m.4", | ||
"license": "UNLICENSED", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
446731
51
4748