@bigbinary/neeto-media-recorder 2.7.29-beta.2 → 2.7.30

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
@@ -8,6 +8,7 @@ import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
8
8
  import Alert from '@bigbinary/neetoui/Alert';
9
9
  import { Trans, useTranslation } from 'react-i18next';
10
10
  import axios from 'axios';
11
+ import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils/general';
11
12
  import Toastr from '@bigbinary/neetoui/Toastr';
12
13
  import platform from 'platform';
13
14
  import { isNotNil } from 'ramda';
@@ -688,48 +689,119 @@ var copyRecordingLinkToClipboardOnStop = function copyRecordingLinkToClipboardOn
688
689
  recordingRef = _ref3.recordingRef,
689
690
  baseURLRef = _ref3.baseURLRef,
690
691
  successMessage = _ref3.successMessage;
691
- if (typeof window.ClipboardItem !== "function" || !((_navigator$clipboard = navigator.clipboard) !== null && _navigator$clipboard !== void 0 && _navigator$clipboard.write)) {
692
+ var resolveLink = /*#__PURE__*/function () {
693
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
694
+ var _recordingRef$current;
695
+ var recordingId, baseURL;
696
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
697
+ while (1) switch (_context2.prev = _context2.next) {
698
+ case 0:
699
+ if (!(createRecordingPromise !== null && createRecordingPromise !== void 0 && createRecordingPromise.current)) {
700
+ _context2.next = 3;
701
+ break;
702
+ }
703
+ _context2.next = 3;
704
+ return createRecordingPromise.current;
705
+ case 3:
706
+ recordingId = recordingRef === null || recordingRef === void 0 ? void 0 : (_recordingRef$current = recordingRef.current) === null || _recordingRef$current === void 0 ? void 0 : _recordingRef$current.id;
707
+ baseURL = baseURLRef === null || baseURLRef === void 0 ? void 0 : baseURLRef.current;
708
+ if (!(!recordingId || !baseURL)) {
709
+ _context2.next = 7;
710
+ break;
711
+ }
712
+ throw new Error("Recording id or base URL unavailable");
713
+ case 7:
714
+ return _context2.abrupt("return", generatePublicUrl(recordingId, baseURL));
715
+ case 8:
716
+ case "end":
717
+ return _context2.stop();
718
+ }
719
+ }, _callee2);
720
+ }));
721
+ return function resolveLink() {
722
+ return _ref4.apply(this, arguments);
723
+ };
724
+ }();
725
+ if (typeof window.ClipboardItem === "function" && (_navigator$clipboard = navigator.clipboard) !== null && _navigator$clipboard !== void 0 && _navigator$clipboard.write) {
726
+ var linkBlobPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
727
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
728
+ while (1) switch (_context3.prev = _context3.next) {
729
+ case 0:
730
+ _context3.t0 = Blob;
731
+ _context3.next = 3;
732
+ return resolveLink();
733
+ case 3:
734
+ _context3.t1 = _context3.sent;
735
+ _context3.t2 = [_context3.t1];
736
+ _context3.t3 = {
737
+ type: "text/plain"
738
+ };
739
+ return _context3.abrupt("return", new _context3.t0(_context3.t2, _context3.t3));
740
+ case 7:
741
+ case "end":
742
+ return _context3.stop();
743
+ }
744
+ }, _callee3);
745
+ }))();
746
+
747
+ // Synchronously initiate clipboard.write so Safari preserves the user
748
+ // activation across the wait for linkBlobPromise.
749
+ var writePromise = navigator.clipboard.write([new ClipboardItem({
750
+ "text/plain": linkBlobPromise
751
+ })]);
752
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
753
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
754
+ while (1) switch (_context4.prev = _context4.next) {
755
+ case 0:
756
+ _context4.prev = 0;
757
+ _context4.next = 3;
758
+ return writePromise;
759
+ case 3:
760
+ Toastr.success(successMessage);
761
+ _context4.next = 8;
762
+ break;
763
+ case 6:
764
+ _context4.prev = 6;
765
+ _context4.t0 = _context4["catch"](0);
766
+ case 8:
767
+ case "end":
768
+ return _context4.stop();
769
+ }
770
+ }, _callee4, null, [[0, 6]]);
771
+ }))();
692
772
  return;
693
773
  }
694
- var linkBlobPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
695
- var _recordingRef$current;
696
- var recordingId, baseURL;
697
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
698
- while (1) switch (_context2.prev = _context2.next) {
774
+
775
+ // Legacy fallback for browsers without ClipboardItem (e.g. Firefox < 127).
776
+ // These browsers don't enforce Safari's strict gesture requirement, so a
777
+ // deferred async write is acceptable. copyToClipboard handles its own
778
+ // success toastr and falls back to document.execCommand internally.
779
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
780
+ var link;
781
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
782
+ while (1) switch (_context5.prev = _context5.next) {
699
783
  case 0:
700
- if (!(createRecordingPromise !== null && createRecordingPromise !== void 0 && createRecordingPromise.current)) {
701
- _context2.next = 3;
702
- break;
703
- }
704
- _context2.next = 3;
705
- return createRecordingPromise.current;
784
+ _context5.prev = 0;
785
+ _context5.next = 3;
786
+ return resolveLink();
706
787
  case 3:
707
- recordingId = recordingRef === null || recordingRef === void 0 ? void 0 : (_recordingRef$current = recordingRef.current) === null || _recordingRef$current === void 0 ? void 0 : _recordingRef$current.id;
708
- baseURL = baseURLRef === null || baseURLRef === void 0 ? void 0 : baseURLRef.current;
709
- if (!(!recordingId || !baseURL)) {
710
- _context2.next = 7;
711
- break;
712
- }
713
- throw new Error("Recording id or base URL unavailable");
714
- case 7:
715
- return _context2.abrupt("return", new Blob([generatePublicUrl(recordingId, baseURL)], {
716
- type: "text/plain"
717
- }));
788
+ link = _context5.sent;
789
+ _context5.next = 6;
790
+ return copyToClipboard(link, {
791
+ message: successMessage
792
+ });
793
+ case 6:
794
+ _context5.next = 10;
795
+ break;
718
796
  case 8:
797
+ _context5.prev = 8;
798
+ _context5.t0 = _context5["catch"](0);
799
+ case 10:
719
800
  case "end":
720
- return _context2.stop();
801
+ return _context5.stop();
721
802
  }
722
- }, _callee2);
803
+ }, _callee5, null, [[0, 8]]);
723
804
  }))();
724
-
725
- // Swallow the unhandled rejection on the inner promise; clipboard.write
726
- // already observes it, but we don't want stray unhandled rejection logs.
727
- linkBlobPromise["catch"](noop);
728
- navigator.clipboard.write([new ClipboardItem({
729
- "text/plain": linkBlobPromise
730
- })]).then(function () {
731
- return Toastr.success(successMessage);
732
- })["catch"](noop);
733
805
  };
734
806
 
735
807
  function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }