@atlaskit/media-common 2.17.0 → 2.18.0

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/docs/index.js +9 -1
  3. package/dist/cjs/docs/media-use-only.js +41 -0
  4. package/dist/cjs/mediaFeatureFlags/mediaFeatureFlags.js +0 -2
  5. package/dist/cjs/mediaFeatureFlags/productKeys.js +0 -2
  6. package/dist/cjs/utils/helpers.js +22 -2
  7. package/dist/cjs/version.json +1 -1
  8. package/dist/es2019/docs/index.js +2 -1
  9. package/dist/es2019/docs/media-use-only.js +29 -0
  10. package/dist/es2019/mediaFeatureFlags/mediaFeatureFlags.js +0 -2
  11. package/dist/es2019/mediaFeatureFlags/productKeys.js +0 -2
  12. package/dist/es2019/utils/helpers.js +21 -2
  13. package/dist/es2019/version.json +1 -1
  14. package/dist/esm/docs/index.js +2 -1
  15. package/dist/esm/docs/media-use-only.js +31 -0
  16. package/dist/esm/mediaFeatureFlags/mediaFeatureFlags.js +0 -2
  17. package/dist/esm/mediaFeatureFlags/productKeys.js +0 -2
  18. package/dist/esm/utils/helpers.js +23 -2
  19. package/dist/esm/version.json +1 -1
  20. package/dist/types/analytics/types.d.ts +2 -1
  21. package/dist/types/docs/index.d.ts +1 -0
  22. package/dist/types/docs/media-use-only.d.ts +5 -0
  23. package/dist/types/mediaFeatureFlags/types.d.ts +0 -1
  24. package/dist/types/utils/helpers.d.ts +1 -1
  25. package/package.json +2 -10
  26. package/report.api.md +52 -31
  27. package/dist/types-ts4.0/analytics/constants.d.ts +0 -1
  28. package/dist/types-ts4.0/analytics/index.d.ts +0 -3
  29. package/dist/types-ts4.0/analytics/types.d.ts +0 -80
  30. package/dist/types-ts4.0/analytics/withMediaAnalyticsContext.d.ts +0 -18
  31. package/dist/types-ts4.0/docs/index.d.ts +0 -1
  32. package/dist/types-ts4.0/docs/rxjs-notice.d.ts +0 -2
  33. package/dist/types-ts4.0/downloadUrl.d.ts +0 -4
  34. package/dist/types-ts4.0/index.d.ts +0 -19
  35. package/dist/types-ts4.0/mediaFeatureFlag-local.d.ts +0 -1
  36. package/dist/types-ts4.0/mediaFeatureFlags/index.d.ts +0 -2
  37. package/dist/types-ts4.0/mediaFeatureFlags/mediaFeatureFlags.d.ts +0 -26
  38. package/dist/types-ts4.0/mediaFeatureFlags/productKeys.d.ts +0 -2
  39. package/dist/types-ts4.0/mediaFeatureFlags/types.d.ts +0 -21
  40. package/dist/types-ts4.0/mediaTypeUtils/index.d.ts +0 -4
  41. package/dist/types-ts4.0/mediaTypeUtils/isArchive.d.ts +0 -1
  42. package/dist/types-ts4.0/mediaTypeUtils/isMimeTypeSupportedByBrowser.d.ts +0 -14
  43. package/dist/types-ts4.0/mediaTypeUtils/isMimeTypeSupportedByServer.d.ts +0 -6
  44. package/dist/types-ts4.0/utils/helpers.d.ts +0 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/media-common
2
2
 
3
+ ## 2.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`81573c1dfa7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/81573c1dfa7) - Items call creates a batched metadata trace Id
8
+ - [`0bccac57db6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0bccac57db6) - remove mediaUploadApiV2 Feature flag
9
+
10
+ ### Patch Changes
11
+
12
+ - [`a8eeb045e3a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a8eeb045e3a) - adding media only callouts to docs
13
+ - [`3d40d5e9b37`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3d40d5e9b37) - Refactor traceId generator getRandomHex function to avoid id collision
14
+ - [`10480433c71`](https://bitbucket.org/atlassian/atlassian-frontend/commits/10480433c71) - Fix getRandomHex function to mitigate the issue of lacking digits in hex value.
15
+
3
16
  ## 2.17.0
4
17
 
5
18
  ### Minor Changes
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "createMediaUseOnlyNotice", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _mediaUseOnly.createMediaUseOnlyNotice;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "createRxjsNotice", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -10,4 +16,6 @@ Object.defineProperty(exports, "createRxjsNotice", {
10
16
  }
11
17
  });
12
18
 
13
- var _rxjsNotice = require("./rxjs-notice");
19
+ var _rxjsNotice = require("./rxjs-notice");
20
+
21
+ var _mediaUseOnly = require("./media-use-only");
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createMediaUseOnlyNotice = createMediaUseOnlyNotice;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _sectionMessage = _interopRequireDefault(require("@atlaskit/section-message"));
13
+
14
+ function AlternativePackagesMessage(_ref) {
15
+ var alternatePackages = _ref.alternatePackages;
16
+
17
+ if (!alternatePackages) {
18
+ return null;
19
+ }
20
+
21
+ if (alternatePackages.length === 1) {
22
+ return /*#__PURE__*/_react.default.createElement("p", null, "Consider using", ' ', /*#__PURE__*/_react.default.createElement("a", {
23
+ href: alternatePackages[0].link
24
+ }, alternatePackages[0].name), ' ', "instead.");
25
+ }
26
+
27
+ return /*#__PURE__*/_react.default.createElement("p", null, "Consider using one of these packages instead:", /*#__PURE__*/_react.default.createElement("ul", null, alternatePackages.map(function (p) {
28
+ return /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement("a", {
29
+ href: p.link
30
+ }, p.name));
31
+ })));
32
+ }
33
+
34
+ function createMediaUseOnlyNotice(componentName, alternatePackages) {
35
+ return /*#__PURE__*/_react.default.createElement(_sectionMessage.default, {
36
+ title: "Internal Media Use Only",
37
+ appearance: "error"
38
+ }, /*#__PURE__*/_react.default.createElement("p", null, componentName, " is intended for internal use by the Media Platform and as a transitive dependency of a media package within your product."), /*#__PURE__*/_react.default.createElement("p", null, "Direct use of this component is not supported."), /*#__PURE__*/_react.default.createElement(AlternativePackagesMessage, {
39
+ alternatePackages: alternatePackages
40
+ }));
41
+ }
@@ -35,7 +35,6 @@ var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
35
35
  folderUploads: ffA.folderUploads === ffB.folderUploads,
36
36
  observedWidth: ffA.observedWidth === ffB.observedWidth,
37
37
  timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
38
- mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
39
38
  memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging
40
39
  };
41
40
  return Object.values(results).every(function (result) {
@@ -107,7 +106,6 @@ var defaultMediaFeatureFlags = {
107
106
  folderUploads: false,
108
107
  observedWidth: false,
109
108
  timestampOnVideo: false,
110
- mediaUploadApiV2: true,
111
109
  memoryCacheLogging: false
112
110
  };
113
111
  /**
@@ -14,7 +14,6 @@ var productKeys = {
14
14
  observedWidth: '',
15
15
  // TODO https://product-fabric.atlassian.net/browse/MEX-1620
16
16
  timestampOnVideo: '',
17
- mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
18
17
  memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging'
19
18
  },
20
19
  jira: {
@@ -27,7 +26,6 @@ var productKeys = {
27
26
  observedWidth: '',
28
27
  // TODO https://product-fabric.atlassian.net/browse/MEX-1620
29
28
  timestampOnVideo: '',
30
- mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
31
29
  memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging'
32
30
  }
33
31
  };
@@ -80,8 +80,28 @@ var matches = function matches(srcObj) {
80
80
 
81
81
  exports.matches = matches;
82
82
 
83
- function getRandomHex(size) {
84
- return (0, _toConsumableArray2.default)(Array(size)).map(function () {
83
+ function getRandomHexValues(byte) {
84
+ return (0, _toConsumableArray2.default)(Array(byte * 2)).map(function () {
85
85
  return Math.floor(Math.random() * 16).toString(16);
86
86
  }).join('');
87
+ }
88
+
89
+ function getRandomHex(byte) {
90
+ var _window;
91
+
92
+ var randomHex;
93
+
94
+ if ((_window = window) !== null && _window !== void 0 && _window.crypto) {
95
+ try {
96
+ randomHex = Array.from(window.crypto.getRandomValues(new Uint8Array(byte))).map(function (b) {
97
+ return b.toString(16).padStart(2, '0');
98
+ }).join('');
99
+ } catch (e) {
100
+ randomHex = getRandomHexValues(byte);
101
+ }
102
+ } else {
103
+ randomHex = getRandomHexValues(byte);
104
+ }
105
+
106
+ return randomHex;
87
107
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1 +1,2 @@
1
- export { createRxjsNotice } from './rxjs-notice';
1
+ export { createRxjsNotice } from './rxjs-notice';
2
+ export { createMediaUseOnlyNotice } from './media-use-only';
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import SectionMessage from '@atlaskit/section-message';
3
+
4
+ function AlternativePackagesMessage({
5
+ alternatePackages
6
+ }) {
7
+ if (!alternatePackages) {
8
+ return null;
9
+ }
10
+
11
+ if (alternatePackages.length === 1) {
12
+ return /*#__PURE__*/React.createElement("p", null, "Consider using", ' ', /*#__PURE__*/React.createElement("a", {
13
+ href: alternatePackages[0].link
14
+ }, alternatePackages[0].name), ' ', "instead.");
15
+ }
16
+
17
+ return /*#__PURE__*/React.createElement("p", null, "Consider using one of these packages instead:", /*#__PURE__*/React.createElement("ul", null, alternatePackages.map(p => /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
18
+ href: p.link
19
+ }, p.name)))));
20
+ }
21
+
22
+ export function createMediaUseOnlyNotice(componentName, alternatePackages) {
23
+ return /*#__PURE__*/React.createElement(SectionMessage, {
24
+ title: "Internal Media Use Only",
25
+ appearance: "error"
26
+ }, /*#__PURE__*/React.createElement("p", null, componentName, " is intended for internal use by the Media Platform and as a transitive dependency of a media package within your product."), /*#__PURE__*/React.createElement("p", null, "Direct use of this component is not supported."), /*#__PURE__*/React.createElement(AlternativePackagesMessage, {
27
+ alternatePackages: alternatePackages
28
+ }));
29
+ }
@@ -18,7 +18,6 @@ export const areEqualFeatureFlags = (ffA, ffB) => {
18
18
  folderUploads: ffA.folderUploads === ffB.folderUploads,
19
19
  observedWidth: ffA.observedWidth === ffB.observedWidth,
20
20
  timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
21
- mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
22
21
  memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging
23
22
  };
24
23
  return Object.values(results).every(result => result);
@@ -58,7 +57,6 @@ export const defaultMediaFeatureFlags = {
58
57
  folderUploads: false,
59
58
  observedWidth: false,
60
59
  timestampOnVideo: false,
61
- mediaUploadApiV2: true,
62
60
  memoryCacheLogging: false
63
61
  };
64
62
  /**
@@ -8,7 +8,6 @@ const productKeys = {
8
8
  observedWidth: '',
9
9
  // TODO https://product-fabric.atlassian.net/browse/MEX-1620
10
10
  timestampOnVideo: '',
11
- mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
12
11
  memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging'
13
12
  },
14
13
  jira: {
@@ -21,7 +20,6 @@ const productKeys = {
21
20
  observedWidth: '',
22
21
  // TODO https://product-fabric.atlassian.net/browse/MEX-1620
23
22
  timestampOnVideo: '',
24
- mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
25
23
  memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging'
26
24
  }
27
25
  };
@@ -27,6 +27,25 @@ export const matches = srcObj => {
27
27
  return true;
28
28
  };
29
29
  };
30
- export function getRandomHex(size) {
31
- return [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
30
+
31
+ function getRandomHexValues(byte) {
32
+ return [...Array(byte * 2)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
33
+ }
34
+
35
+ export function getRandomHex(byte) {
36
+ var _window;
37
+
38
+ let randomHex;
39
+
40
+ if ((_window = window) !== null && _window !== void 0 && _window.crypto) {
41
+ try {
42
+ randomHex = Array.from(window.crypto.getRandomValues(new Uint8Array(byte))).map(b => b.toString(16).padStart(2, '0')).join('');
43
+ } catch (e) {
44
+ randomHex = getRandomHexValues(byte);
45
+ }
46
+ } else {
47
+ randomHex = getRandomHexValues(byte);
48
+ }
49
+
50
+ return randomHex;
32
51
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1 +1,2 @@
1
- export { createRxjsNotice } from './rxjs-notice';
1
+ export { createRxjsNotice } from './rxjs-notice';
2
+ export { createMediaUseOnlyNotice } from './media-use-only';
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import SectionMessage from '@atlaskit/section-message';
3
+
4
+ function AlternativePackagesMessage(_ref) {
5
+ var alternatePackages = _ref.alternatePackages;
6
+
7
+ if (!alternatePackages) {
8
+ return null;
9
+ }
10
+
11
+ if (alternatePackages.length === 1) {
12
+ return /*#__PURE__*/React.createElement("p", null, "Consider using", ' ', /*#__PURE__*/React.createElement("a", {
13
+ href: alternatePackages[0].link
14
+ }, alternatePackages[0].name), ' ', "instead.");
15
+ }
16
+
17
+ return /*#__PURE__*/React.createElement("p", null, "Consider using one of these packages instead:", /*#__PURE__*/React.createElement("ul", null, alternatePackages.map(function (p) {
18
+ return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("a", {
19
+ href: p.link
20
+ }, p.name));
21
+ })));
22
+ }
23
+
24
+ export function createMediaUseOnlyNotice(componentName, alternatePackages) {
25
+ return /*#__PURE__*/React.createElement(SectionMessage, {
26
+ title: "Internal Media Use Only",
27
+ appearance: "error"
28
+ }, /*#__PURE__*/React.createElement("p", null, componentName, " is intended for internal use by the Media Platform and as a transitive dependency of a media package within your product."), /*#__PURE__*/React.createElement("p", null, "Direct use of this component is not supported."), /*#__PURE__*/React.createElement(AlternativePackagesMessage, {
29
+ alternatePackages: alternatePackages
30
+ }));
31
+ }
@@ -19,7 +19,6 @@ export var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
19
19
  folderUploads: ffA.folderUploads === ffB.folderUploads,
20
20
  observedWidth: ffA.observedWidth === ffB.observedWidth,
21
21
  timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
22
- mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
23
22
  memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging
24
23
  };
25
24
  return Object.values(results).every(function (result) {
@@ -80,7 +79,6 @@ export var defaultMediaFeatureFlags = {
80
79
  folderUploads: false,
81
80
  observedWidth: false,
82
81
  timestampOnVideo: false,
83
- mediaUploadApiV2: true,
84
82
  memoryCacheLogging: false
85
83
  };
86
84
  /**
@@ -8,7 +8,6 @@ var productKeys = {
8
8
  observedWidth: '',
9
9
  // TODO https://product-fabric.atlassian.net/browse/MEX-1620
10
10
  timestampOnVideo: '',
11
- mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
12
11
  memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging'
13
12
  },
14
13
  jira: {
@@ -21,7 +20,6 @@ var productKeys = {
21
20
  observedWidth: '',
22
21
  // TODO https://product-fabric.atlassian.net/browse/MEX-1620
23
22
  timestampOnVideo: '',
24
- mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
25
23
  memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging'
26
24
  }
27
25
  };
@@ -52,8 +52,29 @@ export var matches = function matches(srcObj) {
52
52
  return true;
53
53
  };
54
54
  };
55
- export function getRandomHex(size) {
56
- return _toConsumableArray(Array(size)).map(function () {
55
+
56
+ function getRandomHexValues(byte) {
57
+ return _toConsumableArray(Array(byte * 2)).map(function () {
57
58
  return Math.floor(Math.random() * 16).toString(16);
58
59
  }).join('');
60
+ }
61
+
62
+ export function getRandomHex(byte) {
63
+ var _window;
64
+
65
+ var randomHex;
66
+
67
+ if ((_window = window) !== null && _window !== void 0 && _window.crypto) {
68
+ try {
69
+ randomHex = Array.from(window.crypto.getRandomValues(new Uint8Array(byte))).map(function (b) {
70
+ return b.toString(16).padStart(2, '0');
71
+ }).join('');
72
+ } catch (e) {
73
+ randomHex = getRandomHexValues(byte);
74
+ }
75
+ } else {
76
+ randomHex = getRandomHexValues(byte);
77
+ }
78
+
79
+ return randomHex;
59
80
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "sideEffects": false
5
5
  }
@@ -33,6 +33,7 @@ export declare type WithPerformanceAttributes = {
33
33
  };
34
34
  export declare type WithTraceContext = {
35
35
  traceContext?: MediaTraceContext;
36
+ metadataTraceContext?: MediaTraceContext;
36
37
  };
37
38
  export declare type SuccessAttributes = {
38
39
  status: 'success';
@@ -45,7 +46,7 @@ export declare type FailureAttributes = {
45
46
  errorDetail?: string;
46
47
  };
47
48
  export declare type StatusAttributes = SuccessAttributes | FailureAttributes;
48
- export declare type OperationalAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes & WithPerformanceAttributes);
49
+ export declare type OperationalAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes & WithPerformanceAttributes & WithTraceContext);
49
50
  export declare type OperationalEventPayload<Attributes extends OperationalAttributes, Action extends string, ActionSubject extends string, ActionSubjectId extends string = string> = BaseEventPayload<Attributes> & {
50
51
  eventType: 'operational';
51
52
  action: Action;
@@ -1 +1,2 @@
1
1
  export { createRxjsNotice } from './rxjs-notice';
2
+ export { createMediaUseOnlyNotice } from './media-use-only';
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ export declare function createMediaUseOnlyNotice(componentName: string, alternatePackages?: {
3
+ name: string;
4
+ link: string;
5
+ }[]): JSX.Element;
@@ -5,7 +5,6 @@ export interface MediaFeatureFlags {
5
5
  folderUploads?: boolean;
6
6
  observedWidth?: boolean;
7
7
  timestampOnVideo?: boolean;
8
- mediaUploadApiV2?: boolean;
9
8
  memoryCacheLogging?: boolean;
10
9
  }
11
10
  export interface WithMediaFeatureFlags {
@@ -7,4 +7,4 @@ export declare const omitBy: (obj: Object, predicate: Function) => {
7
7
  };
8
8
  export declare const debounce: (func: Function, wait: number) => (...args: any[]) => void;
9
9
  export declare const matches: (srcObj: Object) => (obj: Object) => boolean;
10
- export declare function getRandomHex(size: number): string;
10
+ export declare function getRandomHex(byte: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.17.0",
3
+ "version": "2.18.0",
4
4
  "description": "Includes common utilities used by other media packages",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -12,14 +12,6 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
- "typesVersions": {
16
- ">=4.0 <4.5": {
17
- "*": [
18
- "dist/types-ts4.0/*",
19
- "dist/types-ts4.0/index.d.ts"
20
- ]
21
- }
22
- },
23
15
  "sideEffects": false,
24
16
  "atlaskit:src": "src/index.ts",
25
17
  "af:exports": {
@@ -52,7 +44,7 @@
52
44
  },
53
45
  "devDependencies": {
54
46
  "@atlaskit/docs": "*",
55
- "@atlaskit/media-test-helpers": "^30.0.0",
47
+ "@atlaskit/media-test-helpers": "^30.1.0",
56
48
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
57
49
  "enzyme": "^3.10.0",
58
50
  "react": "^16.8.0",
package/report.api.md CHANGED
@@ -1,12 +1,17 @@
1
+ <!-- API Report Version: 2.3 -->
2
+
1
3
  ## API Report File for "@atlaskit/media-common"
2
4
 
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
5
+ > Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
6
+ > [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
7
+
8
+ ### Table of contents
4
9
 
5
- <!--
6
- Generated API Report version: 2.0
7
- -->
10
+ - [Main Entry Types](#main-entry-types)
8
11
 
9
- [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
12
+ ### Main Entry Types
13
+
14
+ <!--SECTION START: Main Entry Types-->
10
15
 
11
16
  ```ts
12
17
  import { GasCorePayload } from '@atlaskit/analytics-gas-types';
@@ -79,11 +84,11 @@ export type FileAttributes = {
79
84
 
80
85
  // @public (undocumented)
81
86
  export type FileStatus =
82
- | 'uploading'
83
- | 'processing'
84
- | 'processed'
85
87
  | 'error'
86
- | 'failed-processing';
88
+ | 'failed-processing'
89
+ | 'processed'
90
+ | 'processing'
91
+ | 'uploading';
87
92
 
88
93
  // @public
89
94
  export const filterFeatureFlagKeysAllProducts: (
@@ -104,6 +109,9 @@ export function getMediaFeatureFlag<T = boolean>(
104
109
  // @public (undocumented)
105
110
  export const getMediaTypeFromMimeType: (mimeType: string) => MediaType;
106
111
 
112
+ // @public (undocumented)
113
+ export function getRandomHex(byte: number): string;
114
+
107
115
  // @public (undocumented)
108
116
  export const isAudioMimeTypeSupportedByServer: (mimeType: string) => boolean;
109
117
 
@@ -148,8 +156,6 @@ export interface MediaFeatureFlags {
148
156
  // (undocumented)
149
157
  mediaInline?: boolean;
150
158
  // (undocumented)
151
- mediaUploadApiV2?: boolean;
152
- // (undocumented)
153
159
  memoryCacheLogging?: boolean;
154
160
  // (undocumented)
155
161
  newCardExperience?: boolean;
@@ -159,14 +165,20 @@ export interface MediaFeatureFlags {
159
165
  timestampOnVideo?: boolean;
160
166
  }
161
167
 
168
+ // @public (undocumented)
169
+ export type MediaTraceContext = {
170
+ traceId: string;
171
+ spanId?: string;
172
+ };
173
+
162
174
  // @public (undocumented)
163
175
  export type MediaType =
164
- | 'doc'
176
+ | 'archive'
165
177
  | 'audio'
166
- | 'video'
178
+ | 'doc'
167
179
  | 'image'
168
- | 'archive'
169
- | 'unknown';
180
+ | 'unknown'
181
+ | 'video';
170
182
 
171
183
  // @public (undocumented)
172
184
  export interface NumericalCardDimensions {
@@ -186,20 +198,21 @@ export const omitBy: (
186
198
 
187
199
  // @public (undocumented)
188
200
  export type OperationalAttributes =
189
- | BaseAttributes
190
- | (BaseAttributes & WithFileAttributes)
191
- | (BaseAttributes & WithFileAttributes & StatusAttributes)
192
201
  | (BaseAttributes &
193
202
  WithFileAttributes &
194
203
  StatusAttributes &
195
- WithPerformanceAttributes);
204
+ WithPerformanceAttributes &
205
+ WithTraceContext)
206
+ | (BaseAttributes & WithFileAttributes & StatusAttributes)
207
+ | (BaseAttributes & WithFileAttributes)
208
+ | BaseAttributes;
196
209
 
197
210
  // @public (undocumented)
198
211
  export type OperationalEventPayload<
199
212
  Attributes extends OperationalAttributes,
200
213
  Action extends string,
201
214
  ActionSubject extends string,
202
- ActionSubjectId extends string = string
215
+ ActionSubjectId extends string = string,
203
216
  > = BaseEventPayload<Attributes> & {
204
217
  eventType: 'operational';
205
218
  action: Action;
@@ -239,13 +252,13 @@ type RequiredMediaFeatureFlags = Record<
239
252
 
240
253
  // @public (undocumented)
241
254
  export type ScreenAttributes =
242
- | BaseAttributes
243
- | (BaseAttributes & WithFileAttributes);
255
+ | (BaseAttributes & WithFileAttributes)
256
+ | BaseAttributes;
244
257
 
245
258
  // @public (undocumented)
246
259
  export type ScreenEventPayload<
247
260
  Attributes extends ScreenAttributes,
248
- ActionSubject extends string
261
+ ActionSubject extends string,
249
262
  > = BaseEventPayload<Attributes> & {
250
263
  eventType: 'screen';
251
264
  actionSubject: ActionSubject;
@@ -256,7 +269,7 @@ export type ScreenEventPayload<
256
269
  export type SSR = 'client' | 'server';
257
270
 
258
271
  // @public (undocumented)
259
- type StatusAttributes = SuccessAttributes | FailureAttributes;
272
+ type StatusAttributes = FailureAttributes | SuccessAttributes;
260
273
 
261
274
  // @public (undocumented)
262
275
  export type SuccessAttributes = {
@@ -266,15 +279,15 @@ export type SuccessAttributes = {
266
279
 
267
280
  // @public (undocumented)
268
281
  export type TrackAttributes =
269
- | BaseAttributes
270
- | (BaseAttributes & WithFileAttributes);
282
+ | (BaseAttributes & WithFileAttributes)
283
+ | BaseAttributes;
271
284
 
272
285
  // @public (undocumented)
273
286
  export type TrackEventPayload<
274
287
  Attributes extends TrackAttributes,
275
288
  Action extends string,
276
289
  ActionSubject extends string,
277
- ActionSubjectId extends string = string
290
+ ActionSubjectId extends string = string,
278
291
  > = BaseEventPayload<Attributes> & {
279
292
  eventType: 'track';
280
293
  action: Action;
@@ -284,14 +297,14 @@ export type TrackEventPayload<
284
297
 
285
298
  // @public (undocumented)
286
299
  export type UIAttributes =
287
- | BaseAttributes
288
- | (BaseAttributes & WithFileAttributes);
300
+ | (BaseAttributes & WithFileAttributes)
301
+ | BaseAttributes;
289
302
 
290
303
  // @public (undocumented)
291
304
  export type UIEventPayload<
292
305
  Attributes extends UIAttributes,
293
306
  Action extends string,
294
- ActionSubject extends string
307
+ ActionSubject extends string,
295
308
  > = BaseEventPayload<Attributes> & {
296
309
  eventType: 'ui';
297
310
  action: Action;
@@ -317,7 +330,7 @@ export const withMediaAnalyticsContext: (
317
330
  },
318
331
  ) => <
319
332
  Props extends WithMediaFeatureFlags,
320
- Component extends React_2.ComponentType<Props>
333
+ Component extends React_2.ComponentType<Props>,
321
334
  >(
322
335
  WrappedComponent: React_2.JSXElementConstructor<Props> & Component,
323
336
  ) => React_2.ForwardRefExoticComponent<
@@ -336,5 +349,13 @@ export type WithPerformanceAttributes = {
336
349
  performanceAttributes?: PerformanceAttributes;
337
350
  };
338
351
 
352
+ // @public (undocumented)
353
+ export type WithTraceContext = {
354
+ traceContext?: MediaTraceContext;
355
+ metadataTraceContext?: MediaTraceContext;
356
+ };
357
+
339
358
  // (No @packageDocumentation comment for this package)
340
359
  ```
360
+
361
+ <!--SECTION END: Main Entry Types-->
@@ -1 +0,0 @@
1
- export declare const ANALYTICS_MEDIA_CHANNEL = "media";
@@ -1,3 +0,0 @@
1
- export type { PackageAttributes, WithFileAttributes, FileAttributes, SuccessAttributes, FailureAttributes, OperationalAttributes, OperationalEventPayload, UIAttributes, UIEventPayload, ScreenAttributes, ScreenEventPayload, TrackAttributes, TrackEventPayload, ContextPublicAttributes, ContextStaticProps, } from './types';
2
- export { withMediaAnalyticsContext } from './withMediaAnalyticsContext';
3
- export { ANALYTICS_MEDIA_CHANNEL } from './constants';
@@ -1,80 +0,0 @@
1
- import { GasCorePayload } from '@atlaskit/analytics-gas-types';
2
- import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context/MediaAnalyticsContext';
3
- import { MediaType, FileStatus, WithMediaFeatureFlags, MediaTraceContext } from '..';
4
- export declare type BaseAttributes = {};
5
- export declare type PackageAttributes = {
6
- packageName: string;
7
- packageVersion: string;
8
- componentName: string;
9
- component: string;
10
- };
11
- export declare type BaseEventPayload<Attributes extends BaseAttributes> = Omit<GasCorePayload, 'attributes'> & {
12
- attributes: Attributes;
13
- };
14
- export declare type FileAttributes = {
15
- fileId: string;
16
- fileSize?: number;
17
- fileMediatype?: MediaType;
18
- fileMimetype?: string;
19
- fileSource?: string;
20
- fileStatus?: FileStatus;
21
- };
22
- export declare type PerformanceAttributes = {
23
- overall: {
24
- durationSincePageStart: number;
25
- durationSinceCommenced?: number;
26
- };
27
- };
28
- export declare type WithFileAttributes = {
29
- fileAttributes: FileAttributes;
30
- };
31
- export declare type WithPerformanceAttributes = {
32
- performanceAttributes?: PerformanceAttributes;
33
- };
34
- export declare type WithTraceContext = {
35
- traceContext?: MediaTraceContext;
36
- };
37
- export declare type SuccessAttributes = {
38
- status: 'success';
39
- fileMediatype?: MediaType;
40
- };
41
- export declare type FailureAttributes = {
42
- status: 'fail';
43
- failReason: string;
44
- error?: string;
45
- errorDetail?: string;
46
- };
47
- export declare type StatusAttributes = SuccessAttributes | FailureAttributes;
48
- export declare type OperationalAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes & WithPerformanceAttributes);
49
- export declare type OperationalEventPayload<Attributes extends OperationalAttributes, Action extends string, ActionSubject extends string, ActionSubjectId extends string = string> = BaseEventPayload<Attributes> & {
50
- eventType: 'operational';
51
- action: Action;
52
- actionSubject: ActionSubject;
53
- actionSubjectId?: ActionSubjectId;
54
- };
55
- export declare type UIAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes);
56
- export declare type UIEventPayload<Attributes extends UIAttributes, Action extends string, ActionSubject extends string> = BaseEventPayload<Attributes> & {
57
- eventType: 'ui';
58
- action: Action;
59
- actionSubject: ActionSubject;
60
- actionSubjectId?: string;
61
- };
62
- export declare type ScreenAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes);
63
- export declare type ScreenEventPayload<Attributes extends ScreenAttributes, ActionSubject extends string> = BaseEventPayload<Attributes> & {
64
- eventType: 'screen';
65
- actionSubject: ActionSubject;
66
- name: ActionSubject;
67
- };
68
- export declare type TrackAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes);
69
- export declare type TrackEventPayload<Attributes extends TrackAttributes, Action extends string, ActionSubject extends string, ActionSubjectId extends string = string> = BaseEventPayload<Attributes> & {
70
- eventType: 'track';
71
- action: Action;
72
- actionSubject: ActionSubject;
73
- actionSubjectId?: ActionSubjectId;
74
- };
75
- export declare type ContextPublicAttributes = PackageAttributes;
76
- export declare type ContextPrivateAttributes = WithMediaFeatureFlags;
77
- export declare type ContextStaticProps = WithMediaFeatureFlags;
78
- export declare type ContextData = ContextPublicAttributes & {
79
- [MEDIA_CONTEXT]: ContextPrivateAttributes;
80
- };
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { MediaFeatureFlags } from '../mediaFeatureFlags';
3
- import { ContextPublicAttributes } from './types';
4
- /**
5
- * HOC for attaching MediaAnalyticsContext to a top-level React Component.
6
- *
7
- * Similar than "packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx",
8
- * except that we restrict attributes put in this context using ContextPublicAttributes and ContextPrivateAttributes.
9
- *
10
- * As a constraint, the wrapped React Component's props must extend ContextStaticProps.
11
- *
12
- * @param {ContextPublicAttributes} attributes public attributes to put in context
13
- *
14
- * @see packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx
15
- */
16
- export declare const withMediaAnalyticsContext: (contextPublicAttributes: ContextPublicAttributes, options?: {
17
- filterFeatureFlags?: Array<keyof MediaFeatureFlags>;
18
- }) => <Props extends import("../mediaFeatureFlags").WithMediaFeatureFlags, Component extends React.ComponentType<Props>>(WrappedComponent: React.JSXElementConstructor<Props> & Component) => React.ForwardRefExoticComponent<React.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Props>> & React.RefAttributes<any>>;
@@ -1 +0,0 @@
1
- export { createRxjsNotice } from './rxjs-notice';
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function createRxjsNotice(componentName: string): JSX.Element;
@@ -1,4 +0,0 @@
1
- export interface DownloadUrlOptions {
2
- name?: string;
3
- }
4
- export declare const downloadUrl: (url: string, options?: DownloadUrlOptions | undefined) => void;
@@ -1,19 +0,0 @@
1
- export { downloadUrl } from './downloadUrl';
2
- export declare type MediaType = 'doc' | 'audio' | 'video' | 'image' | 'archive' | 'unknown';
3
- export declare type FileStatus = 'uploading' | 'processing' | 'processed' | 'error' | 'failed-processing';
4
- export { getMediaFeatureFlag, defaultMediaFeatureFlags, areEqualFeatureFlags, useMemoizeFeatureFlags, filterFeatureFlagNames, filterFeatureFlagKeysAllProducts, } from './mediaFeatureFlags';
5
- export type { MediaFeatureFlags, WithMediaFeatureFlags, } from './mediaFeatureFlags';
6
- export interface NumericalCardDimensions {
7
- width: number;
8
- height: number;
9
- }
10
- export type { PackageAttributes, WithFileAttributes, WithPerformanceAttributes, WithTraceContext, FileAttributes, PerformanceAttributes, SuccessAttributes, FailureAttributes, OperationalAttributes, OperationalEventPayload, UIAttributes, UIEventPayload, ScreenAttributes, ScreenEventPayload, TrackAttributes, TrackEventPayload, ContextPublicAttributes, ContextStaticProps, } from './analytics/types';
11
- export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext';
12
- export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
13
- export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer, } from './mediaTypeUtils';
14
- export declare type SSR = 'client' | 'server';
15
- export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, } from './utils/helpers';
16
- export declare type MediaTraceContext = {
17
- traceId: string;
18
- spanId?: string;
19
- };
@@ -1 +0,0 @@
1
- export declare const getLocalMediaFeatureFlag: (key: string) => string | null;
@@ -1,2 +0,0 @@
1
- export { getMediaFeatureFlag, useMemoizeFeatureFlags, defaultMediaFeatureFlags, areEqualFeatureFlags, filterFeatureFlagNames, filterFeatureFlagKeysAllProducts, } from './mediaFeatureFlags';
2
- export type { MediaFeatureFlags, WithMediaFeatureFlags, SupportedProduct, } from './types';
@@ -1,26 +0,0 @@
1
- import { RequiredMediaFeatureFlags, MediaFeatureFlags, SupportedProduct } from './types';
2
- export declare const areEqualFeatureFlags: (ffA?: MediaFeatureFlags | undefined, ffB?: MediaFeatureFlags | undefined) => boolean;
3
- export declare const filterFeatureFlagNames: (flags: RequiredMediaFeatureFlags) => Array<keyof MediaFeatureFlags>;
4
- /**
5
- * Takes a record of {Media Feature Flag Names → boolean} and a supported product name.
6
- * Returns the corresponding product’s Launch Darkly Keys for each of the flags set as true in the input record.
7
- * */
8
- export declare const mapAndFilterFeatureFlagNames: (flags: RequiredMediaFeatureFlags, product: SupportedProduct) => Array<string>;
9
- /**
10
- * Takes a record of {Media Feature Flag Names → boolean}.
11
- * Returns the Launch Darkly Keys from all products for each of the flags set as true in the input record.
12
- * */
13
- export declare const filterFeatureFlagKeysAllProducts: (flags: RequiredMediaFeatureFlags) => Array<string>;
14
- export declare const defaultMediaFeatureFlags: Required<MediaFeatureFlags>;
15
- /**
16
- * Public accessor from components to fallback to defaults if flags not passed,
17
- * otherwise whatever product has set will be returned.
18
- *
19
- * To override locally for testing:
20
- * - `localStorage[flagName] = true` to enable locally,
21
- * - `delete localStorage[flagName]` to remove.
22
- *
23
- * (you will see a warning in console if override used)
24
- * */
25
- export declare function getMediaFeatureFlag<T = boolean>(flagName: keyof MediaFeatureFlags, featureFlags?: MediaFeatureFlags): T;
26
- export declare const useMemoizeFeatureFlags: (featureFlags?: MediaFeatureFlags | undefined) => MediaFeatureFlags | undefined;
@@ -1,2 +0,0 @@
1
- import { ProductKeys } from './types';
2
- export declare const getProductKeys: () => ProductKeys;
@@ -1,21 +0,0 @@
1
- export interface MediaFeatureFlags {
2
- newCardExperience?: boolean;
3
- captions?: boolean;
4
- mediaInline?: boolean;
5
- folderUploads?: boolean;
6
- observedWidth?: boolean;
7
- timestampOnVideo?: boolean;
8
- mediaUploadApiV2?: boolean;
9
- memoryCacheLogging?: boolean;
10
- }
11
- export interface WithMediaFeatureFlags {
12
- featureFlags?: MediaFeatureFlags;
13
- }
14
- export declare type RequiredMediaFeatureFlags = Record<keyof Required<MediaFeatureFlags>, boolean>;
15
- export declare type MediaFeatureFlagsMap = Record<keyof Required<MediaFeatureFlags>, string>;
16
- export declare const supportedProducts: readonly [
17
- "confluence",
18
- "jira"
19
- ];
20
- export declare type SupportedProduct = typeof supportedProducts[number];
21
- export declare type ProductKeys = Record<SupportedProduct, MediaFeatureFlagsMap>;
@@ -1,4 +0,0 @@
1
- import { MediaType } from '..';
2
- export { isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isAudioMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, } from './isMimeTypeSupportedByBrowser';
3
- export { isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer, } from './isMimeTypeSupportedByServer';
4
- export declare const getMediaTypeFromMimeType: (mimeType: string) => MediaType;
@@ -1 +0,0 @@
1
- export declare const isArchive: (mimeType: string) => boolean;
@@ -1,14 +0,0 @@
1
- export declare const isImageMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
2
- export declare const isDocumentMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
3
- export declare const isAudioMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
4
- /**
5
- * For backward compatilbity, we assume MP4/MOV is natively supported.
6
- * TODO: Improve detection of supported video formats by the browser.
7
- *
8
- * See related tickets:
9
- * - https://product-fabric.atlassian.net/browse/MPT-477
10
- * - https://product-fabric.atlassian.net/browse/EDM-634
11
- * - https://product-fabric.atlassian.net/browse/EDM-426
12
- */
13
- export declare const isVideoMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
14
- export declare const isMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
@@ -1,6 +0,0 @@
1
- export declare const isImageMimeTypeSupportedByServer: (mimeType: string) => boolean;
2
- export declare const isDocumentMimeTypeSupportedByServer: (mimeType: string) => boolean;
3
- export declare const isAudioMimeTypeSupportedByServer: (mimeType: string) => boolean;
4
- export declare const isVideoMimeTypeSupportedByServer: (mimeType: string) => boolean;
5
- export declare const isUnknownMimeTypeSupportedByServer: (mimeType: string) => boolean;
6
- export declare const isMimeTypeSupportedByServer: (mimeType: string) => boolean;
@@ -1,10 +0,0 @@
1
- export declare const isUndefined: (value: any) => boolean;
2
- export declare const pick: (obj?: Object | undefined, keys?: Array<String>) => {
3
- [k: string]: any;
4
- };
5
- export declare const omitBy: (obj: Object, predicate: Function) => {
6
- [k: string]: any;
7
- };
8
- export declare const debounce: (func: Function, wait: number) => (...args: any[]) => void;
9
- export declare const matches: (srcObj: Object) => (obj: Object) => boolean;
10
- export declare function getRandomHex(size: number): string;