@atlaskit/media-common 2.19.1 → 2.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -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 +0 -6
- package/dist/cjs/mediaFeatureFlag-local.js +2 -4
- package/dist/cjs/mediaFeatureFlags/index.js +0 -1
- package/dist/cjs/mediaFeatureFlags/mediaFeatureFlags.js +9 -34
- package/dist/cjs/mediaFeatureFlags/productKeys.js +0 -2
- 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 +4 -2
- package/dist/es2019/mediaFeatureFlag-local.js +2 -2
- package/dist/es2019/mediaFeatureFlags/mediaFeatureFlags.js +6 -12
- 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 +4 -2
- package/dist/esm/mediaFeatureFlag-local.js +2 -2
- package/dist/esm/mediaFeatureFlags/mediaFeatureFlags.js +9 -17
- 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/package.json +2 -2
|
@@ -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,
|
|
@@ -32,34 +30,32 @@ export var filterFeatureFlagNames = function filterFeatureFlagNames(flags) {
|
|
|
32
30
|
var pairs = Object.entries(flags);
|
|
33
31
|
return pairs.filter(function (_ref) {
|
|
34
32
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
_key = _ref2[0],
|
|
34
|
+
value = _ref2[1];
|
|
38
35
|
return !!value;
|
|
39
36
|
}).map(function (_ref3) {
|
|
40
37
|
var _ref4 = _slicedToArray(_ref3, 1),
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
key = _ref4[0];
|
|
43
39
|
return key;
|
|
44
40
|
});
|
|
45
41
|
};
|
|
42
|
+
|
|
46
43
|
/**
|
|
47
44
|
* Takes a record of {Media Feature Flag Names → boolean} and a supported product name.
|
|
48
45
|
* Returns the corresponding product’s Launch Darkly Keys for each of the flags set as true in the input record.
|
|
49
46
|
* */
|
|
50
|
-
|
|
51
47
|
export var mapAndFilterFeatureFlagNames = function mapAndFilterFeatureFlagNames(flags, product) {
|
|
52
48
|
var mediaFeatureFlags = filterFeatureFlagNames(flags);
|
|
53
49
|
return mediaFeatureFlags.map(function (key) {
|
|
54
50
|
return getProductKeys()[product][key];
|
|
55
51
|
});
|
|
56
|
-
};
|
|
52
|
+
};
|
|
57
53
|
|
|
54
|
+
// TODO(MEX-1547): This is temporary solution to just return the launch darkly feature flags for all products.
|
|
58
55
|
/**
|
|
59
56
|
* Takes a record of {Media Feature Flag Names → boolean}.
|
|
60
57
|
* Returns the Launch Darkly Keys from all products for each of the flags set as true in the input record.
|
|
61
58
|
* */
|
|
62
|
-
|
|
63
59
|
export var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllProducts(flags) {
|
|
64
60
|
var filteredFlags = filterFeatureFlagNames(flags);
|
|
65
61
|
var ldFeatureFlags = [];
|
|
@@ -71,8 +67,9 @@ export var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllP
|
|
|
71
67
|
return ldFeatureFlags.filter(function (flag) {
|
|
72
68
|
return flag !== '';
|
|
73
69
|
});
|
|
74
|
-
};
|
|
70
|
+
};
|
|
75
71
|
|
|
72
|
+
// default values defined here, not necessary for components to know directly as they should use the function below
|
|
76
73
|
export var defaultMediaFeatureFlags = {
|
|
77
74
|
newCardExperience: false,
|
|
78
75
|
captions: false,
|
|
@@ -87,6 +84,7 @@ export var defaultMediaFeatureFlags = {
|
|
|
87
84
|
memoryCacheLogging: false,
|
|
88
85
|
fetchFileStateAfterUpload: false
|
|
89
86
|
};
|
|
87
|
+
|
|
90
88
|
/**
|
|
91
89
|
* Public accessor from components to fallback to defaults if flags not passed,
|
|
92
90
|
* otherwise whatever product has set will be returned.
|
|
@@ -97,28 +95,22 @@ export var defaultMediaFeatureFlags = {
|
|
|
97
95
|
*
|
|
98
96
|
* (you will see a warning in console if override used)
|
|
99
97
|
* */
|
|
100
|
-
|
|
101
98
|
export function getMediaFeatureFlag(flagName, featureFlags) {
|
|
102
99
|
var devOverride = getLocalMediaFeatureFlag(flagName);
|
|
103
|
-
|
|
104
100
|
if (devOverride !== null) {
|
|
105
101
|
try {
|
|
106
102
|
return JSON.parse(devOverride);
|
|
107
103
|
} catch (e) {}
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
if (featureFlags) {
|
|
111
106
|
return flagName in featureFlags ? featureFlags[flagName] : defaultMediaFeatureFlags[flagName];
|
|
112
107
|
}
|
|
113
|
-
|
|
114
108
|
return defaultMediaFeatureFlags[flagName];
|
|
115
109
|
}
|
|
116
110
|
export var useMemoizeFeatureFlags = function useMemoizeFeatureFlags(featureFlags) {
|
|
117
111
|
var ref = useRef();
|
|
118
|
-
|
|
119
112
|
if (!areEqualFeatureFlags(featureFlags, ref.current)) {
|
|
120
113
|
ref.current = featureFlags;
|
|
121
114
|
}
|
|
122
|
-
|
|
123
115
|
return ref.current;
|
|
124
116
|
};
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-common",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.2",
|
|
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
|
},
|