@bigbinary/neeto-media-recorder 2.7.2 → 2.7.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios from 'axios';
2
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';
3
+ import { MIME_TYPE as MIME_TYPE$1, UPLOAD_EVENT, UPLOAD_STATUS, SCREEN_RECORDER_STATUS, START_RECORDING_SOUND, RECORDING_LIMIT_REACHED_WARNING_SOUND, STOP_RECORDING_DUE_TO_LIMIT_REACHED_SOUND, RECORDING_TIME_LIMIT_FREE_PLAN, SCREEN_RECORDER_ERROR, SCREEN_RECORDER_EVENT, HALF_A_SECOND_IN_MILLISECONDS, ONE_SECOND, ONE_SECOND_IN_MILLISECONDS, TWO_HUNDRED_MILLISECONDS, ONE_MINUTE_IN_MILLISECONDS, 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';
@@ -1494,17 +1494,21 @@ var _recordingLimitWarningAudio = /*#__PURE__*/new WeakMap();
1494
1494
  var _stopRecordingDueToLimitReachedAudio = /*#__PURE__*/new WeakMap();
1495
1495
  var _stream = /*#__PURE__*/new WeakMap();
1496
1496
  var _audioStream = /*#__PURE__*/new WeakMap();
1497
+ var _micAudioStream = /*#__PURE__*/new WeakMap();
1497
1498
  var _timeLimit = /*#__PURE__*/new WeakMap();
1498
1499
  var _startRecordingTimeoutID = /*#__PURE__*/new WeakMap();
1499
1500
  var _enableNoiseCancellation = /*#__PURE__*/new WeakMap();
1501
+ var _showCountdown = /*#__PURE__*/new WeakMap();
1500
1502
  var _mimeType = /*#__PURE__*/new WeakMap();
1503
+ var _stopAllStreams = /*#__PURE__*/new WeakMap();
1501
1504
  var _checkCompatibility = /*#__PURE__*/new WeakMap();
1502
1505
  var _acquireMediaStream = /*#__PURE__*/new WeakMap();
1503
1506
  var _fireCallbacks = /*#__PURE__*/new WeakMap();
1504
1507
  var _onRecordingStart = /*#__PURE__*/new WeakMap();
1505
1508
  var _onRecordingActive = /*#__PURE__*/new WeakMap();
1506
1509
  var _onRecordingStop = /*#__PURE__*/new WeakMap();
1507
- var _countdownAndStartRecording = /*#__PURE__*/new WeakMap();
1510
+ var _startMediaRecorder = /*#__PURE__*/new WeakMap();
1511
+ var _startCountdown = /*#__PURE__*/new WeakMap();
1508
1512
  var _startTimer = /*#__PURE__*/new WeakMap();
1509
1513
  var _stopTimer = /*#__PURE__*/new WeakMap();
1510
1514
  var _checkIfTimeLimitReached = /*#__PURE__*/new WeakMap();
@@ -1570,7 +1574,7 @@ var ScreenRecorder = /*#__PURE__*/function () {
1570
1574
  });
1571
1575
  _classPrivateFieldInitSpec(this, _stopRecordingDueToLimitReachedAudio, {
1572
1576
  writable: true,
1573
- value: void 0
1577
+ value: new Audio(STOP_RECORDING_DUE_TO_LIMIT_REACHED_SOUND)
1574
1578
  });
1575
1579
  _classPrivateFieldInitSpec(this, _stream, {
1576
1580
  writable: true,
@@ -1580,6 +1584,10 @@ var ScreenRecorder = /*#__PURE__*/function () {
1580
1584
  writable: true,
1581
1585
  value: void 0
1582
1586
  });
1587
+ _classPrivateFieldInitSpec(this, _micAudioStream, {
1588
+ writable: true,
1589
+ value: void 0
1590
+ });
1583
1591
  _classPrivateFieldInitSpec(this, _timeLimit, {
1584
1592
  writable: true,
1585
1593
  value: RECORDING_TIME_LIMIT_FREE_PLAN
@@ -1592,6 +1600,10 @@ var ScreenRecorder = /*#__PURE__*/function () {
1592
1600
  writable: true,
1593
1601
  value: false
1594
1602
  });
1603
+ _classPrivateFieldInitSpec(this, _showCountdown, {
1604
+ writable: true,
1605
+ value: true
1606
+ });
1595
1607
  _classPrivateFieldInitSpec(this, _mimeType, {
1596
1608
  writable: true,
1597
1609
  value: getSupportedMimeType()
@@ -1605,6 +1617,9 @@ var ScreenRecorder = /*#__PURE__*/function () {
1605
1617
  _defineProperty(this, "setAudioConfiguration", function (audio) {
1606
1618
  return _classPrivateFieldSet(_this, _audio, audio);
1607
1619
  });
1620
+ _defineProperty(this, "setShowCountdown", function (showCountdown) {
1621
+ return _classPrivateFieldSet(_this, _showCountdown, showCountdown);
1622
+ });
1608
1623
  _defineProperty(this, "setTimeLimit", function () {
1609
1624
  var timeLimit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : RECORDING_TIME_LIMIT_FREE_PLAN;
1610
1625
  return _classPrivateFieldSet(_this, _timeLimit, timeLimit);
@@ -1668,7 +1683,11 @@ var ScreenRecorder = /*#__PURE__*/function () {
1668
1683
  error: SCREEN_RECORDER_ERROR.NoRecorder
1669
1684
  });
1670
1685
  };
1671
- _classPrivateFieldGet(_this, _countdownAndStartRecording).call(_this);
1686
+ if (_classPrivateFieldGet(_this, _showCountdown)) {
1687
+ _classPrivateFieldGet(_this, _startCountdown).call(_this);
1688
+ } else {
1689
+ _classPrivateFieldGet(_this, _startMediaRecorder).call(_this);
1690
+ }
1672
1691
  case 19:
1673
1692
  case "end":
1674
1693
  return _context.stop();
@@ -1676,40 +1695,22 @@ var ScreenRecorder = /*#__PURE__*/function () {
1676
1695
  }, _callee);
1677
1696
  })));
1678
1697
  _defineProperty(this, "stopRecording", function () {
1679
- var _classPrivateFieldGet8, _classPrivateFieldGet12, _classPrivateFieldGet13, _classPrivateFieldGet14;
1698
+ var _classPrivateFieldGet4;
1680
1699
  if (_classPrivateFieldGet(_this, _mediaRecorder) === undefined) {
1681
- var _classPrivateFieldGet4, _classPrivateFieldGet5, _classPrivateFieldGet6, _classPrivateFieldGet7;
1682
1700
  /**
1683
1701
  * If the permission is denied and "Stop sharing" overlay is clicked
1684
1702
  */
1685
- (_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _mediaStream)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.getTracks().forEach(function (track) {
1686
- return track.stop();
1687
- });
1688
- (_classPrivateFieldGet5 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.getTracks().forEach(function (track) {
1689
- return track.stop();
1690
- });
1691
- (_classPrivateFieldGet6 = _classPrivateFieldGet(_this, _audioStream)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : (_classPrivateFieldGet7 = _classPrivateFieldGet6.getAudioTracks()) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.forEach(function (track) {
1692
- return track.stop();
1693
- });
1703
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1694
1704
  return;
1695
1705
  }
1696
- if (((_classPrivateFieldGet8 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet8 === void 0 ? void 0 : _classPrivateFieldGet8.state) === "inactive") {
1697
- var _classPrivateFieldGet9, _classPrivateFieldGet10, _classPrivateFieldGet11;
1706
+ if (((_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.state) === "inactive") {
1698
1707
  // When recording is stopped from the 'Stop Sharing' overlay
1699
1708
  // before it even starts, i.e during the countdown.
1700
1709
  // Or if the recording is stopped before startRecordingTimeoutID timeout executes
1701
1710
  _this.removeCallback(SCREEN_RECORDER_EVENT.onStop);
1702
1711
  clearTimeout(_classPrivateFieldGet(_this, _startRecordingTimeoutID));
1703
1712
  clearInterval(_classPrivateFieldGet(_this, _countdownTimerId));
1704
- _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
1705
- return track.stop();
1706
- });
1707
- (_classPrivateFieldGet9 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet9 === void 0 ? void 0 : _classPrivateFieldGet9.getTracks().forEach(function (track) {
1708
- return track.stop();
1709
- });
1710
- (_classPrivateFieldGet10 = _classPrivateFieldGet(_this, _audioStream)) === null || _classPrivateFieldGet10 === void 0 ? void 0 : (_classPrivateFieldGet11 = _classPrivateFieldGet10.getAudioTracks()) === null || _classPrivateFieldGet11 === void 0 ? void 0 : _classPrivateFieldGet11.forEach(function (track) {
1711
- return track.stop();
1712
- });
1713
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1713
1714
  _classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onDiscardDuringCountdown);
1714
1715
  return;
1715
1716
  }
@@ -1717,20 +1718,12 @@ var ScreenRecorder = /*#__PURE__*/function () {
1717
1718
  status: SCREEN_RECORDER_STATUS.stopping
1718
1719
  });
1719
1720
  _classPrivateFieldGet(_this, _mediaRecorder).stop();
1720
- _classPrivateFieldGet(_this, _mediaStream) && _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
1721
- return track.stop();
1722
- });
1723
- (_classPrivateFieldGet12 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet12 === void 0 ? void 0 : _classPrivateFieldGet12.getTracks().forEach(function (track) {
1724
- return track.stop();
1725
- });
1726
- (_classPrivateFieldGet13 = _classPrivateFieldGet(_this, _audioStream)) === null || _classPrivateFieldGet13 === void 0 ? void 0 : (_classPrivateFieldGet14 = _classPrivateFieldGet13.getAudioTracks()) === null || _classPrivateFieldGet14 === void 0 ? void 0 : _classPrivateFieldGet14.forEach(function (track) {
1727
- return track.stop();
1728
- });
1721
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1729
1722
  _classPrivateFieldGet(_this, _stopTimer).call(_this);
1730
1723
  });
1731
1724
  _defineProperty(this, "pauseRecording", function () {
1732
- var _classPrivateFieldGet15;
1733
- if (((_classPrivateFieldGet15 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet15 === void 0 ? void 0 : _classPrivateFieldGet15.state) === "recording") {
1725
+ var _classPrivateFieldGet5;
1726
+ if (((_classPrivateFieldGet5 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.state) === "recording") {
1734
1727
  _classPrivateFieldGet(_this, _store).setState({
1735
1728
  status: SCREEN_RECORDER_STATUS.paused
1736
1729
  });
@@ -1739,8 +1732,8 @@ var ScreenRecorder = /*#__PURE__*/function () {
1739
1732
  _classPrivateFieldGet(_this, _stopTimer).call(_this);
1740
1733
  });
1741
1734
  _defineProperty(this, "resumeRecording", function () {
1742
- var _classPrivateFieldGet16;
1743
- if (((_classPrivateFieldGet16 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet16 === void 0 ? void 0 : _classPrivateFieldGet16.state) === "paused") {
1735
+ var _classPrivateFieldGet6;
1736
+ if (((_classPrivateFieldGet6 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.state) === "paused") {
1744
1737
  _classPrivateFieldGet(_this, _store).setState({
1745
1738
  status: SCREEN_RECORDER_STATUS.recording
1746
1739
  });
@@ -1749,19 +1742,14 @@ var ScreenRecorder = /*#__PURE__*/function () {
1749
1742
  _classPrivateFieldGet(_this, _startTimer).call(_this);
1750
1743
  });
1751
1744
  _defineProperty(this, "discardRecording", function () {
1752
- var _classPrivateFieldGet17, _classPrivateFieldGet18;
1753
- if (((_classPrivateFieldGet17 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet17 === void 0 ? void 0 : _classPrivateFieldGet17.state) === "inactive") return;
1745
+ var _classPrivateFieldGet7;
1746
+ if (((_classPrivateFieldGet7 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.state) === "inactive") return;
1754
1747
  _classPrivateFieldGet(_this, _store).setState({
1755
1748
  status: SCREEN_RECORDER_STATUS.stopping
1756
1749
  });
1757
1750
  _this.removeAllCallbacksByEvent(SCREEN_RECORDER_EVENT.onStop);
1758
1751
  _classPrivateFieldGet(_this, _mediaRecorder).stop();
1759
- _classPrivateFieldGet(_this, _mediaStream) && _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
1760
- return track.stop();
1761
- });
1762
- (_classPrivateFieldGet18 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet18 === void 0 ? void 0 : _classPrivateFieldGet18.getTracks().forEach(function (track) {
1763
- return track.stop();
1764
- });
1752
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1765
1753
  clearInterval(_classPrivateFieldGet(_this, _timerId));
1766
1754
  _classPrivateFieldGet(_this, _store).setState(pick(["elapsedTime"], initialState));
1767
1755
  _classPrivateFieldSet(_this, _mediaChunks, []);
@@ -1788,18 +1776,27 @@ var ScreenRecorder = /*#__PURE__*/function () {
1788
1776
  _classPrivateFieldGet(_this, _checkCompatibility).call(_this);
1789
1777
  });
1790
1778
  _defineProperty(this, "revokePermissions", function () {
1791
- var _classPrivateFieldGet19, _classPrivateFieldGet20, _classPrivateFieldGet21;
1792
1779
  if (!_classPrivateFieldGet(_this, _mediaRecorder)) return;
1793
1780
  _classPrivateFieldGet(_this, _mediaRecorder).onstop = null;
1794
- _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
1795
- return track.stop();
1796
- });
1797
- (_classPrivateFieldGet19 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet19 === void 0 ? void 0 : _classPrivateFieldGet19.getTracks().forEach(function (track) {
1798
- return track.stop();
1799
- });
1800
- (_classPrivateFieldGet20 = _classPrivateFieldGet(_this, _audioStream)) === null || _classPrivateFieldGet20 === void 0 ? void 0 : (_classPrivateFieldGet21 = _classPrivateFieldGet20.getAudioTracks()) === null || _classPrivateFieldGet21 === void 0 ? void 0 : _classPrivateFieldGet21.forEach(function (track) {
1801
- return track.stop();
1802
- });
1781
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1782
+ });
1783
+ _classPrivateFieldInitSpec(this, _stopAllStreams, {
1784
+ writable: true,
1785
+ value: function value() {
1786
+ var _classPrivateFieldGet8, _classPrivateFieldGet9, _classPrivateFieldGet10, _classPrivateFieldGet11, _classPrivateFieldGet12, _classPrivateFieldGet13;
1787
+ _classPrivateFieldGet(_this, _mediaStream) && ((_classPrivateFieldGet8 = _classPrivateFieldGet(_this, _mediaStream)) === null || _classPrivateFieldGet8 === void 0 ? void 0 : _classPrivateFieldGet8.getTracks().forEach(function (track) {
1788
+ return track.stop();
1789
+ }));
1790
+ (_classPrivateFieldGet9 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet9 === void 0 ? void 0 : _classPrivateFieldGet9.getTracks().forEach(function (track) {
1791
+ return track.stop();
1792
+ });
1793
+ (_classPrivateFieldGet10 = _classPrivateFieldGet(_this, _audioStream)) === null || _classPrivateFieldGet10 === void 0 ? void 0 : (_classPrivateFieldGet11 = _classPrivateFieldGet10.getAudioTracks()) === null || _classPrivateFieldGet11 === void 0 ? void 0 : _classPrivateFieldGet11.forEach(function (track) {
1794
+ return track.stop();
1795
+ });
1796
+ (_classPrivateFieldGet12 = _classPrivateFieldGet(_this, _micAudioStream)) === null || _classPrivateFieldGet12 === void 0 ? void 0 : (_classPrivateFieldGet13 = _classPrivateFieldGet12.getAudioTracks()) === null || _classPrivateFieldGet13 === void 0 ? void 0 : _classPrivateFieldGet13.forEach(function (track) {
1797
+ return track.stop();
1798
+ });
1799
+ }
1803
1800
  });
1804
1801
  _classPrivateFieldInitSpec(this, _checkCompatibility, {
1805
1802
  writable: true,
@@ -1826,58 +1823,65 @@ var ScreenRecorder = /*#__PURE__*/function () {
1826
1823
  });
1827
1824
  _context2.prev = 1;
1828
1825
  if (!_classPrivateFieldGet(_this, _audio)) {
1829
- _context2.next = 25;
1826
+ _context2.next = 29;
1830
1827
  break;
1831
1828
  }
1832
- _context2.next = 5;
1829
+ _context2.t0 = _classPrivateFieldSet;
1830
+ _context2.t1 = _this;
1831
+ _context2.t2 = _micAudioStream;
1832
+ _context2.next = 8;
1833
1833
  return window.navigator.mediaDevices.getUserMedia({
1834
1834
  audio: _classPrivateFieldGet(_this, _audio) ? _objectSpread({
1835
1835
  echoCancellation: false
1836
1836
  }, _classPrivateFieldGet(_this, _audio)) : false
1837
1837
  });
1838
- case 5:
1839
- audioStream = _context2.sent;
1840
- audioStream = addGainNode(audioStream, 1.75); // Increase volume by 50%
1838
+ case 8:
1839
+ _context2.t3 = _context2.sent;
1840
+ (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t3);
1841
+ audioStream = addGainNode(_classPrivateFieldGet(_this, _micAudioStream), 1.75); // Increase volume by 50%
1841
1842
  _classPrivateFieldSet(_this, _audioStream, audioStream);
1842
1843
  if (!_classPrivateFieldGet(_this, _enableNoiseCancellation)) {
1843
- _context2.next = 25;
1844
+ _context2.next = 29;
1844
1845
  break;
1845
1846
  }
1846
- _context2.prev = 9;
1847
- workletUrl = IS_EXTENSION ? chrome.runtime.getURL("public/NoiseSuppressorWorklet.js") : "NoiseSuppressorWorklet.js";
1847
+ _context2.prev = 13;
1848
+ workletUrl = IS_EXTENSION ?
1849
+ // eslint-disable-next-line no-undef
1850
+ chrome.runtime.getURL("public/NoiseSuppressorWorklet.js") : "NoiseSuppressorWorklet.js";
1848
1851
  audioContext = new AudioContext();
1849
- _context2.next = 14;
1852
+ _context2.next = 18;
1850
1853
  return audioContext.audioWorklet.addModule(workletUrl);
1851
- case 14:
1854
+ case 18:
1852
1855
  audioStreamSource = audioContext.createMediaStreamSource(audioStream);
1853
1856
  destinationStream = audioContext.createMediaStreamDestination();
1854
1857
  noiseSuppressorNode = new AudioWorkletNode(audioContext, "nn-suppressor-processor");
1855
1858
  audioStreamSource.connect(noiseSuppressorNode);
1856
1859
  noiseSuppressorNode.connect(destinationStream);
1857
1860
  _classPrivateFieldSet(_this, _audioStream, destinationStream.stream);
1858
- _context2.next = 25;
1861
+ _context2.next = 29;
1859
1862
  break;
1860
- case 22:
1861
- _context2.prev = 22;
1862
- _context2.t0 = _context2["catch"](9);
1863
- console.error("Failed to load audio worklet:", _context2.t0);
1864
- case 25:
1863
+ case 26:
1864
+ _context2.prev = 26;
1865
+ _context2.t4 = _context2["catch"](13);
1866
+ // eslint-disable-next-line no-console
1867
+ console.error("Failed to load audio worklet:", _context2.t4);
1868
+ case 29:
1865
1869
  if (!_classPrivateFieldGet(_this, _videoStream)) {
1866
- _context2.next = 29;
1870
+ _context2.next = 33;
1867
1871
  break;
1868
1872
  }
1869
1873
  stream = _classPrivateFieldGet(_this, _videoStream);
1870
- _context2.next = 32;
1874
+ _context2.next = 36;
1871
1875
  break;
1872
- case 29:
1873
- _context2.next = 31;
1876
+ case 33:
1877
+ _context2.next = 35;
1874
1878
  return window.navigator.mediaDevices.getDisplayMedia({
1875
1879
  video: _classPrivateFieldGet(_this, _video) || true,
1876
1880
  audio: true
1877
1881
  });
1878
- case 31:
1882
+ case 35:
1879
1883
  stream = _context2.sent;
1880
- case 32:
1884
+ case 36:
1881
1885
  // Event triggered when the user clicks on the stop sharing overlay button
1882
1886
  stream.getVideoTracks()[0].addEventListener("ended", function () {
1883
1887
  _this.stopRecording();
@@ -1908,11 +1912,11 @@ var ScreenRecorder = /*#__PURE__*/function () {
1908
1912
  _classPrivateFieldGet(_this, _store).setState({
1909
1913
  status: SCREEN_RECORDER_STATUS.media_acquired
1910
1914
  });
1911
- _context2.next = 44;
1915
+ _context2.next = 48;
1912
1916
  break;
1913
- case 41:
1914
- _context2.prev = 41;
1915
- _context2.t1 = _context2["catch"](1);
1917
+ case 45:
1918
+ _context2.prev = 45;
1919
+ _context2.t5 = _context2["catch"](1);
1916
1920
  if (_classPrivateFieldGet(_this, _audio) && !_classPrivateFieldGet(_this, _audioStream)) {
1917
1921
  _classPrivateFieldGet(_this, _store).setState({
1918
1922
  error: SCREEN_RECORDER_ERROR.MicPermissionDenied,
@@ -1920,15 +1924,15 @@ var ScreenRecorder = /*#__PURE__*/function () {
1920
1924
  });
1921
1925
  } else if (!_classPrivateFieldGet(_this, _mediaStream) || isStreamEnded(_classPrivateFieldGet(_this, _mediaStream))) {
1922
1926
  _classPrivateFieldGet(_this, _store).setState({
1923
- error: SCREEN_RECORDER_ERROR[_context2.t1.name],
1927
+ error: SCREEN_RECORDER_ERROR[_context2.t5.name],
1924
1928
  status: SCREEN_RECORDER_STATUS.idle
1925
1929
  });
1926
1930
  }
1927
- case 44:
1931
+ case 48:
1928
1932
  case "end":
1929
1933
  return _context2.stop();
1930
1934
  }
1931
- }, _callee2, null, [[1, 41], [9, 22]]);
1935
+ }, _callee2, null, [[1, 45], [13, 26]]);
1932
1936
  }));
1933
1937
  function value() {
1934
1938
  return _value.apply(this, arguments);
@@ -1939,9 +1943,9 @@ var ScreenRecorder = /*#__PURE__*/function () {
1939
1943
  _classPrivateFieldInitSpec(this, _fireCallbacks, {
1940
1944
  writable: true,
1941
1945
  value: function value(event) {
1942
- var _classPrivateFieldGet22;
1946
+ var _classPrivateFieldGet14;
1943
1947
  var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1944
- (_classPrivateFieldGet22 = _classPrivateFieldGet(_this, _callbacks)[event]) === null || _classPrivateFieldGet22 === void 0 ? void 0 : _classPrivateFieldGet22.forEach(function (callback) {
1948
+ (_classPrivateFieldGet14 = _classPrivateFieldGet(_this, _callbacks)[event]) === null || _classPrivateFieldGet14 === void 0 ? void 0 : _classPrivateFieldGet14.forEach(function (callback) {
1945
1949
  callback.apply(void 0, _toConsumableArray(args));
1946
1950
  });
1947
1951
  }
@@ -1980,7 +1984,59 @@ var ScreenRecorder = /*#__PURE__*/function () {
1980
1984
  }
1981
1985
  }
1982
1986
  });
1983
- _classPrivateFieldInitSpec(this, _countdownAndStartRecording, {
1987
+ _classPrivateFieldInitSpec(this, _startMediaRecorder, {
1988
+ writable: true,
1989
+ value: function value() {
1990
+ _classPrivateFieldSet(_this, _startRecordingTimeoutID, setTimeout(function () {
1991
+ try {
1992
+ _classPrivateFieldGet(_this, _logger).info("starting mediaRecorder");
1993
+ if (!_classPrivateFieldGet(_this, _mediaRecorder)) {
1994
+ _classPrivateFieldGet(_this, _logger).info("mediaRecorder is not defined");
1995
+ _classPrivateFieldGet(_this, _store).setState({
1996
+ status: SCREEN_RECORDER_STATUS.idle,
1997
+ error: SCREEN_RECORDER_ERROR.FailedToStart
1998
+ });
1999
+ return;
2000
+ }
2001
+ if (!_classPrivateFieldGet(_this, _mediaStream) || isStreamEnded(_classPrivateFieldGet(_this, _mediaStream))) {
2002
+ _classPrivateFieldGet(_this, _logger).info("media stream ended, not starting mediaRecorder");
2003
+ _classPrivateFieldGet(_this, _store).setState({
2004
+ status: SCREEN_RECORDER_STATUS.idle,
2005
+ error: SCREEN_RECORDER_ERROR.FailedToStart
2006
+ });
2007
+ return;
2008
+ }
2009
+ _classPrivateFieldGet(_this, _store).setState({
2010
+ status: SCREEN_RECORDER_STATUS.recording
2011
+ });
2012
+ _classPrivateFieldGet(_this, _mediaRecorder).start(5000);
2013
+ _classPrivateFieldGet(_this, _logger).info("started mediaRecorder");
2014
+ _classPrivateFieldGet(_this, _startTimer).call(_this);
2015
+ } catch (error) {
2016
+ _classPrivateFieldGet(_this, _logger).info("Failed to start mediaRecorder", error);
2017
+ _classPrivateFieldGet(_this, _store).setState({
2018
+ status: SCREEN_RECORDER_STATUS.idle,
2019
+ error: SCREEN_RECORDER_ERROR.FailedToStart
2020
+ });
2021
+
2022
+ // To prevent triggering #onRecordingStop when the mediaRecorder is failed to start.
2023
+ if (_classPrivateFieldGet(_this, _mediaRecorder)) {
2024
+ _classPrivateFieldGet(_this, _mediaRecorder).onstop = noop;
2025
+ }
2026
+ if (_classPrivateFieldGet(_this, _mediaStream)) {
2027
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
2028
+ _classPrivateFieldSet(_this, _mediaStream, null);
2029
+ }
2030
+ _classPrivateFieldSet(_this, _stream, null);
2031
+ _classPrivateFieldSet(_this, _audioStream, null);
2032
+ _classPrivateFieldSet(_this, _micAudioStream, null);
2033
+ _classPrivateFieldSet(_this, _mediaRecorder, null);
2034
+ throw error;
2035
+ }
2036
+ }, HALF_A_SECOND_IN_MILLISECONDS));
2037
+ }
2038
+ });
2039
+ _classPrivateFieldInitSpec(this, _startCountdown, {
1984
2040
  writable: true,
1985
2041
  value: function value() {
1986
2042
  if (_classPrivateFieldGet(_this, _countdownTimerId)) return;
@@ -1999,56 +2055,9 @@ var ScreenRecorder = /*#__PURE__*/function () {
1999
2055
  }
2000
2056
  _classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onCountdown, [0]);
2001
2057
  _classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onCountdownEnd);
2002
- _classPrivateFieldGet(_this, _store).setState({
2003
- status: SCREEN_RECORDER_STATUS.recording
2004
- });
2005
2058
  clearInterval(_classPrivateFieldGet(_this, _countdownTimerId));
2006
2059
  _classPrivateFieldSet(_this, _countdownTimerId, null);
2007
- _classPrivateFieldSet(_this, _startRecordingTimeoutID, setTimeout(function () {
2008
- try {
2009
- _classPrivateFieldGet(_this, _logger).info("starting mediaRecorder");
2010
- if (!_classPrivateFieldGet(_this, _mediaRecorder)) {
2011
- _classPrivateFieldGet(_this, _logger).info("mediaRecorder is not defined");
2012
- _classPrivateFieldGet(_this, _store).setState({
2013
- status: SCREEN_RECORDER_STATUS.idle,
2014
- error: SCREEN_RECORDER_ERROR.FailedToStart
2015
- });
2016
- return;
2017
- }
2018
- if (!_classPrivateFieldGet(_this, _mediaStream) || isStreamEnded(_classPrivateFieldGet(_this, _mediaStream))) {
2019
- _classPrivateFieldGet(_this, _logger).info("media stream ended, not starting mediaRecorder");
2020
- _classPrivateFieldGet(_this, _store).setState({
2021
- status: SCREEN_RECORDER_STATUS.idle,
2022
- error: SCREEN_RECORDER_ERROR.FailedToStart
2023
- });
2024
- return;
2025
- }
2026
- _classPrivateFieldGet(_this, _mediaRecorder).start(5000);
2027
- _classPrivateFieldGet(_this, _logger).info("started mediaRecorder");
2028
- _classPrivateFieldGet(_this, _startTimer).call(_this);
2029
- } catch (error) {
2030
- _classPrivateFieldGet(_this, _logger).info("Failed to start mediaRecorder", error);
2031
- _classPrivateFieldGet(_this, _store).setState({
2032
- status: SCREEN_RECORDER_STATUS.idle,
2033
- error: SCREEN_RECORDER_ERROR.FailedToStart
2034
- });
2035
-
2036
- // To prevent triggering #onRecordingStop when the mediaRecorder is failed to start.
2037
- if (_classPrivateFieldGet(_this, _mediaRecorder)) {
2038
- _classPrivateFieldGet(_this, _mediaRecorder).onstop = noop;
2039
- }
2040
- if (_classPrivateFieldGet(_this, _mediaStream)) {
2041
- _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
2042
- return track.stop();
2043
- });
2044
- _classPrivateFieldSet(_this, _mediaStream, null);
2045
- }
2046
- _classPrivateFieldSet(_this, _stream, null);
2047
- _classPrivateFieldSet(_this, _audioStream, null);
2048
- _classPrivateFieldSet(_this, _mediaRecorder, null);
2049
- throw error;
2050
- }
2051
- }, HALF_A_SECOND_IN_MILLISECONDS));
2060
+ _classPrivateFieldGet(_this, _startMediaRecorder).call(_this);
2052
2061
  return {
2053
2062
  countdownTimeLeft: 0
2054
2063
  };
@@ -2094,7 +2103,6 @@ var ScreenRecorder = /*#__PURE__*/function () {
2094
2103
  _classPrivateFieldGet(_this, _store).setState({
2095
2104
  showTimeLimitWarning: true
2096
2105
  });
2097
- _classPrivateFieldSet(_this, _stopRecordingDueToLimitReachedAudio, new Audio(STOP_RECORDING_DUE_TO_LIMIT_REACHED_SOUND));
2098
2106
  return;
2099
2107
  }
2100
2108
  _classPrivateFieldGet(_this, _stopRecordingDueToLimitReachedAudio).play();
@@ -2124,11 +2132,11 @@ var ScreenRecorder = /*#__PURE__*/function () {
2124
2132
  }, {
2125
2133
  key: "displaySurface",
2126
2134
  get: function get() {
2127
- var _classPrivateFieldGet25;
2128
- var _classPrivateFieldGet23 = (_classPrivateFieldGet25 = _classPrivateFieldGet(this, _mediaStream)) === null || _classPrivateFieldGet25 === void 0 ? void 0 : _classPrivateFieldGet25.getVideoTracks(),
2129
- _classPrivateFieldGet24 = _slicedToArray(_classPrivateFieldGet23, 1),
2130
- videoTrack = _classPrivateFieldGet24[0];
2131
- return videoTrack.getSettings().displaySurface;
2135
+ var _classPrivateFieldGet15, _classPrivateFieldGet16;
2136
+ var _ref5 = (_classPrivateFieldGet15 = (_classPrivateFieldGet16 = _classPrivateFieldGet(this, _mediaStream)) === null || _classPrivateFieldGet16 === void 0 ? void 0 : _classPrivateFieldGet16.getVideoTracks()) !== null && _classPrivateFieldGet15 !== void 0 ? _classPrivateFieldGet15 : [],
2137
+ _ref6 = _slicedToArray(_ref5, 1),
2138
+ videoTrack = _ref6[0];
2139
+ return videoTrack === null || videoTrack === void 0 ? void 0 : videoTrack.getSettings().displaySurface;
2132
2140
  }
2133
2141
  }, {
2134
2142
  key: "audioConfiguration",