@bigbinary/neeto-media-recorder 1.4.0-beta2 → 2.0.1

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 React, { useState, useEffect, forwardRef, useImperativeHandle, useRef } 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 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';
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, IS_EXTENSION as IS_EXTENSION$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 PageLoader from '@bigbinary/neeto-molecules/PageLoader';
8
8
  import { Typography, Spinner, Button, Callout, Alert } from '@bigbinary/neetoui';
@@ -10,14 +10,15 @@ import { useTranslation, Trans } from 'react-i18next';
10
10
  import { useMutation } from '@tanstack/react-query';
11
11
  import axios from 'axios';
12
12
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
13
- import { Computer, Unlock, Pause, Delete, Download, Close } from '@bigbinary/neeto-icons';
13
+ import { Computer, Unlock, Pause, Delete, Copy, Download, Close } from '@bigbinary/neeto-icons';
14
14
  import platform from 'platform';
15
15
  import { isNotNil, isEmpty } from 'ramda';
16
16
  import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils/general';
17
+ import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardButton';
17
18
 
18
19
  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
20
 
20
- var css = ".nrec-done-button{background-color:rgb(var(--neeto-ui-error-100));padding:8px 12px}.nrec-done-button:hover{box-shadow:0 0 0 3px rgba(var(--neeto-ui-error-500),15%)}";
21
+ var css = ".nrec-done-button{background-color:rgb(var(--neeto-ui-error-100));padding:8px 12px}.nrec-done-button:hover{box-shadow:0 0 0 3px rgba(var(--neeto-ui-error-500),15%)}body .neeto-ui-modal__wrapper .neeto-ui-btn--style-danger{background:rgb(var(--neeto-ui-error-500))}.nrec-media-upload-loader{background:#d9d9d9;border-radius:14px;display:inline-block;height:10px;margin:0 auto;max-width:480px;overflow:hidden;position:relative;width:100%}.nrec-media-upload-loader:after{animation:movementLoader 3s linear infinite,barAnimation 1.5s linear infinite;background-color:#fff;background-image:linear-gradient(45deg,#268e6c 25%,#12805c 0,#12805c 50%,#268e6c 0,#268e6c 75%,#12805c 0,#12805c);background-size:1em 1em;border-radius:14px;box-sizing:border-box;content:\"\";height:10px;left:0;position:absolute;top:0;width:230px}@media only screen and (max-width:767px){.nrec-media-upload-loader:after{width:130px}}@keyframes barAnimation{0%{background-position:1em 0}to{background-position:0 0}}@keyframes movementLoader{0%{left:0;transform:translateX(-100%)}to{left:100%;transform:translateX(0)}}";
21
22
  n(css,{});
22
23
 
23
24
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -501,8 +502,12 @@ function _defineProperty(obj, key, value) {
501
502
  }
502
503
 
503
504
  var baseUrl = "/api/v1/recordings";
504
- var create = function create() {
505
- return axios.post(baseUrl);
505
+ var create = function create(deviceInfo) {
506
+ return axios.post(baseUrl, {
507
+ recording: {
508
+ deviceInfo: deviceInfo
509
+ }
510
+ });
506
511
  };
507
512
  var update = function update(_ref) {
508
513
  var id = _ref.id,
@@ -888,6 +893,63 @@ var getRecorderTimeLimitInHumanFormat = function getRecorderTimeLimitInHumanForm
888
893
  }
889
894
  return "".concat(hours, " hours");
890
895
  };
896
+ var getDeviceInfo = /*#__PURE__*/function () {
897
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
898
+ var _yield$chrome$storage, _platform$os;
899
+ var isCameraEnabled;
900
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
901
+ while (1) switch (_context.prev = _context.next) {
902
+ case 0:
903
+ if (!IS_EXTENSION$1) {
904
+ _context.next = 15;
905
+ break;
906
+ }
907
+ _context.next = 3;
908
+ return chrome.storage.local.get("isCameraOn");
909
+ case 3:
910
+ _context.t2 = _yield$chrome$storage = _context.sent;
911
+ _context.t1 = _context.t2 === null;
912
+ if (_context.t1) {
913
+ _context.next = 7;
914
+ break;
915
+ }
916
+ _context.t1 = _yield$chrome$storage === void 0;
917
+ case 7:
918
+ if (!_context.t1) {
919
+ _context.next = 11;
920
+ break;
921
+ }
922
+ _context.t3 = void 0;
923
+ _context.next = 12;
924
+ break;
925
+ case 11:
926
+ _context.t3 = _yield$chrome$storage.isCameraOn;
927
+ case 12:
928
+ _context.t0 = _context.t3;
929
+ _context.next = 16;
930
+ break;
931
+ case 15:
932
+ _context.t0 = false;
933
+ case 16:
934
+ isCameraEnabled = _context.t0;
935
+ return _context.abrupt("return", {
936
+ os: (_platform$os = platform.os) === null || _platform$os === void 0 ? void 0 : _platform$os.toString(),
937
+ app: IS_EXTENSION$1 ? "chrome extension v".concat(chrome.runtime.getManifest().version) : "web",
938
+ browser: "".concat(platform.name, " v").concat(platform.version),
939
+ isCameraEnabled: isCameraEnabled,
940
+ isMicEnabled: !!screenRecorder.audioConfiguration,
941
+ displaySurface: screenRecorder.displaySurface
942
+ });
943
+ case 18:
944
+ case "end":
945
+ return _context.stop();
946
+ }
947
+ }, _callee);
948
+ }));
949
+ return function getDeviceInfo() {
950
+ return _ref2.apply(this, arguments);
951
+ };
952
+ }();
891
953
 
892
954
  var Timer = function Timer() {
893
955
  var _useTranslation = useTranslation(),
@@ -969,31 +1031,45 @@ var UploadingInProgress = function UploadingInProgress(_ref) {
969
1031
  return /*#__PURE__*/React.createElement("div", {
970
1032
  className: "flex h-screen w-full flex-col items-center justify-center"
971
1033
  }, /*#__PURE__*/React.createElement("div", {
972
- className: "flex h-full w-full flex-col items-center justify-start py-10 xl:py-14 2xl:py-20"
1034
+ className: "flex h-full w-full flex-col items-center justify-start py-14 lg:py-20 xl:py-28 2xl:py-36"
973
1035
  }, /*#__PURE__*/React.createElement("div", {
974
- className: "w-full space-y-2 pb-6 text-center"
1036
+ className: "w-full pb-6 text-center"
975
1037
  }, /*#__PURE__*/React.createElement(Typography, {
976
- className: "select-none",
1038
+ className: "select-none pb-6",
1039
+ "data-cy": "please-dont-close-this-tab",
1040
+ style: "h1"
1041
+ }, t("neetoMediaRecorder.record.pleaseDontCloseThisTab")), /*#__PURE__*/React.createElement(Typography, {
1042
+ className: "select-none pb-3",
977
1043
  "data-cy": "recorder-uploading-recording-message",
978
- style: "h2"
979
- }, t("neetoMediaRecorder.record.uploadingRecording"), /*#__PURE__*/React.createElement(Spinner, {
980
- className: "ml-3 select-none"
1044
+ style: "h2",
1045
+ weight: "normal"
1046
+ }, t("neetoMediaRecorder.record.uploadingRecording")), /*#__PURE__*/React.createElement("div", {
1047
+ className: "pb-3"
1048
+ }, /*#__PURE__*/React.createElement("span", {
1049
+ className: "nrec-media-upload-loader"
981
1050
  })), /*#__PURE__*/React.createElement(Typography, {
982
1051
  className: "select-none",
983
- "data-cy": "recorder-do-not-leave-page-message"
984
- }, t("neetoMediaRecorder.record.doNotLeaveThePage"))), /*#__PURE__*/React.createElement("div", {
985
- className: "flex flex-wrap items-center justify-center gap-4"
986
- }, /*#__PURE__*/React.createElement(Button, {
1052
+ "data-cy": "recorder-do-not-leave-page-message",
1053
+ style: "body2"
1054
+ }, t("neetoMediaRecorder.record.copyLinkDescription"))), /*#__PURE__*/React.createElement("div", {
1055
+ className: "flex flex-wrap items-center justify-center gap-3"
1056
+ }, /*#__PURE__*/React.createElement(CopyToClipboardButton, {
1057
+ "data-cy": "recorder-copy-link-button",
1058
+ icon: Copy,
1059
+ label: t("neetoMediaRecorder.record.copyToClipboard"),
1060
+ style: "tertiary",
1061
+ value: generatePublicUrl(recording.id, baseURL)
1062
+ }), /*#__PURE__*/React.createElement(Button, {
987
1063
  "data-cy": "recorder-download-webm-button",
988
1064
  icon: Download,
989
1065
  label: t("neetoMediaRecorder.record.downloadWebm"),
990
- style: "secondary",
1066
+ style: "tertiary",
991
1067
  onClick: handleRecordingBlobDownload
992
1068
  }), /*#__PURE__*/React.createElement(Button, {
993
1069
  "data-cy": "recorder-discard-recording-button",
994
1070
  icon: Close,
995
1071
  label: t("neetoMediaRecorder.record.discardRecording"),
996
- style: "secondary",
1072
+ style: "tertiary",
997
1073
  onClick: function onClick() {
998
1074
  return setIsDiscardAlertOpen(true);
999
1075
  }
@@ -1178,6 +1254,27 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1178
1254
  recording = _useCreateRecording$d3 === void 0 ? {} : _useCreateRecording$d3;
1179
1255
  var _useRecordingUploadSu = useRecordingUploadSuccess(),
1180
1256
  markRecordingAsUploaded = _useRecordingUploadSu.mutate;
1257
+ var handleCreateRecording = /*#__PURE__*/function () {
1258
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1259
+ var deviceInfo;
1260
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1261
+ while (1) switch (_context.prev = _context.next) {
1262
+ case 0:
1263
+ _context.next = 2;
1264
+ return getDeviceInfo();
1265
+ case 2:
1266
+ deviceInfo = _context.sent;
1267
+ createRecording(deviceInfo);
1268
+ case 4:
1269
+ case "end":
1270
+ return _context.stop();
1271
+ }
1272
+ }, _callee);
1273
+ }));
1274
+ return function handleCreateRecording() {
1275
+ return _ref3.apply(this, arguments);
1276
+ };
1277
+ }();
1181
1278
  var handleUploadComplete = function handleUploadComplete() {
1182
1279
  return markRecordingAsUploaded(recording.id, {
1183
1280
  onSuccess: function onSuccess() {
@@ -1186,49 +1283,49 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1186
1283
  });
1187
1284
  };
1188
1285
  var handleDiscardRecording = /*#__PURE__*/function () {
1189
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1286
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1190
1287
  var uploadStatus;
1191
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1192
- while (1) switch (_context.prev = _context.next) {
1288
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1289
+ while (1) switch (_context2.prev = _context2.next) {
1193
1290
  case 0:
1194
- _context.next = 2;
1291
+ _context2.next = 2;
1195
1292
  return multipartS3Uploader.abortUpload();
1196
1293
  case 2:
1197
1294
  uploadStatus = useMultipartS3UploadStore.getState().status;
1198
1295
  if (!(uploadStatus === UPLOAD_STATUS.aborting)) {
1199
- _context.next = 5;
1296
+ _context2.next = 5;
1200
1297
  break;
1201
1298
  }
1202
- return _context.abrupt("return");
1299
+ return _context2.abrupt("return");
1203
1300
  case 5:
1204
1301
  onDiscard();
1205
1302
  case 6:
1206
1303
  case "end":
1207
- return _context.stop();
1304
+ return _context2.stop();
1208
1305
  }
1209
- }, _callee);
1306
+ }, _callee2);
1210
1307
  }));
1211
1308
  return function handleDiscardRecording() {
1212
- return _ref3.apply(this, arguments);
1309
+ return _ref4.apply(this, arguments);
1213
1310
  };
1214
1311
  }();
1215
1312
  var handleRestartRecording = /*#__PURE__*/function () {
1216
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1217
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1218
- while (1) switch (_context2.prev = _context2.next) {
1313
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
1314
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1315
+ while (1) switch (_context3.prev = _context3.next) {
1219
1316
  case 0:
1220
- _context2.next = 2;
1317
+ _context3.next = 2;
1221
1318
  return multipartS3Uploader.abortUpload();
1222
1319
  case 2:
1223
1320
  multipartS3Uploader.resetState();
1224
1321
  case 3:
1225
1322
  case "end":
1226
- return _context2.stop();
1323
+ return _context3.stop();
1227
1324
  }
1228
- }, _callee2);
1325
+ }, _callee3);
1229
1326
  }));
1230
1327
  return function handleRestartRecording() {
1231
- return _ref4.apply(this, arguments);
1328
+ return _ref5.apply(this, arguments);
1232
1329
  };
1233
1330
  }();
1234
1331
  var handleDiscardAlertClose = function handleDiscardAlertClose() {
@@ -1293,7 +1390,7 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1293
1390
  };
1294
1391
  }, [recording.id]);
1295
1392
  useEffect(function () {
1296
- screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onStart, createRecording);
1393
+ screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onStart, handleCreateRecording);
1297
1394
  screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onDiscardDuringCountdown, onDiscard);
1298
1395
  return function () {
1299
1396
  screenRecorder.revokePermissions();