@atlaskit/media-common 2.19.1 → 3.0.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 +16 -0
- package/dist/cjs/analytics/index.js +0 -2
- package/dist/cjs/analytics/withMediaAnalyticsContext.js +3 -17
- package/dist/cjs/docs/index.js +0 -2
- package/dist/cjs/docs/media-use-only.js +0 -8
- package/dist/cjs/docs/rxjs-notice.js +0 -4
- package/dist/cjs/downloadUrl.js +0 -6
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/mediaFeatureFlag-local.js +2 -4
- package/dist/cjs/mediaFeatureFlags/index.js +0 -1
- package/dist/cjs/mediaFeatureFlags/mediaFeatureFlags.js +19 -38
- package/dist/cjs/mediaFeatureFlags/productKeys.js +0 -6
- package/dist/cjs/mediaFeatureFlags/types.js +2 -0
- package/dist/cjs/mediaTypeUtils/index.js +0 -10
- package/dist/cjs/mediaTypeUtils/isArchive.js +0 -2
- package/dist/cjs/mediaTypeUtils/isMimeTypeSupportedByBrowser.js +3 -12
- package/dist/cjs/mediaTypeUtils/isMimeTypeSupportedByServer.js +27 -26
- package/dist/cjs/utils/helpers.js +3 -28
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +3 -1
- package/dist/es2019/analytics/withMediaAnalyticsContext.js +9 -7
- package/dist/es2019/docs/media-use-only.js +0 -4
- package/dist/es2019/downloadUrl.js +0 -4
- package/dist/es2019/index.js +5 -3
- package/dist/es2019/mediaFeatureFlag-local.js +2 -2
- package/dist/es2019/mediaFeatureFlags/mediaFeatureFlags.js +16 -16
- package/dist/es2019/mediaFeatureFlags/productKeys.js +0 -4
- package/dist/es2019/mediaFeatureFlags/types.js +2 -0
- package/dist/es2019/mediaTypeUtils/index.js +0 -5
- package/dist/es2019/mediaTypeUtils/isMimeTypeSupportedByBrowser.js +3 -2
- package/dist/es2019/mediaTypeUtils/isMimeTypeSupportedByServer.js +27 -14
- package/dist/es2019/utils/helpers.js +0 -8
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +3 -1
- package/dist/esm/analytics/withMediaAnalyticsContext.js +3 -7
- package/dist/esm/docs/media-use-only.js +0 -5
- package/dist/esm/downloadUrl.js +0 -4
- package/dist/esm/index.js +5 -3
- package/dist/esm/mediaFeatureFlag-local.js +2 -2
- package/dist/esm/mediaFeatureFlags/mediaFeatureFlags.js +19 -21
- package/dist/esm/mediaFeatureFlags/productKeys.js +0 -4
- package/dist/esm/mediaFeatureFlags/types.js +2 -0
- package/dist/esm/mediaTypeUtils/index.js +0 -5
- package/dist/esm/mediaTypeUtils/isMimeTypeSupportedByBrowser.js +3 -2
- package/dist/esm/mediaTypeUtils/isMimeTypeSupportedByServer.js +27 -14
- package/dist/esm/utils/helpers.js +3 -15
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mediaFeatureFlags/mediaFeatureFlags.d.ts +11 -0
- package/package.json +2 -2
- package/report.api.md +4 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
export { downloadUrl } from './downloadUrl';
|
|
1
|
+
export { downloadUrl } from './downloadUrl';
|
|
2
|
+
// Warning! You can't add new media types!
|
|
2
3
|
// See packages/media/media-core/src/__tests__/cache-backward-compatibility.spec.ts
|
|
3
4
|
|
|
4
5
|
// Media Feature Flags
|
|
5
6
|
export { getMediaFeatureFlag, defaultMediaFeatureFlags, areEqualFeatureFlags, useMemoizeFeatureFlags, filterFeatureFlagNames, filterFeatureFlagKeysAllProducts } from './mediaFeatureFlags';
|
|
6
7
|
// Analytics context
|
|
7
|
-
export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext';
|
|
8
|
+
export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext';
|
|
8
9
|
|
|
10
|
+
// Analytics constants
|
|
9
11
|
export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
|
|
10
|
-
export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './mediaTypeUtils';
|
|
12
|
+
export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './mediaTypeUtils';
|
|
11
13
|
export { isUndefined, pick, omitBy, debounce, matches, getRandomHex } from './utils/helpers';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
export var getLocalMediaFeatureFlag = function getLocalMediaFeatureFlag(key) {
|
|
3
3
|
try {
|
|
4
4
|
return typeof window !== 'undefined' && window.localStorage ? window.localStorage.getItem(key) : null;
|
|
5
|
-
} catch (e) {
|
|
5
|
+
} catch (e) {
|
|
6
|
+
// do nothing, return null by default
|
|
6
7
|
}
|
|
7
|
-
|
|
8
8
|
return null;
|
|
9
9
|
};
|
|
@@ -7,11 +7,9 @@ export var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
|
|
|
7
7
|
if (!ffA && !ffB) {
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
if (!ffA || !ffB) {
|
|
12
11
|
return false;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
var results = {
|
|
16
14
|
newCardExperience: ffA.newCardExperience === ffB.newCardExperience,
|
|
17
15
|
captions: ffA.captions === ffB.captions,
|
|
@@ -19,8 +17,6 @@ export var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
|
|
|
19
17
|
folderUploads: ffA.folderUploads === ffB.folderUploads,
|
|
20
18
|
observedWidth: ffA.observedWidth === ffB.observedWidth,
|
|
21
19
|
timestampOnVideo: ffA.timestampOnVideo === ffB.timestampOnVideo,
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
mediaUploadApiV2: ffA.mediaUploadApiV2 === ffB.mediaUploadApiV2,
|
|
24
20
|
memoryCacheLogging: ffA.memoryCacheLogging === ffB.memoryCacheLogging,
|
|
25
21
|
fetchFileStateAfterUpload: ffA.fetchFileStateAfterUpload === ffB.fetchFileStateAfterUpload
|
|
26
22
|
};
|
|
@@ -32,34 +28,32 @@ export var filterFeatureFlagNames = function filterFeatureFlagNames(flags) {
|
|
|
32
28
|
var pairs = Object.entries(flags);
|
|
33
29
|
return pairs.filter(function (_ref) {
|
|
34
30
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
_key = _ref2[0],
|
|
32
|
+
value = _ref2[1];
|
|
38
33
|
return !!value;
|
|
39
34
|
}).map(function (_ref3) {
|
|
40
35
|
var _ref4 = _slicedToArray(_ref3, 1),
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
key = _ref4[0];
|
|
43
37
|
return key;
|
|
44
38
|
});
|
|
45
39
|
};
|
|
40
|
+
|
|
46
41
|
/**
|
|
47
42
|
* Takes a record of {Media Feature Flag Names → boolean} and a supported product name.
|
|
48
43
|
* Returns the corresponding product’s Launch Darkly Keys for each of the flags set as true in the input record.
|
|
49
44
|
* */
|
|
50
|
-
|
|
51
45
|
export var mapAndFilterFeatureFlagNames = function mapAndFilterFeatureFlagNames(flags, product) {
|
|
52
46
|
var mediaFeatureFlags = filterFeatureFlagNames(flags);
|
|
53
47
|
return mediaFeatureFlags.map(function (key) {
|
|
54
48
|
return getProductKeys()[product][key];
|
|
55
49
|
});
|
|
56
|
-
};
|
|
50
|
+
};
|
|
57
51
|
|
|
52
|
+
// TODO(MEX-1547): This is temporary solution to just return the launch darkly feature flags for all products.
|
|
58
53
|
/**
|
|
59
54
|
* Takes a record of {Media Feature Flag Names → boolean}.
|
|
60
55
|
* Returns the Launch Darkly Keys from all products for each of the flags set as true in the input record.
|
|
61
56
|
* */
|
|
62
|
-
|
|
63
57
|
export var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllProducts(flags) {
|
|
64
58
|
var filteredFlags = filterFeatureFlagNames(flags);
|
|
65
59
|
var ldFeatureFlags = [];
|
|
@@ -71,8 +65,19 @@ export var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllP
|
|
|
71
65
|
return ldFeatureFlags.filter(function (flag) {
|
|
72
66
|
return flag !== '';
|
|
73
67
|
});
|
|
74
|
-
};
|
|
68
|
+
};
|
|
75
69
|
|
|
70
|
+
/**
|
|
71
|
+
* defaultMediaFeatureFlags set default values used by the getter function getMediaFeatureFlag
|
|
72
|
+
*
|
|
73
|
+
* *************************************
|
|
74
|
+
* ************* IMPORTANT *************
|
|
75
|
+
* *************************************
|
|
76
|
+
* Only in exceptional cases a FF should be 'true' by default.
|
|
77
|
+
* Making a flag default to 'true' can lead to confusing and unexpected scenarios.
|
|
78
|
+
* If you must set a flag default = true, whenever you remove that flag
|
|
79
|
+
* that change should be released as a MAJOR, because it's a breaking change.
|
|
80
|
+
*/
|
|
76
81
|
export var defaultMediaFeatureFlags = {
|
|
77
82
|
newCardExperience: false,
|
|
78
83
|
captions: false,
|
|
@@ -82,11 +87,10 @@ export var defaultMediaFeatureFlags = {
|
|
|
82
87
|
folderUploads: false,
|
|
83
88
|
observedWidth: false,
|
|
84
89
|
timestampOnVideo: false,
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
mediaUploadApiV2: true,
|
|
87
90
|
memoryCacheLogging: false,
|
|
88
91
|
fetchFileStateAfterUpload: false
|
|
89
92
|
};
|
|
93
|
+
|
|
90
94
|
/**
|
|
91
95
|
* Public accessor from components to fallback to defaults if flags not passed,
|
|
92
96
|
* otherwise whatever product has set will be returned.
|
|
@@ -97,28 +101,22 @@ export var defaultMediaFeatureFlags = {
|
|
|
97
101
|
*
|
|
98
102
|
* (you will see a warning in console if override used)
|
|
99
103
|
* */
|
|
100
|
-
|
|
101
104
|
export function getMediaFeatureFlag(flagName, featureFlags) {
|
|
102
105
|
var devOverride = getLocalMediaFeatureFlag(flagName);
|
|
103
|
-
|
|
104
106
|
if (devOverride !== null) {
|
|
105
107
|
try {
|
|
106
108
|
return JSON.parse(devOverride);
|
|
107
109
|
} catch (e) {}
|
|
108
110
|
}
|
|
109
|
-
|
|
110
111
|
if (featureFlags) {
|
|
111
112
|
return flagName in featureFlags ? featureFlags[flagName] : defaultMediaFeatureFlags[flagName];
|
|
112
113
|
}
|
|
113
|
-
|
|
114
114
|
return defaultMediaFeatureFlags[flagName];
|
|
115
115
|
}
|
|
116
116
|
export var useMemoizeFeatureFlags = function useMemoizeFeatureFlags(featureFlags) {
|
|
117
117
|
var ref = useRef();
|
|
118
|
-
|
|
119
118
|
if (!areEqualFeatureFlags(featureFlags, ref.current)) {
|
|
120
119
|
ref.current = featureFlags;
|
|
121
120
|
}
|
|
122
|
-
|
|
123
121
|
return ref.current;
|
|
124
122
|
};
|
|
@@ -7,8 +7,6 @@ var productKeys = {
|
|
|
7
7
|
//TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
|
|
8
8
|
observedWidth: '',
|
|
9
9
|
timestampOnVideo: 'confluence.frontend.media.timestamp.on.video',
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
mediaUploadApiV2: 'confluence.enable.media.upload.api.v2',
|
|
12
10
|
memoryCacheLogging: 'confluence-frontend-media-card-memory-cache-logging',
|
|
13
11
|
fetchFileStateAfterUpload: 'confluence-frontend-media-client-fetch-file-state-after-upload'
|
|
14
12
|
},
|
|
@@ -21,8 +19,6 @@ var productKeys = {
|
|
|
21
19
|
//TODO fill the value after https://product-fabric.atlassian.net/browse/MEX-1593
|
|
22
20
|
observedWidth: '',
|
|
23
21
|
timestampOnVideo: 'issue.details.media-cards-timestamp-on-video',
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
mediaUploadApiV2: 'issue.details.enable-media-upload-api-version-2',
|
|
26
22
|
memoryCacheLogging: 'jira-frontend-media-card-memory-cache-logging',
|
|
27
23
|
fetchFileStateAfterUpload: 'jira-frontend-media-client-fetch-file-state-after-upload'
|
|
28
24
|
}
|
|
@@ -7,22 +7,17 @@ export var getMediaTypeFromMimeType = function getMediaTypeFromMimeType(mimeType
|
|
|
7
7
|
if (isArchive(mimeType)) {
|
|
8
8
|
return 'archive';
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
if (isImageMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByServer(mimeType)) {
|
|
12
11
|
return 'image';
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
if (isDocumentMimeTypeSupportedByBrowser(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType)) {
|
|
16
14
|
return 'doc';
|
|
17
15
|
}
|
|
18
|
-
|
|
19
16
|
if (isAudioMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByServer(mimeType)) {
|
|
20
17
|
return 'audio';
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
if (isVideoMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByServer(mimeType)) {
|
|
24
20
|
return 'video';
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
return 'unknown';
|
|
28
23
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Based on https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
|
2
2
|
export var isImageMimeTypeSupportedByBrowser = function isImageMimeTypeSupportedByBrowser(mimeType) {
|
|
3
|
-
return ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp'
|
|
3
|
+
return ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp'
|
|
4
|
+
//'image/svg+xml', // Removed because of https://product-fabric.atlassian.net/browse/BMPT-625
|
|
4
5
|
].indexOf(mimeType.toLowerCase()) > -1;
|
|
5
6
|
};
|
|
6
7
|
export var isDocumentMimeTypeSupportedByBrowser = function isDocumentMimeTypeSupportedByBrowser(mimeType) {
|
|
@@ -9,6 +10,7 @@ export var isDocumentMimeTypeSupportedByBrowser = function isDocumentMimeTypeSup
|
|
|
9
10
|
export var isAudioMimeTypeSupportedByBrowser = function isAudioMimeTypeSupportedByBrowser(mimeType) {
|
|
10
11
|
return ['audio/aac', 'audio/flac', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/wav', 'audio/x-wav'].indexOf(mimeType.toLowerCase()) > -1;
|
|
11
12
|
};
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* For backward compatilbity, we assume MP4/MOV is natively supported.
|
|
14
16
|
* TODO: Improve detection of supported video formats by the browser.
|
|
@@ -18,7 +20,6 @@ export var isAudioMimeTypeSupportedByBrowser = function isAudioMimeTypeSupported
|
|
|
18
20
|
* - https://product-fabric.atlassian.net/browse/EDM-634
|
|
19
21
|
* - https://product-fabric.atlassian.net/browse/EDM-426
|
|
20
22
|
*/
|
|
21
|
-
|
|
22
23
|
export var isVideoMimeTypeSupportedByBrowser = function isVideoMimeTypeSupportedByBrowser(mimeType) {
|
|
23
24
|
return ['video/mp4', 'video/quicktime'].indexOf(mimeType.toLowerCase()) > -1;
|
|
24
25
|
};
|
|
@@ -3,18 +3,30 @@ export var isImageMimeTypeSupportedByServer = function isImageMimeTypeSupportedB
|
|
|
3
3
|
return ['image/bmp', 'image/x-windows-bmp', 'application/dicom', 'image/gif', 'image/jpeg', 'image/jpg', 'image/jp_', 'application/jpg', 'application/x-jpg', 'image/png', 'application/png', 'application/x-png', 'application/vnd.adobe.photoshop', 'image/vnd.adobe.photoshop', 'image/photoshop', 'image/x-photoshop', 'image/psd', 'application/photoshop', 'application/psd', 'zz-application/zz-winassoc-psd', 'image/tiff', 'image/x-tif', 'image/x-tiff', 'application/tif', 'application/x-tif', 'application/tiff', 'application/x-tiff', 'image/svg+xml', 'image/heif', 'image/heif-sequence', 'image/heic', 'image/heic-sequence'].indexOf(mimeType.toLowerCase()) > -1;
|
|
4
4
|
};
|
|
5
5
|
export var isDocumentMimeTypeSupportedByServer = function isDocumentMimeTypeSupportedByServer(mimeType) {
|
|
6
|
-
return [
|
|
7
|
-
|
|
8
|
-
'application/vnd.
|
|
9
|
-
|
|
10
|
-
'application/
|
|
11
|
-
|
|
12
|
-
'application/vnd.ms-
|
|
13
|
-
|
|
14
|
-
'application/
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
|
|
6
|
+
return [
|
|
7
|
+
// Adobe PDF
|
|
8
|
+
'application/pdf', 'application/x-pdf', 'application/acrobat', 'applications/vnd.pdf', 'text/pdf', 'text/x-pdf',
|
|
9
|
+
// Adobe Illustrator
|
|
10
|
+
'application/vnd.adobe.illustrator',
|
|
11
|
+
// Microsoft Office
|
|
12
|
+
'application/vnd.ms-office',
|
|
13
|
+
// Microsoft Word
|
|
14
|
+
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/vnd.ms-word.document.macroenabled.12', 'application/vnd.ms-word.template.macroenabled.12',
|
|
15
|
+
// Microsoft Excel
|
|
16
|
+
'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'application/vnd.ms-excel.sheet.macroenabled.12', 'application/vnd.ms-excel.template.macroenabled.12', 'application/vnd.ms-excel.addin.macroenabled.12', 'application/vnd.ms-excel.sheet.macroenabled', 'application/vnd.ms-excel.template.macroenabled', 'application/vnd.ms-excel.addin.macroenabled',
|
|
17
|
+
// Microsoft Powerpoint
|
|
18
|
+
'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.presentationml.template', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'application/vnd.ms-powerpoint.presentation.macroenabled.12', 'application/vnd.ms-powerpoint.template.macroenabled.12', 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
|
|
19
|
+
// OpenOffice
|
|
20
|
+
'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template',
|
|
21
|
+
// OpenDocument
|
|
22
|
+
'application/vnd.sun.xml.draw', 'application/vnd.sun.xml.draw.template', 'application/vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.presentation', 'application/x-vnd.oasis.opendocument.presentation', 'application/vnd.sun.xml.calc', 'application/vnd.sun.xml.calc.template', 'application/vnd.oasis.opendocument.spreadsheet', 'application/x-vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet-template', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.text-template', 'application/vnd.oasis.opendocument.text-master', 'application/x-vnd.oasis.opendocument.text', 'application/x-vnd.oasis.opendocument.text-template', 'application/x-vnd.oasis.opendocument.text-master',
|
|
23
|
+
// WordPerfect
|
|
24
|
+
'application/vnd.wordperfect',
|
|
25
|
+
// Text files
|
|
26
|
+
'text/csv', 'text/x-diff', 'text/x-perl', 'text/x-python', 'text/x-ruby', 'text/rtf', 'text/richtext', 'text/plain', 'application/txt',
|
|
27
|
+
// Rich text
|
|
28
|
+
'application/rtf', 'application/x-rtf',
|
|
29
|
+
// PostScript
|
|
18
30
|
'application/postscript'].indexOf(mimeType.toLowerCase()) > -1;
|
|
19
31
|
};
|
|
20
32
|
export var isAudioMimeTypeSupportedByServer = function isAudioMimeTypeSupportedByServer(mimeType) {
|
|
@@ -22,9 +34,10 @@ export var isAudioMimeTypeSupportedByServer = function isAudioMimeTypeSupportedB
|
|
|
22
34
|
};
|
|
23
35
|
export var isVideoMimeTypeSupportedByServer = function isVideoMimeTypeSupportedByServer(mimeType) {
|
|
24
36
|
return ['video/3gpp', 'video/3gpp2', 'video/x-ms-asf', 'video/avi', 'video/msvideo', 'video/x-msvideo', 'video/x-dv', 'video/x-flv', 'video/m2ts', 'video/x-m4v', 'video/x-matroska', 'video/quicktime', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/x-ogg', 'video/webm', 'video/x-ms-wmv'].indexOf(mimeType.toLowerCase()) > -1;
|
|
25
|
-
};
|
|
26
|
-
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
37
|
+
};
|
|
27
38
|
|
|
39
|
+
// BMPT-620: The backend momentarily returns this mimeType for cloud files imported via dt-api-mediapicker
|
|
40
|
+
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
28
41
|
export var isUnknownMimeTypeSupportedByServer = function isUnknownMimeTypeSupportedByServer(mimeType) {
|
|
29
42
|
return ['binary/octet-stream'].indexOf(mimeType.toLowerCase()) > -1;
|
|
30
43
|
};
|
|
@@ -5,24 +5,20 @@ export var isUndefined = function isUndefined(value) {
|
|
|
5
5
|
};
|
|
6
6
|
export var pick = function pick(obj) {
|
|
7
7
|
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
8
|
-
|
|
9
8
|
if (obj === undefined) {
|
|
10
9
|
return {};
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
return Object.fromEntries(Object.entries(obj).filter(function (_ref) {
|
|
14
12
|
var _ref2 = _slicedToArray(_ref, 1),
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
k = _ref2[0];
|
|
17
14
|
return keys.includes(k);
|
|
18
15
|
}));
|
|
19
16
|
};
|
|
20
17
|
export var omitBy = function omitBy(obj, predicate) {
|
|
21
18
|
return Object.fromEntries(Object.entries(obj).filter(function (_ref3) {
|
|
22
19
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
k = _ref4[0],
|
|
21
|
+
v = _ref4[1];
|
|
26
22
|
return !predicate(v);
|
|
27
23
|
}));
|
|
28
24
|
};
|
|
@@ -32,7 +28,6 @@ export var debounce = function debounce(func, wait) {
|
|
|
32
28
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
29
|
args[_key] = arguments[_key];
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
clearTimeout(timeout);
|
|
37
32
|
timeout = setTimeout(function () {
|
|
38
33
|
return func.apply(void 0, args);
|
|
@@ -42,28 +37,22 @@ export var debounce = function debounce(func, wait) {
|
|
|
42
37
|
export var matches = function matches(srcObj) {
|
|
43
38
|
return function (obj) {
|
|
44
39
|
var key;
|
|
45
|
-
|
|
46
40
|
for (key in srcObj) {
|
|
47
41
|
if (obj[key] === undefined || obj[key] !== srcObj[key]) {
|
|
48
42
|
return false;
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
|
-
|
|
52
45
|
return true;
|
|
53
46
|
};
|
|
54
47
|
};
|
|
55
|
-
|
|
56
48
|
function getRandomHexValues(byte) {
|
|
57
49
|
return _toConsumableArray(Array(byte * 2)).map(function () {
|
|
58
50
|
return Math.floor(Math.random() * 16).toString(16);
|
|
59
51
|
}).join('');
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
export function getRandomHex(byte) {
|
|
63
54
|
var _window;
|
|
64
|
-
|
|
65
55
|
var randomHex;
|
|
66
|
-
|
|
67
56
|
if ((_window = window) !== null && _window !== void 0 && _window.crypto) {
|
|
68
57
|
try {
|
|
69
58
|
randomHex = Array.from(window.crypto.getRandomValues(new Uint8Array(byte))).map(function (b) {
|
|
@@ -75,6 +64,5 @@ export function getRandomHex(byte) {
|
|
|
75
64
|
} else {
|
|
76
65
|
randomHex = getRandomHexValues(byte);
|
|
77
66
|
}
|
|
78
|
-
|
|
79
67
|
return randomHex;
|
|
80
68
|
}
|
package/dist/esm/version.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface NumericalCardDimensions {
|
|
|
10
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
11
|
export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext';
|
|
12
12
|
export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
|
|
13
|
-
export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer, } from './mediaTypeUtils';
|
|
13
|
+
export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer, } from './mediaTypeUtils';
|
|
14
14
|
export declare type SSR = 'client' | 'server';
|
|
15
15
|
export { isUndefined, pick, omitBy, debounce, matches, getRandomHex, } from './utils/helpers';
|
|
16
16
|
export declare type MediaTraceContext = {
|
|
@@ -11,6 +11,17 @@ 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
|
+
/**
|
|
15
|
+
* defaultMediaFeatureFlags set default values used by the getter function getMediaFeatureFlag
|
|
16
|
+
*
|
|
17
|
+
* *************************************
|
|
18
|
+
* ************* IMPORTANT *************
|
|
19
|
+
* *************************************
|
|
20
|
+
* Only in exceptional cases a FF should be 'true' by default.
|
|
21
|
+
* Making a flag default to 'true' can lead to confusing and unexpected scenarios.
|
|
22
|
+
* If you must set a flag default = true, whenever you remove that flag
|
|
23
|
+
* that change should be released as a MAJOR, because it's a breaking change.
|
|
24
|
+
*/
|
|
14
25
|
export declare const defaultMediaFeatureFlags: Required<MediaFeatureFlags>;
|
|
15
26
|
/**
|
|
16
27
|
* Public accessor from components to fallback to defaults if flags not passed,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Includes common utilities used by other media packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/analytics-gas-types": "^5.0.5",
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.6.0",
|
|
37
|
-
"@atlaskit/analytics-next": "^
|
|
37
|
+
"@atlaskit/analytics-next": "^9.0.0",
|
|
38
38
|
"@atlaskit/section-message": "^6.3.0",
|
|
39
39
|
"@babel/runtime": "^7.0.0"
|
|
40
40
|
},
|
package/report.api.md
CHANGED
|
@@ -50,7 +50,7 @@ export const debounce: (
|
|
|
50
50
|
wait: number,
|
|
51
51
|
) => (...args: any[]) => void;
|
|
52
52
|
|
|
53
|
-
// @public
|
|
53
|
+
// @public
|
|
54
54
|
export const defaultMediaFeatureFlags: Required<MediaFeatureFlags>;
|
|
55
55
|
|
|
56
56
|
// @public (undocumented)
|
|
@@ -142,6 +142,9 @@ export const isUndefined: (value: any) => boolean;
|
|
|
142
142
|
// @public (undocumented)
|
|
143
143
|
export const isUnknownMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
144
144
|
|
|
145
|
+
// @public
|
|
146
|
+
export const isVideoMimeTypeSupportedByBrowser: (mimeType: string) => boolean;
|
|
147
|
+
|
|
145
148
|
// @public (undocumented)
|
|
146
149
|
export const isVideoMimeTypeSupportedByServer: (mimeType: string) => boolean;
|
|
147
150
|
|