@atlaskit/media-client 37.2.0 → 37.2.2

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,19 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 37.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 37.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`bea4da79c297d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bea4da79c297d) -
14
+ [ux] EDITOR-7679 use fallback media name for filename in download
15
+ - Updated dependencies
16
+
3
17
  ## 37.2.0
4
18
 
5
19
  ### Minor Changes
@@ -516,8 +516,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
516
516
  }
517
517
  }, {
518
518
  key: "getFileBinaryURL",
519
- value: function getFileBinaryURL(id, collectionName, maxAge) {
520
- return this.mediaApi.getFileBinaryURL(id, collectionName, maxAge);
519
+ value: function getFileBinaryURL(id, collectionName, maxAge, name) {
520
+ return this.mediaApi.getFileBinaryURL(id, collectionName, maxAge, name);
521
521
  }
522
522
  }, {
523
523
  key: "touchFiles",
@@ -764,7 +764,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
764
764
  collectionName = _args1.length > 2 ? _args1[2] : undefined;
765
765
  traceContext = _args1.length > 3 ? _args1[3] : undefined;
766
766
  _context1.next = 1;
767
- return this.mediaApi.getFileBinaryURL(id, collectionName);
767
+ return this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name);
768
768
  case 1:
769
769
  url = _context1.sent;
770
770
  (0, _downloadUrl.downloadUrl)(url, {
@@ -10,6 +10,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
13
14
  var _mediaCore = require("@atlaskit/media-core");
14
15
  var _constants = require("../../constants");
15
16
  var _artifacts = require("../../models/artifacts");
@@ -519,6 +520,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
519
520
  value: function () {
520
521
  var _getFileBinaryURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(id, collectionName) {
521
522
  var maxAge,
523
+ name,
522
524
  auth,
523
525
  options,
524
526
  binaryEndpoint,
@@ -527,6 +529,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
527
529
  while (1) switch (_context0.prev = _context0.next) {
528
530
  case 0:
529
531
  maxAge = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : _constants.FILE_CACHE_MAX_AGE;
532
+ name = _args0.length > 3 ? _args0[3] : undefined;
530
533
  _context0.next = 1;
531
534
  return this.resolveAuth({
532
535
  collectionName: collectionName
@@ -534,11 +537,13 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
534
537
  case 1:
535
538
  auth = _context0.sent;
536
539
  options = {
537
- params: {
540
+ params: _objectSpread({
538
541
  dl: true,
539
542
  collection: collectionName,
540
543
  'max-age': maxAge
541
- },
544
+ }, name && (0, _expValEquals.expValEquals)('platform_editor_media_download_fallback_name', 'isEnabled', true) ? {
545
+ name: name
546
+ } : {}),
542
547
  auth: auth
543
548
  };
544
549
  binaryEndpoint = cdnFeatureFlag('binary');
@@ -1114,14 +1119,19 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
1114
1119
  }]);
1115
1120
  }();
1116
1121
  var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
1122
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1117
1123
  return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
1118
1124
  };
1119
1125
  var setKeyValueInSessionStorage = function setKeyValueInSessionStorage(key, value) {
1126
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1120
1127
  if (!value || !(window && window.sessionStorage)) {
1121
1128
  return;
1122
1129
  }
1130
+
1131
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1123
1132
  var currentValue = window.sessionStorage.getItem(key);
1124
1133
  if (currentValue !== value) {
1134
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1125
1135
  window.sessionStorage.setItem(key, value);
1126
1136
  }
1127
1137
  };
@@ -319,8 +319,8 @@ export class FileFetcherImpl {
319
319
  getArtifactURL(artifacts, artifactName, collectionName) {
320
320
  return this.mediaApi.getArtifactURL(artifacts, artifactName, collectionName);
321
321
  }
322
- getFileBinaryURL(id, collectionName, maxAge) {
323
- return this.mediaApi.getFileBinaryURL(id, collectionName, maxAge);
322
+ getFileBinaryURL(id, collectionName, maxAge, name) {
323
+ return this.mediaApi.getFileBinaryURL(id, collectionName, maxAge, name);
324
324
  }
325
325
  touchFiles(descriptors, collection, traceContext, expectedFileSize) {
326
326
  return this.mediaApi.touchFiles({
@@ -494,7 +494,7 @@ export class FileFetcherImpl {
494
494
  return fromObservable(subject);
495
495
  }
496
496
  async downloadBinary(id, name = 'download', collectionName, traceContext) {
497
- const url = await this.mediaApi.getFileBinaryURL(id, collectionName);
497
+ const url = await this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name);
498
498
  downloadUrl(url, {
499
499
  name
500
500
  });
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
2
3
  import { isClientBasedAuth } from '@atlaskit/media-core';
3
4
  import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
4
5
  import { getArtifactUrl } from '../../models/artifacts';
@@ -343,7 +344,7 @@ export class MediaStore {
343
344
  };
344
345
  return this.request(`/file/${id}/${binaryEndpoint}`, options, abortController, true).then(createMapResponseToBlob(metadata));
345
346
  }
346
- async getFileBinaryURL(id, collectionName, maxAge = FILE_CACHE_MAX_AGE) {
347
+ async getFileBinaryURL(id, collectionName, maxAge = FILE_CACHE_MAX_AGE, name) {
347
348
  const auth = await this.resolveAuth({
348
349
  collectionName
349
350
  });
@@ -351,7 +352,10 @@ export class MediaStore {
351
352
  params: {
352
353
  dl: true,
353
354
  collection: collectionName,
354
- 'max-age': maxAge
355
+ 'max-age': maxAge,
356
+ ...(name && expValEquals('platform_editor_media_download_fallback_name', 'isEnabled', true) ? {
357
+ name
358
+ } : {})
355
359
  },
356
360
  auth
357
361
  };
@@ -685,14 +689,19 @@ export class MediaStore {
685
689
  }
686
690
  }
687
691
  const getValueFromSessionStorage = key => {
692
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
688
693
  return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
689
694
  };
690
695
  const setKeyValueInSessionStorage = (key, value) => {
696
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
691
697
  if (!value || !(window && window.sessionStorage)) {
692
698
  return;
693
699
  }
700
+
701
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
694
702
  const currentValue = window.sessionStorage.getItem(key);
695
703
  if (currentValue !== value) {
704
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
696
705
  window.sessionStorage.setItem(key, value);
697
706
  }
698
707
  };
@@ -499,8 +499,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
499
499
  }
500
500
  }, {
501
501
  key: "getFileBinaryURL",
502
- value: function getFileBinaryURL(id, collectionName, maxAge) {
503
- return this.mediaApi.getFileBinaryURL(id, collectionName, maxAge);
502
+ value: function getFileBinaryURL(id, collectionName, maxAge, name) {
503
+ return this.mediaApi.getFileBinaryURL(id, collectionName, maxAge, name);
504
504
  }
505
505
  }, {
506
506
  key: "touchFiles",
@@ -747,7 +747,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
747
747
  collectionName = _args1.length > 2 ? _args1[2] : undefined;
748
748
  traceContext = _args1.length > 3 ? _args1[3] : undefined;
749
749
  _context1.next = 1;
750
- return this.mediaApi.getFileBinaryURL(id, collectionName);
750
+ return this.mediaApi.getFileBinaryURL(id, collectionName, undefined, name);
751
751
  case 1:
752
752
  url = _context1.sent;
753
753
  downloadUrl(url, {
@@ -5,6 +5,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  function ownKeys(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; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { isClientBasedAuth } from '@atlaskit/media-core';
9
10
  import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
10
11
  import { getArtifactUrl } from '../../models/artifacts';
@@ -513,6 +514,7 @@ export var MediaStore = /*#__PURE__*/function () {
513
514
  value: function () {
514
515
  var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(id, collectionName) {
515
516
  var maxAge,
517
+ name,
516
518
  auth,
517
519
  options,
518
520
  binaryEndpoint,
@@ -521,6 +523,7 @@ export var MediaStore = /*#__PURE__*/function () {
521
523
  while (1) switch (_context0.prev = _context0.next) {
522
524
  case 0:
523
525
  maxAge = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : FILE_CACHE_MAX_AGE;
526
+ name = _args0.length > 3 ? _args0[3] : undefined;
524
527
  _context0.next = 1;
525
528
  return this.resolveAuth({
526
529
  collectionName: collectionName
@@ -528,11 +531,13 @@ export var MediaStore = /*#__PURE__*/function () {
528
531
  case 1:
529
532
  auth = _context0.sent;
530
533
  options = {
531
- params: {
534
+ params: _objectSpread({
532
535
  dl: true,
533
536
  collection: collectionName,
534
537
  'max-age': maxAge
535
- },
538
+ }, name && expValEquals('platform_editor_media_download_fallback_name', 'isEnabled', true) ? {
539
+ name: name
540
+ } : {}),
536
541
  auth: auth
537
542
  };
538
543
  binaryEndpoint = cdnFeatureFlag('binary');
@@ -1108,14 +1113,19 @@ export var MediaStore = /*#__PURE__*/function () {
1108
1113
  }]);
1109
1114
  }();
1110
1115
  var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
1116
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1111
1117
  return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
1112
1118
  };
1113
1119
  var setKeyValueInSessionStorage = function setKeyValueInSessionStorage(key, value) {
1120
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1114
1121
  if (!value || !(window && window.sessionStorage)) {
1115
1122
  return;
1116
1123
  }
1124
+
1125
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1117
1126
  var currentValue = window.sessionStorage.getItem(key);
1118
1127
  if (currentValue !== value) {
1128
+ // eslint-disable-next-line @atlaskit/platform/no-direct-web-storage-usage -- existing usage
1119
1129
  window.sessionStorage.setItem(key, value);
1120
1130
  }
1121
1131
  };
@@ -40,7 +40,7 @@ export interface FileFetcher {
40
40
  downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
41
41
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
42
42
  copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
43
- getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
43
+ getFileBinaryURL(id: string, collectionName?: string, maxAge?: number, name?: string): Promise<string>;
44
44
  registerCopyIntent(id: string, collectionName?: string): Promise<void>;
45
45
  uploadArtifact(id: string, file: File, params: UploadArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaItemDetails>;
46
46
  deleteArtifact(id: string, artifactName: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
@@ -63,7 +63,7 @@ export declare class FileFetcherImpl implements FileFetcher {
63
63
  getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
64
64
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
65
65
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
66
- getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
66
+ getFileBinaryURL(id: string, collectionName?: string, maxAge?: number, name?: string): Promise<string>;
67
67
  private createDownloadFileStream;
68
68
  touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext, expectedFileSize?: number): Promise<TouchedFiles>;
69
69
  private generateUploadableFileUpfrontIds;
@@ -27,7 +27,7 @@ export declare class MediaStore implements MediaApi {
27
27
  getFileImageURLSync(id: string, params?: MediaStoreGetFileImageParams): string;
28
28
  private createFileImageURL;
29
29
  getFileBinary(id: string, collectionName?: string, abortController?: AbortController, maxAge?: number): Promise<Blob>;
30
- getFileBinaryURL(id: string, collectionName?: string, maxAge?: number): Promise<string>;
30
+ getFileBinaryURL(id: string, collectionName?: string, maxAge?: number, name?: string): Promise<string>;
31
31
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string, maxAge?: number): Promise<string>;
32
32
  getArtifactBinary: MediaApi['getArtifactBinary'];
33
33
  uploadArtifact: MediaApi['uploadArtifact'];
@@ -179,7 +179,7 @@ export interface MediaApi {
179
179
  getFileImageURL: (id: string, params?: MediaStoreGetFileImageParams) => Promise<string>;
180
180
  getFileImageURLSync: (id: string, params?: MediaStoreGetFileImageParams) => string;
181
181
  getFileBinary: (id: string, collectionName?: string, abortController?: AbortController) => Promise<Blob>;
182
- getFileBinaryURL: (id: string, collectionName?: string) => Promise<string>;
182
+ getFileBinaryURL: (id: string, collectionName?: string, maxAge?: number, name?: string) => Promise<string>;
183
183
  getArtifactURL: (artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string) => Promise<string>;
184
184
  getArtifactBinary(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, options: GetArtifactBinaryOptions): Promise<Blob>;
185
185
  uploadArtifact(id: string, file: File, params: UploadArtifactParams, collectionName?: string, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaItemDetails>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "37.2.0",
3
+ "version": "37.2.2",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -23,8 +23,9 @@
23
23
  "dependencies": {
24
24
  "@atlaskit/atlassian-context": "^1.0.0",
25
25
  "@atlaskit/chunkinator": "^8.0.0",
26
- "@atlaskit/media-common": "^14.2.0",
26
+ "@atlaskit/media-common": "^14.3.0",
27
27
  "@atlaskit/platform-feature-flags": "^2.0.0",
28
+ "@atlaskit/tmp-editor-statsig": "^122.0.0",
28
29
  "@babel/runtime": "^7.0.0",
29
30
  "dataloader": "^2.1.0",
30
31
  "deep-equal": "^1.0.1",
@@ -44,7 +45,7 @@
44
45
  "@atlaskit/media-core": "^38.0.0",
45
46
  "@atlaskit/media-state": "^3.0.0",
46
47
  "@atlaskit/ssr": "workspace:^",
47
- "@atlaskit/tokens": "^15.4.0",
48
+ "@atlaskit/tokens": "^15.5.0",
48
49
  "@atlassian/a11y-jest-testing": "^0.13.0",
49
50
  "@atlassian/feature-flags-test-utils": "^1.1.0",
50
51
  "@emotion/react": "^11.7.1",