@atlaskit/media-common 2.13.0 → 2.16.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/media-common
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`a332288b5ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a332288b5ea) - Added analytics for media-card memoryCacheLogging and added relevant featureFlag keys for media-common package.
8
+
9
+ ## 2.15.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`1a76e2839e6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1a76e2839e6) - Default value for mediaUploadApiV2 Media feature flag set to true.
14
+
15
+ ## 2.14.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`bfde909c9b4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bfde909c9b4) - Add new feature flag mediaUploadApiV2
20
+ - [`8d6064cece4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d6064cece4) - Add missing values for the launch darkly feature flags name
21
+
3
22
  ## 2.13.0
4
23
 
5
24
  ### Minor Changes
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.filterFeatureFlagNames = exports.filterFeatureFlagKeysAllProducts = exports.defaultMediaFeatureFlags = exports.areEqualFeatureFlags = void 0;
9
9
  exports.getMediaFeatureFlag = getMediaFeatureFlag;
10
- exports.useMemoizeFeatureFlags = exports.mediaFeatureFlagsProductToLaunchDarklyMap = exports.mapAndFilterFeatureFlagNames = void 0;
10
+ exports.useMemoizeFeatureFlags = exports.mapAndFilterFeatureFlagNames = void 0;
11
11
 
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
13
 
@@ -15,6 +15,10 @@ var _react = require("react");
15
15
 
16
16
  var _mediaFeatureFlagLocal = require("../mediaFeatureFlag-local");
17
17
 
18
+ var _types = require("./types");
19
+
20
+ var _productKeys = require("./productKeys");
21
+
18
22
  var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
19
23
  if (!ffA && !ffB) {
20
24
  return true;
@@ -29,8 +33,10 @@ var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
29
33
  captions: ffA.captions === ffB.captions,
30
34
  mediaInline: ffA.mediaInline === ffB.mediaInline,
31
35
  folderUploads: ffA.folderUploads === ffB.folderUploads,
36
+ observedWidth: ffA.observedWidth === ffB.observedWidth,
32
37
  timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
33
- observedWidth: ffA.observedWidth === ffB.observedWidth
38
+ mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
39
+ memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging
34
40
  };
35
41
  return Object.values(results).every(function (result) {
36
42
  return result;
@@ -65,7 +71,7 @@ exports.filterFeatureFlagNames = filterFeatureFlagNames;
65
71
  var mapAndFilterFeatureFlagNames = function mapAndFilterFeatureFlagNames(flags, product) {
66
72
  var mediaFeatureFlags = filterFeatureFlagNames(flags);
67
73
  return mediaFeatureFlags.map(function (key) {
68
- return mediaFeatureFlagsProductToLaunchDarklyMap[product][key];
74
+ return (0, _productKeys.getProductKeys)()[product][key];
69
75
  });
70
76
  }; // TODO(MEX-1547): This is temporary solution to just return the launch darkly feature flags for all products.
71
77
 
@@ -79,39 +85,19 @@ exports.mapAndFilterFeatureFlagNames = mapAndFilterFeatureFlagNames;
79
85
 
80
86
  var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllProducts(flags) {
81
87
  var filteredFlags = filterFeatureFlagNames(flags);
82
- var supportedProducts = Object.keys(mediaFeatureFlagsProductToLaunchDarklyMap);
83
88
  var ldFeatureFlags = [];
84
89
  filteredFlags.forEach(function (flag) {
85
- return supportedProducts.forEach(function (product) {
86
- return ldFeatureFlags.push(mediaFeatureFlagsProductToLaunchDarklyMap[product][flag]);
90
+ return _types.supportedProducts.forEach(function (product) {
91
+ return ldFeatureFlags.push((0, _productKeys.getProductKeys)()[product][flag]);
87
92
  });
88
93
  });
89
94
  return ldFeatureFlags.filter(function (flag) {
90
95
  return flag !== '';
91
96
  });
92
- };
93
-
94
- exports.filterFeatureFlagKeysAllProducts = filterFeatureFlagKeysAllProducts;
95
- var mediaFeatureFlagsProductToLaunchDarklyMap = {
96
- confluence: {
97
- newCardExperience: 'confluence.media.cards.new.experience',
98
- captions: 'confluence.frontend.fabric.editor.media.captions',
99
- mediaInline: 'confluence.frontend.fabric.editor.media.inline',
100
- folderUploads: 'confluence.media.picker.folder.uploads',
101
- timestampOnVideo: '',
102
- observedWidth: ''
103
- },
104
- jira: {
105
- newCardExperience: 'issue.details.media-cards-new-experience',
106
- captions: 'issue.details.editor.media.captions',
107
- mediaInline: '',
108
- folderUploads: '',
109
- timestampOnVideo: '',
110
- observedWidth: ''
111
- }
112
97
  }; // default values defined here, not necessary for components to know directly as they should use the function below
113
98
 
114
- exports.mediaFeatureFlagsProductToLaunchDarklyMap = mediaFeatureFlagsProductToLaunchDarklyMap;
99
+
100
+ exports.filterFeatureFlagKeysAllProducts = filterFeatureFlagKeysAllProducts;
115
101
  var defaultMediaFeatureFlags = {
116
102
  newCardExperience: false,
117
103
  captions: false,
@@ -119,8 +105,10 @@ var defaultMediaFeatureFlags = {
119
105
  // We can't yet switch this feature on
120
106
  // TODO https://product-fabric.atlassian.net/browse/MEX-104
121
107
  folderUploads: false,
108
+ observedWidth: false,
122
109
  timestampOnVideo: false,
123
- observedWidth: false
110
+ mediaUploadApiV2: true,
111
+ memoryCacheLogging: false
124
112
  };
125
113
  /**
126
114
  * Public accessor from components to fallback to defaults if flags not passed,
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getProductKeys = void 0;
7
+ var productKeys = {
8
+ confluence: {
9
+ newCardExperience: 'confluence.frontend.media.cards.new.experience',
10
+ captions: 'confluence.frontend.fabric.editor.media.captions',
11
+ mediaInline: 'confluence.frontend.fabric.editor.media.inline',
12
+ folderUploads: 'confluence.frontend.media.picker.folder.uploads',
13
+ //TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
14
+ observedWidth: '',
15
+ // TODO https://product-fabric.atlassian.net/browse/MEX-1620
16
+ timestampOnVideo: '',
17
+ mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
18
+ memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging'
19
+ },
20
+ jira: {
21
+ newCardExperience: 'issue.details.media-cards-new-experience',
22
+ captions: 'issue.details.editor.media.captions',
23
+ // Manged by Linking Platform. No Rollout plan found for Jira
24
+ mediaInline: '',
25
+ folderUploads: 'issue.details.media-picker-folder-upload',
26
+ //TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
27
+ observedWidth: '',
28
+ // TODO https://product-fabric.atlassian.net/browse/MEX-1620
29
+ timestampOnVideo: '',
30
+ mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
31
+ memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging'
32
+ }
33
+ };
34
+
35
+ var getProductKeys = function getProductKeys() {
36
+ return productKeys;
37
+ };
38
+
39
+ exports.getProductKeys = getProductKeys;
@@ -2,4 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ exports.supportedProducts = void 0;
7
+ // Media feature flags - type and defaults defined here in one source of truth
8
+ // With this type we ensure the object will contain all the flags
9
+ var supportedProducts = ['confluence', 'jira'];
10
+ exports.supportedProducts = supportedProducts;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.13.0",
3
+ "version": "2.16.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,7 @@
1
1
  import { useRef } from 'react';
2
2
  import { getLocalMediaFeatureFlag } from '../mediaFeatureFlag-local';
3
+ import { supportedProducts } from './types';
4
+ import { getProductKeys } from './productKeys';
3
5
  export const areEqualFeatureFlags = (ffA, ffB) => {
4
6
  if (!ffA && !ffB) {
5
7
  return true;
@@ -14,8 +16,10 @@ export const areEqualFeatureFlags = (ffA, ffB) => {
14
16
  captions: ffA.captions === ffB.captions,
15
17
  mediaInline: ffA.mediaInline === ffB.mediaInline,
16
18
  folderUploads: ffA.folderUploads === ffB.folderUploads,
19
+ observedWidth: ffA.observedWidth === ffB.observedWidth,
17
20
  timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
18
- observedWidth: ffA.observedWidth === ffB.observedWidth
21
+ mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
22
+ memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging
19
23
  };
20
24
  return Object.values(results).every(result => result);
21
25
  };
@@ -30,7 +34,7 @@ export const filterFeatureFlagNames = flags => {
30
34
 
31
35
  export const mapAndFilterFeatureFlagNames = (flags, product) => {
32
36
  const mediaFeatureFlags = filterFeatureFlagNames(flags);
33
- return mediaFeatureFlags.map(key => mediaFeatureFlagsProductToLaunchDarklyMap[product][key]);
37
+ return mediaFeatureFlags.map(key => getProductKeys()[product][key]);
34
38
  }; // TODO(MEX-1547): This is temporary solution to just return the launch darkly feature flags for all products.
35
39
 
36
40
  /**
@@ -40,28 +44,9 @@ export const mapAndFilterFeatureFlagNames = (flags, product) => {
40
44
 
41
45
  export const filterFeatureFlagKeysAllProducts = flags => {
42
46
  const filteredFlags = filterFeatureFlagNames(flags);
43
- const supportedProducts = Object.keys(mediaFeatureFlagsProductToLaunchDarklyMap);
44
47
  const ldFeatureFlags = [];
45
- filteredFlags.forEach(flag => supportedProducts.forEach(product => ldFeatureFlags.push(mediaFeatureFlagsProductToLaunchDarklyMap[product][flag])));
48
+ filteredFlags.forEach(flag => supportedProducts.forEach(product => ldFeatureFlags.push(getProductKeys()[product][flag])));
46
49
  return ldFeatureFlags.filter(flag => flag !== '');
47
- };
48
- export const mediaFeatureFlagsProductToLaunchDarklyMap = {
49
- confluence: {
50
- newCardExperience: 'confluence.media.cards.new.experience',
51
- captions: 'confluence.frontend.fabric.editor.media.captions',
52
- mediaInline: 'confluence.frontend.fabric.editor.media.inline',
53
- folderUploads: 'confluence.media.picker.folder.uploads',
54
- timestampOnVideo: '',
55
- observedWidth: ''
56
- },
57
- jira: {
58
- newCardExperience: 'issue.details.media-cards-new-experience',
59
- captions: 'issue.details.editor.media.captions',
60
- mediaInline: '',
61
- folderUploads: '',
62
- timestampOnVideo: '',
63
- observedWidth: ''
64
- }
65
50
  }; // default values defined here, not necessary for components to know directly as they should use the function below
66
51
 
67
52
  export const defaultMediaFeatureFlags = {
@@ -71,8 +56,10 @@ export const defaultMediaFeatureFlags = {
71
56
  // We can't yet switch this feature on
72
57
  // TODO https://product-fabric.atlassian.net/browse/MEX-104
73
58
  folderUploads: false,
59
+ observedWidth: false,
74
60
  timestampOnVideo: false,
75
- observedWidth: false
61
+ mediaUploadApiV2: true,
62
+ memoryCacheLogging: false
76
63
  };
77
64
  /**
78
65
  * Public accessor from components to fallback to defaults if flags not passed,
@@ -0,0 +1,28 @@
1
+ const productKeys = {
2
+ confluence: {
3
+ newCardExperience: 'confluence.frontend.media.cards.new.experience',
4
+ captions: 'confluence.frontend.fabric.editor.media.captions',
5
+ mediaInline: 'confluence.frontend.fabric.editor.media.inline',
6
+ folderUploads: 'confluence.frontend.media.picker.folder.uploads',
7
+ //TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
8
+ observedWidth: '',
9
+ // TODO https://product-fabric.atlassian.net/browse/MEX-1620
10
+ timestampOnVideo: '',
11
+ mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
12
+ memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging'
13
+ },
14
+ jira: {
15
+ newCardExperience: 'issue.details.media-cards-new-experience',
16
+ captions: 'issue.details.editor.media.captions',
17
+ // Manged by Linking Platform. No Rollout plan found for Jira
18
+ mediaInline: '',
19
+ folderUploads: 'issue.details.media-picker-folder-upload',
20
+ //TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
21
+ observedWidth: '',
22
+ // TODO https://product-fabric.atlassian.net/browse/MEX-1620
23
+ timestampOnVideo: '',
24
+ mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
25
+ memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging'
26
+ }
27
+ };
28
+ export const getProductKeys = () => productKeys;
@@ -1 +1,3 @@
1
- export {};
1
+ // Media feature flags - type and defaults defined here in one source of truth
2
+ // With this type we ensure the object will contain all the flags
3
+ export const supportedProducts = ['confluence', 'jira'];
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.13.0",
3
+ "version": "2.16.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,8 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { useRef } from 'react';
3
3
  import { getLocalMediaFeatureFlag } from '../mediaFeatureFlag-local';
4
+ import { supportedProducts } from './types';
5
+ import { getProductKeys } from './productKeys';
4
6
  export var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
5
7
  if (!ffA && !ffB) {
6
8
  return true;
@@ -15,8 +17,10 @@ export var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
15
17
  captions: ffA.captions === ffB.captions,
16
18
  mediaInline: ffA.mediaInline === ffB.mediaInline,
17
19
  folderUploads: ffA.folderUploads === ffB.folderUploads,
20
+ observedWidth: ffA.observedWidth === ffB.observedWidth,
18
21
  timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
19
- observedWidth: ffA.observedWidth === ffB.observedWidth
22
+ mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
23
+ memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging
20
24
  };
21
25
  return Object.values(results).every(function (result) {
22
26
  return result;
@@ -45,7 +49,7 @@ export var filterFeatureFlagNames = function filterFeatureFlagNames(flags) {
45
49
  export var mapAndFilterFeatureFlagNames = function mapAndFilterFeatureFlagNames(flags, product) {
46
50
  var mediaFeatureFlags = filterFeatureFlagNames(flags);
47
51
  return mediaFeatureFlags.map(function (key) {
48
- return mediaFeatureFlagsProductToLaunchDarklyMap[product][key];
52
+ return getProductKeys()[product][key];
49
53
  });
50
54
  }; // TODO(MEX-1547): This is temporary solution to just return the launch darkly feature flags for all products.
51
55
 
@@ -56,34 +60,15 @@ export var mapAndFilterFeatureFlagNames = function mapAndFilterFeatureFlagNames(
56
60
 
57
61
  export var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllProducts(flags) {
58
62
  var filteredFlags = filterFeatureFlagNames(flags);
59
- var supportedProducts = Object.keys(mediaFeatureFlagsProductToLaunchDarklyMap);
60
63
  var ldFeatureFlags = [];
61
64
  filteredFlags.forEach(function (flag) {
62
65
  return supportedProducts.forEach(function (product) {
63
- return ldFeatureFlags.push(mediaFeatureFlagsProductToLaunchDarklyMap[product][flag]);
66
+ return ldFeatureFlags.push(getProductKeys()[product][flag]);
64
67
  });
65
68
  });
66
69
  return ldFeatureFlags.filter(function (flag) {
67
70
  return flag !== '';
68
71
  });
69
- };
70
- export var mediaFeatureFlagsProductToLaunchDarklyMap = {
71
- confluence: {
72
- newCardExperience: 'confluence.media.cards.new.experience',
73
- captions: 'confluence.frontend.fabric.editor.media.captions',
74
- mediaInline: 'confluence.frontend.fabric.editor.media.inline',
75
- folderUploads: 'confluence.media.picker.folder.uploads',
76
- timestampOnVideo: '',
77
- observedWidth: ''
78
- },
79
- jira: {
80
- newCardExperience: 'issue.details.media-cards-new-experience',
81
- captions: 'issue.details.editor.media.captions',
82
- mediaInline: '',
83
- folderUploads: '',
84
- timestampOnVideo: '',
85
- observedWidth: ''
86
- }
87
72
  }; // default values defined here, not necessary for components to know directly as they should use the function below
88
73
 
89
74
  export var defaultMediaFeatureFlags = {
@@ -93,8 +78,10 @@ export var defaultMediaFeatureFlags = {
93
78
  // We can't yet switch this feature on
94
79
  // TODO https://product-fabric.atlassian.net/browse/MEX-104
95
80
  folderUploads: false,
81
+ observedWidth: false,
96
82
  timestampOnVideo: false,
97
- observedWidth: false
83
+ mediaUploadApiV2: true,
84
+ memoryCacheLogging: false
98
85
  };
99
86
  /**
100
87
  * Public accessor from components to fallback to defaults if flags not passed,
@@ -0,0 +1,30 @@
1
+ var productKeys = {
2
+ confluence: {
3
+ newCardExperience: 'confluence.frontend.media.cards.new.experience',
4
+ captions: 'confluence.frontend.fabric.editor.media.captions',
5
+ mediaInline: 'confluence.frontend.fabric.editor.media.inline',
6
+ folderUploads: 'confluence.frontend.media.picker.folder.uploads',
7
+ //TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
8
+ observedWidth: '',
9
+ // TODO https://product-fabric.atlassian.net/browse/MEX-1620
10
+ timestampOnVideo: '',
11
+ mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
12
+ memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging'
13
+ },
14
+ jira: {
15
+ newCardExperience: 'issue.details.media-cards-new-experience',
16
+ captions: 'issue.details.editor.media.captions',
17
+ // Manged by Linking Platform. No Rollout plan found for Jira
18
+ mediaInline: '',
19
+ folderUploads: 'issue.details.media-picker-folder-upload',
20
+ //TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
21
+ observedWidth: '',
22
+ // TODO https://product-fabric.atlassian.net/browse/MEX-1620
23
+ timestampOnVideo: '',
24
+ mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
25
+ memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging'
26
+ }
27
+ };
28
+ export var getProductKeys = function getProductKeys() {
29
+ return productKeys;
30
+ };
@@ -1 +1,3 @@
1
- export {};
1
+ // Media feature flags - type and defaults defined here in one source of truth
2
+ // With this type we ensure the object will contain all the flags
3
+ export var supportedProducts = ['confluence', 'jira'];
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.13.0",
3
+ "version": "2.16.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { RequiredMediaFeatureFlags, MediaFeatureFlags, MediaFeatureFlagsMap, SupportedProduct } from './types';
1
+ import { RequiredMediaFeatureFlags, MediaFeatureFlags, SupportedProduct } from './types';
2
2
  export declare const areEqualFeatureFlags: (ffA?: MediaFeatureFlags | undefined, ffB?: MediaFeatureFlags | undefined) => boolean;
3
3
  export declare const filterFeatureFlagNames: (flags: RequiredMediaFeatureFlags) => Array<keyof MediaFeatureFlags>;
4
4
  /**
@@ -11,7 +11,6 @@ export declare const mapAndFilterFeatureFlagNames: (flags: RequiredMediaFeatureF
11
11
  * Returns the Launch Darkly Keys from all products for each of the flags set as true in the input record.
12
12
  * */
13
13
  export declare const filterFeatureFlagKeysAllProducts: (flags: RequiredMediaFeatureFlags) => Array<string>;
14
- export declare const mediaFeatureFlagsProductToLaunchDarklyMap: Record<SupportedProduct, MediaFeatureFlagsMap>;
15
14
  export declare const defaultMediaFeatureFlags: Required<MediaFeatureFlags>;
16
15
  /**
17
16
  * Public accessor from components to fallback to defaults if flags not passed,
@@ -0,0 +1,2 @@
1
+ import { ProductKeys } from './types';
2
+ export declare const getProductKeys: () => ProductKeys;
@@ -3,12 +3,16 @@ export interface MediaFeatureFlags {
3
3
  captions?: boolean;
4
4
  mediaInline?: boolean;
5
5
  folderUploads?: boolean;
6
- timestampOnVideo?: boolean;
7
6
  observedWidth?: boolean;
7
+ timestampOnVideo?: boolean;
8
+ mediaUploadApiV2?: boolean;
9
+ memoryCacheLogging?: boolean;
8
10
  }
9
11
  export interface WithMediaFeatureFlags {
10
12
  featureFlags?: MediaFeatureFlags;
11
13
  }
12
14
  export declare type RequiredMediaFeatureFlags = Record<keyof Required<MediaFeatureFlags>, boolean>;
13
15
  export declare type MediaFeatureFlagsMap = Record<keyof Required<MediaFeatureFlags>, string>;
14
- export declare type SupportedProduct = 'confluence' | 'jira';
16
+ export declare const supportedProducts: readonly ["confluence", "jira"];
17
+ export declare type SupportedProduct = typeof supportedProducts[number];
18
+ export declare type ProductKeys = Record<SupportedProduct, MediaFeatureFlagsMap>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-common",
3
- "version": "2.13.0",
3
+ "version": "2.16.0",
4
4
  "description": "Includes common utilities used by other media packages",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@
33
33
  "scripts": {},
34
34
  "dependencies": {
35
35
  "@atlaskit/analytics-gas-types": "^5.0.5",
36
- "@atlaskit/analytics-namespaced-context": "^6.4.0",
36
+ "@atlaskit/analytics-namespaced-context": "^6.5.0",
37
37
  "@atlaskit/analytics-next": "^8.1.1",
38
38
  "@atlaskit/section-message": "^6.0.0",
39
39
  "@babel/runtime": "^7.0.0"
package/report.api.md ADDED
@@ -0,0 +1,308 @@
1
+ ## API Report File for "@atlaskit/media-common"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+ import { GasCorePayload } from '@atlaskit/analytics-gas-types';
7
+ import { default as React_2 } from 'react';
8
+
9
+ export declare const ANALYTICS_MEDIA_CHANNEL = 'media';
10
+
11
+ export declare const areEqualFeatureFlags: (
12
+ ffA?: MediaFeatureFlags | undefined,
13
+ ffB?: MediaFeatureFlags | undefined,
14
+ ) => boolean;
15
+
16
+ declare type BaseAttributes = {};
17
+
18
+ declare type BaseEventPayload<Attributes extends BaseAttributes> = Omit<
19
+ GasCorePayload,
20
+ 'attributes'
21
+ > & {
22
+ attributes: Attributes;
23
+ };
24
+
25
+ export declare type ContextPublicAttributes = PackageAttributes;
26
+
27
+ export declare type ContextStaticProps = WithMediaFeatureFlags;
28
+
29
+ export declare const debounce: (
30
+ func: Function,
31
+ wait: number,
32
+ ) => (...args: any[]) => void;
33
+
34
+ export declare const defaultMediaFeatureFlags: Required<MediaFeatureFlags>;
35
+
36
+ export declare const downloadUrl: (
37
+ url: string,
38
+ options?: DownloadUrlOptions | undefined,
39
+ ) => void;
40
+
41
+ declare interface DownloadUrlOptions {
42
+ name?: string;
43
+ }
44
+
45
+ export declare type FailureAttributes = {
46
+ status: 'fail';
47
+ failReason: string;
48
+ error?: string;
49
+ errorDetail?: string;
50
+ };
51
+
52
+ export declare type FileAttributes = {
53
+ fileId: string;
54
+ fileSize?: number;
55
+ fileMediatype?: MediaType;
56
+ fileMimetype?: string;
57
+ fileSource?: string;
58
+ fileStatus?: FileStatus;
59
+ };
60
+
61
+ export declare type FileStatus =
62
+ | 'uploading'
63
+ | 'processing'
64
+ | 'processed'
65
+ | 'error'
66
+ | 'failed-processing';
67
+
68
+ /**
69
+ * Takes a record of {Media Feature Flag Names → boolean}.
70
+ * Returns the Launch Darkly Keys from all products for each of the flags set as true in the input record.
71
+ * */
72
+ export declare const filterFeatureFlagKeysAllProducts: (
73
+ flags: RequiredMediaFeatureFlags,
74
+ ) => Array<string>;
75
+
76
+ export declare const filterFeatureFlagNames: (
77
+ flags: RequiredMediaFeatureFlags,
78
+ ) => Array<keyof MediaFeatureFlags>;
79
+
80
+ /**
81
+ * Public accessor from components to fallback to defaults if flags not passed,
82
+ * otherwise whatever product has set will be returned.
83
+ *
84
+ * To override locally for testing:
85
+ * - `localStorage[flagName] = true` to enable locally,
86
+ * - `delete localStorage[flagName]` to remove.
87
+ *
88
+ * (you will see a warning in console if override used)
89
+ * */
90
+ export declare function getMediaFeatureFlag<T = boolean>(
91
+ flagName: keyof MediaFeatureFlags,
92
+ featureFlags?: MediaFeatureFlags,
93
+ ): T;
94
+
95
+ export declare const getMediaTypeFromMimeType: (mimeType: string) => MediaType;
96
+
97
+ export declare const isAudioMimeTypeSupportedByServer: (
98
+ mimeType: string,
99
+ ) => boolean;
100
+
101
+ export declare const isDocumentMimeTypeSupportedByBrowser: (
102
+ mimeType: string,
103
+ ) => boolean;
104
+
105
+ export declare const isDocumentMimeTypeSupportedByServer: (
106
+ mimeType: string,
107
+ ) => boolean;
108
+
109
+ export declare const isImageMimeTypeSupportedByBrowser: (
110
+ mimeType: string,
111
+ ) => boolean;
112
+
113
+ export declare const isImageMimeTypeSupportedByServer: (
114
+ mimeType: string,
115
+ ) => boolean;
116
+
117
+ export declare const isMimeTypeSupportedByBrowser: (
118
+ mimeType: string,
119
+ ) => boolean;
120
+
121
+ export declare const isMimeTypeSupportedByServer: (mimeType: string) => boolean;
122
+
123
+ export declare const isUndefined: (value: any) => boolean;
124
+
125
+ export declare const isUnknownMimeTypeSupportedByServer: (
126
+ mimeType: string,
127
+ ) => boolean;
128
+
129
+ export declare const isVideoMimeTypeSupportedByServer: (
130
+ mimeType: string,
131
+ ) => boolean;
132
+
133
+ export declare const matches: (srcObj: Object) => (obj: Object) => boolean;
134
+
135
+ export declare interface MediaFeatureFlags {
136
+ newCardExperience?: boolean;
137
+ captions?: boolean;
138
+ mediaInline?: boolean;
139
+ folderUploads?: boolean;
140
+ observedWidth?: boolean;
141
+ timestampOnVideo?: boolean;
142
+ mediaUploadApiV2?: boolean;
143
+ }
144
+
145
+ export declare type MediaType =
146
+ | 'doc'
147
+ | 'audio'
148
+ | 'video'
149
+ | 'image'
150
+ | 'archive'
151
+ | 'unknown';
152
+
153
+ export declare interface NumericalCardDimensions {
154
+ width: number;
155
+ height: number;
156
+ }
157
+
158
+ export declare const omitBy: (
159
+ obj: Object,
160
+ predicate: Function,
161
+ ) => {
162
+ [k: string]: any;
163
+ };
164
+
165
+ export declare type OperationalAttributes =
166
+ | BaseAttributes
167
+ | (BaseAttributes & WithFileAttributes)
168
+ | (BaseAttributes & WithFileAttributes & StatusAttributes)
169
+ | (BaseAttributes &
170
+ WithFileAttributes &
171
+ StatusAttributes &
172
+ WithPerformanceAttributes);
173
+
174
+ export declare type OperationalEventPayload<
175
+ Attributes extends OperationalAttributes,
176
+ Action extends string,
177
+ ActionSubject extends string,
178
+ ActionSubjectId extends string = string
179
+ > = BaseEventPayload<Attributes> & {
180
+ eventType: 'operational';
181
+ action: Action;
182
+ actionSubject: ActionSubject;
183
+ actionSubjectId?: ActionSubjectId;
184
+ };
185
+
186
+ export declare type PackageAttributes = {
187
+ packageName: string;
188
+ packageVersion: string;
189
+ componentName: string;
190
+ component: string;
191
+ };
192
+
193
+ export declare type PerformanceAttributes = {
194
+ overall: {
195
+ durationSincePageStart: number;
196
+ durationSinceCommenced?: number;
197
+ };
198
+ };
199
+
200
+ export declare const pick: (
201
+ obj?: Object | undefined,
202
+ keys?: Array<String>,
203
+ ) => {
204
+ [k: string]: any;
205
+ };
206
+
207
+ declare type RequiredMediaFeatureFlags = Record<
208
+ keyof Required<MediaFeatureFlags>,
209
+ boolean
210
+ >;
211
+
212
+ export declare type ScreenAttributes =
213
+ | BaseAttributes
214
+ | (BaseAttributes & WithFileAttributes);
215
+
216
+ export declare type ScreenEventPayload<
217
+ Attributes extends ScreenAttributes,
218
+ ActionSubject extends string
219
+ > = BaseEventPayload<Attributes> & {
220
+ eventType: 'screen';
221
+ actionSubject: ActionSubject;
222
+ name: ActionSubject;
223
+ };
224
+
225
+ export declare type SSR = 'client' | 'server';
226
+
227
+ declare type StatusAttributes = SuccessAttributes | FailureAttributes;
228
+
229
+ export declare type SuccessAttributes = {
230
+ status: 'success';
231
+ };
232
+
233
+ export declare type TrackAttributes =
234
+ | BaseAttributes
235
+ | (BaseAttributes & WithFileAttributes);
236
+
237
+ export declare type TrackEventPayload<
238
+ Attributes extends TrackAttributes,
239
+ Action extends string,
240
+ ActionSubject extends string,
241
+ ActionSubjectId extends string = string
242
+ > = BaseEventPayload<Attributes> & {
243
+ eventType: 'track';
244
+ action: Action;
245
+ actionSubject: ActionSubject;
246
+ actionSubjectId?: ActionSubjectId;
247
+ };
248
+
249
+ export declare type UIAttributes =
250
+ | BaseAttributes
251
+ | (BaseAttributes & WithFileAttributes);
252
+
253
+ export declare type UIEventPayload<
254
+ Attributes extends UIAttributes,
255
+ Action extends string,
256
+ ActionSubject extends string
257
+ > = BaseEventPayload<Attributes> & {
258
+ eventType: 'ui';
259
+ action: Action;
260
+ actionSubject: ActionSubject;
261
+ actionSubjectId?: string;
262
+ };
263
+
264
+ export declare const useMemoizeFeatureFlags: (
265
+ featureFlags?: MediaFeatureFlags | undefined,
266
+ ) => MediaFeatureFlags | undefined;
267
+
268
+ export declare type WithFileAttributes = {
269
+ fileAttributes: FileAttributes;
270
+ };
271
+
272
+ /**
273
+ * HOC for attaching MediaAnalyticsContext to a top-level React Component.
274
+ *
275
+ * Similar than "packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx",
276
+ * except that we restrict attributes put in this context using ContextPublicAttributes and ContextPrivateAttributes.
277
+ *
278
+ * As a constraint, the wrapped React Component's props must extend ContextStaticProps.
279
+ *
280
+ * @param {ContextPublicAttributes} attributes public attributes to put in context
281
+ *
282
+ * @see packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx
283
+ */
284
+ export declare const withMediaAnalyticsContext: (
285
+ contextPublicAttributes: ContextPublicAttributes,
286
+ options?: {
287
+ filterFeatureFlags?: Array<keyof MediaFeatureFlags>;
288
+ },
289
+ ) => <
290
+ Props extends WithMediaFeatureFlags,
291
+ Component extends React_2.ComponentType<Props>
292
+ >(
293
+ WrappedComponent: React_2.JSXElementConstructor<Props> & Component,
294
+ ) => React_2.ForwardRefExoticComponent<
295
+ React_2.PropsWithoutRef<JSX.LibraryManagedAttributes<Component, Props>> &
296
+ React_2.RefAttributes<any>
297
+ >;
298
+
299
+ export declare interface WithMediaFeatureFlags {
300
+ featureFlags?: MediaFeatureFlags;
301
+ }
302
+
303
+ export declare type WithPerformanceAttributes = {
304
+ performanceAttributes?: PerformanceAttributes;
305
+ };
306
+
307
+ export {};
308
+ ```