@atlaskit/media-client 35.5.0 → 35.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 35.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`371b214b9bcc5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/371b214b9bcc5) -
8
+ Fixed the artifact URL generation when the basePath contains `/media-api`
9
+
10
+ ## 35.6.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`b3183021fdece`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b3183021fdece) -
15
+ Bug fix for path based routing - "/media-api" getting prepended twice resolved"
16
+
3
17
  ## 35.5.0
4
18
 
5
19
  ### Minor Changes
@@ -299,7 +313,6 @@
299
313
  - [#102527](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102527)
300
314
  [`a90d34cd14faf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a90d34cd14faf) -
301
315
  Updated the constructor of the following classes. Consult the type definitions for details.
302
-
303
316
  - `RequestError`
304
317
 
305
318
  - `PollingError`
@@ -311,7 +324,6 @@
311
324
  - [#102527](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102527)
312
325
  [`a90d34cd14faf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a90d34cd14faf) - -
313
326
  New error verification helper `isCommonMediaClientError`
314
-
315
327
  - `ErrorFileState` is now deserializable into a `CommonMediaClientError` using new export
316
328
  `toCommonMediaClientError`
317
329
 
@@ -491,7 +503,6 @@
491
503
  - [#134882](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/134882)
492
504
  [`ba204702f8e32`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ba204702f8e32) -
493
505
  [ED-24567]
494
-
495
506
  - **@atlaskit/editor-common** Add MEDIA_PICKER as a variable fo analytics
496
507
  - **@atlaskit/media-client** Return the mime-type from when calling the `uploadExternal` function
497
508
 
@@ -919,7 +930,6 @@
919
930
  - [#32424](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32424)
920
931
  [`0f99ed9df35`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0f99ed9df35) - BREAKING
921
932
  CHANGES:
922
-
923
933
  - Media Store class no longer exposes getCollectionItems method
924
934
 
925
935
  - `MediaClient.collection.removeFile` method is now accessible through the replacement method
@@ -927,7 +937,6 @@
927
937
 
928
938
  - `MediaClient.collection` has been fully removed. The following classes, types and utils have
929
939
  been also removed:
930
-
931
940
  - MediaCollection
932
941
  - MediaCollectionItem
933
942
  - MediaCollectionItems
@@ -1132,7 +1141,6 @@
1132
1141
  Client Uploader enforces a hard limit of 2Tb files.
1133
1142
 
1134
1143
  To mitigate these changes:
1135
-
1136
1144
  - Set the feature flag mediaUploadApiV2 as false or Revert to a previous version for affected
1137
1145
  consumers and methods; Media Client uploadFile method. Media Client File Fetcher upload method.
1138
1146
  Media Picker.
@@ -1437,7 +1445,6 @@
1437
1445
  pollingMaxFailuresExceeded error from implementation and feature flags
1438
1446
  - [`50cc05dde71`](https://bitbucket.org/atlassian/atlassian-frontend/commits/50cc05dde71) - Mark the
1439
1447
  following members as deprecated:
1440
-
1441
1448
  - getMediaTypeFromMimeType
1442
1449
  - isImageMimeTypeSupportedByBrowser
1443
1450
  - isDocumentMimeTypeSupportedByBrowser
@@ -1885,7 +1892,6 @@
1885
1892
  ### Minor Changes
1886
1893
 
1887
1894
  - [minor][eb962d2c36](https://bitbucket.org/atlassian/atlassian-frontend/commits/eb962d2c36):
1888
-
1889
1895
  - Add MAX_RESOLUTION constant. Can be imported via direct entry point
1890
1896
  `import { MAX_RESOLUTION } from '@atlaskit/media-client/constants';`
1891
1897
  - `Preview` class (`preview` prop in most `FileState`) now has optional field `origin` that can be
@@ -1981,7 +1987,6 @@
1981
1987
 
1982
1988
  Remove namespace imports from React, ReactDom, and PropTypes- Updated dependencies
1983
1989
  [6548261c9a](https://bitbucket.org/atlassian/atlassian-frontend/commits/6548261c9a):
1984
-
1985
1990
  - @atlaskit/docs@8.3.2
1986
1991
  - @atlaskit/button@13.3.7
1987
1992
  - @atlaskit/type-helpers@4.2.3
@@ -2074,7 +2079,6 @@
2074
2079
  Check if the subscription is defined before calling unsubscribe in utils observableToPromise-
2075
2080
  Updated dependencies
2076
2081
  [24865cfaff](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/24865cfaff):
2077
-
2078
2082
  - @atlaskit/media-card@66.1.2
2079
2083
 
2080
2084
  ## 4.1.1
@@ -2230,7 +2234,6 @@ Bumped dependencies.
2230
2234
  ### Changed
2231
2235
 
2232
2236
  **getMediaClient**
2233
-
2234
2237
  - Before
2235
2238
 
2236
2239
  > works with passing either mediaClientConfig or context
@@ -2301,7 +2304,6 @@ Bumped dependencies.
2301
2304
  - [minor][65ada7f318](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/65ada7f318):
2302
2305
 
2303
2306
  **FABDODGEM-12 Editor Cashmere Release**
2304
-
2305
2307
  - [Internal post](http://go.atlassian.com/cashmere-release)
2306
2308
 
2307
2309
  **Affected editor components:**
@@ -2309,19 +2311,16 @@ Bumped dependencies.
2309
2311
  tables, media, mobile, text color, emoji, copy/paste, analytics
2310
2312
 
2311
2313
  **Performance**
2312
-
2313
2314
  - Async import for code blocks and task items on renderer
2314
2315
  - https://product-fabric.atlassian.net/browse/ED-7155
2315
2316
 
2316
2317
  **Table**
2317
-
2318
2318
  - Add support to sort tables that contains smart links
2319
2319
  - https://product-fabric.atlassian.net/browse/ED-7449
2320
2320
  - Scale table when changing to full width mode
2321
2321
  - https://product-fabric.atlassian.net/browse/ED-7724
2322
2322
 
2323
2323
  **Text color**
2324
-
2325
2324
  - Update text color toolbar with right color when text is inside a list, panel, etc.
2326
2325
  - https://product-fabric.atlassian.net/browse/FM-1752
2327
2326
 
@@ -2508,7 +2507,6 @@ https://product-fabric.atlassian.net/browse/FM-2393
2508
2507
  - [patch][18dfac7332](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/18dfac7332):
2509
2508
 
2510
2509
  In this PR, we are:
2511
-
2512
2510
  - Re-introducing dist build folders
2513
2511
  - Adding back cjs
2514
2512
  - Replacing es5 by cjs and es2015 by esm
@@ -2567,14 +2565,12 @@ https://product-fabric.atlassian.net/browse/FM-2393
2567
2565
  ## 1.2.1
2568
2566
 
2569
2567
  - [patch][b0ef06c685](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/b0ef06c685):
2570
-
2571
2568
  - This is just a safety release in case anything strange happened in in the previous one. See Pull
2572
2569
  Request #5942 for details
2573
2570
 
2574
2571
  ## 1.2.0
2575
2572
 
2576
2573
  - [minor][dcda79d48c](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/dcda79d48c):
2577
-
2578
2574
  - `withMediaClient` and associated Props are introduced to make possible soft transition from
2579
2575
  Context based media components to Media Client Config ones.
2580
2576
 
@@ -2587,13 +2583,11 @@ https://product-fabric.atlassian.net/browse/FM-2393
2587
2583
  ## 1.1.5
2588
2584
 
2589
2585
  - [patch][af1cbd4ce4](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/af1cbd4ce4):
2590
-
2591
2586
  - Removing unnecessary deps and dev deps in media-core and media-client
2592
2587
 
2593
2588
  ## 1.1.4
2594
2589
 
2595
2590
  - [patch][12aa76d5b5](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/12aa76d5b5):
2596
-
2597
2591
  - ED-6814: fixed rendering mediaSingle without collection
2598
2592
 
2599
2593
  ## 1.1.3
@@ -2607,27 +2601,23 @@ https://product-fabric.atlassian.net/browse/FM-2393
2607
2601
  ## 1.1.2
2608
2602
 
2609
2603
  - [patch][7c17b35107](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/7c17b35107):
2610
-
2611
2604
  - Updates react and react-dom peer dependencies to react@^16.8.0 and react-dom@^16.8.0. To use
2612
2605
  this package, please ensure you use at least this version of react and react-dom.
2613
2606
 
2614
2607
  ## 1.1.1
2615
2608
 
2616
2609
  - [patch][2f58d39758](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/2f58d39758):
2617
-
2618
2610
  - Fix problem with double exporting one of the existing items
2619
2611
 
2620
2612
  ## 1.1.0
2621
2613
 
2622
2614
  - [minor][8536258182](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/8536258182):
2623
-
2624
2615
  - expose on + off + emit methods on client in order to communicate events with integrators. At
2625
2616
  this point the only emitted event is 'file-added'
2626
2617
 
2627
2618
  ## 1.0.0
2628
2619
 
2629
2620
  - [major][e38d662f7d](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/e38d662f7d):
2630
-
2631
2621
  - Media API Web Client Library initial release. It contains mostly combined code from media-core
2632
2622
  and media-store.
2633
2623
 
package/compass.yml CHANGED
@@ -10,6 +10,9 @@ fields:
10
10
  labels:
11
11
  - atlassian-platform
12
12
  links:
13
+ - name: Root Repository
14
+ type: REPOSITORY
15
+ url: https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master
13
16
  - name: ''
14
17
  type: REPOSITORY
15
18
  url: 'https://bitbucket.org/atlassian/atlassian-frontend-monorepo/src/master/platform/packages/media/media-client/'
@@ -52,7 +52,7 @@ var _createCopyIntentRegisterationBatcher = require("../../utils/createCopyInten
52
52
  var _helpers = require("../../utils/request/helpers");
53
53
  var _errors = require("../../models/errors");
54
54
  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; }
55
- 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) { (0, _defineProperty2.default)(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; }
55
+ 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) { (0, _defineProperty2.default)(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; } // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
56
56
  var isCopySourceFileWithToken = function isCopySourceFileWithToken(token) {
57
57
  return !!token.authProvider;
58
58
  };
@@ -297,7 +297,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
297
297
  }
298
298
  throw new Error('File is not a video');
299
299
  case 5:
300
- if (!((_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration)) {
300
+ if (!('mediaMetadata' in fileState && (_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration)) {
301
301
  _context5.next = 7;
302
302
  break;
303
303
  }
@@ -523,7 +523,9 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
523
523
  }, {
524
524
  key: "generateUploadableFileUpfrontIds",
525
525
  value: function generateUploadableFileUpfrontIds(collection, traceContext) {
526
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
526
527
  var id = (0, _v.default)();
528
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
527
529
  var occurrenceKey = (0, _v.default)();
528
530
  var touchFileDescriptor = {
529
531
  fileId: id,
@@ -17,7 +17,6 @@ var _request3 = require("../../utils/request");
17
17
  var _helpers = require("../../utils/request/helpers");
18
18
  var _mediaCdn = require("../../utils/mediaCdn");
19
19
  var _resolveAuth = require("./resolveAuth");
20
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
20
  var _pathBasedUrl = require("../../utils/pathBasedUrl");
22
21
  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; }
23
22
  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) { (0, _defineProperty2.default)(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; }
@@ -411,7 +410,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
411
410
  auth: auth
412
411
  };
413
412
  var imageEndpoint = cdnFeatureFlag('image');
414
- if ((0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
413
+ if ((0, _pathBasedUrl.isPathBasedEnabled)()) {
415
414
  return (0, _pathBasedUrl.mapToPathBasedUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options));
416
415
  }
417
416
  return (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options), auth.token);
@@ -486,7 +485,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
486
485
  auth: auth
487
486
  };
488
487
  binaryEndpoint = cdnFeatureFlag('binary');
489
- if (!(0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
488
+ if (!(0, _pathBasedUrl.isPathBasedEnabled)()) {
490
489
  _context9.next = 8;
491
490
  break;
492
491
  }
@@ -550,8 +549,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
550
549
  },
551
550
  auth: auth
552
551
  };
553
- url = (0, _helpers.createUrl)((0, _mediaCdn.mapToMediaCdnUrl)(artifactUrl, auth.token), options);
554
- if (!(0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
552
+ url = (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl).concat(artifactUrl), options), auth.token);
553
+ if (!(0, _pathBasedUrl.isPathBasedEnabled)()) {
555
554
  _context0.next = 11;
556
555
  break;
557
556
  }
@@ -945,7 +944,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
945
944
  if (useMediaCdn) {
946
945
  url = (0, _mediaCdn.mapToMediaCdnUrl)(url, auth.token);
947
946
  }
948
- if ((0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
947
+ if ((0, _pathBasedUrl.isPathBasedEnabled)()) {
949
948
  url = (0, _pathBasedUrl.mapToPathBasedUrl)(url);
950
949
  }
951
950
  _context16.next = 20;
@@ -90,7 +90,7 @@ function isCommonMediaClientError(error) {
90
90
  var toCommonMediaClientError = exports.toCommonMediaClientError = function toCommonMediaClientError(errorFileState) {
91
91
  var _errorFileState$detai;
92
92
  var error = (_errorFileState$detai = errorFileState.details) === null || _errorFileState$detai === void 0 ? void 0 : _errorFileState$detai.error;
93
- return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error.metadata, error.innerError);
93
+ return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error === null || error === void 0 ? void 0 : error.metadata, error === null || error === void 0 ? void 0 : error.innerError);
94
94
  };
95
95
 
96
96
  /** Serializer CommonMediaClientError -> ErrorFileState */
@@ -9,6 +9,7 @@ exports.mapToMediaCdnUrl = mapToMediaCdnUrl;
9
9
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
10
  var _isCommercial = require("./isCommercial");
11
11
  var _atlassianContext = require("@atlaskit/atlassian-context");
12
+ var _pathBasedUrl = require("./pathBasedUrl");
12
13
  var MEDIA_CDN_MAP = exports.MEDIA_CDN_MAP = {
13
14
  'api.media.atlassian.com': 'media-cdn.atlassian.com',
14
15
  'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
@@ -19,7 +20,7 @@ var MEDIA_CDN_MAP = exports.MEDIA_CDN_MAP = {
19
20
  // Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
20
21
  var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
21
22
  function isCDNEnabled() {
22
- return (0, _isCommercial.isCommercial)() && !(0, _atlassianContext.isIsolatedCloud)() && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery') && !(0, _platformFeatureFlags.fg)('platform_media_path_based_route');
23
+ return (0, _isCommercial.isCommercial)() && !(0, _atlassianContext.isIsolatedCloud)() && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery') && !(0, _pathBasedUrl.isPathBasedEnabled)();
23
24
  }
24
25
  function mapToMediaCdnUrl(url, token) {
25
26
  var _token$length;
@@ -4,20 +4,29 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.isPathBasedEnabled = isPathBasedEnabled;
7
8
  exports.mapRetryUrlToPathBasedUrl = mapRetryUrlToPathBasedUrl;
8
9
  exports.mapToPathBasedUrl = mapToPathBasedUrl;
9
10
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
- var _getDocument3 = _interopRequireDefault(require("./getDocument"));
11
+ var _getDocument4 = _interopRequireDefault(require("./getDocument"));
12
+ var mediaApiPathPrefix = '/media-api';
11
13
  function getRelativeUrl(absoluteUrl) {
12
14
  var url = new URL(absoluteUrl);
13
15
  return "".concat(url.pathname).concat(url.search).concat(url.hash);
14
16
  }
17
+ function isPathBasedEnabled() {
18
+ var _getDocument;
19
+ var isLocalhost = ((_getDocument = (0, _getDocument4.default)()) === null || _getDocument === void 0 || (_getDocument = _getDocument.location) === null || _getDocument === void 0 ? void 0 : _getDocument.hostname) === 'localhost';
20
+ return (0, _platformFeatureFlags.fg)('platform_media_path_based_route') && !isLocalhost;
21
+ }
15
22
  function mapToPathBasedUrl(url) {
16
- if ((0, _platformFeatureFlags.fg)('platform_media_path_based_route')) {
17
- var _getDocument;
23
+ if (isPathBasedEnabled()) {
24
+ var _getDocument2;
18
25
  var parsedUrl = new URL(url);
19
- parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
20
- var location = (_getDocument = (0, _getDocument3.default)()) === null || _getDocument === void 0 ? void 0 : _getDocument.location;
26
+ if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
27
+ parsedUrl.pathname = "".concat(mediaApiPathPrefix).concat(parsedUrl.pathname);
28
+ }
29
+ var location = (_getDocument2 = (0, _getDocument4.default)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location;
21
30
 
22
31
  // in this case we are most likely in SSR / a non browser environment so just return a relative URL
23
32
  if (!location) {
@@ -29,15 +38,17 @@ function mapToPathBasedUrl(url) {
29
38
  return url;
30
39
  }
31
40
  function mapRetryUrlToPathBasedUrl(url) {
32
- var _getDocument$location, _getDocument2;
41
+ var _getDocument$location, _getDocument3;
33
42
  var parsedUrl = new URL(url);
34
- parsedUrl.host = (_getDocument$location = (_getDocument2 = (0, _getDocument3.default)()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : '';
43
+ parsedUrl.host = (_getDocument$location = (_getDocument3 = (0, _getDocument4.default)()) === null || _getDocument3 === void 0 ? void 0 : _getDocument3.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : '';
35
44
 
36
45
  // remove CDN from the URL for retry if it exists
37
46
  var pathname = parsedUrl.pathname;
38
47
  if (pathname.endsWith('/cdn')) {
39
48
  parsedUrl.pathname = pathname.replace('/cdn', '');
40
49
  }
41
- parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
50
+ if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
51
+ parsedUrl.pathname = "".concat(mediaApiPathPrefix).concat(parsedUrl.pathname);
52
+ }
42
53
  return parsedUrl;
43
54
  }
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { Subscription } from 'rxjs/Subscription';
3
3
  import { map } from 'rxjs/operators/map';
4
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
4
5
  import uuid from 'uuid/v4';
5
6
  import { authToOwner } from '@atlaskit/media-core';
6
7
  import { downloadUrl } from '@atlaskit/media-common/downloadUrl';
@@ -184,7 +185,7 @@ export class FileFetcherImpl {
184
185
  if (fileState.status !== 'processed' || fileState.mediaType !== 'video' || !fileState.artifacts['video.mp4']) {
185
186
  throw new Error('File is not a video');
186
187
  }
187
- if ((_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration) {
188
+ if ('mediaMetadata' in fileState && (_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration) {
188
189
  return fileState.mediaMetadata.duration;
189
190
  }
190
191
 
@@ -323,7 +324,9 @@ export class FileFetcherImpl {
323
324
  }) => data);
324
325
  }
325
326
  generateUploadableFileUpfrontIds(collection, traceContext) {
327
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
326
328
  const id = uuid();
329
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
327
330
  const occurrenceKey = uuid();
328
331
  const touchFileDescriptor = {
329
332
  fileId: id,
@@ -7,8 +7,7 @@ import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultSho
7
7
  import { isCDNEnabled, mapToMediaCdnUrl } from '../../utils/mediaCdn';
8
8
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
9
9
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
- import { mapToPathBasedUrl } from '../../utils/pathBasedUrl';
10
+ import { isPathBasedEnabled, mapToPathBasedUrl } from '../../utils/pathBasedUrl';
12
11
  const MEDIA_API_REGION = 'media-api-region';
13
12
  const MEDIA_API_ENVIRONMENT = 'media-api-environment';
14
13
  const extendImageParams = (params, fetchMaxRes = false) => {
@@ -268,7 +267,7 @@ export class MediaStore {
268
267
  auth
269
268
  };
270
269
  const imageEndpoint = cdnFeatureFlag('image');
271
- if (fg('platform_media_path_based_route')) {
270
+ if (isPathBasedEnabled()) {
272
271
  return mapToPathBasedUrl(createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options));
273
272
  }
274
273
  return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options), auth.token);
@@ -306,7 +305,7 @@ export class MediaStore {
306
305
  auth
307
306
  };
308
307
  const binaryEndpoint = cdnFeatureFlag('binary');
309
- if (fg('platform_media_path_based_route')) {
308
+ if (isPathBasedEnabled()) {
310
309
  return mapToPathBasedUrl(createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options));
311
310
  }
312
311
  return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options), auth.token);
@@ -339,8 +338,8 @@ export class MediaStore {
339
338
  },
340
339
  auth
341
340
  };
342
- const url = createUrl(mapToMediaCdnUrl(artifactUrl, auth.token), options);
343
- if (fg('platform_media_path_based_route')) {
341
+ const url = mapToMediaCdnUrl(createUrl(`${auth.baseUrl}${artifactUrl}`, options), auth.token);
342
+ if (isPathBasedEnabled()) {
344
343
  return mapToPathBasedUrl(url);
345
344
  }
346
345
  return url;
@@ -573,7 +572,7 @@ export class MediaStore {
573
572
  if (useMediaCdn) {
574
573
  url = mapToMediaCdnUrl(url, auth.token);
575
574
  }
576
- if (fg('platform_media_path_based_route')) {
575
+ if (isPathBasedEnabled()) {
577
576
  url = mapToPathBasedUrl(url);
578
577
  }
579
578
  const response = await request(url, {
@@ -51,7 +51,7 @@ export function isCommonMediaClientError(error) {
51
51
  export const toCommonMediaClientError = errorFileState => {
52
52
  var _errorFileState$detai;
53
53
  const error = (_errorFileState$detai = errorFileState.details) === null || _errorFileState$detai === void 0 ? void 0 : _errorFileState$detai.error;
54
- return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error.metadata, error.innerError);
54
+ return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error === null || error === void 0 ? void 0 : error.metadata, error === null || error === void 0 ? void 0 : error.innerError);
55
55
  };
56
56
 
57
57
  /** Serializer CommonMediaClientError -> ErrorFileState */
@@ -1,6 +1,7 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { isCommercial } from './isCommercial';
3
3
  import { isIsolatedCloud } from '@atlaskit/atlassian-context';
4
+ import { isPathBasedEnabled } from './pathBasedUrl';
4
5
  export const MEDIA_CDN_MAP = {
5
6
  'api.media.atlassian.com': 'media-cdn.atlassian.com',
6
7
  'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
@@ -11,7 +12,7 @@ export const MEDIA_CDN_MAP = {
11
12
  // Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
12
13
  const MEDIA_TOKEN_LENGTH_LIMIT = 7000;
13
14
  export function isCDNEnabled() {
14
- return isCommercial() && !isIsolatedCloud() && fg('platform_media_cdn_delivery') && !fg('platform_media_path_based_route');
15
+ return isCommercial() && !isIsolatedCloud() && fg('platform_media_cdn_delivery') && !isPathBasedEnabled();
15
16
  }
16
17
  export function mapToMediaCdnUrl(url, token) {
17
18
  var _token$length;
@@ -1,15 +1,23 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import getDocument from './getDocument';
3
+ const mediaApiPathPrefix = '/media-api';
3
4
  function getRelativeUrl(absoluteUrl) {
4
5
  const url = new URL(absoluteUrl);
5
6
  return `${url.pathname}${url.search}${url.hash}`;
6
7
  }
8
+ export function isPathBasedEnabled() {
9
+ var _getDocument, _getDocument$location;
10
+ const isLocalhost = ((_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : (_getDocument$location = _getDocument.location) === null || _getDocument$location === void 0 ? void 0 : _getDocument$location.hostname) === 'localhost';
11
+ return fg('platform_media_path_based_route') && !isLocalhost;
12
+ }
7
13
  export function mapToPathBasedUrl(url) {
8
- if (fg('platform_media_path_based_route')) {
9
- var _getDocument;
14
+ if (isPathBasedEnabled()) {
15
+ var _getDocument2;
10
16
  const parsedUrl = new URL(url);
11
- parsedUrl.pathname = `/media-api${parsedUrl.pathname}`;
12
- const location = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.location;
17
+ if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
18
+ parsedUrl.pathname = `${mediaApiPathPrefix}${parsedUrl.pathname}`;
19
+ }
20
+ const location = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location;
13
21
 
14
22
  // in this case we are most likely in SSR / a non browser environment so just return a relative URL
15
23
  if (!location) {
@@ -21,15 +29,17 @@ export function mapToPathBasedUrl(url) {
21
29
  return url;
22
30
  }
23
31
  export function mapRetryUrlToPathBasedUrl(url) {
24
- var _getDocument$location, _getDocument2;
32
+ var _getDocument$location2, _getDocument3;
25
33
  const parsedUrl = new URL(url);
26
- parsedUrl.host = (_getDocument$location = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : '';
34
+ parsedUrl.host = (_getDocument$location2 = (_getDocument3 = getDocument()) === null || _getDocument3 === void 0 ? void 0 : _getDocument3.location.host) !== null && _getDocument$location2 !== void 0 ? _getDocument$location2 : '';
27
35
 
28
36
  // remove CDN from the URL for retry if it exists
29
37
  const pathname = parsedUrl.pathname;
30
38
  if (pathname.endsWith('/cdn')) {
31
39
  parsedUrl.pathname = pathname.replace('/cdn', '');
32
40
  }
33
- parsedUrl.pathname = `/media-api${parsedUrl.pathname}`;
41
+ if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
42
+ parsedUrl.pathname = `${mediaApiPathPrefix}${parsedUrl.pathname}`;
43
+ }
34
44
  return parsedUrl;
35
45
  }
@@ -7,6 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { Subscription } from 'rxjs/Subscription';
9
9
  import { map } from 'rxjs/operators/map';
10
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
10
11
  import uuid from 'uuid/v4';
11
12
  import { authToOwner } from '@atlaskit/media-core';
12
13
  import { downloadUrl } from '@atlaskit/media-common/downloadUrl';
@@ -279,7 +280,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
279
280
  }
280
281
  throw new Error('File is not a video');
281
282
  case 5:
282
- if (!((_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration)) {
283
+ if (!('mediaMetadata' in fileState && (_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration)) {
283
284
  _context5.next = 7;
284
285
  break;
285
286
  }
@@ -505,7 +506,9 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
505
506
  }, {
506
507
  key: "generateUploadableFileUpfrontIds",
507
508
  value: function generateUploadableFileUpfrontIds(collection, traceContext) {
509
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
508
510
  var id = uuid();
511
+ // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
509
512
  var occurrenceKey = uuid();
510
513
  var touchFileDescriptor = {
511
514
  fileId: id,
@@ -13,8 +13,7 @@ import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultSho
13
13
  import { isCDNEnabled, mapToMediaCdnUrl } from '../../utils/mediaCdn';
14
14
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
15
15
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
16
- import { fg } from '@atlaskit/platform-feature-flags';
17
- import { mapToPathBasedUrl } from '../../utils/pathBasedUrl';
16
+ import { isPathBasedEnabled, mapToPathBasedUrl } from '../../utils/pathBasedUrl';
18
17
  var MEDIA_API_REGION = 'media-api-region';
19
18
  var MEDIA_API_ENVIRONMENT = 'media-api-environment';
20
19
  var extendImageParams = function extendImageParams(params) {
@@ -405,7 +404,7 @@ export var MediaStore = /*#__PURE__*/function () {
405
404
  auth: auth
406
405
  };
407
406
  var imageEndpoint = cdnFeatureFlag('image');
408
- if (fg('platform_media_path_based_route')) {
407
+ if (isPathBasedEnabled()) {
409
408
  return mapToPathBasedUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options));
410
409
  }
411
410
  return mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options), auth.token);
@@ -480,7 +479,7 @@ export var MediaStore = /*#__PURE__*/function () {
480
479
  auth: auth
481
480
  };
482
481
  binaryEndpoint = cdnFeatureFlag('binary');
483
- if (!fg('platform_media_path_based_route')) {
482
+ if (!isPathBasedEnabled()) {
484
483
  _context9.next = 8;
485
484
  break;
486
485
  }
@@ -544,8 +543,8 @@ export var MediaStore = /*#__PURE__*/function () {
544
543
  },
545
544
  auth: auth
546
545
  };
547
- url = createUrl(mapToMediaCdnUrl(artifactUrl, auth.token), options);
548
- if (!fg('platform_media_path_based_route')) {
546
+ url = mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl).concat(artifactUrl), options), auth.token);
547
+ if (!isPathBasedEnabled()) {
549
548
  _context0.next = 11;
550
549
  break;
551
550
  }
@@ -939,7 +938,7 @@ export var MediaStore = /*#__PURE__*/function () {
939
938
  if (useMediaCdn) {
940
939
  url = mapToMediaCdnUrl(url, auth.token);
941
940
  }
942
- if (fg('platform_media_path_based_route')) {
941
+ if (isPathBasedEnabled()) {
943
942
  url = mapToPathBasedUrl(url);
944
943
  }
945
944
  _context16.next = 20;
@@ -72,7 +72,7 @@ export function isCommonMediaClientError(error) {
72
72
  export var toCommonMediaClientError = function toCommonMediaClientError(errorFileState) {
73
73
  var _errorFileState$detai;
74
74
  var error = (_errorFileState$detai = errorFileState.details) === null || _errorFileState$detai === void 0 ? void 0 : _errorFileState$detai.error;
75
- return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error.metadata, error.innerError);
75
+ return new CommonMediaClientError((error === null || error === void 0 ? void 0 : error.reason) || 'unknown-reason', error === null || error === void 0 ? void 0 : error.metadata, error === null || error === void 0 ? void 0 : error.innerError);
76
76
  };
77
77
 
78
78
  /** Serializer CommonMediaClientError -> ErrorFileState */
@@ -1,6 +1,7 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import { isCommercial } from './isCommercial';
3
3
  import { isIsolatedCloud } from '@atlaskit/atlassian-context';
4
+ import { isPathBasedEnabled } from './pathBasedUrl';
4
5
  export var MEDIA_CDN_MAP = {
5
6
  'api.media.atlassian.com': 'media-cdn.atlassian.com',
6
7
  'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
@@ -11,7 +12,7 @@ export var MEDIA_CDN_MAP = {
11
12
  // Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
12
13
  var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
13
14
  export function isCDNEnabled() {
14
- return isCommercial() && !isIsolatedCloud() && fg('platform_media_cdn_delivery') && !fg('platform_media_path_based_route');
15
+ return isCommercial() && !isIsolatedCloud() && fg('platform_media_cdn_delivery') && !isPathBasedEnabled();
15
16
  }
16
17
  export function mapToMediaCdnUrl(url, token) {
17
18
  var _token$length;
@@ -1,15 +1,23 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import getDocument from './getDocument';
3
+ var mediaApiPathPrefix = '/media-api';
3
4
  function getRelativeUrl(absoluteUrl) {
4
5
  var url = new URL(absoluteUrl);
5
6
  return "".concat(url.pathname).concat(url.search).concat(url.hash);
6
7
  }
8
+ export function isPathBasedEnabled() {
9
+ var _getDocument;
10
+ var isLocalhost = ((_getDocument = getDocument()) === null || _getDocument === void 0 || (_getDocument = _getDocument.location) === null || _getDocument === void 0 ? void 0 : _getDocument.hostname) === 'localhost';
11
+ return fg('platform_media_path_based_route') && !isLocalhost;
12
+ }
7
13
  export function mapToPathBasedUrl(url) {
8
- if (fg('platform_media_path_based_route')) {
9
- var _getDocument;
14
+ if (isPathBasedEnabled()) {
15
+ var _getDocument2;
10
16
  var parsedUrl = new URL(url);
11
- parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
12
- var location = (_getDocument = getDocument()) === null || _getDocument === void 0 ? void 0 : _getDocument.location;
17
+ if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
18
+ parsedUrl.pathname = "".concat(mediaApiPathPrefix).concat(parsedUrl.pathname);
19
+ }
20
+ var location = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location;
13
21
 
14
22
  // in this case we are most likely in SSR / a non browser environment so just return a relative URL
15
23
  if (!location) {
@@ -21,15 +29,17 @@ export function mapToPathBasedUrl(url) {
21
29
  return url;
22
30
  }
23
31
  export function mapRetryUrlToPathBasedUrl(url) {
24
- var _getDocument$location, _getDocument2;
32
+ var _getDocument$location, _getDocument3;
25
33
  var parsedUrl = new URL(url);
26
- parsedUrl.host = (_getDocument$location = (_getDocument2 = getDocument()) === null || _getDocument2 === void 0 ? void 0 : _getDocument2.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : '';
34
+ parsedUrl.host = (_getDocument$location = (_getDocument3 = getDocument()) === null || _getDocument3 === void 0 ? void 0 : _getDocument3.location.host) !== null && _getDocument$location !== void 0 ? _getDocument$location : '';
27
35
 
28
36
  // remove CDN from the URL for retry if it exists
29
37
  var pathname = parsedUrl.pathname;
30
38
  if (pathname.endsWith('/cdn')) {
31
39
  parsedUrl.pathname = pathname.replace('/cdn', '');
32
40
  }
33
- parsedUrl.pathname = "/media-api".concat(parsedUrl.pathname);
41
+ if (!parsedUrl.pathname.startsWith(mediaApiPathPrefix)) {
42
+ parsedUrl.pathname = "".concat(mediaApiPathPrefix).concat(parsedUrl.pathname);
43
+ }
34
44
  return parsedUrl;
35
45
  }
@@ -1,2 +1,3 @@
1
+ export declare function isPathBasedEnabled(): boolean;
1
2
  export declare function mapToPathBasedUrl(url: string): string;
2
3
  export declare function mapRetryUrlToPathBasedUrl(url: string): URL;
@@ -1,2 +1,3 @@
1
+ export declare function isPathBasedEnabled(): boolean;
1
2
  export declare function mapToPathBasedUrl(url: string): string;
2
3
  export declare function mapRetryUrlToPathBasedUrl(url: string): URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "35.5.0",
3
+ "version": "35.6.1",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -53,8 +53,8 @@
53
53
  "@atlaskit/media-core": "^37.0.0",
54
54
  "@atlaskit/media-state": "^1.8.0",
55
55
  "@atlaskit/ssr": "workspace:^",
56
- "@atlaskit/tokens": "^6.4.0",
57
- "@atlassian/feature-flags-test-utils": "^0.3.0",
56
+ "@atlaskit/tokens": "^8.4.0",
57
+ "@atlassian/feature-flags-test-utils": "^1.0.0",
58
58
  "@emotion/react": "^11.7.1",
59
59
  "@types/deep-equal": "^1.0.1",
60
60
  "@types/uuid-validate": "^0.0.2",