@atlaskit/media-client 37.2.16 → 37.2.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 37.2.18
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e3550afc43327`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e3550afc43327) -
8
+ [ux] EDITOR-7679 bug fix for media name fallback falling back to "download" when the media name
9
+ was not being passed
10
+ - Updated dependencies
11
+
12
+ ## 37.2.17
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 37.2.16
4
19
 
5
20
  ### Patch Changes
@@ -28,6 +28,7 @@ var _v = _interopRequireDefault(require("uuid/v4"));
28
28
  var _mediaCore = require("@atlaskit/media-core");
29
29
  var _isValidUuid = require("@atlaskit/media-common/isValidUuid");
30
30
  var _downloadUrl = require("@atlaskit/media-common/downloadUrl");
31
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
31
32
  var _mediaStore = require("../media-store");
32
33
  var _fileState2 = require("../../models/file-state");
33
34
  var _media = require("../../models/media");
@@ -751,24 +752,31 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
751
752
  }, {
752
753
  key: "downloadBinary",
753
754
  value: function () {
754
- var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(id) {
755
- var name,
756
- collectionName,
757
- traceContext,
758
- url,
759
- _args1 = arguments;
755
+ var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(id, name, collectionName, traceContext) {
756
+ var downloadName, url, _t5;
760
757
  return _regenerator.default.wrap(function (_context1) {
761
758
  while (1) switch (_context1.prev = _context1.next) {
762
759
  case 0:
763
- name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
764
- collectionName = _args1.length > 2 ? _args1[2] : undefined;
765
- traceContext = _args1.length > 3 ? _args1[3] : undefined;
760
+ downloadName = name !== null && name !== void 0 ? name : 'download';
761
+ if (!(0, _expValEquals.expValEquals)('platform_editor_media_download_fallback_name', 'isEnabled', true)) {
762
+ _context1.next = 2;
763
+ break;
764
+ }
766
765
  _context1.next = 1;
767
766
  return this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name);
768
767
  case 1:
769
- url = _context1.sent;
768
+ _t5 = _context1.sent;
769
+ _context1.next = 4;
770
+ break;
771
+ case 2:
772
+ _context1.next = 3;
773
+ return this.mediaApi.getFileBinaryURL(id, collectionName);
774
+ case 3:
775
+ _t5 = _context1.sent;
776
+ case 4:
777
+ url = _t5;
770
778
  (0, _downloadUrl.downloadUrl)(url, {
771
- name: name
779
+ name: downloadName
772
780
  });
773
781
  _globalMediaEventEmitter.globalMediaEventEmitter.emit('media-viewed', {
774
782
  fileId: id,
@@ -776,17 +784,17 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
776
784
  viewingLevel: 'download'
777
785
  });
778
786
  // Test the download after initiated the Browser process to catch any potential errors.
779
- _context1.next = 2;
787
+ _context1.next = 5;
780
788
  return this.mediaApi.testUrl(url, {
781
789
  traceContext: traceContext
782
790
  });
783
- case 2:
791
+ case 5:
784
792
  case "end":
785
793
  return _context1.stop();
786
794
  }
787
795
  }, _callee1, this);
788
796
  }));
789
- function downloadBinary(_x22) {
797
+ function downloadBinary(_x22, _x23, _x24, _x25) {
790
798
  return _downloadBinary.apply(this, arguments);
791
799
  }
792
800
  return downloadBinary;
@@ -829,7 +837,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
829
837
  }
830
838
  }, _callee10, this);
831
839
  }));
832
- function registerCopyIntent(_x23, _x24) {
840
+ function registerCopyIntent(_x26, _x27) {
833
841
  return _registerCopyIntent.apply(this, arguments);
834
842
  }
835
843
  return registerCopyIntent;
@@ -838,7 +846,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
838
846
  key: "copyFileWithToken",
839
847
  value: function () {
840
848
  var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(source, destination, traceContext) {
841
- var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data, _t5;
849
+ var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data, _t6;
842
850
  return _regenerator.default.wrap(function (_context11) {
843
851
  while (1) switch (_context11.prev = _context11.next) {
844
852
  case 0:
@@ -847,13 +855,13 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
847
855
  mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
848
856
  authProvider: destinationAuthProvider
849
857
  });
850
- _t5 = _mediaCore.authToOwner;
858
+ _t6 = _mediaCore.authToOwner;
851
859
  _context11.next = 1;
852
860
  return authProvider({
853
861
  collectionName: sourceCollection
854
862
  });
855
863
  case 1:
856
- owner = _t5(_context11.sent);
864
+ owner = _t6(_context11.sent);
857
865
  body = {
858
866
  sourceFile: {
859
867
  id: id,
@@ -878,7 +886,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
878
886
  }
879
887
  }, _callee11);
880
888
  }));
881
- function copyFileWithToken(_x25, _x26, _x27) {
889
+ function copyFileWithToken(_x28, _x29, _x30) {
882
890
  return _copyFileWithToken.apply(this, arguments);
883
891
  }
884
892
  return copyFileWithToken;
@@ -907,7 +915,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
907
915
  }
908
916
  }, _callee12, this);
909
917
  }));
910
- function copyFileWithIntent(_x28, _x29, _x30) {
918
+ function copyFileWithIntent(_x31, _x32, _x33) {
911
919
  return _copyFileWithIntent.apply(this, arguments);
912
920
  }
913
921
  return copyFileWithIntent;
@@ -943,8 +951,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
943
951
  key,
944
952
  errorFileState,
945
953
  _args13 = arguments,
946
- _t6,
947
- _t7;
954
+ _t7,
955
+ _t8;
948
956
  return _regenerator.default.wrap(function (_context13) {
949
957
  while (1) switch (_context13.prev = _context13.next) {
950
958
  case 0:
@@ -986,20 +994,20 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
986
994
  previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
987
995
  preview: preview
988
996
  } : {};
989
- _t6 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
997
+ _t7 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
990
998
  // mimeType should always be returned by "copyFileWithToken"
991
999
  // but in case it's not, we don't want to penalize "copyFile"
992
1000
  copiedMimeType;
993
- if (!_t6) {
1001
+ if (!_t7) {
994
1002
  _context13.next = 7;
995
1003
  break;
996
1004
  }
997
1005
  _context13.next = 6;
998
1006
  return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
999
1007
  case 6:
1000
- _t6 = _context13.sent;
1008
+ _t7 = _context13.sent;
1001
1009
  case 7:
1002
- if (!_t6) {
1010
+ if (!_t7) {
1003
1011
  _context13.next = 8;
1004
1012
  break;
1005
1013
  }
@@ -1036,7 +1044,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
1036
1044
  return _context13.abrupt("return", copiedFile);
1037
1045
  case 10:
1038
1046
  _context13.prev = 10;
1039
- _t7 = _context13["catch"](1);
1047
+ _t8 = _context13["catch"](1);
1040
1048
  if (processingSubscription) {
1041
1049
  processingSubscription.unsubscribe();
1042
1050
  }
@@ -1044,23 +1052,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
1044
1052
  _fileCache = cache.get(replaceFileId);
1045
1053
  replaceFileState = this.store.getState().files[replaceFileId];
1046
1054
  if (_fileCache) {
1047
- _fileCache.error(_t7);
1055
+ _fileCache.error(_t8);
1048
1056
  } else {
1049
1057
  // Create a new subject with the error state for new subscriptions
1050
- cache.set(id, (0, _createMediaSubject.createMediaSubject)(_t7));
1058
+ cache.set(id, (0, _createMediaSubject.createMediaSubject)(_t8));
1051
1059
  }
1052
1060
  key = replaceFileState ? replaceFileId : id;
1053
- errorFileState = this.getErrorFileState(_t7, id, occurrenceKey);
1061
+ errorFileState = this.getErrorFileState(_t8, id, occurrenceKey);
1054
1062
  this.setFileState(key, errorFileState);
1055
1063
  }
1056
- throw _t7;
1064
+ throw _t8;
1057
1065
  case 11:
1058
1066
  case "end":
1059
1067
  return _context13.stop();
1060
1068
  }
1061
1069
  }, _callee13, this, [[1, 10]]);
1062
1070
  }));
1063
- function copyFile(_x31, _x32) {
1071
+ function copyFile(_x34, _x35) {
1064
1072
  return _copyFile.apply(this, arguments);
1065
1073
  }
1066
1074
  return copyFile;
@@ -6,6 +6,7 @@ import uuid from 'uuid/v4';
6
6
  import { authToOwner } from '@atlaskit/media-core';
7
7
  import { isValidUuid } from '@atlaskit/media-common/isValidUuid';
8
8
  import { downloadUrl } from '@atlaskit/media-common/downloadUrl';
9
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
10
  import { MediaStore as MediaApi } from '../media-store';
10
11
  import { isErrorFileState, isFinalFileState, isProcessingFileState, mapMediaFileToFileState, mapMediaItemToFileState } from '../../models/file-state';
11
12
  import { isNotFoundMediaItemDetails } from '../../models/media';
@@ -493,10 +494,11 @@ export class FileFetcherImpl {
493
494
  setTimeout(onProgress, 0, 0);
494
495
  return fromObservable(subject);
495
496
  }
496
- async downloadBinary(id, name = 'download', collectionName, traceContext) {
497
- const url = await this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name);
497
+ async downloadBinary(id, name, collectionName, traceContext) {
498
+ const downloadName = name !== null && name !== void 0 ? name : 'download';
499
+ const url = expValEquals('platform_editor_media_download_fallback_name', 'isEnabled', true) ? await this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name) : await this.mediaApi.getFileBinaryURL(id, collectionName);
498
500
  downloadUrl(url, {
499
- name
501
+ name: downloadName
500
502
  });
501
503
  globalMediaEventEmitter.emit('media-viewed', {
502
504
  fileId: id,
@@ -12,6 +12,7 @@ import uuid from 'uuid/v4';
12
12
  import { authToOwner } from '@atlaskit/media-core';
13
13
  import { isValidUuid } from '@atlaskit/media-common/isValidUuid';
14
14
  import { downloadUrl } from '@atlaskit/media-common/downloadUrl';
15
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
16
  import { MediaStore as MediaApi } from '../media-store';
16
17
  import { isErrorFileState, isFinalFileState, isProcessingFileState, mapMediaFileToFileState, mapMediaItemToFileState } from '../../models/file-state';
17
18
  import { isNotFoundMediaItemDetails } from '../../models/media';
@@ -734,24 +735,31 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
734
735
  }, {
735
736
  key: "downloadBinary",
736
737
  value: function () {
737
- var _downloadBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(id) {
738
- var name,
739
- collectionName,
740
- traceContext,
741
- url,
742
- _args1 = arguments;
738
+ var _downloadBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(id, name, collectionName, traceContext) {
739
+ var downloadName, url, _t5;
743
740
  return _regeneratorRuntime.wrap(function (_context1) {
744
741
  while (1) switch (_context1.prev = _context1.next) {
745
742
  case 0:
746
- name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
747
- collectionName = _args1.length > 2 ? _args1[2] : undefined;
748
- traceContext = _args1.length > 3 ? _args1[3] : undefined;
743
+ downloadName = name !== null && name !== void 0 ? name : 'download';
744
+ if (!expValEquals('platform_editor_media_download_fallback_name', 'isEnabled', true)) {
745
+ _context1.next = 2;
746
+ break;
747
+ }
749
748
  _context1.next = 1;
750
749
  return this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name);
751
750
  case 1:
752
- url = _context1.sent;
751
+ _t5 = _context1.sent;
752
+ _context1.next = 4;
753
+ break;
754
+ case 2:
755
+ _context1.next = 3;
756
+ return this.mediaApi.getFileBinaryURL(id, collectionName);
757
+ case 3:
758
+ _t5 = _context1.sent;
759
+ case 4:
760
+ url = _t5;
753
761
  downloadUrl(url, {
754
- name: name
762
+ name: downloadName
755
763
  });
756
764
  globalMediaEventEmitter.emit('media-viewed', {
757
765
  fileId: id,
@@ -759,17 +767,17 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
759
767
  viewingLevel: 'download'
760
768
  });
761
769
  // Test the download after initiated the Browser process to catch any potential errors.
762
- _context1.next = 2;
770
+ _context1.next = 5;
763
771
  return this.mediaApi.testUrl(url, {
764
772
  traceContext: traceContext
765
773
  });
766
- case 2:
774
+ case 5:
767
775
  case "end":
768
776
  return _context1.stop();
769
777
  }
770
778
  }, _callee1, this);
771
779
  }));
772
- function downloadBinary(_x22) {
780
+ function downloadBinary(_x22, _x23, _x24, _x25) {
773
781
  return _downloadBinary.apply(this, arguments);
774
782
  }
775
783
  return downloadBinary;
@@ -812,7 +820,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
812
820
  }
813
821
  }, _callee10, this);
814
822
  }));
815
- function registerCopyIntent(_x23, _x24) {
823
+ function registerCopyIntent(_x26, _x27) {
816
824
  return _registerCopyIntent.apply(this, arguments);
817
825
  }
818
826
  return registerCopyIntent;
@@ -821,7 +829,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
821
829
  key: "copyFileWithToken",
822
830
  value: function () {
823
831
  var _copyFileWithToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(source, destination, traceContext) {
824
- var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data, _t5;
832
+ var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data, _t6;
825
833
  return _regeneratorRuntime.wrap(function (_context11) {
826
834
  while (1) switch (_context11.prev = _context11.next) {
827
835
  case 0:
@@ -830,13 +838,13 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
830
838
  mediaStore = destination.mediaStore || new MediaApi({
831
839
  authProvider: destinationAuthProvider
832
840
  });
833
- _t5 = authToOwner;
841
+ _t6 = authToOwner;
834
842
  _context11.next = 1;
835
843
  return authProvider({
836
844
  collectionName: sourceCollection
837
845
  });
838
846
  case 1:
839
- owner = _t5(_context11.sent);
847
+ owner = _t6(_context11.sent);
840
848
  body = {
841
849
  sourceFile: {
842
850
  id: id,
@@ -861,7 +869,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
861
869
  }
862
870
  }, _callee11);
863
871
  }));
864
- function copyFileWithToken(_x25, _x26, _x27) {
872
+ function copyFileWithToken(_x28, _x29, _x30) {
865
873
  return _copyFileWithToken.apply(this, arguments);
866
874
  }
867
875
  return copyFileWithToken;
@@ -890,7 +898,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
890
898
  }
891
899
  }, _callee12, this);
892
900
  }));
893
- function copyFileWithIntent(_x28, _x29, _x30) {
901
+ function copyFileWithIntent(_x31, _x32, _x33) {
894
902
  return _copyFileWithIntent.apply(this, arguments);
895
903
  }
896
904
  return copyFileWithIntent;
@@ -926,8 +934,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
926
934
  key,
927
935
  errorFileState,
928
936
  _args13 = arguments,
929
- _t6,
930
- _t7;
937
+ _t7,
938
+ _t8;
931
939
  return _regeneratorRuntime.wrap(function (_context13) {
932
940
  while (1) switch (_context13.prev = _context13.next) {
933
941
  case 0:
@@ -969,20 +977,20 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
969
977
  previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
970
978
  preview: preview
971
979
  } : {};
972
- _t6 = !isFinalFileState(copiedFileState) &&
980
+ _t7 = !isFinalFileState(copiedFileState) &&
973
981
  // mimeType should always be returned by "copyFileWithToken"
974
982
  // but in case it's not, we don't want to penalize "copyFile"
975
983
  copiedMimeType;
976
- if (!_t6) {
984
+ if (!_t7) {
977
985
  _context13.next = 7;
978
986
  break;
979
987
  }
980
988
  _context13.next = 6;
981
989
  return shouldFetchRemoteFileStates(mediaType, copiedMimeType, preview);
982
990
  case 6:
983
- _t6 = _context13.sent;
991
+ _t7 = _context13.sent;
984
992
  case 7:
985
- if (!_t6) {
993
+ if (!_t7) {
986
994
  _context13.next = 8;
987
995
  break;
988
996
  }
@@ -1019,7 +1027,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
1019
1027
  return _context13.abrupt("return", copiedFile);
1020
1028
  case 10:
1021
1029
  _context13.prev = 10;
1022
- _t7 = _context13["catch"](1);
1030
+ _t8 = _context13["catch"](1);
1023
1031
  if (processingSubscription) {
1024
1032
  processingSubscription.unsubscribe();
1025
1033
  }
@@ -1027,23 +1035,23 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
1027
1035
  _fileCache = cache.get(replaceFileId);
1028
1036
  replaceFileState = this.store.getState().files[replaceFileId];
1029
1037
  if (_fileCache) {
1030
- _fileCache.error(_t7);
1038
+ _fileCache.error(_t8);
1031
1039
  } else {
1032
1040
  // Create a new subject with the error state for new subscriptions
1033
- cache.set(id, createMediaSubject(_t7));
1041
+ cache.set(id, createMediaSubject(_t8));
1034
1042
  }
1035
1043
  key = replaceFileState ? replaceFileId : id;
1036
- errorFileState = this.getErrorFileState(_t7, id, occurrenceKey);
1044
+ errorFileState = this.getErrorFileState(_t8, id, occurrenceKey);
1037
1045
  this.setFileState(key, errorFileState);
1038
1046
  }
1039
- throw _t7;
1047
+ throw _t8;
1040
1048
  case 11:
1041
1049
  case "end":
1042
1050
  return _context13.stop();
1043
1051
  }
1044
1052
  }, _callee13, this, [[1, 10]]);
1045
1053
  }));
1046
- function copyFile(_x31, _x32) {
1054
+ function copyFile(_x34, _x35) {
1047
1055
  return _copyFile.apply(this, arguments);
1048
1056
  }
1049
1057
  return copyFile;
@@ -1,2 +1,2 @@
1
- declare const _default: () => Document | undefined;
2
1
  export default _default;
2
+ declare function _default(): Document | undefined;
@@ -1,2 +1,2 @@
1
- declare const _default: () => Navigator | undefined;
2
1
  export default _default;
2
+ declare function _default(): Navigator | undefined;
@@ -1,3 +1,3 @@
1
1
  import { type MediaStoreGetFileImageParams } from '../client/media-store';
2
2
  export type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
3
- export declare const imageResizeModeToFileImageMode: (resizeMode?: ImageResizeMode) => MediaStoreGetFileImageParams["mode"];
3
+ export declare const imageResizeModeToFileImageMode: (resizeMode?: ImageResizeMode) => MediaStoreGetFileImageParams['mode'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "37.2.16",
3
+ "version": "37.2.18",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -25,7 +25,7 @@
25
25
  "@atlaskit/chunkinator": "^8.0.0",
26
26
  "@atlaskit/media-common": "^14.3.0",
27
27
  "@atlaskit/platform-feature-flags": "^2.1.0",
28
- "@atlaskit/tmp-editor-statsig": "^134.0.0",
28
+ "@atlaskit/tmp-editor-statsig": "^135.2.0",
29
29
  "@babel/runtime": "^7.0.0",
30
30
  "dataloader": "^2.1.0",
31
31
  "deep-equal": "^1.0.1",