@bigbinary/neeto-media-recorder 2.7.2 → 2.7.3

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.
Files changed (3) hide show
  1. package/core.js +77 -90
  2. package/core.js.map +1 -1
  3. package/package.json +1 -1
package/core.js CHANGED
@@ -1494,10 +1494,12 @@ 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();
1500
1501
  var _mimeType = /*#__PURE__*/new WeakMap();
1502
+ var _stopAllStreams = /*#__PURE__*/new WeakMap();
1501
1503
  var _checkCompatibility = /*#__PURE__*/new WeakMap();
1502
1504
  var _acquireMediaStream = /*#__PURE__*/new WeakMap();
1503
1505
  var _fireCallbacks = /*#__PURE__*/new WeakMap();
@@ -1580,6 +1582,10 @@ var ScreenRecorder = /*#__PURE__*/function () {
1580
1582
  writable: true,
1581
1583
  value: void 0
1582
1584
  });
1585
+ _classPrivateFieldInitSpec(this, _micAudioStream, {
1586
+ writable: true,
1587
+ value: void 0
1588
+ });
1583
1589
  _classPrivateFieldInitSpec(this, _timeLimit, {
1584
1590
  writable: true,
1585
1591
  value: RECORDING_TIME_LIMIT_FREE_PLAN
@@ -1676,40 +1682,22 @@ var ScreenRecorder = /*#__PURE__*/function () {
1676
1682
  }, _callee);
1677
1683
  })));
1678
1684
  _defineProperty(this, "stopRecording", function () {
1679
- var _classPrivateFieldGet8, _classPrivateFieldGet12, _classPrivateFieldGet13, _classPrivateFieldGet14;
1685
+ var _classPrivateFieldGet4;
1680
1686
  if (_classPrivateFieldGet(_this, _mediaRecorder) === undefined) {
1681
- var _classPrivateFieldGet4, _classPrivateFieldGet5, _classPrivateFieldGet6, _classPrivateFieldGet7;
1682
1687
  /**
1683
1688
  * If the permission is denied and "Stop sharing" overlay is clicked
1684
1689
  */
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
- });
1690
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1694
1691
  return;
1695
1692
  }
1696
- if (((_classPrivateFieldGet8 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet8 === void 0 ? void 0 : _classPrivateFieldGet8.state) === "inactive") {
1697
- var _classPrivateFieldGet9, _classPrivateFieldGet10, _classPrivateFieldGet11;
1693
+ if (((_classPrivateFieldGet4 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.state) === "inactive") {
1698
1694
  // When recording is stopped from the 'Stop Sharing' overlay
1699
1695
  // before it even starts, i.e during the countdown.
1700
1696
  // Or if the recording is stopped before startRecordingTimeoutID timeout executes
1701
1697
  _this.removeCallback(SCREEN_RECORDER_EVENT.onStop);
1702
1698
  clearTimeout(_classPrivateFieldGet(_this, _startRecordingTimeoutID));
1703
1699
  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
- });
1700
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1713
1701
  _classPrivateFieldGet(_this, _fireCallbacks).call(_this, SCREEN_RECORDER_EVENT.onDiscardDuringCountdown);
1714
1702
  return;
1715
1703
  }
@@ -1717,20 +1705,12 @@ var ScreenRecorder = /*#__PURE__*/function () {
1717
1705
  status: SCREEN_RECORDER_STATUS.stopping
1718
1706
  });
1719
1707
  _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
- });
1708
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1729
1709
  _classPrivateFieldGet(_this, _stopTimer).call(_this);
1730
1710
  });
1731
1711
  _defineProperty(this, "pauseRecording", function () {
1732
- var _classPrivateFieldGet15;
1733
- if (((_classPrivateFieldGet15 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet15 === void 0 ? void 0 : _classPrivateFieldGet15.state) === "recording") {
1712
+ var _classPrivateFieldGet5;
1713
+ if (((_classPrivateFieldGet5 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.state) === "recording") {
1734
1714
  _classPrivateFieldGet(_this, _store).setState({
1735
1715
  status: SCREEN_RECORDER_STATUS.paused
1736
1716
  });
@@ -1739,8 +1719,8 @@ var ScreenRecorder = /*#__PURE__*/function () {
1739
1719
  _classPrivateFieldGet(_this, _stopTimer).call(_this);
1740
1720
  });
1741
1721
  _defineProperty(this, "resumeRecording", function () {
1742
- var _classPrivateFieldGet16;
1743
- if (((_classPrivateFieldGet16 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet16 === void 0 ? void 0 : _classPrivateFieldGet16.state) === "paused") {
1722
+ var _classPrivateFieldGet6;
1723
+ if (((_classPrivateFieldGet6 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.state) === "paused") {
1744
1724
  _classPrivateFieldGet(_this, _store).setState({
1745
1725
  status: SCREEN_RECORDER_STATUS.recording
1746
1726
  });
@@ -1749,19 +1729,14 @@ var ScreenRecorder = /*#__PURE__*/function () {
1749
1729
  _classPrivateFieldGet(_this, _startTimer).call(_this);
1750
1730
  });
1751
1731
  _defineProperty(this, "discardRecording", function () {
1752
- var _classPrivateFieldGet17, _classPrivateFieldGet18;
1753
- if (((_classPrivateFieldGet17 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet17 === void 0 ? void 0 : _classPrivateFieldGet17.state) === "inactive") return;
1732
+ var _classPrivateFieldGet7;
1733
+ if (((_classPrivateFieldGet7 = _classPrivateFieldGet(_this, _mediaRecorder)) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.state) === "inactive") return;
1754
1734
  _classPrivateFieldGet(_this, _store).setState({
1755
1735
  status: SCREEN_RECORDER_STATUS.stopping
1756
1736
  });
1757
1737
  _this.removeAllCallbacksByEvent(SCREEN_RECORDER_EVENT.onStop);
1758
1738
  _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
- });
1739
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1765
1740
  clearInterval(_classPrivateFieldGet(_this, _timerId));
1766
1741
  _classPrivateFieldGet(_this, _store).setState(pick(["elapsedTime"], initialState));
1767
1742
  _classPrivateFieldSet(_this, _mediaChunks, []);
@@ -1788,18 +1763,27 @@ var ScreenRecorder = /*#__PURE__*/function () {
1788
1763
  _classPrivateFieldGet(_this, _checkCompatibility).call(_this);
1789
1764
  });
1790
1765
  _defineProperty(this, "revokePermissions", function () {
1791
- var _classPrivateFieldGet19, _classPrivateFieldGet20, _classPrivateFieldGet21;
1792
1766
  if (!_classPrivateFieldGet(_this, _mediaRecorder)) return;
1793
1767
  _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
- });
1768
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
1769
+ });
1770
+ _classPrivateFieldInitSpec(this, _stopAllStreams, {
1771
+ writable: true,
1772
+ value: function value() {
1773
+ var _classPrivateFieldGet8, _classPrivateFieldGet9, _classPrivateFieldGet10, _classPrivateFieldGet11, _classPrivateFieldGet12, _classPrivateFieldGet13;
1774
+ _classPrivateFieldGet(_this, _mediaStream) && ((_classPrivateFieldGet8 = _classPrivateFieldGet(_this, _mediaStream)) === null || _classPrivateFieldGet8 === void 0 ? void 0 : _classPrivateFieldGet8.getTracks().forEach(function (track) {
1775
+ return track.stop();
1776
+ }));
1777
+ (_classPrivateFieldGet9 = _classPrivateFieldGet(_this, _stream)) === null || _classPrivateFieldGet9 === void 0 ? void 0 : _classPrivateFieldGet9.getTracks().forEach(function (track) {
1778
+ return track.stop();
1779
+ });
1780
+ (_classPrivateFieldGet10 = _classPrivateFieldGet(_this, _audioStream)) === null || _classPrivateFieldGet10 === void 0 ? void 0 : (_classPrivateFieldGet11 = _classPrivateFieldGet10.getAudioTracks()) === null || _classPrivateFieldGet11 === void 0 ? void 0 : _classPrivateFieldGet11.forEach(function (track) {
1781
+ return track.stop();
1782
+ });
1783
+ (_classPrivateFieldGet12 = _classPrivateFieldGet(_this, _micAudioStream)) === null || _classPrivateFieldGet12 === void 0 ? void 0 : (_classPrivateFieldGet13 = _classPrivateFieldGet12.getAudioTracks()) === null || _classPrivateFieldGet13 === void 0 ? void 0 : _classPrivateFieldGet13.forEach(function (track) {
1784
+ return track.stop();
1785
+ });
1786
+ }
1803
1787
  });
1804
1788
  _classPrivateFieldInitSpec(this, _checkCompatibility, {
1805
1789
  writable: true,
@@ -1826,58 +1810,62 @@ var ScreenRecorder = /*#__PURE__*/function () {
1826
1810
  });
1827
1811
  _context2.prev = 1;
1828
1812
  if (!_classPrivateFieldGet(_this, _audio)) {
1829
- _context2.next = 25;
1813
+ _context2.next = 29;
1830
1814
  break;
1831
1815
  }
1832
- _context2.next = 5;
1816
+ _context2.t0 = _classPrivateFieldSet;
1817
+ _context2.t1 = _this;
1818
+ _context2.t2 = _micAudioStream;
1819
+ _context2.next = 8;
1833
1820
  return window.navigator.mediaDevices.getUserMedia({
1834
1821
  audio: _classPrivateFieldGet(_this, _audio) ? _objectSpread({
1835
1822
  echoCancellation: false
1836
1823
  }, _classPrivateFieldGet(_this, _audio)) : false
1837
1824
  });
1838
- case 5:
1839
- audioStream = _context2.sent;
1840
- audioStream = addGainNode(audioStream, 1.75); // Increase volume by 50%
1825
+ case 8:
1826
+ _context2.t3 = _context2.sent;
1827
+ (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t3);
1828
+ audioStream = addGainNode(_classPrivateFieldGet(_this, _micAudioStream), 1.75); // Increase volume by 50%
1841
1829
  _classPrivateFieldSet(_this, _audioStream, audioStream);
1842
1830
  if (!_classPrivateFieldGet(_this, _enableNoiseCancellation)) {
1843
- _context2.next = 25;
1831
+ _context2.next = 29;
1844
1832
  break;
1845
1833
  }
1846
- _context2.prev = 9;
1834
+ _context2.prev = 13;
1847
1835
  workletUrl = IS_EXTENSION ? chrome.runtime.getURL("public/NoiseSuppressorWorklet.js") : "NoiseSuppressorWorklet.js";
1848
1836
  audioContext = new AudioContext();
1849
- _context2.next = 14;
1837
+ _context2.next = 18;
1850
1838
  return audioContext.audioWorklet.addModule(workletUrl);
1851
- case 14:
1839
+ case 18:
1852
1840
  audioStreamSource = audioContext.createMediaStreamSource(audioStream);
1853
1841
  destinationStream = audioContext.createMediaStreamDestination();
1854
1842
  noiseSuppressorNode = new AudioWorkletNode(audioContext, "nn-suppressor-processor");
1855
1843
  audioStreamSource.connect(noiseSuppressorNode);
1856
1844
  noiseSuppressorNode.connect(destinationStream);
1857
1845
  _classPrivateFieldSet(_this, _audioStream, destinationStream.stream);
1858
- _context2.next = 25;
1846
+ _context2.next = 29;
1859
1847
  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:
1848
+ case 26:
1849
+ _context2.prev = 26;
1850
+ _context2.t4 = _context2["catch"](13);
1851
+ console.error("Failed to load audio worklet:", _context2.t4);
1852
+ case 29:
1865
1853
  if (!_classPrivateFieldGet(_this, _videoStream)) {
1866
- _context2.next = 29;
1854
+ _context2.next = 33;
1867
1855
  break;
1868
1856
  }
1869
1857
  stream = _classPrivateFieldGet(_this, _videoStream);
1870
- _context2.next = 32;
1858
+ _context2.next = 36;
1871
1859
  break;
1872
- case 29:
1873
- _context2.next = 31;
1860
+ case 33:
1861
+ _context2.next = 35;
1874
1862
  return window.navigator.mediaDevices.getDisplayMedia({
1875
1863
  video: _classPrivateFieldGet(_this, _video) || true,
1876
1864
  audio: true
1877
1865
  });
1878
- case 31:
1866
+ case 35:
1879
1867
  stream = _context2.sent;
1880
- case 32:
1868
+ case 36:
1881
1869
  // Event triggered when the user clicks on the stop sharing overlay button
1882
1870
  stream.getVideoTracks()[0].addEventListener("ended", function () {
1883
1871
  _this.stopRecording();
@@ -1908,11 +1896,11 @@ var ScreenRecorder = /*#__PURE__*/function () {
1908
1896
  _classPrivateFieldGet(_this, _store).setState({
1909
1897
  status: SCREEN_RECORDER_STATUS.media_acquired
1910
1898
  });
1911
- _context2.next = 44;
1899
+ _context2.next = 48;
1912
1900
  break;
1913
- case 41:
1914
- _context2.prev = 41;
1915
- _context2.t1 = _context2["catch"](1);
1901
+ case 45:
1902
+ _context2.prev = 45;
1903
+ _context2.t5 = _context2["catch"](1);
1916
1904
  if (_classPrivateFieldGet(_this, _audio) && !_classPrivateFieldGet(_this, _audioStream)) {
1917
1905
  _classPrivateFieldGet(_this, _store).setState({
1918
1906
  error: SCREEN_RECORDER_ERROR.MicPermissionDenied,
@@ -1920,15 +1908,15 @@ var ScreenRecorder = /*#__PURE__*/function () {
1920
1908
  });
1921
1909
  } else if (!_classPrivateFieldGet(_this, _mediaStream) || isStreamEnded(_classPrivateFieldGet(_this, _mediaStream))) {
1922
1910
  _classPrivateFieldGet(_this, _store).setState({
1923
- error: SCREEN_RECORDER_ERROR[_context2.t1.name],
1911
+ error: SCREEN_RECORDER_ERROR[_context2.t5.name],
1924
1912
  status: SCREEN_RECORDER_STATUS.idle
1925
1913
  });
1926
1914
  }
1927
- case 44:
1915
+ case 48:
1928
1916
  case "end":
1929
1917
  return _context2.stop();
1930
1918
  }
1931
- }, _callee2, null, [[1, 41], [9, 22]]);
1919
+ }, _callee2, null, [[1, 45], [13, 26]]);
1932
1920
  }));
1933
1921
  function value() {
1934
1922
  return _value.apply(this, arguments);
@@ -1939,9 +1927,9 @@ var ScreenRecorder = /*#__PURE__*/function () {
1939
1927
  _classPrivateFieldInitSpec(this, _fireCallbacks, {
1940
1928
  writable: true,
1941
1929
  value: function value(event) {
1942
- var _classPrivateFieldGet22;
1930
+ var _classPrivateFieldGet14;
1943
1931
  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) {
1932
+ (_classPrivateFieldGet14 = _classPrivateFieldGet(_this, _callbacks)[event]) === null || _classPrivateFieldGet14 === void 0 ? void 0 : _classPrivateFieldGet14.forEach(function (callback) {
1945
1933
  callback.apply(void 0, _toConsumableArray(args));
1946
1934
  });
1947
1935
  }
@@ -2038,13 +2026,12 @@ var ScreenRecorder = /*#__PURE__*/function () {
2038
2026
  _classPrivateFieldGet(_this, _mediaRecorder).onstop = noop;
2039
2027
  }
2040
2028
  if (_classPrivateFieldGet(_this, _mediaStream)) {
2041
- _classPrivateFieldGet(_this, _mediaStream).getTracks().forEach(function (track) {
2042
- return track.stop();
2043
- });
2029
+ _classPrivateFieldGet(_this, _stopAllStreams).call(_this);
2044
2030
  _classPrivateFieldSet(_this, _mediaStream, null);
2045
2031
  }
2046
2032
  _classPrivateFieldSet(_this, _stream, null);
2047
2033
  _classPrivateFieldSet(_this, _audioStream, null);
2034
+ _classPrivateFieldSet(_this, _micAudioStream, null);
2048
2035
  _classPrivateFieldSet(_this, _mediaRecorder, null);
2049
2036
  throw error;
2050
2037
  }
@@ -2124,10 +2111,10 @@ var ScreenRecorder = /*#__PURE__*/function () {
2124
2111
  }, {
2125
2112
  key: "displaySurface",
2126
2113
  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];
2114
+ var _classPrivateFieldGet17;
2115
+ var _classPrivateFieldGet15 = (_classPrivateFieldGet17 = _classPrivateFieldGet(this, _mediaStream)) === null || _classPrivateFieldGet17 === void 0 ? void 0 : _classPrivateFieldGet17.getVideoTracks(),
2116
+ _classPrivateFieldGet16 = _slicedToArray(_classPrivateFieldGet15, 1),
2117
+ videoTrack = _classPrivateFieldGet16[0];
2131
2118
  return videoTrack.getSettings().displaySurface;
2132
2119
  }
2133
2120
  }, {