@bigbinary/neeto-media-recorder 1.1.3 → 1.2.0

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
@@ -5,15 +5,16 @@ import { isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
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';
6
6
  import { screenRecorder, multipartS3Uploader } from '@bigbinary/neeto-media-recorder/core';
7
7
  import { Typography, Spinner, Button, Callout, Alert } from '@bigbinary/neetoui';
8
- import { useTranslation } from 'react-i18next';
8
+ import { useTranslation, Trans } from 'react-i18next';
9
9
  import { useMutation } from 'react-query';
10
10
  import axios from 'axios';
11
+ import platform from 'platform';
12
+ import { isNotNil, isEmpty } from 'ramda';
11
13
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
12
- import { Pause, Delete, Copy, Download } from '@bigbinary/neeto-icons';
14
+ import { Pause, Delete, Copy, Download, Close } from '@bigbinary/neeto-icons';
13
15
  import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils/general';
14
16
  import { generatePublicUrl } from '@bigbinary/neeto-media-recorder/utils';
15
17
  import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardButton';
16
- import { isEmpty } from 'ramda';
17
18
 
18
19
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
19
20
  try {
@@ -484,15 +485,6 @@ var useRecordingUploadSuccess = function useRecordingUploadSuccess() {
484
485
  });
485
486
  };
486
487
 
487
- var AbortUpload = withT(function (_ref) {
488
- var t = _ref.t;
489
- return /*#__PURE__*/React.createElement("div", {
490
- className: "flex h-screen w-full flex-col items-center justify-center"
491
- }, /*#__PURE__*/React.createElement("div", {
492
- className: "flex h-full w-full flex-col items-center justify-center space-y-4"
493
- }, /*#__PURE__*/React.createElement(Typography, null, t("neetoMediaRecorder.record.discardingVideo")), /*#__PURE__*/React.createElement(Spinner, null)));
494
- });
495
-
496
488
  function _typeof(obj) {
497
489
  "@babel/helpers - typeof";
498
490
 
@@ -503,6 +495,20 @@ function _typeof(obj) {
503
495
  }, _typeof(obj);
504
496
  }
505
497
 
498
+ var HAS_CHROME_NAMESPACE = (typeof chrome === "undefined" ? "undefined" : _typeof(chrome)) === "object";
499
+ HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);
500
+ platform.name === "Safari";
501
+ var PERMISSIONS_HELP_DOC = "https://neetorecordhelp.neetokb.com/p/a-10efcfd7";
502
+
503
+ var AbortUpload = withT(function (_ref) {
504
+ var t = _ref.t;
505
+ return /*#__PURE__*/React.createElement("div", {
506
+ className: "flex h-screen w-full flex-col items-center justify-center"
507
+ }, /*#__PURE__*/React.createElement("div", {
508
+ className: "flex h-full w-full flex-col items-center justify-center space-y-4"
509
+ }, /*#__PURE__*/React.createElement(Typography, null, t("neetoMediaRecorder.record.discardingVideo")), /*#__PURE__*/React.createElement(Spinner, null)));
510
+ });
511
+
506
512
  function _toPrimitive(input, hint) {
507
513
  if (_typeof(input) !== "object" || input === null) return input;
508
514
  var prim = input[Symbol.toPrimitive];
@@ -855,11 +861,16 @@ var UnSupportedBrowser = withT(function (_ref) {
855
861
  });
856
862
 
857
863
  var UploadingInProgress = function UploadingInProgress(_ref) {
858
- var recording = _ref.recording;
864
+ var recording = _ref.recording,
865
+ onDiscard = _ref.onDiscard;
859
866
  var _useState = useState(""),
860
867
  _useState2 = _slicedToArray(_useState, 2),
861
868
  baseURL = _useState2[0],
862
869
  setBaseURL = _useState2[1];
870
+ var _useState3 = useState(false),
871
+ _useState4 = _slicedToArray(_useState3, 2),
872
+ isDiscardAlertOpen = _useState4[0],
873
+ setIsDiscardAlertOpen = _useState4[1];
863
874
  var _useTranslation = useTranslation(),
864
875
  t = _useTranslation.t;
865
876
  var handleRecordingBlobDownload = function handleRecordingBlobDownload() {
@@ -901,7 +912,23 @@ var UploadingInProgress = function UploadingInProgress(_ref) {
901
912
  label: t("neetoMediaRecorder.record.downloadWebm"),
902
913
  style: "secondary",
903
914
  onClick: handleRecordingBlobDownload
904
- }))));
915
+ }), /*#__PURE__*/React.createElement(Button, {
916
+ icon: Close,
917
+ label: t("neetoMediaRecorder.record.discardRecording"),
918
+ style: "secondary",
919
+ onClick: function onClick() {
920
+ return setIsDiscardAlertOpen(true);
921
+ }
922
+ }))), /*#__PURE__*/React.createElement(Alert, {
923
+ isOpen: isDiscardAlertOpen,
924
+ message: t("neetoMediaRecorder.record.discardConfirmation.message"),
925
+ submitButtonLabel: t("neetoMediaRecorder.record.discard"),
926
+ title: t("neetoMediaRecorder.record.discardConfirmation.title"),
927
+ onClose: function onClose() {
928
+ return setIsDiscardAlertOpen(false);
929
+ },
930
+ onSubmit: onDiscard
931
+ }));
905
932
  };
906
933
 
907
934
  var useRecorderStore = screenRecorder.useRecorderStore,
@@ -1074,7 +1101,8 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1074
1101
  }
1075
1102
  if (isRecorderStatus(SCREEN_RECORDER_STATUS.stopped) && isUploadStatus(UPLOAD_STATUS.uploading)) {
1076
1103
  return /*#__PURE__*/React.createElement(UploadingInProgress, {
1077
- recording: recording
1104
+ recording: recording,
1105
+ onDiscard: handleDiscardRecording
1078
1106
  });
1079
1107
  }
1080
1108
  if (hasRecordingDiscarded({
@@ -1090,7 +1118,17 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1090
1118
  }, error === SCREEN_RECORDER_ERROR.NotAllowedError && /*#__PURE__*/React.createElement(Callout, {
1091
1119
  className: "mb-2 p-3",
1092
1120
  style: "danger"
1093
- }, t("neetoMediaRecorder.record.permissionDeniedMessage")), isRecorderStatus(SCREEN_RECORDER_STATUS.acquiring_media) && /*#__PURE__*/React.createElement(Callout, {
1121
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Trans, {
1122
+ i18nKey: "neetoMediaRecorder.record.permissionDeniedMessage",
1123
+ components: {
1124
+ a: /*#__PURE__*/React.createElement("a", {
1125
+ className: "neeto-ui-text-primary-800",
1126
+ href: PERMISSIONS_HELP_DOC,
1127
+ rel: "noreferrer",
1128
+ target: "_blank"
1129
+ })
1130
+ }
1131
+ }))), isRecorderStatus(SCREEN_RECORDER_STATUS.acquiring_media) && /*#__PURE__*/React.createElement(Callout, {
1094
1132
  className: "mb-2 p-3",
1095
1133
  style: "info"
1096
1134
  }, t("neetoMediaRecorder.record.grantPermissionMessage")), shouldShowSafariExtensionCalloutToStartRecording && /*#__PURE__*/React.createElement(Callout, {