@bigbinary/neeto-media-recorder 1.3.14 → 1.3.16-beta

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,17 +1,19 @@
1
1
  import { shallow } from 'zustand/shallow';
2
- import React, { useState, forwardRef, useImperativeHandle, useEffect } from 'react';
2
+ import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
3
3
  import classNames from 'classnames';
4
4
  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 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
+ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
7
8
  import { Typography, Spinner, Button, Callout, Alert } from '@bigbinary/neetoui';
8
9
  import { useTranslation, Trans } from 'react-i18next';
9
10
  import { useMutation } from 'react-query';
10
11
  import axios from 'axios';
11
12
  import platform from 'platform';
12
- import { isNotNil } from 'ramda';
13
+ import { isNotNil, isEmpty } from 'ramda';
13
14
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
14
15
  import { Pause, Delete, Download, Close } from '@bigbinary/neeto-icons';
16
+ import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils/general';
15
17
 
16
18
  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}}
17
19
 
@@ -501,7 +503,7 @@ var ONE_SECOND_IN_MILLISECONDS = 1000;
501
503
  var ONE_MINUTE_IN_MILLISECONDS = 60 * ONE_SECOND_IN_MILLISECONDS;
502
504
  var ONE_HOUR_IN_MILLISECONDS = 60 * ONE_MINUTE_IN_MILLISECONDS;
503
505
  var HAS_CHROME_NAMESPACE = (typeof chrome === "undefined" ? "undefined" : _typeof(chrome)) === "object";
504
- HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);
506
+ var IS_EXTENSION = HAS_CHROME_NAMESPACE && isNotNil(chrome.extension);
505
507
  platform.name === "Safari";
506
508
  var PERMISSIONS_HELP_DOC = "https://neetorecordhelp.neetokb.com/p/a-10efcfd7";
507
509
  // 2 hours
@@ -899,15 +901,42 @@ var UnSupportedBrowser = withT(function (_ref) {
899
901
  }, t("neetoMediaRecorder.unsupportedBrowser")));
900
902
  });
901
903
 
904
+ var generatePublicUrl = function generatePublicUrl(recordingId) {
905
+ var baseURL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.origin;
906
+ return "".concat(baseURL, "/watch/").concat(recordingId);
907
+ };
908
+
902
909
  var UploadingInProgress = function UploadingInProgress(_ref) {
903
910
  var recording = _ref.recording,
904
911
  onDiscard = _ref.onDiscard;
905
- var _useState = useState(false),
912
+ var _useState = useState(""),
906
913
  _useState2 = _slicedToArray(_useState, 2),
907
- isDiscardAlertOpen = _useState2[0],
908
- setIsDiscardAlertOpen = _useState2[1];
914
+ baseURL = _useState2[0],
915
+ setBaseURL = _useState2[1];
916
+ var _useState3 = useState(false),
917
+ _useState4 = _slicedToArray(_useState3, 2),
918
+ isDiscardAlertOpen = _useState4[0],
919
+ setIsDiscardAlertOpen = _useState4[1];
909
920
  var _useTranslation = useTranslation(),
910
921
  t = _useTranslation.t;
922
+ useEffect(function () {
923
+ if (!IS_EXTENSION) {
924
+ setBaseURL(window.location.origin);
925
+ return;
926
+ }
927
+ chrome.storage.local.get("baseURL").then(function (_ref2) {
928
+ var baseURL = _ref2.baseURL;
929
+ setBaseURL(baseURL);
930
+ });
931
+ }, []);
932
+ useEffect(function () {
933
+ if (!window.document.hasFocus() || !recording.id || isEmpty(baseURL)) {
934
+ return;
935
+ }
936
+ copyToClipboard(generatePublicUrl(recording.id, baseURL), {
937
+ message: t("neetoMediaRecorder.record.copyToClipboardToastrMessage")
938
+ });
939
+ }, [recording.id, baseURL]);
911
940
  var handleRecordingBlobDownload = function handleRecordingBlobDownload() {
912
941
  downloadRecordingBlob(screenRecorder.getWebmMediaBlob(), recording.title);
913
942
  };
@@ -1131,6 +1160,11 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1131
1160
  onDiscard: handleDiscardRecording
1132
1161
  });
1133
1162
  }
1163
+ if (isRecorderStatus(SCREEN_RECORDER_STATUS.stopped) && isUploadStatus(UPLOAD_STATUS.completed)) {
1164
+ return /*#__PURE__*/React.createElement("div", {
1165
+ className: "h-screen w-full"
1166
+ }, /*#__PURE__*/React.createElement(PageLoader, null));
1167
+ }
1134
1168
  if (hasRecordingDiscarded({
1135
1169
  recorderStatus: recorderStatus,
1136
1170
  uploadStatus: uploadStatus