@bigbinary/neeto-media-recorder 2.7.7 → 2.7.9

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/index.js CHANGED
@@ -2,7 +2,7 @@ import { shallow } from 'zustand/shallow';
2
2
  import { useState, useRef, useCallback, useEffect, forwardRef, useImperativeHandle } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
- import { SCREEN_RECORDER_STATUS, UPLOAD_STATUS as UPLOAD_STATUS$1, ONE_SECOND_IN_MILLISECONDS as ONE_SECOND_IN_MILLISECONDS$1, MIME_TYPE as MIME_TYPE$1, ONE_MINUTE_IN_MILLISECONDS as ONE_MINUTE_IN_MILLISECONDS$1, IS_EXTENSION as IS_EXTENSION$1, SCREEN_RECORDER_ERROR, IS_SAFARI_EXTENSION, MIC_NOT_WORKING_SILENCE_TIMEOUT, SCREEN_RECORDER_EVENT, UPLOAD_EVENT } from '@bigbinary/neeto-media-recorder/constants';
5
+ import { SCREEN_RECORDER_STATUS, UPLOAD_STATUS as UPLOAD_STATUS$1, ONE_SECOND_IN_MILLISECONDS as ONE_SECOND_IN_MILLISECONDS$1, MIME_TYPE as MIME_TYPE$1, ONE_MINUTE_IN_MILLISECONDS as ONE_MINUTE_IN_MILLISECONDS$1, IS_EXTENSION as IS_EXTENSION$1, SCREEN_RECORDER_ERROR, IS_SAFARI_EXTENSION, MIC_NOT_WORKING_SILENCE_TIMEOUT, SCREEN_RECORDER_EVENT, COUNTDOWN_TIME, UPLOAD_EVENT } from '@bigbinary/neeto-media-recorder/constants';
6
6
  import { screenRecorder, useMultipartS3UploadStatus, getMultipartS3Uploader } from '@bigbinary/neeto-media-recorder/core';
7
7
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
8
8
  import Alert from '@bigbinary/neetoui/Alert';
@@ -703,7 +703,8 @@ var _excluded = ["size"],
703
703
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
704
704
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
705
705
  var PlayIcon = function PlayIcon(_ref) {
706
- var size = _ref.size,
706
+ var _ref$size = _ref.size,
707
+ size = _ref$size === void 0 ? 24 : _ref$size,
707
708
  other = _objectWithoutProperties(_ref, _excluded);
708
709
  return /*#__PURE__*/jsx("svg", _objectSpread(_objectSpread({
709
710
  height: size,
@@ -717,11 +718,9 @@ var PlayIcon = function PlayIcon(_ref) {
717
718
  })
718
719
  }));
719
720
  };
720
- PlayIcon.defaultProps = {
721
- size: 24
722
- };
723
721
  var StopIcon = function StopIcon(_ref2) {
724
- var size = _ref2.size,
722
+ var _ref2$size = _ref2.size,
723
+ size = _ref2$size === void 0 ? 24 : _ref2$size,
725
724
  other = _objectWithoutProperties(_ref2, _excluded2);
726
725
  return /*#__PURE__*/jsx("svg", _objectSpread(_objectSpread({
727
726
  height: size,
@@ -735,11 +734,9 @@ var StopIcon = function StopIcon(_ref2) {
735
734
  })
736
735
  }));
737
736
  };
738
- StopIcon.defaultProps = {
739
- size: 24
740
- };
741
737
  var RestartIcon = function RestartIcon(_ref3) {
742
- var size = _ref3.size,
738
+ var _ref3$size = _ref3.size,
739
+ size = _ref3$size === void 0 ? 24 : _ref3$size,
743
740
  other = _objectWithoutProperties(_ref3, _excluded3);
744
741
  return /*#__PURE__*/jsx("svg", _objectSpread(_objectSpread({
745
742
  height: size,
@@ -755,9 +752,6 @@ var RestartIcon = function RestartIcon(_ref3) {
755
752
  })
756
753
  }));
757
754
  };
758
- RestartIcon.defaultProps = {
759
- size: 24
760
- };
761
755
 
762
756
  var useRecorderStatus = function useRecorderStatus() {
763
757
  var useRecorderStore = screenRecorder.useRecorderStore;
@@ -1009,7 +1003,6 @@ var useAudioIsCapturing = function useAudioIsCapturing(_ref) {
1009
1003
  };
1010
1004
  }, []);
1011
1005
  useEffect(function () {
1012
- logger.info("useAudioIsCapturing->", timerStarted, hasAudio, isMicOn, disable);
1013
1006
  if (!isMicOn || !timerStarted || disable) return noop;
1014
1007
  var analyserObj = null;
1015
1008
  var rafId;
@@ -1046,24 +1039,19 @@ var useAudioIsCapturing = function useAudioIsCapturing(_ref) {
1046
1039
  var _callbacks;
1047
1040
  if (!isMicOn) return noop;
1048
1041
  var callbacks = (_callbacks = {}, _defineProperty(_callbacks, SCREEN_RECORDER_EVENT.onStart, function () {
1049
- logger.info("useAudioIsCapturing onStart");
1050
1042
  reset();
1051
1043
  setTimerStarted(true);
1052
1044
  armTimer();
1053
1045
  }), _defineProperty(_callbacks, SCREEN_RECORDER_EVENT.onRestart, function () {
1054
- logger.info("useAudioIsCapturing onRestart");
1055
1046
  reset();
1056
1047
  setTimerStarted(true);
1057
1048
  armTimer();
1058
1049
  }), _defineProperty(_callbacks, SCREEN_RECORDER_EVENT.onResume, function () {
1059
- logger.info("useAudioIsCapturing onResume");
1060
1050
  setTimerStarted(true);
1061
1051
  resumeTimer();
1062
1052
  }), _defineProperty(_callbacks, SCREEN_RECORDER_EVENT.onPause, function () {
1063
- logger.info("useAudioIsCapturing onPause");
1064
1053
  pauseTimer();
1065
1054
  }), _defineProperty(_callbacks, SCREEN_RECORDER_EVENT.onStop, function () {
1066
- logger.info("useAudioIsCapturing onStop");
1067
1055
  clearTimer();
1068
1056
  reset();
1069
1057
  }), _defineProperty(_callbacks, "disable-mic-not-working-warning", function disableMicNotWorkingWarning() {
@@ -1466,7 +1454,9 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1466
1454
  _ref$isMicOn = _ref.isMicOn,
1467
1455
  isMicOn = _ref$isMicOn === void 0 ? false : _ref$isMicOn,
1468
1456
  _ref$onAudioNotCaptur = _ref.onAudioNotCapturing,
1469
- onAudioNotCapturing = _ref$onAudioNotCaptur === void 0 ? function () {} : _ref$onAudioNotCaptur;
1457
+ onAudioNotCapturing = _ref$onAudioNotCaptur === void 0 ? function () {} : _ref$onAudioNotCaptur,
1458
+ _ref$onError = _ref.onError,
1459
+ onError = _ref$onError === void 0 ? function () {} : _ref$onError;
1470
1460
  var _useTranslation = useTranslation(),
1471
1461
  t = _useTranslation.t;
1472
1462
  var _useState = useState(false),
@@ -1551,6 +1541,16 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1551
1541
  _useCreateRecording$d2 = _useCreateRecording$d === void 0 ? {} : _useCreateRecording$d,
1552
1542
  _useCreateRecording$d3 = _useCreateRecording$d2.recording,
1553
1543
  recording = _useCreateRecording$d3 === void 0 ? {} : _useCreateRecording$d3;
1544
+ useEffect(function () {
1545
+ var elapsedTimeInSec = Math.round(elapsedTime / 1000);
1546
+ var checkDelay = 7; // we get data every 5 sec, 7 for safety
1547
+ // If data is insufficient after n secs, there is some issue with media recorder, discard.
1548
+ if (elapsedTimeInSec < checkDelay) return;
1549
+ if (!screenRecorder.hasData() && recorderStatus === SCREEN_RECORDER_STATUS.recording) {
1550
+ screenRecorder.setError(SCREEN_RECORDER_ERROR.InsufficientData);
1551
+ onError(SCREEN_RECORDER_ERROR.InsufficientData);
1552
+ }
1553
+ }, [elapsedTime]);
1554
1554
  recordingRef.current = recording;
1555
1555
  var handleCreateRecording = /*#__PURE__*/function () {
1556
1556
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
@@ -1780,7 +1780,12 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1780
1780
  className: "flex h-screen w-full flex-col items-center justify-start py-10 xl:py-14 2xl:py-20",
1781
1781
  children: [/*#__PURE__*/jsxs("div", {
1782
1782
  className: classNames("w-full max-w-3xl"),
1783
- children: [/*#__PURE__*/jsx(UseDesktopAppCallout, {}), error === SCREEN_RECORDER_ERROR.NotAllowedError && /*#__PURE__*/jsxs("div", {
1783
+ children: [/*#__PURE__*/jsx(UseDesktopAppCallout, {}), error === SCREEN_RECORDER_ERROR.InsufficientData && /*#__PURE__*/jsx(Callout, {
1784
+ className: "mb-2 p-3",
1785
+ "data-cy": "recorder-insufficient-data-error-callout",
1786
+ style: "danger",
1787
+ children: t("neetoMediaRecorder.insufficientDataError")
1788
+ }), error === SCREEN_RECORDER_ERROR.NotAllowedError && /*#__PURE__*/jsxs("div", {
1784
1789
  className: "flex flex-col items-center",
1785
1790
  children: [/*#__PURE__*/jsx(Typography, {
1786
1791
  className: "mb-2",
@@ -1842,15 +1847,44 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1842
1847
  })
1843
1848
  })
1844
1849
  }), isRecorderStatus(SCREEN_RECORDER_STATUS.media_acquired, SCREEN_RECORDER_STATUS.restarting) && /*#__PURE__*/jsxs("div", {
1845
- className: "mx-auto flex flex-col items-center justify-center space-y-4",
1850
+ className: "neeto-ui-rounded-lg mx-auto mb-8 flex w-full max-w-4xl flex-col items-center justify-center p-12",
1846
1851
  "data-cy": "recorder-countdown-wrapper",
1847
- children: [/*#__PURE__*/jsx(Typography, {
1852
+ children: [/*#__PURE__*/jsx("div", {
1853
+ className: "relative mb-8",
1854
+ children: /*#__PURE__*/jsxs("div", {
1855
+ className: "relative flex h-32 w-32 items-center justify-center",
1856
+ children: [/*#__PURE__*/jsxs("svg", {
1857
+ className: "absolute h-32 w-32 -rotate-90 transform",
1858
+ viewBox: "0 0 120 120",
1859
+ children: [/*#__PURE__*/jsx("circle", {
1860
+ cx: "60",
1861
+ cy: "60",
1862
+ fill: "transparent",
1863
+ r: "50",
1864
+ stroke: "rgba(2, 128, 105, 0.2)",
1865
+ strokeWidth: "4"
1866
+ }), /*#__PURE__*/jsx("circle", {
1867
+ className: "transition-all duration-1000 ease-linear",
1868
+ cx: "60",
1869
+ cy: "60",
1870
+ fill: "transparent",
1871
+ r: "50",
1872
+ stroke: "rgb(2, 128, 105)",
1873
+ strokeDasharray: 2 * Math.PI * 50,
1874
+ strokeLinecap: "round",
1875
+ strokeWidth: "4",
1876
+ strokeDashoffset: 2 * Math.PI * 50 * (countdownTimeLeft / COUNTDOWN_TIME)
1877
+ })]
1878
+ }), /*#__PURE__*/jsx(Typography, {
1879
+ className: " text-6xl font-bold",
1880
+ weight: "semibold",
1881
+ children: countdownTimeLeft
1882
+ })]
1883
+ })
1884
+ }), /*#__PURE__*/jsx(Typography, {
1885
+ className: "mb-4",
1848
1886
  style: "h3",
1849
1887
  children: t("neetoMediaRecorder.record.startsIn")
1850
- }), /*#__PURE__*/jsx(Typography, {
1851
- className: "neeto-ui-text-4xl neeto-ui-bg-primary-100 neeto-ui-rounded-full flex h-32 w-32 items-center justify-center",
1852
- weight: "semibold",
1853
- children: countdownTimeLeft
1854
1888
  })]
1855
1889
  }), isRecorderStatus(SCREEN_RECORDER_STATUS.recording, SCREEN_RECORDER_STATUS.paused) && /*#__PURE__*/jsx(Timer, {})]
1856
1890
  }), /*#__PURE__*/jsx(Controls, {