@bigbinary/neeto-media-recorder 1.3.12 → 1.3.14

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
@@ -1,19 +1,17 @@
1
1
  import { shallow } from 'zustand/shallow';
2
- import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
2
+ import React, { useState, forwardRef, useImperativeHandle, useEffect } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
- import { SCREEN_RECORDER_STATUS, SCREEN_RECORDER_ERROR, IS_SAFARI_EXTENSION, UPLOAD_STATUS, ONE_MINUTE_IN_MILLISECONDS, ONE_SECOND_IN_MILLISECONDS, IS_EXTENSION, SCREEN_RECORDER_EVENT, UPLOAD_EVENT } from '@bigbinary/neeto-media-recorder/constants';
5
+ import { SCREEN_RECORDER_STATUS, SCREEN_RECORDER_ERROR, IS_SAFARI_EXTENSION, UPLOAD_STATUS, ONE_MINUTE_IN_MILLISECONDS as ONE_MINUTE_IN_MILLISECONDS$1, ONE_SECOND_IN_MILLISECONDS as ONE_SECOND_IN_MILLISECONDS$1, SCREEN_RECORDER_EVENT, UPLOAD_EVENT } from '@bigbinary/neeto-media-recorder/constants';
6
6
  import { screenRecorder, multipartS3Uploader } from '@bigbinary/neeto-media-recorder/core';
7
7
  import { Typography, Spinner, Button, Callout, Alert } from '@bigbinary/neetoui';
8
8
  import { useTranslation, Trans } from 'react-i18next';
9
9
  import { useMutation } from 'react-query';
10
10
  import axios from 'axios';
11
11
  import platform from 'platform';
12
- import { isNotNil, isEmpty } from 'ramda';
12
+ import { isNotNil } from 'ramda';
13
13
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
14
14
  import { Pause, Delete, Download, Close } from '@bigbinary/neeto-icons';
15
- import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils/general';
16
- import { generatePublicUrl } from '@bigbinary/neeto-media-recorder/utils';
17
15
 
18
16
  var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
19
17
 
@@ -499,10 +497,14 @@ function _typeof(obj) {
499
497
  }, _typeof(obj);
500
498
  }
501
499
 
500
+ var ONE_SECOND_IN_MILLISECONDS = 1000;
501
+ var ONE_MINUTE_IN_MILLISECONDS = 60 * ONE_SECOND_IN_MILLISECONDS;
502
+ var ONE_HOUR_IN_MILLISECONDS = 60 * ONE_MINUTE_IN_MILLISECONDS;
502
503
  var HAS_CHROME_NAMESPACE = (typeof chrome === "undefined" ? "undefined" : _typeof(chrome)) === "object";
503
504
  HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);
504
505
  platform.name === "Safari";
505
506
  var PERMISSIONS_HELP_DOC = "https://neetorecordhelp.neetokb.com/p/a-10efcfd7";
507
+ // 2 hours
506
508
 
507
509
  var AbortUpload = withT(function (_ref) {
508
510
  var t = _ref.t;
@@ -820,8 +822,12 @@ var formatTime = function formatTime(time) {
820
822
  return Math.floor(time).toString().padStart(2, "0");
821
823
  };
822
824
  var getTimeString = function getTimeString(date) {
823
- var minutes = formatTime(date / ONE_MINUTE_IN_MILLISECONDS);
824
- var seconds = formatTime(date % ONE_MINUTE_IN_MILLISECONDS / ONE_SECOND_IN_MILLISECONDS);
825
+ var hours = formatTime(Math.floor(date / ONE_HOUR_IN_MILLISECONDS));
826
+ var minutes = formatTime(date % ONE_HOUR_IN_MILLISECONDS / ONE_MINUTE_IN_MILLISECONDS$1);
827
+ var seconds = formatTime(date % ONE_MINUTE_IN_MILLISECONDS$1 / ONE_SECOND_IN_MILLISECONDS$1);
828
+ if (hours > 0) {
829
+ return "".concat(hours, ":").concat(minutes, ":").concat(seconds);
830
+ }
825
831
  return "".concat(minutes, ":").concat(seconds);
826
832
  };
827
833
  var downloadRecordingBlob = function downloadRecordingBlob(blob, name) {
@@ -846,6 +852,14 @@ var hasRecordingDiscarded = function hasRecordingDiscarded(_ref) {
846
852
  uploadStatus = _ref.uploadStatus;
847
853
  return recorderStatus === SCREEN_RECORDER_STATUS.stopped && uploadStatus === UPLOAD_STATUS.aborting;
848
854
  };
855
+ var getRecorderTimeLimitInHumanFormat = function getRecorderTimeLimitInHumanFormat(timeInMs) {
856
+ var minutes = Math.floor(timeInMs / (1000 * 60));
857
+ var hours = Math.floor(minutes / 60);
858
+ if (hours < 1) {
859
+ return "".concat(minutes, " minutes");
860
+ }
861
+ return "".concat(hours, " hours");
862
+ };
849
863
 
850
864
  var Timer = function Timer() {
851
865
  var _useTranslation = useTranslation(),
@@ -888,37 +902,15 @@ var UnSupportedBrowser = withT(function (_ref) {
888
902
  var UploadingInProgress = function UploadingInProgress(_ref) {
889
903
  var recording = _ref.recording,
890
904
  onDiscard = _ref.onDiscard;
891
- var _useState = useState(""),
905
+ var _useState = useState(false),
892
906
  _useState2 = _slicedToArray(_useState, 2),
893
- baseURL = _useState2[0],
894
- setBaseURL = _useState2[1];
895
- var _useState3 = useState(false),
896
- _useState4 = _slicedToArray(_useState3, 2),
897
- isDiscardAlertOpen = _useState4[0],
898
- setIsDiscardAlertOpen = _useState4[1];
907
+ isDiscardAlertOpen = _useState2[0],
908
+ setIsDiscardAlertOpen = _useState2[1];
899
909
  var _useTranslation = useTranslation(),
900
910
  t = _useTranslation.t;
901
911
  var handleRecordingBlobDownload = function handleRecordingBlobDownload() {
902
912
  downloadRecordingBlob(screenRecorder.getWebmMediaBlob(), recording.title);
903
913
  };
904
- useEffect(function () {
905
- if (!IS_EXTENSION) {
906
- setBaseURL(window.location.origin);
907
- return;
908
- }
909
- chrome.storage.local.get("baseURL").then(function (_ref2) {
910
- var baseURL = _ref2.baseURL;
911
- setBaseURL(baseURL);
912
- });
913
- }, []);
914
- useEffect(function () {
915
- if (!window.document.hasFocus() || !recording.id || isEmpty(baseURL)) {
916
- return;
917
- }
918
- copyToClipboard(generatePublicUrl(recording.id, baseURL), {
919
- message: t("neetoMediaRecorder.record.copyToClipboardToastrMessage")
920
- });
921
- }, [recording.id, baseURL]);
922
914
  return /*#__PURE__*/React.createElement("div", {
923
915
  className: "flex h-screen w-full flex-col items-center justify-center"
924
916
  }, /*#__PURE__*/React.createElement("div", {
@@ -1175,7 +1167,9 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1175
1167
  className: "mx-auto mb-2 w-1/2 p-3",
1176
1168
  "data-cy": "recorder-time-limit-warning-callout",
1177
1169
  style: "warning"
1178
- }, t("neetoMediaRecorder.record.timeLimitWarning")), isRecorderStatus(SCREEN_RECORDER_STATUS.media_acquired, SCREEN_RECORDER_STATUS.restarting) && /*#__PURE__*/React.createElement("div", {
1170
+ }, t("neetoMediaRecorder.record.timeLimitWarning", {
1171
+ duration: getRecorderTimeLimitInHumanFormat(screenRecorder.timeLimit)
1172
+ })), isRecorderStatus(SCREEN_RECORDER_STATUS.media_acquired, SCREEN_RECORDER_STATUS.restarting) && /*#__PURE__*/React.createElement("div", {
1179
1173
  className: " mx-auto flex flex-col items-center justify-center space-y-4",
1180
1174
  "data-cy": "recorder-countdown-wrapper"
1181
1175
  }, /*#__PURE__*/React.createElement(Typography, {