@bigbinary/neeto-media-recorder 1.0.2 → 1.0.3

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,13 +1,13 @@
1
1
  import { shallow } from 'zustand/shallow';
2
- import React, { useEffect, useState } from 'react';
3
- import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
2
+ import React, { useState, useEffect } from 'react';
3
+ import classNames from 'classnames';
4
4
  import { Typography, Spinner, Button, Alert, Callout } from '@bigbinary/neetoui';
5
5
  import { isEmpty } from 'ramda';
6
- import { useTranslation, Trans } from 'react-i18next';
6
+ import { useTranslation } from 'react-i18next';
7
7
  import { useMutation } from 'react-query';
8
8
  import axios from 'axios';
9
9
  import { screenRecorder, multipartS3Uploader } from '@bigbinary/neeto-media-recorder/core';
10
- import { SCREEN_RECORDER_STATUS, SCREEN_RECORDER_ERROR, ONE_MINUTE_IN_MILLISECONDS, ONE_SECOND_IN_MILLISECONDS, UPLOAD_STATUS, SCREEN_RECORDER_EVENT, UPLOAD_EVENT } from '@bigbinary/neeto-media-recorder/constants';
10
+ import { SCREEN_RECORDER_STATUS, SCREEN_RECORDER_ERROR, ONE_MINUTE_IN_MILLISECONDS, ONE_SECOND_IN_MILLISECONDS, SCREEN_RECORDER_EVENT, UPLOAD_EVENT, UPLOAD_STATUS } from '@bigbinary/neeto-media-recorder/constants';
11
11
  import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
12
12
  import { isNotEmpty, noop } from '@bigbinary/neeto-cist';
13
13
  import { Pause, Delete, Copy } from '@bigbinary/neeto-icons';
@@ -453,69 +453,6 @@ try {
453
453
 
454
454
  var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
455
455
 
456
- var classnames = {exports: {}};
457
-
458
- /*!
459
- Copyright (c) 2018 Jed Watson.
460
- Licensed under the MIT License (MIT), see
461
- http://jedwatson.github.io/classnames
462
- */
463
- classnames.exports;
464
-
465
- (function (module) {
466
- /* global define */
467
-
468
- (function () {
469
-
470
- var hasOwn = {}.hasOwnProperty;
471
-
472
- function classNames() {
473
- var classes = [];
474
-
475
- for (var i = 0; i < arguments.length; i++) {
476
- var arg = arguments[i];
477
- if (!arg) continue;
478
-
479
- var argType = typeof arg;
480
-
481
- if (argType === 'string' || argType === 'number') {
482
- classes.push(arg);
483
- } else if (Array.isArray(arg)) {
484
- if (arg.length) {
485
- var inner = classNames.apply(null, arg);
486
- if (inner) {
487
- classes.push(inner);
488
- }
489
- }
490
- } else if (argType === 'object') {
491
- if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
492
- classes.push(arg.toString());
493
- continue;
494
- }
495
-
496
- for (var key in arg) {
497
- if (hasOwn.call(arg, key) && arg[key]) {
498
- classes.push(key);
499
- }
500
- }
501
- }
502
- }
503
-
504
- return classes.join(' ');
505
- }
506
-
507
- if (module.exports) {
508
- classNames.default = classNames;
509
- module.exports = classNames;
510
- } else {
511
- window.classNames = classNames;
512
- }
513
- }());
514
- } (classnames));
515
-
516
- var classnamesExports = classnames.exports;
517
- var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
518
-
519
456
  var baseUrl = "/api/v1/recordings";
520
457
  var create = function create(payload) {
521
458
  return axios.post(baseUrl, payload);
@@ -546,28 +483,6 @@ var useRecordingUploadSuccess = function useRecordingUploadSuccess() {
546
483
  });
547
484
  };
548
485
 
549
- var useBeforeUnload = function useBeforeUnload(enabled) {
550
- var _useTranslation = useTranslation(),
551
- t = _useTranslation.t;
552
- var handler = function handler(event) {
553
- event.preventDefault();
554
- var defaultMessage = t("neetoMediaRecorder.common.leaveSite");
555
-
556
- // Gecko + IE browsers
557
- event.returnValue = defaultMessage;
558
-
559
- // Safari, Chrome, and other WebKit-derived browsers
560
- return defaultMessage;
561
- };
562
- useEffect(function () {
563
- if (!enabled) return undefined;
564
- window.addEventListener("beforeunload", handler);
565
- return function () {
566
- return window.removeEventListener("beforeunload", handler);
567
- };
568
- }, [enabled]);
569
- };
570
-
571
486
  var AbortUpload = withT(function (_ref) {
572
487
  var t = _ref.t;
573
488
  return /*#__PURE__*/React.createElement("div", {
@@ -907,29 +822,6 @@ var useMultipartS3UploadStatus = function useMultipartS3UploadStatus() {
907
822
  };
908
823
  };
909
824
 
910
- var SetChromeFlags = function SetChromeFlags() {
911
- return /*#__PURE__*/React.createElement("div", {
912
- className: "flex h-screen w-full flex-col items-center justify-center"
913
- }, /*#__PURE__*/React.createElement("div", {
914
- className: "flex h-full w-full flex-col items-center justify-center space-y-4"
915
- }, /*#__PURE__*/React.createElement(Callout, {
916
- className: "mb-2 p-3",
917
- style: "danger"
918
- }, /*#__PURE__*/React.createElement(Typography, {
919
- style: "body2"
920
- }, /*#__PURE__*/React.createElement(Trans, {
921
- i18nKey: "record.chromeFlagsMissingMessage",
922
- components: {
923
- Button: /*#__PURE__*/React.createElement(Button, {
924
- href: "https://github.com/bigbinary/neeto-record-web#local-development-setup",
925
- rel: "noreferrer",
926
- style: "link",
927
- target: "_blank"
928
- })
929
- }
930
- })))));
931
- };
932
-
933
825
  var formatTime = function formatTime(time) {
934
826
  return Math.floor(time).toString().padStart(2, "0");
935
827
  };
@@ -987,6 +879,7 @@ var UploadingInProgress = withT(function (_ref) {
987
879
  }), /*#__PURE__*/React.createElement(Spinner, null)));
988
880
  });
989
881
 
882
+ var useRecorderStore = screenRecorder.useRecorderStore;
990
883
  var MediaRecorder = function MediaRecorder(_ref) {
991
884
  var _ref$onUploadComplete = _ref.onUploadComplete,
992
885
  onUploadComplete = _ref$onUploadComplete === void 0 ? noop : _ref$onUploadComplete,
@@ -1002,7 +895,6 @@ var MediaRecorder = function MediaRecorder(_ref) {
1002
895
  _useState4 = _slicedToArray(_useState3, 2),
1003
896
  uploadId = _useState4[0],
1004
897
  setUploadId = _useState4[1];
1005
- var useRecorderStore = screenRecorder.useRecorderStore;
1006
898
  var _useRecorderStore = useRecorderStore(function (store) {
1007
899
  return {
1008
900
  status: store["status"],
@@ -1071,8 +963,6 @@ var MediaRecorder = function MediaRecorder(_ref) {
1071
963
  return _ref3.apply(this, arguments);
1072
964
  };
1073
965
  }();
1074
- var shouldShowConfirmation = isRecorderStatus(SCREEN_RECORDER_STATUS.recording, SCREEN_RECORDER_STATUS.paused, SCREEN_RECORDER_STATUS.stopping) || isUploadStatus(UPLOAD_STATUS.uploading, UPLOAD_STATUS.aborting, UPLOAD_STATUS.completed);
1075
- useBeforeUnload(shouldShowConfirmation);
1076
966
  useEffect(function () {
1077
967
  if (!isRecorderStatus(SCREEN_RECORDER_STATUS.idle) || error === SCREEN_RECORDER_ERROR.NotAllowedError) {
1078
968
  return;
@@ -1105,9 +995,6 @@ var MediaRecorder = function MediaRecorder(_ref) {
1105
995
  };
1106
996
  }, []);
1107
997
  if (error === SCREEN_RECORDER_ERROR.UnSupportedBrowser) return /*#__PURE__*/React.createElement(UnSupportedBrowser, null);
1108
- if (globalProps.railsEnv === "development" && error === SCREEN_RECORDER_ERROR.TypeError) {
1109
- return /*#__PURE__*/React.createElement(SetChromeFlags, null);
1110
- }
1111
998
  if (isRecorderStatus(SCREEN_RECORDER_STATUS.stopped) && isUploadStatus(UPLOAD_STATUS.uploading)) {
1112
999
  return /*#__PURE__*/React.createElement(UploadingInProgress, {
1113
1000
  recordingId: recordingId