@bigbinary/neeto-media-recorder 2.0.0 → 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';
@@ -502,8 +502,12 @@ function _defineProperty(obj, key, value) {
502
502
  }
503
503
 
504
504
  var baseUrl = "/api/v1/recordings";
505
- var create = function create() {
506
- return axios.post(baseUrl);
505
+ var create = function create(deviceInfo) {
506
+ return axios.post(baseUrl, {
507
+ recording: {
508
+ deviceInfo: deviceInfo
509
+ }
510
+ });
507
511
  };
508
512
  var update = function update(_ref) {
509
513
  var id = _ref.id,
@@ -889,6 +893,63 @@ var getRecorderTimeLimitInHumanFormat = function getRecorderTimeLimitInHumanForm
889
893
  }
890
894
  return "".concat(hours, " hours");
891
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
+ }();
892
953
 
893
954
  var Timer = function Timer() {
894
955
  var _useTranslation = useTranslation(),
@@ -1193,6 +1254,27 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1193
1254
  recording = _useCreateRecording$d3 === void 0 ? {} : _useCreateRecording$d3;
1194
1255
  var _useRecordingUploadSu = useRecordingUploadSuccess(),
1195
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
+ }();
1196
1278
  var handleUploadComplete = function handleUploadComplete() {
1197
1279
  return markRecordingAsUploaded(recording.id, {
1198
1280
  onSuccess: function onSuccess() {
@@ -1201,49 +1283,49 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1201
1283
  });
1202
1284
  };
1203
1285
  var handleDiscardRecording = /*#__PURE__*/function () {
1204
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1286
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1205
1287
  var uploadStatus;
1206
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1207
- while (1) switch (_context.prev = _context.next) {
1288
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1289
+ while (1) switch (_context2.prev = _context2.next) {
1208
1290
  case 0:
1209
- _context.next = 2;
1291
+ _context2.next = 2;
1210
1292
  return multipartS3Uploader.abortUpload();
1211
1293
  case 2:
1212
1294
  uploadStatus = useMultipartS3UploadStore.getState().status;
1213
1295
  if (!(uploadStatus === UPLOAD_STATUS.aborting)) {
1214
- _context.next = 5;
1296
+ _context2.next = 5;
1215
1297
  break;
1216
1298
  }
1217
- return _context.abrupt("return");
1299
+ return _context2.abrupt("return");
1218
1300
  case 5:
1219
1301
  onDiscard();
1220
1302
  case 6:
1221
1303
  case "end":
1222
- return _context.stop();
1304
+ return _context2.stop();
1223
1305
  }
1224
- }, _callee);
1306
+ }, _callee2);
1225
1307
  }));
1226
1308
  return function handleDiscardRecording() {
1227
- return _ref3.apply(this, arguments);
1309
+ return _ref4.apply(this, arguments);
1228
1310
  };
1229
1311
  }();
1230
1312
  var handleRestartRecording = /*#__PURE__*/function () {
1231
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
1232
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1233
- 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) {
1234
1316
  case 0:
1235
- _context2.next = 2;
1317
+ _context3.next = 2;
1236
1318
  return multipartS3Uploader.abortUpload();
1237
1319
  case 2:
1238
1320
  multipartS3Uploader.resetState();
1239
1321
  case 3:
1240
1322
  case "end":
1241
- return _context2.stop();
1323
+ return _context3.stop();
1242
1324
  }
1243
- }, _callee2);
1325
+ }, _callee3);
1244
1326
  }));
1245
1327
  return function handleRestartRecording() {
1246
- return _ref4.apply(this, arguments);
1328
+ return _ref5.apply(this, arguments);
1247
1329
  };
1248
1330
  }();
1249
1331
  var handleDiscardAlertClose = function handleDiscardAlertClose() {
@@ -1308,7 +1390,7 @@ var MediaRecorder = function MediaRecorder(_ref, ref) {
1308
1390
  };
1309
1391
  }, [recording.id]);
1310
1392
  useEffect(function () {
1311
- screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onStart, createRecording);
1393
+ screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onStart, handleCreateRecording);
1312
1394
  screenRecorder.addCallback(SCREEN_RECORDER_EVENT.onDiscardDuringCountdown, onDiscard);
1313
1395
  return function () {
1314
1396
  screenRecorder.revokePermissions();