@bigbinary/neeto-media-recorder 2.7.0 → 2.7.2
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/core.js +50 -48
- package/core.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { isNotEmpty, existsBy, isNot, noop } from '@bigbinary/neeto-cist';
|
|
3
|
+
import { MIME_TYPE as MIME_TYPE$1, UPLOAD_EVENT, UPLOAD_STATUS, SCREEN_RECORDER_STATUS, START_RECORDING_SOUND, RECORDING_LIMIT_REACHED_WARNING_SOUND, RECORDING_TIME_LIMIT_FREE_PLAN, SCREEN_RECORDER_ERROR, SCREEN_RECORDER_EVENT, ONE_SECOND, HALF_A_SECOND_IN_MILLISECONDS, ONE_SECOND_IN_MILLISECONDS, TWO_HUNDRED_MILLISECONDS, ONE_MINUTE_IN_MILLISECONDS, STOP_RECORDING_DUE_TO_LIMIT_REACHED_SOUND, IS_EXTENSION } from '@bigbinary/neeto-media-recorder/constants';
|
|
4
4
|
import { useMultipartS3UploadStatus as useMultipartS3UploadStatus$1, getMultipartS3Uploader as getMultipartS3Uploader$1 } from '@bigbinary/neeto-media-recorder/core';
|
|
5
5
|
import { isNotNil, min, isNil, identity, isEmpty, pick, equals, not } from 'ramda';
|
|
6
6
|
import platform from 'platform';
|
|
@@ -639,11 +639,6 @@ var DEFAULT_RETRY_CONFIG = {
|
|
|
639
639
|
retryDelay: INITIAL_RETRY_DELAY,
|
|
640
640
|
retryableStatuses: []
|
|
641
641
|
};
|
|
642
|
-
|
|
643
|
-
// No need to localize this since it will only be used in the code
|
|
644
|
-
// eslint-disable-next-line @bigbinary/neeto/hard-coded-strings-should-be-localized
|
|
645
|
-
var NETWORK_ERROR = "Network Error";
|
|
646
|
-
var TIMEOUT_ERROR = "ECONNABORTED";
|
|
647
642
|
var HAS_CHROME_NAMESPACE = (typeof chrome === "undefined" ? "undefined" : _typeof$1(chrome)) === "object";
|
|
648
643
|
HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);
|
|
649
644
|
platform.name === "Safari";
|
|
@@ -675,12 +670,11 @@ var buildRetryableApi = function buildRetryableApi(apiConnector) {
|
|
|
675
670
|
_ref$retries = _ref.retries,
|
|
676
671
|
retries = _ref$retries === void 0 ? TOTAL_RETRIES : _ref$retries,
|
|
677
672
|
_ref$retryDelay = _ref.retryDelay,
|
|
678
|
-
retryDelay = _ref$retryDelay === void 0 ? INITIAL_RETRY_DELAY : _ref$retryDelay
|
|
679
|
-
retryableStatuses = _ref.retryableStatuses;
|
|
673
|
+
retryDelay = _ref$retryDelay === void 0 ? INITIAL_RETRY_DELAY : _ref$retryDelay;
|
|
680
674
|
return /*#__PURE__*/function () {
|
|
681
675
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(apiConnectorArgs) {
|
|
682
676
|
var _config$signal;
|
|
683
|
-
var _apiConnectorArgs$con, config, remainingAttempts, shouldCancelRetries, _error$config, _error$response,
|
|
677
|
+
var _apiConnectorArgs$con, config, remainingAttempts, shouldCancelRetries, _error$config, _error$response, _error$response2;
|
|
684
678
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
685
679
|
while (1) switch (_context.prev = _context.next) {
|
|
686
680
|
case 0:
|
|
@@ -692,7 +686,7 @@ var buildRetryableApi = function buildRetryableApi(apiConnector) {
|
|
|
692
686
|
});
|
|
693
687
|
case 4:
|
|
694
688
|
if (!(remainingAttempts-- && !shouldCancelRetries)) {
|
|
695
|
-
_context.next =
|
|
689
|
+
_context.next = 24;
|
|
696
690
|
break;
|
|
697
691
|
}
|
|
698
692
|
_context.prev = 5;
|
|
@@ -703,28 +697,26 @@ var buildRetryableApi = function buildRetryableApi(apiConnector) {
|
|
|
703
697
|
case 11:
|
|
704
698
|
_context.prev = 11;
|
|
705
699
|
_context.t0 = _context["catch"](5);
|
|
706
|
-
logger.error("buildRetryableApi -> Failed to connect, remainingAttempts:", _context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$config = _context.t0.config) === null || _error$config === void 0 ? void 0 : _error$config.url, remainingAttempts);
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
if (!(isRetryableError && remainingAttempts > 0)) {
|
|
710
|
-
_context.next = 23;
|
|
700
|
+
logger.error("buildRetryableApi -> Failed to connect, remainingAttempts:", _context.t0 === null || _context.t0 === void 0 ? void 0 : (_error$config = _context.t0.config) === null || _error$config === void 0 ? void 0 : _error$config.url, (_error$response = _context.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.status, remainingAttempts);
|
|
701
|
+
if (!(((_error$response2 = _context.t0.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== 401 && remainingAttempts > 0)) {
|
|
702
|
+
_context.next = 21;
|
|
711
703
|
break;
|
|
712
704
|
}
|
|
713
|
-
logger.info("buildRetryableApi -> Failed to connect
|
|
714
|
-
_context.next =
|
|
705
|
+
logger.info("buildRetryableApi -> Failed to connect -> retry in:", retryDelay);
|
|
706
|
+
_context.next = 18;
|
|
715
707
|
return sleep(retryDelay);
|
|
716
|
-
case
|
|
708
|
+
case 18:
|
|
717
709
|
retryDelay = min(retryDelay * 2, MAX_RETRY_DELAY);
|
|
718
|
-
_context.next =
|
|
710
|
+
_context.next = 22;
|
|
719
711
|
break;
|
|
720
|
-
case
|
|
712
|
+
case 21:
|
|
721
713
|
throw _context.t0;
|
|
722
|
-
case
|
|
714
|
+
case 22:
|
|
723
715
|
_context.next = 4;
|
|
724
716
|
break;
|
|
725
|
-
case
|
|
717
|
+
case 24:
|
|
726
718
|
throw new RetryError("Request cancelled or request retries exhausted");
|
|
727
|
-
case
|
|
719
|
+
case 25:
|
|
728
720
|
case "end":
|
|
729
721
|
return _context.stop();
|
|
730
722
|
}
|
|
@@ -843,6 +835,17 @@ var getMediaRecorderOptions = function getMediaRecorderOptions() {
|
|
|
843
835
|
mimeType: mimeType
|
|
844
836
|
};
|
|
845
837
|
};
|
|
838
|
+
var addGainNode = function addGainNode(audioStream) {
|
|
839
|
+
var gain = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1.5;
|
|
840
|
+
var audioContext = new AudioContext();
|
|
841
|
+
var audioStreamSource = audioContext.createMediaStreamSource(audioStream);
|
|
842
|
+
var destinationStream = audioContext.createMediaStreamDestination();
|
|
843
|
+
var gainNode = audioContext.createGain();
|
|
844
|
+
gainNode.gain.value = gain;
|
|
845
|
+
audioStreamSource.connect(gainNode);
|
|
846
|
+
gainNode.connect(destinationStream);
|
|
847
|
+
return destinationStream.stream;
|
|
848
|
+
};
|
|
846
849
|
|
|
847
850
|
var s3AxiosInstance = axios.create({
|
|
848
851
|
headers: {
|
|
@@ -858,9 +861,7 @@ var presignedUpload = function presignedUpload(_ref) {
|
|
|
858
861
|
config = _ref.config;
|
|
859
862
|
return s3AxiosInstance.put(presignedUrl, blob, config);
|
|
860
863
|
};
|
|
861
|
-
var retryablePresignedUpload = buildRetryableApi(presignedUpload
|
|
862
|
-
retryableStatuses: RETRYABLE_ERRORS
|
|
863
|
-
});
|
|
864
|
+
var retryablePresignedUpload = buildRetryableApi(presignedUpload);
|
|
864
865
|
var s3Api = {
|
|
865
866
|
presignedUpload: retryablePresignedUpload
|
|
866
867
|
};
|
|
@@ -1825,7 +1826,7 @@ var ScreenRecorder = /*#__PURE__*/function () {
|
|
|
1825
1826
|
});
|
|
1826
1827
|
_context2.prev = 1;
|
|
1827
1828
|
if (!_classPrivateFieldGet(_this, _audio)) {
|
|
1828
|
-
_context2.next =
|
|
1829
|
+
_context2.next = 25;
|
|
1829
1830
|
break;
|
|
1830
1831
|
}
|
|
1831
1832
|
_context2.next = 5;
|
|
@@ -1836,46 +1837,47 @@ var ScreenRecorder = /*#__PURE__*/function () {
|
|
|
1836
1837
|
});
|
|
1837
1838
|
case 5:
|
|
1838
1839
|
audioStream = _context2.sent;
|
|
1840
|
+
audioStream = addGainNode(audioStream, 1.75); // Increase volume by 50%
|
|
1839
1841
|
_classPrivateFieldSet(_this, _audioStream, audioStream);
|
|
1840
1842
|
if (!_classPrivateFieldGet(_this, _enableNoiseCancellation)) {
|
|
1841
|
-
_context2.next =
|
|
1843
|
+
_context2.next = 25;
|
|
1842
1844
|
break;
|
|
1843
1845
|
}
|
|
1844
|
-
_context2.prev =
|
|
1846
|
+
_context2.prev = 9;
|
|
1845
1847
|
workletUrl = IS_EXTENSION ? chrome.runtime.getURL("public/NoiseSuppressorWorklet.js") : "NoiseSuppressorWorklet.js";
|
|
1846
1848
|
audioContext = new AudioContext();
|
|
1847
|
-
_context2.next =
|
|
1849
|
+
_context2.next = 14;
|
|
1848
1850
|
return audioContext.audioWorklet.addModule(workletUrl);
|
|
1849
|
-
case
|
|
1851
|
+
case 14:
|
|
1850
1852
|
audioStreamSource = audioContext.createMediaStreamSource(audioStream);
|
|
1851
1853
|
destinationStream = audioContext.createMediaStreamDestination();
|
|
1852
1854
|
noiseSuppressorNode = new AudioWorkletNode(audioContext, "nn-suppressor-processor");
|
|
1853
1855
|
audioStreamSource.connect(noiseSuppressorNode);
|
|
1854
1856
|
noiseSuppressorNode.connect(destinationStream);
|
|
1855
1857
|
_classPrivateFieldSet(_this, _audioStream, destinationStream.stream);
|
|
1856
|
-
_context2.next =
|
|
1858
|
+
_context2.next = 25;
|
|
1857
1859
|
break;
|
|
1858
|
-
case
|
|
1859
|
-
_context2.prev =
|
|
1860
|
-
_context2.t0 = _context2["catch"](
|
|
1860
|
+
case 22:
|
|
1861
|
+
_context2.prev = 22;
|
|
1862
|
+
_context2.t0 = _context2["catch"](9);
|
|
1861
1863
|
console.error("Failed to load audio worklet:", _context2.t0);
|
|
1862
|
-
case
|
|
1864
|
+
case 25:
|
|
1863
1865
|
if (!_classPrivateFieldGet(_this, _videoStream)) {
|
|
1864
|
-
_context2.next =
|
|
1866
|
+
_context2.next = 29;
|
|
1865
1867
|
break;
|
|
1866
1868
|
}
|
|
1867
1869
|
stream = _classPrivateFieldGet(_this, _videoStream);
|
|
1868
|
-
_context2.next =
|
|
1870
|
+
_context2.next = 32;
|
|
1869
1871
|
break;
|
|
1870
|
-
case
|
|
1871
|
-
_context2.next =
|
|
1872
|
+
case 29:
|
|
1873
|
+
_context2.next = 31;
|
|
1872
1874
|
return window.navigator.mediaDevices.getDisplayMedia({
|
|
1873
1875
|
video: _classPrivateFieldGet(_this, _video) || true,
|
|
1874
1876
|
audio: true
|
|
1875
1877
|
});
|
|
1876
|
-
case 30:
|
|
1877
|
-
stream = _context2.sent;
|
|
1878
1878
|
case 31:
|
|
1879
|
+
stream = _context2.sent;
|
|
1880
|
+
case 32:
|
|
1879
1881
|
// Event triggered when the user clicks on the stop sharing overlay button
|
|
1880
1882
|
stream.getVideoTracks()[0].addEventListener("ended", function () {
|
|
1881
1883
|
_this.stopRecording();
|
|
@@ -1906,10 +1908,10 @@ var ScreenRecorder = /*#__PURE__*/function () {
|
|
|
1906
1908
|
_classPrivateFieldGet(_this, _store).setState({
|
|
1907
1909
|
status: SCREEN_RECORDER_STATUS.media_acquired
|
|
1908
1910
|
});
|
|
1909
|
-
_context2.next =
|
|
1911
|
+
_context2.next = 44;
|
|
1910
1912
|
break;
|
|
1911
|
-
case
|
|
1912
|
-
_context2.prev =
|
|
1913
|
+
case 41:
|
|
1914
|
+
_context2.prev = 41;
|
|
1913
1915
|
_context2.t1 = _context2["catch"](1);
|
|
1914
1916
|
if (_classPrivateFieldGet(_this, _audio) && !_classPrivateFieldGet(_this, _audioStream)) {
|
|
1915
1917
|
_classPrivateFieldGet(_this, _store).setState({
|
|
@@ -1922,11 +1924,11 @@ var ScreenRecorder = /*#__PURE__*/function () {
|
|
|
1922
1924
|
status: SCREEN_RECORDER_STATUS.idle
|
|
1923
1925
|
});
|
|
1924
1926
|
}
|
|
1925
|
-
case
|
|
1927
|
+
case 44:
|
|
1926
1928
|
case "end":
|
|
1927
1929
|
return _context2.stop();
|
|
1928
1930
|
}
|
|
1929
|
-
}, _callee2, null, [[1,
|
|
1931
|
+
}, _callee2, null, [[1, 41], [9, 22]]);
|
|
1930
1932
|
}));
|
|
1931
1933
|
function value() {
|
|
1932
1934
|
return _value.apply(this, arguments);
|