diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-07-02 23:15:40 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-07-03 13:53:54 +0300 |
commit | 64828d50d43e542b6fc57e9a343680239991a4bc (patch) | |
tree | 6eecafd4271e510f49d7cc50be320ca1610acd66 | |
parent | 402a6d021f6e3ccb4e32fc299b9e536b266461a2 (diff) |
Use shared Browserslist config for Babel in root
Browserslist is used by Babel, which in turn is used in Talk to bundle
the SimpleWebRTC code with its dependencies (like WebRTC adapter). Until
recently, in the server its configuration was got from the Babel config,
but now it is stated in the "package.json" file. However, it is not
hardcoded, but provided through a new NPM module,
"browserslist-config-nextcloud". Browserslist gets its configuration
from the "package.json" in current or parent directories, so if
SimpleWebRTC was bundled and the "spreed" directory was a subdirectory
of the "server" directory of Nextcloud Browserslists got its
configuration from the "package.json" file in the server. In that case
the bundle failed because "browserslist-config-nextcloud" was not part
of the modules installed for Talk development.
To prevent that, now "browserslist-config-nextcloud" is a development
dependency of Talk. Also, for consistency,
"browserslist-config-nextcloud" is now always used when bundling
SimpleWebRTC, so the result is the same whether the Talk directory is a
subdirectory of the server or not when performing the bundle.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | js/simplewebrtc/bundled.js | 70 | ||||
-rw-r--r-- | package-lock.json | 6 | ||||
-rw-r--r-- | package.json | 6 |
3 files changed, 46 insertions, 36 deletions
diff --git a/js/simplewebrtc/bundled.js b/js/simplewebrtc/bundled.js index c649c5ff8..b45c1efdd 100644 --- a/js/simplewebrtc/bundled.js +++ b/js/simplewebrtc/bundled.js @@ -17,7 +17,7 @@ var getUserMedia = function getUserMedia(constraints, callback) { window.navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { callback(null, stream); - })["catch"](function (error) { + }).catch(function (error) { callback(error, null); }); }; // cache for constraints and callback @@ -41,7 +41,7 @@ module.exports = function (mode, constraints, cb) { video: true }).then(function (stream) { callback(null, stream); - })["catch"](function (error) { + }).catch(function (error) { callback(error, null); }); } else if (navigator.webkitGetUserMedia) { @@ -327,7 +327,7 @@ LocalMedia.prototype.start = function (mediaConstraints, cb) { if (cb) { return cb(null, stream); } - })["catch"](function (err) { + }).catch(function (err) { // Fallback for users without a camera if (self.config.audioFallback && err.name === 'NotFoundError' && constraints.video !== false) { constraints.video = false; @@ -705,10 +705,10 @@ Peer.prototype.offer = function (options) { } this.send('offer', offer); - }.bind(this))["catch"](function (error) { + }.bind(this)).catch(function (error) { console.warn("setLocalDescription for offer failed: ", error); }.bind(this)); - }.bind(this))["catch"](function (error) { + }.bind(this)).catch(function (error) { console.warn("createOffer failed: ", error); }.bind(this)); }; @@ -716,7 +716,7 @@ Peer.prototype.offer = function (options) { Peer.prototype.handleOffer = function (offer) { this.pc.setRemoteDescription(offer).then(function () { this.answer(); - }.bind(this))["catch"](function (error) { + }.bind(this)).catch(function (error) { console.warn("setRemoteDescription for offer failed: ", error); }.bind(this)); }; @@ -736,16 +736,16 @@ Peer.prototype.answer = function () { } this.send('answer', answer); - }.bind(this))["catch"](function (error) { + }.bind(this)).catch(function (error) { console.warn("setLocalDescription for answer failed: ", error); }.bind(this)); - }.bind(this))["catch"](function (error) { + }.bind(this)).catch(function (error) { console.warn("createAnswer failed: ", error); }.bind(this)); }; Peer.prototype.handleAnswer = function (answer) { - this.pc.setRemoteDescription(answer)["catch"](function (error) { + this.pc.setRemoteDescription(answer).catch(function (error) { console.warn("setRemoteDescription for answer failed: ", error); }.bind(this)); }; @@ -3698,11 +3698,11 @@ module.exports = function (window, edgeVersion) { }); stream = streams[remoteMsid.stream]; } else { - if (!streams["default"]) { - streams["default"] = new window.MediaStream(); + if (!streams.default) { + streams.default = new window.MediaStream(); } - stream = streams["default"]; + stream = streams.default; } if (stream) { @@ -3791,12 +3791,12 @@ module.exports = function (window, edgeVersion) { addTrackToStreamAndFireEvent(track, streams[remoteMsid.stream]); receiverList.push([track, rtpReceiver, streams[remoteMsid.stream]]); } else { - if (!streams["default"]) { - streams["default"] = new window.MediaStream(); + if (!streams.default) { + streams.default = new window.MediaStream(); } - addTrackToStreamAndFireEvent(track, streams["default"]); - receiverList.push([track, rtpReceiver, streams["default"]]); + addTrackToStreamAndFireEvent(track, streams.default); + receiverList.push([track, rtpReceiver, streams.default]); } } else { // FIXME: actually the receiver should be created later. @@ -3950,7 +3950,7 @@ module.exports = function (window, edgeVersion) { newState = 'checking'; } else if (states.disconnected > 0) { newState = 'disconnected'; - } else if (states["new"] > 0) { + } else if (states.new > 0) { newState = 'new'; } else if (states.connected > 0) { newState = 'connected'; @@ -3994,7 +3994,7 @@ module.exports = function (window, edgeVersion) { newState = 'connecting'; } else if (states.disconnected > 0) { newState = 'disconnected'; - } else if (states["new"] > 0) { + } else if (states.new > 0) { newState = 'new'; } else if (states.connected > 0) { newState = 'connected'; @@ -5250,7 +5250,7 @@ var safariShim = _interopRequireWildcard(require("./safari/safari_shim")); var commonShim = _interopRequireWildcard(require("./common_shim")); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } /* * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. @@ -5421,7 +5421,7 @@ var _getusermedia = require("./getusermedia"); var _getdisplaymedia = require("./getdisplaymedia"); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -6288,7 +6288,7 @@ exports.shimGetUserMedia = shimGetUserMedia; var utils = _interopRequireWildcard(require("../utils.js")); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -6531,9 +6531,9 @@ var _sdp = _interopRequireDefault(require("sdp")); var utils = _interopRequireWildcard(require("./utils")); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -6557,7 +6557,7 @@ function shimRTCIceCandidate(window) { // Augment the native candidate with the parsed fields. var nativeCandidate = new NativeRTCIceCandidate(args); - var parsedCandidate = _sdp["default"].parseCandidate(args.candidate); + var parsedCandidate = _sdp.default.parseCandidate(args.candidate); var augmentedCandidate = Object.assign(nativeCandidate, parsedCandidate); // Add a serializer that does not serialize the extra attributes. @@ -6611,11 +6611,11 @@ function shimMaxMessageSize(window) { return false; } - var sections = _sdp["default"].splitSections(description.sdp); + var sections = _sdp.default.splitSections(description.sdp); sections.shift(); return sections.some(function (mediaSection) { - var mLine = _sdp["default"].parseMLine(mediaSection); + var mLine = _sdp.default.parseMLine(mediaSection); return mLine && mLine.kind === 'application' && mLine.protocol.indexOf('SCTP') !== -1; }); @@ -6678,7 +6678,7 @@ function shimMaxMessageSize(window) { maxMessageSize = 65535; } - var match = _sdp["default"].matchPrefix(description.sdp, 'a=max-message-size:'); + var match = _sdp.default.matchPrefix(description.sdp, 'a=max-message-size:'); if (match.length > 0) { maxMessageSize = parseInt(match[0].substr(19), 10); @@ -6898,9 +6898,9 @@ var _getusermedia = require("./getusermedia"); var _getdisplaymedia = require("./getdisplaymedia"); -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function shimPeerConnection(window) { var browserDetails = utils.detectBrowser(window); @@ -6958,7 +6958,7 @@ function shimPeerConnection(window) { window.RTCDTMFSender = window.RTCDtmfSender; } - var RTCPeerConnectionShim = (0, _rtcpeerconnectionShim["default"])(window, browserDetails.version); + var RTCPeerConnectionShim = (0, _rtcpeerconnectionShim.default)(window, browserDetails.version); window.RTCPeerConnection = function (config) { if (config && config.iceServers) { @@ -6998,7 +6998,7 @@ exports.filterIceServers = filterIceServers; var utils = _interopRequireWildcard(require("../utils")); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } // Edge does not like // 1) stun: filtered after 14393 unless ?transport=udp is present @@ -7114,7 +7114,7 @@ function shimGetUserMedia(window) { var origGetUserMedia = navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices); navigator.mediaDevices.getUserMedia = function (c) { - return origGetUserMedia(c)["catch"](function (e) { + return origGetUserMedia(c).catch(function (e) { return Promise.reject(shimError_(e)); }); }; @@ -7160,7 +7160,7 @@ var _getusermedia = require("./getusermedia"); var _getdisplaymedia = require("./getdisplaymedia"); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -7414,7 +7414,7 @@ exports.shimGetUserMedia = shimGetUserMedia; var utils = _interopRequireWildcard(require("../utils")); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } @@ -7500,7 +7500,7 @@ exports.shimCreateOfferLegacy = shimCreateOfferLegacy; var utils = _interopRequireWildcard(require("../utils")); -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } diff --git a/package-lock.json b/package-lock.json index 19eecb901..ea5a758fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1086,6 +1086,12 @@ "node-releases": "^1.1.23" } }, + "browserslist-config-nextcloud": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/browserslist-config-nextcloud/-/browserslist-config-nextcloud-0.0.1.tgz", + "integrity": "sha512-BUpPPPfE42jL2puSqfnsoOMoz6g+jqznoaoZmig4Kx1ULApBmM6iH+/7V1yblQz2PsOp39HET1byAB3h3h+kew==", + "dev": true + }, "buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", diff --git a/package.json b/package.json index 50ac209a1..1c2f35b87 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "attachmediastream": "^2.1.0", "babelify": "^10.0.0", "browserify": "^16.2.3", + "browserslist-config-nextcloud": "0.0.1", "handlebars": "^4.1.2", "hark": "^1.2.3", "mockconsole": "0.0.1", @@ -22,5 +23,8 @@ "webrtc-adapter": "^7.2.4", "webrtcsupport": "^2.2.0", "wildemitter": "^1.2.1" - } + }, + "browserslist": [ + "extends browserslist-config-nextcloud" + ] } |