@atlaskit/media-common 2.7.0 → 2.10.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 +55 -0
- package/dist/cjs/index.js +75 -1
- package/dist/cjs/mediaFeatureFlags.js +43 -10
- package/dist/cjs/mediaTypeUtils/index.js +104 -0
- package/dist/cjs/mediaTypeUtils/isArchive.js +13 -0
- package/dist/cjs/mediaTypeUtils/isMimeTypeSupportedByBrowser.js +48 -0
- package/dist/cjs/mediaTypeUtils/isMimeTypeSupportedByServer.js +57 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +3 -2
- package/dist/es2019/mediaFeatureFlags.js +35 -10
- package/dist/es2019/mediaTypeUtils/index.js +28 -0
- package/dist/es2019/mediaTypeUtils/isArchive.js +2 -0
- package/dist/es2019/mediaTypeUtils/isMimeTypeSupportedByBrowser.js +17 -0
- package/dist/es2019/mediaTypeUtils/isMimeTypeSupportedByServer.js +21 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/mediaFeatureFlags.js +37 -10
- package/dist/esm/mediaTypeUtils/index.js +28 -0
- package/dist/esm/mediaTypeUtils/isArchive.js +4 -0
- package/dist/esm/mediaTypeUtils/isMimeTypeSupportedByBrowser.js +27 -0
- package/dist/esm/mediaTypeUtils/isMimeTypeSupportedByServer.js +33 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/types.d.ts +17 -5
- package/dist/types/index.d.ts +4 -2
- package/dist/types/mediaFeatureFlags.d.ts +4 -10
- package/dist/types/mediaTypeUtils/index.d.ts +4 -0
- package/dist/types/mediaTypeUtils/isArchive.d.ts +1 -0
- package/dist/types/mediaTypeUtils/isMimeTypeSupportedByBrowser.d.ts +14 -0
- package/dist/types/mediaTypeUtils/isMimeTypeSupportedByServer.d.ts +6 -0
- package/mediaTypeUtils/package.json +7 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @atlaskit/media-common
|
|
2
2
|
|
|
3
|
+
## 2.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`f461edcfd05`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f461edcfd05) - Added a comparer helper for Media Feature Flags objects
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`fc70978492a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fc70978492a) - Using type for SSR prop to reduce dependency on media-common
|
|
12
|
+
- [`2b24fcc59f2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2b24fcc59f2) - Removed Code Viewer and Zip Previews Feature Flags
|
|
13
|
+
- [`f461edcfd05`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f461edcfd05) - Update CardLoader to use react-loadable
|
|
14
|
+
Add SSR feature prop to be passed in renderer and media card
|
|
15
|
+
- [`01a41e75803`](https://bitbucket.org/atlassian/atlassian-frontend/commits/01a41e75803) - Removes `allowMediaInline` media prop and replaces with Inline Files feature flag for editor and mobile bridge
|
|
16
|
+
|
|
17
|
+
## 2.9.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`fe9ced0cd70`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fe9ced0cd70) - Removed feature flags for polling settings
|
|
22
|
+
|
|
23
|
+
## 2.9.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- [`46d9d2872b4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/46d9d2872b4) - Video Analytics - Add UI events for CustomMediaPlayer
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [`4777a174e6d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4777a174e6d) - Added analytics support for customMediaPlayer + screen event + entrypoint for locales
|
|
32
|
+
- [`b77bfe8e99c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b77bfe8e99c) - Add performance attributes to Commenced, Succeeded, Failed events for media card
|
|
33
|
+
- [`35d85025b4d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/35d85025b4d) - MEX-860 Changed base track events payload + added CustomMediaPlayerType
|
|
34
|
+
|
|
35
|
+
## 2.8.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- [`c74e598326e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c74e598326e) - Add new members (see below). Extra entry point `mediaTypeUtils` for all of them is added.
|
|
40
|
+
|
|
41
|
+
New members:
|
|
42
|
+
|
|
43
|
+
- getMediaTypeFromMimeType
|
|
44
|
+
- isImageMimeTypeSupportedByBrowser
|
|
45
|
+
- isDocumentMimeTypeSupportedByBrowser
|
|
46
|
+
- isMimeTypeSupportedByBrowser
|
|
47
|
+
- isImageMimeTypeSupportedByServer
|
|
48
|
+
- isDocumentMimeTypeSupportedByServer
|
|
49
|
+
- isAudioMimeTypeSupportedByServer
|
|
50
|
+
- isVideoMimeTypeSupportedByServer
|
|
51
|
+
- isUnknownMimeTypeSupportedByServer
|
|
52
|
+
- isMimeTypeSupportedByServer
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- [`8cba1694b5e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cba1694b5e) - Remove pollingMaxFailuresExceeded error from implementation and feature flags
|
|
57
|
+
|
|
3
58
|
## 2.7.0
|
|
4
59
|
|
|
5
60
|
### Minor Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,6 +21,18 @@ Object.defineProperty(exports, "defaultMediaFeatureFlags", {
|
|
|
21
21
|
return _mediaFeatureFlags.defaultMediaFeatureFlags;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "areEqualFeatureFlags", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _mediaFeatureFlags.areEqualFeatureFlags;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "useMemoizeFeatureFlags", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _mediaFeatureFlags.useMemoizeFeatureFlags;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
24
36
|
Object.defineProperty(exports, "withMediaAnalyticsContext", {
|
|
25
37
|
enumerable: true,
|
|
26
38
|
get: function get() {
|
|
@@ -33,6 +45,66 @@ Object.defineProperty(exports, "ANALYTICS_MEDIA_CHANNEL", {
|
|
|
33
45
|
return _constants.ANALYTICS_MEDIA_CHANNEL;
|
|
34
46
|
}
|
|
35
47
|
});
|
|
48
|
+
Object.defineProperty(exports, "getMediaTypeFromMimeType", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _mediaTypeUtils.getMediaTypeFromMimeType;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "isImageMimeTypeSupportedByBrowser", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _mediaTypeUtils.isImageMimeTypeSupportedByBrowser;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "isDocumentMimeTypeSupportedByBrowser", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _mediaTypeUtils.isDocumentMimeTypeSupportedByBrowser;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "isMimeTypeSupportedByBrowser", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _mediaTypeUtils.isMimeTypeSupportedByBrowser;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "isImageMimeTypeSupportedByServer", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _mediaTypeUtils.isImageMimeTypeSupportedByServer;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "isDocumentMimeTypeSupportedByServer", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _mediaTypeUtils.isDocumentMimeTypeSupportedByServer;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "isAudioMimeTypeSupportedByServer", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _mediaTypeUtils.isAudioMimeTypeSupportedByServer;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "isVideoMimeTypeSupportedByServer", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _mediaTypeUtils.isVideoMimeTypeSupportedByServer;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "isUnknownMimeTypeSupportedByServer", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return _mediaTypeUtils.isUnknownMimeTypeSupportedByServer;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "isMimeTypeSupportedByServer", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function get() {
|
|
105
|
+
return _mediaTypeUtils.isMimeTypeSupportedByServer;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
36
108
|
|
|
37
109
|
var _downloadUrl = require("./downloadUrl");
|
|
38
110
|
|
|
@@ -40,4 +112,6 @@ var _mediaFeatureFlags = require("./mediaFeatureFlags");
|
|
|
40
112
|
|
|
41
113
|
var _withMediaAnalyticsContext = require("./analytics/withMediaAnalyticsContext");
|
|
42
114
|
|
|
43
|
-
var _constants = require("./analytics/constants");
|
|
115
|
+
var _constants = require("./analytics/constants");
|
|
116
|
+
|
|
117
|
+
var _mediaTypeUtils = require("./mediaTypeUtils");
|
|
@@ -4,22 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getMediaFeatureFlag = getMediaFeatureFlag;
|
|
7
|
-
exports.defaultMediaFeatureFlags = void 0;
|
|
7
|
+
exports.useMemoizeFeatureFlags = exports.areEqualFeatureFlags = exports.defaultMediaFeatureFlags = void 0;
|
|
8
|
+
|
|
9
|
+
var _react = require("react");
|
|
8
10
|
|
|
9
11
|
var _mediaFeatureFlagLocal = require("./mediaFeatureFlag-local");
|
|
10
12
|
|
|
11
13
|
// default values defined here, not necessary for components to know directly as they should use the function below
|
|
12
14
|
var defaultMediaFeatureFlags = {
|
|
13
15
|
newCardExperience: false,
|
|
14
|
-
zipPreviews: false,
|
|
15
16
|
captions: false,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
poll_backoffFactor: 1.25,
|
|
21
|
-
poll_maxIntervalMs: 200000,
|
|
22
|
-
poll_maxGlobalFailures: 10
|
|
17
|
+
mediaInline: false,
|
|
18
|
+
// We can't yet switch this feature on
|
|
19
|
+
// TODO https://product-fabric.atlassian.net/browse/MEX-104
|
|
20
|
+
folderUploads: false
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
23
|
* Public accessor from components to fallback to defaults if flags not passed,
|
|
@@ -61,4 +59,39 @@ Object.keys(defaultMediaFeatureFlags).forEach(function (flagName) {
|
|
|
61
59
|
// eslint-disable-next-line no-console
|
|
62
60
|
console.info("%c* LOCAL * MediaFeatureFlag.".concat(flagName, " = ").concat(localOverride), 'font-weight:bold;color:cyan');
|
|
63
61
|
}
|
|
64
|
-
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
|
|
65
|
+
if (!ffA && !ffB) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!ffA || !ffB) {
|
|
70
|
+
return false;
|
|
71
|
+
} // With this type we ensure this object will compare all the flags
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
var results = {
|
|
75
|
+
newCardExperience: ffA.newCardExperience === ffB.newCardExperience,
|
|
76
|
+
captions: ffA.captions === ffB.captions,
|
|
77
|
+
mediaInline: ffA.mediaInline === ffB.mediaInline,
|
|
78
|
+
folderUploads: ffA.folderUploads === ffB.folderUploads
|
|
79
|
+
};
|
|
80
|
+
return Object.values(results).every(function (result) {
|
|
81
|
+
return result;
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.areEqualFeatureFlags = areEqualFeatureFlags;
|
|
86
|
+
|
|
87
|
+
var useMemoizeFeatureFlags = function useMemoizeFeatureFlags(featureFlags) {
|
|
88
|
+
var ref = (0, _react.useRef)();
|
|
89
|
+
|
|
90
|
+
if (!areEqualFeatureFlags(featureFlags, ref.current)) {
|
|
91
|
+
ref.current = featureFlags;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return ref.current;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
exports.useMemoizeFeatureFlags = useMemoizeFeatureFlags;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "isImageMimeTypeSupportedByBrowser", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _isMimeTypeSupportedByBrowser.isImageMimeTypeSupportedByBrowser;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "isDocumentMimeTypeSupportedByBrowser", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _isMimeTypeSupportedByBrowser.isDocumentMimeTypeSupportedByBrowser;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "isAudioMimeTypeSupportedByBrowser", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _isMimeTypeSupportedByBrowser.isAudioMimeTypeSupportedByBrowser;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "isVideoMimeTypeSupportedByBrowser", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _isMimeTypeSupportedByBrowser.isVideoMimeTypeSupportedByBrowser;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "isMimeTypeSupportedByBrowser", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _isMimeTypeSupportedByBrowser.isMimeTypeSupportedByBrowser;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "isImageMimeTypeSupportedByServer", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _isMimeTypeSupportedByServer.isImageMimeTypeSupportedByServer;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "isDocumentMimeTypeSupportedByServer", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _isMimeTypeSupportedByServer.isDocumentMimeTypeSupportedByServer;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "isAudioMimeTypeSupportedByServer", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _isMimeTypeSupportedByServer.isAudioMimeTypeSupportedByServer;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "isVideoMimeTypeSupportedByServer", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _isMimeTypeSupportedByServer.isVideoMimeTypeSupportedByServer;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "isUnknownMimeTypeSupportedByServer", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _isMimeTypeSupportedByServer.isUnknownMimeTypeSupportedByServer;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "isMimeTypeSupportedByServer", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _isMimeTypeSupportedByServer.isMimeTypeSupportedByServer;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
exports.getMediaTypeFromMimeType = void 0;
|
|
73
|
+
|
|
74
|
+
var _isArchive = require("./isArchive");
|
|
75
|
+
|
|
76
|
+
var _isMimeTypeSupportedByBrowser = require("./isMimeTypeSupportedByBrowser");
|
|
77
|
+
|
|
78
|
+
var _isMimeTypeSupportedByServer = require("./isMimeTypeSupportedByServer");
|
|
79
|
+
|
|
80
|
+
var getMediaTypeFromMimeType = function getMediaTypeFromMimeType(mimeType) {
|
|
81
|
+
if ((0, _isArchive.isArchive)(mimeType)) {
|
|
82
|
+
return 'archive';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if ((0, _isMimeTypeSupportedByBrowser.isImageMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isImageMimeTypeSupportedByServer)(mimeType)) {
|
|
86
|
+
return 'image';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ((0, _isMimeTypeSupportedByBrowser.isDocumentMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isDocumentMimeTypeSupportedByServer)(mimeType)) {
|
|
90
|
+
return 'doc';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if ((0, _isMimeTypeSupportedByBrowser.isAudioMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isAudioMimeTypeSupportedByServer)(mimeType)) {
|
|
94
|
+
return 'audio';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if ((0, _isMimeTypeSupportedByBrowser.isVideoMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isVideoMimeTypeSupportedByServer)(mimeType)) {
|
|
98
|
+
return 'video';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return 'unknown';
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
exports.getMediaTypeFromMimeType = getMediaTypeFromMimeType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isArchive = void 0;
|
|
7
|
+
|
|
8
|
+
// Based on https://en.wikipedia.org/wiki/List_of_archive_formats
|
|
9
|
+
var isArchive = function isArchive(mimeType) {
|
|
10
|
+
return ['application/x-archive', 'application/x-cpio', 'application/x-shar', 'application/x-iso9660-image', 'application/x-sbx', 'application/x-tar', 'application/x-bzip2', 'application/gzip', 'application/x-gzip', 'application/x-lzip', 'application/x-lzma', 'application/x-lzop', 'application/x-snappy-framed', 'application/x-xz', 'application/x-compress', 'application/zstd', 'application/x-7z-compressed', 'application/x-ace-compressed', 'application/x-astrotite-afa', 'application/x-alz-compressed', 'application/vnd.android.package-archive', 'application/x-freearc', 'application/x-arj', 'application/x-b1', 'application/vnd.ms-cab-compressed', 'application/x-cfs-compressed', 'application/x-dar', 'application/x-dgc-compressed', 'application/x-apple-diskimage', 'application/x-gca-compressed', 'application/java-archive', 'application/x-lzh', 'application/x-lzx', 'application/x-rar-compressed', 'application/x-stuffit', 'application/x-stuffitx', 'application/x-gtar', 'application/x-ms-wim', 'application/x-xar', 'application/zip', 'application/x-zoo', 'application/x-par2'].indexOf(mimeType.toLowerCase()) > -1;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.isArchive = isArchive;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMimeTypeSupportedByBrowser = exports.isVideoMimeTypeSupportedByBrowser = exports.isAudioMimeTypeSupportedByBrowser = exports.isDocumentMimeTypeSupportedByBrowser = exports.isImageMimeTypeSupportedByBrowser = void 0;
|
|
7
|
+
|
|
8
|
+
// Based on https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
|
9
|
+
var isImageMimeTypeSupportedByBrowser = function isImageMimeTypeSupportedByBrowser(mimeType) {
|
|
10
|
+
return ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp' //'image/svg+xml', // Removed because of https://product-fabric.atlassian.net/browse/BMPT-625
|
|
11
|
+
].indexOf(mimeType.toLowerCase()) > -1;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.isImageMimeTypeSupportedByBrowser = isImageMimeTypeSupportedByBrowser;
|
|
15
|
+
|
|
16
|
+
var isDocumentMimeTypeSupportedByBrowser = function isDocumentMimeTypeSupportedByBrowser(mimeType) {
|
|
17
|
+
return mimeType.toLowerCase() === 'application/pdf';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.isDocumentMimeTypeSupportedByBrowser = isDocumentMimeTypeSupportedByBrowser;
|
|
21
|
+
|
|
22
|
+
var isAudioMimeTypeSupportedByBrowser = function isAudioMimeTypeSupportedByBrowser(mimeType) {
|
|
23
|
+
return ['audio/aac', 'audio/flac', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/wav', 'audio/x-wav'].indexOf(mimeType.toLowerCase()) > -1;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* For backward compatilbity, we assume MP4/MOV is natively supported.
|
|
27
|
+
* TODO: Improve detection of supported video formats by the browser.
|
|
28
|
+
*
|
|
29
|
+
* See related tickets:
|
|
30
|
+
* - https://product-fabric.atlassian.net/browse/MPT-477
|
|
31
|
+
* - https://product-fabric.atlassian.net/browse/EDM-634
|
|
32
|
+
* - https://product-fabric.atlassian.net/browse/EDM-426
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.isAudioMimeTypeSupportedByBrowser = isAudioMimeTypeSupportedByBrowser;
|
|
37
|
+
|
|
38
|
+
var isVideoMimeTypeSupportedByBrowser = function isVideoMimeTypeSupportedByBrowser(mimeType) {
|
|
39
|
+
return ['video/mp4', 'video/quicktime'].indexOf(mimeType.toLowerCase()) > -1;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.isVideoMimeTypeSupportedByBrowser = isVideoMimeTypeSupportedByBrowser;
|
|
43
|
+
|
|
44
|
+
var isMimeTypeSupportedByBrowser = function isMimeTypeSupportedByBrowser(mimeType) {
|
|
45
|
+
return isDocumentMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByBrowser(mimeType);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.isMimeTypeSupportedByBrowser = isMimeTypeSupportedByBrowser;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMimeTypeSupportedByServer = exports.isUnknownMimeTypeSupportedByServer = exports.isVideoMimeTypeSupportedByServer = exports.isAudioMimeTypeSupportedByServer = exports.isDocumentMimeTypeSupportedByServer = exports.isImageMimeTypeSupportedByServer = void 0;
|
|
7
|
+
|
|
8
|
+
// Based on https://developer.atlassian.com/platform/media/learning/file-previews/
|
|
9
|
+
var isImageMimeTypeSupportedByServer = function isImageMimeTypeSupportedByServer(mimeType) {
|
|
10
|
+
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;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.isImageMimeTypeSupportedByServer = isImageMimeTypeSupportedByServer;
|
|
14
|
+
|
|
15
|
+
var isDocumentMimeTypeSupportedByServer = function isDocumentMimeTypeSupportedByServer(mimeType) {
|
|
16
|
+
return [// Adobe PDF
|
|
17
|
+
'application/pdf', 'application/x-pdf', 'application/acrobat', 'applications/vnd.pdf', 'text/pdf', 'text/x-pdf', // Adobe Illustrator
|
|
18
|
+
'application/vnd.adobe.illustrator', // Microsoft Office
|
|
19
|
+
'application/vnd.ms-office', // Microsoft Word
|
|
20
|
+
'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', // Microsoft Excel
|
|
21
|
+
'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', // Microsoft Powerpoint
|
|
22
|
+
'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', // OpenOffice
|
|
23
|
+
'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template', // OpenDocument
|
|
24
|
+
'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', // WordPerfect
|
|
25
|
+
'application/vnd.wordperfect', // 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', // Rich text
|
|
27
|
+
'application/rtf', 'application/x-rtf', // PostScript
|
|
28
|
+
'application/postscript'].indexOf(mimeType.toLowerCase()) > -1;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.isDocumentMimeTypeSupportedByServer = isDocumentMimeTypeSupportedByServer;
|
|
32
|
+
|
|
33
|
+
var isAudioMimeTypeSupportedByServer = function isAudioMimeTypeSupportedByServer(mimeType) {
|
|
34
|
+
return ['audio/aac', 'audio/x-hx-aac-adts', 'audio/vnd.dolby.dd-raw', 'audio/aiff', 'audio/x-aiff', 'audio/x-monkeys-audio', 'audio/x-ape', 'audio/basic', 'audio/flac', 'audio/mp4', 'audio/midi', 'audio/x-matroska', 'audio/x-mod', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/x-pn-realaudio', 'audio/wav', 'audio/x-wav', 'audio/x-ms-wma'].indexOf(mimeType.toLowerCase()) > -1;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.isAudioMimeTypeSupportedByServer = isAudioMimeTypeSupportedByServer;
|
|
38
|
+
|
|
39
|
+
var isVideoMimeTypeSupportedByServer = function isVideoMimeTypeSupportedByServer(mimeType) {
|
|
40
|
+
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;
|
|
41
|
+
}; // BMPT-620: The backend momentarily returns this mimeType for cloud files imported via dt-api-mediapicker
|
|
42
|
+
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
exports.isVideoMimeTypeSupportedByServer = isVideoMimeTypeSupportedByServer;
|
|
46
|
+
|
|
47
|
+
var isUnknownMimeTypeSupportedByServer = function isUnknownMimeTypeSupportedByServer(mimeType) {
|
|
48
|
+
return ['binary/octet-stream'].indexOf(mimeType.toLowerCase()) > -1;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.isUnknownMimeTypeSupportedByServer = isUnknownMimeTypeSupportedByServer;
|
|
52
|
+
|
|
53
|
+
var isMimeTypeSupportedByServer = function isMimeTypeSupportedByServer(mimeType) {
|
|
54
|
+
return isImageMimeTypeSupportedByServer(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType) || isAudioMimeTypeSupportedByServer(mimeType) || isVideoMimeTypeSupportedByServer(mimeType) || isUnknownMimeTypeSupportedByServer(mimeType);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.isMimeTypeSupportedByServer = isMimeTypeSupportedByServer;
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/index.js
CHANGED
|
@@ -2,8 +2,9 @@ export { downloadUrl } from './downloadUrl'; // Warning! You can't add new media
|
|
|
2
2
|
// See packages/media/media-core/src/__tests__/cache-backward-compatibility.spec.ts
|
|
3
3
|
|
|
4
4
|
// Media Feature Flags
|
|
5
|
-
export { getMediaFeatureFlag, defaultMediaFeatureFlags } from './mediaFeatureFlags';
|
|
5
|
+
export { getMediaFeatureFlag, defaultMediaFeatureFlags, areEqualFeatureFlags, useMemoizeFeatureFlags } from './mediaFeatureFlags';
|
|
6
6
|
// Analytics context
|
|
7
7
|
export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext'; // Analytics constants
|
|
8
8
|
|
|
9
|
-
export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
|
|
9
|
+
export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
|
|
10
|
+
export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './mediaTypeUtils';
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { getLocalMediaFeatureFlag } from './mediaFeatureFlag-local'; // Media feature flags - type and defaults defined here in one source of truth
|
|
3
|
+
|
|
2
4
|
// default values defined here, not necessary for components to know directly as they should use the function below
|
|
3
5
|
export const defaultMediaFeatureFlags = {
|
|
4
6
|
newCardExperience: false,
|
|
5
|
-
zipPreviews: false,
|
|
6
7
|
captions: false,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
poll_backoffFactor: 1.25,
|
|
12
|
-
poll_maxIntervalMs: 200000,
|
|
13
|
-
poll_maxGlobalFailures: 10
|
|
8
|
+
mediaInline: false,
|
|
9
|
+
// We can't yet switch this feature on
|
|
10
|
+
// TODO https://product-fabric.atlassian.net/browse/MEX-104
|
|
11
|
+
folderUploads: false
|
|
14
12
|
};
|
|
15
13
|
/**
|
|
16
14
|
* Public accessor from components to fallback to defaults if flags not passed,
|
|
@@ -49,4 +47,31 @@ Object.keys(defaultMediaFeatureFlags).forEach(flagName => {
|
|
|
49
47
|
// eslint-disable-next-line no-console
|
|
50
48
|
console.info(`%c* LOCAL * MediaFeatureFlag.${flagName} = ${localOverride}`, 'font-weight:bold;color:cyan');
|
|
51
49
|
}
|
|
52
|
-
});
|
|
50
|
+
});
|
|
51
|
+
export const areEqualFeatureFlags = (ffA, ffB) => {
|
|
52
|
+
if (!ffA && !ffB) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!ffA || !ffB) {
|
|
57
|
+
return false;
|
|
58
|
+
} // With this type we ensure this object will compare all the flags
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const results = {
|
|
62
|
+
newCardExperience: ffA.newCardExperience === ffB.newCardExperience,
|
|
63
|
+
captions: ffA.captions === ffB.captions,
|
|
64
|
+
mediaInline: ffA.mediaInline === ffB.mediaInline,
|
|
65
|
+
folderUploads: ffA.folderUploads === ffB.folderUploads
|
|
66
|
+
};
|
|
67
|
+
return Object.values(results).every(result => result);
|
|
68
|
+
};
|
|
69
|
+
export const useMemoizeFeatureFlags = featureFlags => {
|
|
70
|
+
const ref = useRef();
|
|
71
|
+
|
|
72
|
+
if (!areEqualFeatureFlags(featureFlags, ref.current)) {
|
|
73
|
+
ref.current = featureFlags;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return ref.current;
|
|
77
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isArchive } from './isArchive';
|
|
2
|
+
import { isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isAudioMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser } from './isMimeTypeSupportedByBrowser';
|
|
3
|
+
import { isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer } from './isMimeTypeSupportedByServer';
|
|
4
|
+
export { isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isAudioMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser } from './isMimeTypeSupportedByBrowser';
|
|
5
|
+
export { isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './isMimeTypeSupportedByServer';
|
|
6
|
+
export const getMediaTypeFromMimeType = mimeType => {
|
|
7
|
+
if (isArchive(mimeType)) {
|
|
8
|
+
return 'archive';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (isImageMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByServer(mimeType)) {
|
|
12
|
+
return 'image';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (isDocumentMimeTypeSupportedByBrowser(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType)) {
|
|
16
|
+
return 'doc';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (isAudioMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByServer(mimeType)) {
|
|
20
|
+
return 'audio';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isVideoMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByServer(mimeType)) {
|
|
24
|
+
return 'video';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return 'unknown';
|
|
28
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// Based on https://en.wikipedia.org/wiki/List_of_archive_formats
|
|
2
|
+
export const isArchive = mimeType => ['application/x-archive', 'application/x-cpio', 'application/x-shar', 'application/x-iso9660-image', 'application/x-sbx', 'application/x-tar', 'application/x-bzip2', 'application/gzip', 'application/x-gzip', 'application/x-lzip', 'application/x-lzma', 'application/x-lzop', 'application/x-snappy-framed', 'application/x-xz', 'application/x-compress', 'application/zstd', 'application/x-7z-compressed', 'application/x-ace-compressed', 'application/x-astrotite-afa', 'application/x-alz-compressed', 'application/vnd.android.package-archive', 'application/x-freearc', 'application/x-arj', 'application/x-b1', 'application/vnd.ms-cab-compressed', 'application/x-cfs-compressed', 'application/x-dar', 'application/x-dgc-compressed', 'application/x-apple-diskimage', 'application/x-gca-compressed', 'application/java-archive', 'application/x-lzh', 'application/x-lzx', 'application/x-rar-compressed', 'application/x-stuffit', 'application/x-stuffitx', 'application/x-gtar', 'application/x-ms-wim', 'application/x-xar', 'application/zip', 'application/x-zoo', 'application/x-par2'].indexOf(mimeType.toLowerCase()) > -1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Based on https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
|
2
|
+
export const isImageMimeTypeSupportedByBrowser = mimeType => ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp' //'image/svg+xml', // Removed because of https://product-fabric.atlassian.net/browse/BMPT-625
|
|
3
|
+
].indexOf(mimeType.toLowerCase()) > -1;
|
|
4
|
+
export const isDocumentMimeTypeSupportedByBrowser = mimeType => mimeType.toLowerCase() === 'application/pdf';
|
|
5
|
+
export const isAudioMimeTypeSupportedByBrowser = mimeType => ['audio/aac', 'audio/flac', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/wav', 'audio/x-wav'].indexOf(mimeType.toLowerCase()) > -1;
|
|
6
|
+
/**
|
|
7
|
+
* For backward compatilbity, we assume MP4/MOV is natively supported.
|
|
8
|
+
* TODO: Improve detection of supported video formats by the browser.
|
|
9
|
+
*
|
|
10
|
+
* See related tickets:
|
|
11
|
+
* - https://product-fabric.atlassian.net/browse/MPT-477
|
|
12
|
+
* - https://product-fabric.atlassian.net/browse/EDM-634
|
|
13
|
+
* - https://product-fabric.atlassian.net/browse/EDM-426
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const isVideoMimeTypeSupportedByBrowser = mimeType => ['video/mp4', 'video/quicktime'].indexOf(mimeType.toLowerCase()) > -1;
|
|
17
|
+
export const isMimeTypeSupportedByBrowser = mimeType => isDocumentMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByBrowser(mimeType);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Based on https://developer.atlassian.com/platform/media/learning/file-previews/
|
|
2
|
+
export const isImageMimeTypeSupportedByServer = mimeType => ['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;
|
|
3
|
+
export const isDocumentMimeTypeSupportedByServer = mimeType => [// Adobe PDF
|
|
4
|
+
'application/pdf', 'application/x-pdf', 'application/acrobat', 'applications/vnd.pdf', 'text/pdf', 'text/x-pdf', // Adobe Illustrator
|
|
5
|
+
'application/vnd.adobe.illustrator', // Microsoft Office
|
|
6
|
+
'application/vnd.ms-office', // Microsoft Word
|
|
7
|
+
'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', // Microsoft Excel
|
|
8
|
+
'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', // Microsoft Powerpoint
|
|
9
|
+
'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', // OpenOffice
|
|
10
|
+
'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template', // OpenDocument
|
|
11
|
+
'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', // WordPerfect
|
|
12
|
+
'application/vnd.wordperfect', // Text files
|
|
13
|
+
'text/csv', 'text/x-diff', 'text/x-perl', 'text/x-python', 'text/x-ruby', 'text/rtf', 'text/richtext', 'text/plain', 'application/txt', // Rich text
|
|
14
|
+
'application/rtf', 'application/x-rtf', // PostScript
|
|
15
|
+
'application/postscript'].indexOf(mimeType.toLowerCase()) > -1;
|
|
16
|
+
export const isAudioMimeTypeSupportedByServer = mimeType => ['audio/aac', 'audio/x-hx-aac-adts', 'audio/vnd.dolby.dd-raw', 'audio/aiff', 'audio/x-aiff', 'audio/x-monkeys-audio', 'audio/x-ape', 'audio/basic', 'audio/flac', 'audio/mp4', 'audio/midi', 'audio/x-matroska', 'audio/x-mod', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/x-pn-realaudio', 'audio/wav', 'audio/x-wav', 'audio/x-ms-wma'].indexOf(mimeType.toLowerCase()) > -1;
|
|
17
|
+
export const isVideoMimeTypeSupportedByServer = mimeType => ['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; // BMPT-620: The backend momentarily returns this mimeType for cloud files imported via dt-api-mediapicker
|
|
18
|
+
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
19
|
+
|
|
20
|
+
export const isUnknownMimeTypeSupportedByServer = mimeType => ['binary/octet-stream'].indexOf(mimeType.toLowerCase()) > -1;
|
|
21
|
+
export const isMimeTypeSupportedByServer = mimeType => isImageMimeTypeSupportedByServer(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType) || isAudioMimeTypeSupportedByServer(mimeType) || isVideoMimeTypeSupportedByServer(mimeType) || isUnknownMimeTypeSupportedByServer(mimeType);
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,9 @@ export { downloadUrl } from './downloadUrl'; // Warning! You can't add new media
|
|
|
2
2
|
// See packages/media/media-core/src/__tests__/cache-backward-compatibility.spec.ts
|
|
3
3
|
|
|
4
4
|
// Media Feature Flags
|
|
5
|
-
export { getMediaFeatureFlag, defaultMediaFeatureFlags } from './mediaFeatureFlags';
|
|
5
|
+
export { getMediaFeatureFlag, defaultMediaFeatureFlags, areEqualFeatureFlags, useMemoizeFeatureFlags } from './mediaFeatureFlags';
|
|
6
6
|
// Analytics context
|
|
7
7
|
export { withMediaAnalyticsContext } from './analytics/withMediaAnalyticsContext'; // Analytics constants
|
|
8
8
|
|
|
9
|
-
export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
|
|
9
|
+
export { ANALYTICS_MEDIA_CHANNEL } from './analytics/constants';
|
|
10
|
+
export { getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './mediaTypeUtils';
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { getLocalMediaFeatureFlag } from './mediaFeatureFlag-local'; // Media feature flags - type and defaults defined here in one source of truth
|
|
3
|
+
|
|
2
4
|
// default values defined here, not necessary for components to know directly as they should use the function below
|
|
3
5
|
export var defaultMediaFeatureFlags = {
|
|
4
6
|
newCardExperience: false,
|
|
5
|
-
zipPreviews: false,
|
|
6
7
|
captions: false,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
poll_backoffFactor: 1.25,
|
|
12
|
-
poll_maxIntervalMs: 200000,
|
|
13
|
-
poll_maxGlobalFailures: 10
|
|
8
|
+
mediaInline: false,
|
|
9
|
+
// We can't yet switch this feature on
|
|
10
|
+
// TODO https://product-fabric.atlassian.net/browse/MEX-104
|
|
11
|
+
folderUploads: false
|
|
14
12
|
};
|
|
15
13
|
/**
|
|
16
14
|
* Public accessor from components to fallback to defaults if flags not passed,
|
|
@@ -49,4 +47,33 @@ Object.keys(defaultMediaFeatureFlags).forEach(function (flagName) {
|
|
|
49
47
|
// eslint-disable-next-line no-console
|
|
50
48
|
console.info("%c* LOCAL * MediaFeatureFlag.".concat(flagName, " = ").concat(localOverride), 'font-weight:bold;color:cyan');
|
|
51
49
|
}
|
|
52
|
-
});
|
|
50
|
+
});
|
|
51
|
+
export var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
|
|
52
|
+
if (!ffA && !ffB) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!ffA || !ffB) {
|
|
57
|
+
return false;
|
|
58
|
+
} // With this type we ensure this object will compare all the flags
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
var results = {
|
|
62
|
+
newCardExperience: ffA.newCardExperience === ffB.newCardExperience,
|
|
63
|
+
captions: ffA.captions === ffB.captions,
|
|
64
|
+
mediaInline: ffA.mediaInline === ffB.mediaInline,
|
|
65
|
+
folderUploads: ffA.folderUploads === ffB.folderUploads
|
|
66
|
+
};
|
|
67
|
+
return Object.values(results).every(function (result) {
|
|
68
|
+
return result;
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export var useMemoizeFeatureFlags = function useMemoizeFeatureFlags(featureFlags) {
|
|
72
|
+
var ref = useRef();
|
|
73
|
+
|
|
74
|
+
if (!areEqualFeatureFlags(featureFlags, ref.current)) {
|
|
75
|
+
ref.current = featureFlags;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return ref.current;
|
|
79
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isArchive } from './isArchive';
|
|
2
|
+
import { isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isAudioMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser } from './isMimeTypeSupportedByBrowser';
|
|
3
|
+
import { isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer } from './isMimeTypeSupportedByServer';
|
|
4
|
+
export { isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser, isAudioMimeTypeSupportedByBrowser, isVideoMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser } from './isMimeTypeSupportedByBrowser';
|
|
5
|
+
export { isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer } from './isMimeTypeSupportedByServer';
|
|
6
|
+
export var getMediaTypeFromMimeType = function getMediaTypeFromMimeType(mimeType) {
|
|
7
|
+
if (isArchive(mimeType)) {
|
|
8
|
+
return 'archive';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (isImageMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByServer(mimeType)) {
|
|
12
|
+
return 'image';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (isDocumentMimeTypeSupportedByBrowser(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType)) {
|
|
16
|
+
return 'doc';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (isAudioMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByServer(mimeType)) {
|
|
20
|
+
return 'audio';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isVideoMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByServer(mimeType)) {
|
|
24
|
+
return 'video';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return 'unknown';
|
|
28
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Based on https://en.wikipedia.org/wiki/List_of_archive_formats
|
|
2
|
+
export var isArchive = function isArchive(mimeType) {
|
|
3
|
+
return ['application/x-archive', 'application/x-cpio', 'application/x-shar', 'application/x-iso9660-image', 'application/x-sbx', 'application/x-tar', 'application/x-bzip2', 'application/gzip', 'application/x-gzip', 'application/x-lzip', 'application/x-lzma', 'application/x-lzop', 'application/x-snappy-framed', 'application/x-xz', 'application/x-compress', 'application/zstd', 'application/x-7z-compressed', 'application/x-ace-compressed', 'application/x-astrotite-afa', 'application/x-alz-compressed', 'application/vnd.android.package-archive', 'application/x-freearc', 'application/x-arj', 'application/x-b1', 'application/vnd.ms-cab-compressed', 'application/x-cfs-compressed', 'application/x-dar', 'application/x-dgc-compressed', 'application/x-apple-diskimage', 'application/x-gca-compressed', 'application/java-archive', 'application/x-lzh', 'application/x-lzx', 'application/x-rar-compressed', 'application/x-stuffit', 'application/x-stuffitx', 'application/x-gtar', 'application/x-ms-wim', 'application/x-xar', 'application/zip', 'application/x-zoo', 'application/x-par2'].indexOf(mimeType.toLowerCase()) > -1;
|
|
4
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Based on https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
|
2
|
+
export var isImageMimeTypeSupportedByBrowser = function isImageMimeTypeSupportedByBrowser(mimeType) {
|
|
3
|
+
return ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp' //'image/svg+xml', // Removed because of https://product-fabric.atlassian.net/browse/BMPT-625
|
|
4
|
+
].indexOf(mimeType.toLowerCase()) > -1;
|
|
5
|
+
};
|
|
6
|
+
export var isDocumentMimeTypeSupportedByBrowser = function isDocumentMimeTypeSupportedByBrowser(mimeType) {
|
|
7
|
+
return mimeType.toLowerCase() === 'application/pdf';
|
|
8
|
+
};
|
|
9
|
+
export var isAudioMimeTypeSupportedByBrowser = function isAudioMimeTypeSupportedByBrowser(mimeType) {
|
|
10
|
+
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
|
+
* For backward compatilbity, we assume MP4/MOV is natively supported.
|
|
14
|
+
* TODO: Improve detection of supported video formats by the browser.
|
|
15
|
+
*
|
|
16
|
+
* See related tickets:
|
|
17
|
+
* - https://product-fabric.atlassian.net/browse/MPT-477
|
|
18
|
+
* - https://product-fabric.atlassian.net/browse/EDM-634
|
|
19
|
+
* - https://product-fabric.atlassian.net/browse/EDM-426
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export var isVideoMimeTypeSupportedByBrowser = function isVideoMimeTypeSupportedByBrowser(mimeType) {
|
|
23
|
+
return ['video/mp4', 'video/quicktime'].indexOf(mimeType.toLowerCase()) > -1;
|
|
24
|
+
};
|
|
25
|
+
export var isMimeTypeSupportedByBrowser = function isMimeTypeSupportedByBrowser(mimeType) {
|
|
26
|
+
return isDocumentMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByBrowser(mimeType);
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Based on https://developer.atlassian.com/platform/media/learning/file-previews/
|
|
2
|
+
export var isImageMimeTypeSupportedByServer = function isImageMimeTypeSupportedByServer(mimeType) {
|
|
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
|
+
};
|
|
5
|
+
export var isDocumentMimeTypeSupportedByServer = function isDocumentMimeTypeSupportedByServer(mimeType) {
|
|
6
|
+
return [// Adobe PDF
|
|
7
|
+
'application/pdf', 'application/x-pdf', 'application/acrobat', 'applications/vnd.pdf', 'text/pdf', 'text/x-pdf', // Adobe Illustrator
|
|
8
|
+
'application/vnd.adobe.illustrator', // Microsoft Office
|
|
9
|
+
'application/vnd.ms-office', // Microsoft Word
|
|
10
|
+
'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', // Microsoft Excel
|
|
11
|
+
'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', // Microsoft Powerpoint
|
|
12
|
+
'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', // OpenOffice
|
|
13
|
+
'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template', // OpenDocument
|
|
14
|
+
'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', // WordPerfect
|
|
15
|
+
'application/vnd.wordperfect', // Text files
|
|
16
|
+
'text/csv', 'text/x-diff', 'text/x-perl', 'text/x-python', 'text/x-ruby', 'text/rtf', 'text/richtext', 'text/plain', 'application/txt', // Rich text
|
|
17
|
+
'application/rtf', 'application/x-rtf', // PostScript
|
|
18
|
+
'application/postscript'].indexOf(mimeType.toLowerCase()) > -1;
|
|
19
|
+
};
|
|
20
|
+
export var isAudioMimeTypeSupportedByServer = function isAudioMimeTypeSupportedByServer(mimeType) {
|
|
21
|
+
return ['audio/aac', 'audio/x-hx-aac-adts', 'audio/vnd.dolby.dd-raw', 'audio/aiff', 'audio/x-aiff', 'audio/x-monkeys-audio', 'audio/x-ape', 'audio/basic', 'audio/flac', 'audio/mp4', 'audio/midi', 'audio/x-matroska', 'audio/x-mod', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/x-pn-realaudio', 'audio/wav', 'audio/x-wav', 'audio/x-ms-wma'].indexOf(mimeType.toLowerCase()) > -1;
|
|
22
|
+
};
|
|
23
|
+
export var isVideoMimeTypeSupportedByServer = function isVideoMimeTypeSupportedByServer(mimeType) {
|
|
24
|
+
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
|
+
}; // BMPT-620: The backend momentarily returns this mimeType for cloud files imported via dt-api-mediapicker
|
|
26
|
+
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
27
|
+
|
|
28
|
+
export var isUnknownMimeTypeSupportedByServer = function isUnknownMimeTypeSupportedByServer(mimeType) {
|
|
29
|
+
return ['binary/octet-stream'].indexOf(mimeType.toLowerCase()) > -1;
|
|
30
|
+
};
|
|
31
|
+
export var isMimeTypeSupportedByServer = function isMimeTypeSupportedByServer(mimeType) {
|
|
32
|
+
return isImageMimeTypeSupportedByServer(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType) || isAudioMimeTypeSupportedByServer(mimeType) || isVideoMimeTypeSupportedByServer(mimeType) || isUnknownMimeTypeSupportedByServer(mimeType);
|
|
33
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -19,9 +19,18 @@ export declare type FileAttributes = {
|
|
|
19
19
|
fileSource?: string;
|
|
20
20
|
fileStatus?: FileStatus;
|
|
21
21
|
};
|
|
22
|
+
export declare type PerformanceAttributes = {
|
|
23
|
+
overall: {
|
|
24
|
+
durationSincePageStart: number;
|
|
25
|
+
durationSinceCommenced?: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
22
28
|
export declare type WithFileAttributes = {
|
|
23
29
|
fileAttributes: FileAttributes;
|
|
24
30
|
};
|
|
31
|
+
export declare type WithPerformanceAttributes = {
|
|
32
|
+
performanceAttributes?: PerformanceAttributes;
|
|
33
|
+
};
|
|
25
34
|
export declare type SuccessAttributes = {
|
|
26
35
|
status: 'success';
|
|
27
36
|
};
|
|
@@ -32,29 +41,32 @@ export declare type FailureAttributes = {
|
|
|
32
41
|
errorDetail?: string;
|
|
33
42
|
};
|
|
34
43
|
export declare type StatusAttributes = SuccessAttributes | FailureAttributes;
|
|
35
|
-
export declare type OperationalAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes);
|
|
44
|
+
export declare type OperationalAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes) | (BaseAttributes & WithFileAttributes & StatusAttributes & WithPerformanceAttributes);
|
|
36
45
|
export declare type OperationalEventPayload<Attributes extends OperationalAttributes, Action extends string, ActionSubject extends string, ActionSubjectId extends string = string> = BaseEventPayload<Attributes> & {
|
|
37
46
|
eventType: 'operational';
|
|
38
47
|
action: Action;
|
|
39
48
|
actionSubject: ActionSubject;
|
|
40
49
|
actionSubjectId?: ActionSubjectId;
|
|
41
50
|
};
|
|
42
|
-
export declare type UIAttributes = BaseAttributes;
|
|
51
|
+
export declare type UIAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes);
|
|
43
52
|
export declare type UIEventPayload<Attributes extends UIAttributes, Action extends string, ActionSubject extends string> = BaseEventPayload<Attributes> & {
|
|
44
53
|
eventType: 'ui';
|
|
45
54
|
action: Action;
|
|
46
55
|
actionSubject: ActionSubject;
|
|
47
56
|
actionSubjectId?: string;
|
|
48
57
|
};
|
|
49
|
-
export declare type ScreenAttributes = BaseAttributes;
|
|
58
|
+
export declare type ScreenAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes);
|
|
50
59
|
export declare type ScreenEventPayload<Attributes extends ScreenAttributes, ActionSubject extends string> = BaseEventPayload<Attributes> & {
|
|
51
60
|
eventType: 'screen';
|
|
52
61
|
actionSubject: ActionSubject;
|
|
53
62
|
name: ActionSubject;
|
|
54
63
|
};
|
|
55
|
-
export declare type TrackAttributes = BaseAttributes;
|
|
56
|
-
export declare type TrackEventPayload<Attributes extends TrackAttributes> = BaseEventPayload<Attributes> & {
|
|
64
|
+
export declare type TrackAttributes = BaseAttributes | (BaseAttributes & WithFileAttributes);
|
|
65
|
+
export declare type TrackEventPayload<Attributes extends TrackAttributes, Action extends string, ActionSubject extends string, ActionSubjectId extends string = string> = BaseEventPayload<Attributes> & {
|
|
57
66
|
eventType: 'track';
|
|
67
|
+
action: Action;
|
|
68
|
+
actionSubject: ActionSubject;
|
|
69
|
+
actionSubjectId?: ActionSubjectId;
|
|
58
70
|
};
|
|
59
71
|
export declare type ContextPublicAttributes = PackageAttributes;
|
|
60
72
|
export declare type ContextPrivateAttributes = WithMediaFeatureFlags;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export { downloadUrl } from './downloadUrl';
|
|
2
2
|
export declare type MediaType = 'doc' | 'audio' | 'video' | 'image' | 'archive' | 'unknown';
|
|
3
3
|
export declare type FileStatus = 'uploading' | 'processing' | 'processed' | 'error' | 'failed-processing';
|
|
4
|
-
export { getMediaFeatureFlag, defaultMediaFeatureFlags, } from './mediaFeatureFlags';
|
|
4
|
+
export { getMediaFeatureFlag, defaultMediaFeatureFlags, areEqualFeatureFlags, useMemoizeFeatureFlags, } from './mediaFeatureFlags';
|
|
5
5
|
export type { MediaFeatureFlags, WithMediaFeatureFlags, } from './mediaFeatureFlags';
|
|
6
6
|
export interface NumericalCardDimensions {
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
}
|
|
10
|
-
export type { PackageAttributes, WithFileAttributes, FileAttributes, SuccessAttributes, FailureAttributes, OperationalAttributes, OperationalEventPayload, UIAttributes, UIEventPayload, ScreenAttributes, ScreenEventPayload, TrackAttributes, TrackEventPayload, ContextPublicAttributes, ContextStaticProps, } from './analytics/types';
|
|
10
|
+
export type { PackageAttributes, WithFileAttributes, WithPerformanceAttributes, 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';
|
|
14
|
+
export declare type SSR = 'client' | 'server';
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
poll_intervalMs?: number;
|
|
3
|
-
poll_maxAttempts?: number;
|
|
4
|
-
poll_backoffFactor?: number;
|
|
5
|
-
poll_maxIntervalMs?: number;
|
|
6
|
-
poll_maxGlobalFailures?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface MediaFeatureFlags extends PollingOptions {
|
|
1
|
+
export interface MediaFeatureFlags {
|
|
9
2
|
newCardExperience?: boolean;
|
|
10
|
-
zipPreviews?: boolean;
|
|
11
3
|
captions?: boolean;
|
|
4
|
+
mediaInline?: boolean;
|
|
12
5
|
folderUploads?: boolean;
|
|
13
|
-
codeViewer?: boolean;
|
|
14
6
|
}
|
|
15
7
|
export interface WithMediaFeatureFlags {
|
|
16
8
|
featureFlags?: MediaFeatureFlags;
|
|
@@ -27,3 +19,5 @@ export declare const defaultMediaFeatureFlags: Required<MediaFeatureFlags>;
|
|
|
27
19
|
* (you will see a warning in console if override used)
|
|
28
20
|
* */
|
|
29
21
|
export declare function getMediaFeatureFlag<T = boolean>(flagName: keyof MediaFeatureFlags, featureFlags?: MediaFeatureFlags): T;
|
|
22
|
+
export declare const areEqualFeatureFlags: (ffA?: MediaFeatureFlags | undefined, ffB?: MediaFeatureFlags | undefined) => boolean;
|
|
23
|
+
export declare const useMemoizeFeatureFlags: (featureFlags?: MediaFeatureFlags | undefined) => MediaFeatureFlags | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isArchive: (mimeType: string) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/media-common/mediaTypeUtils",
|
|
3
|
+
"main": "../dist/cjs/mediaTypeUtils/index.js",
|
|
4
|
+
"module": "../dist/esm/mediaTypeUtils/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/mediaTypeUtils/index.js",
|
|
6
|
+
"types": "../dist/types/mediaTypeUtils/index.d.ts"
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Includes common utilities used by other media packages",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -19,10 +19,11 @@
|
|
|
19
19
|
"./mediaFeatureFlags": "./src/mediaFeatureFlags.ts",
|
|
20
20
|
"./analytics": "./src/analytics/index.ts",
|
|
21
21
|
"./docs": "./src/docs/index.ts",
|
|
22
|
+
"./mediaTypeUtils": "./src/mediaTypeUtils/index.ts",
|
|
22
23
|
".": "./src/index.ts"
|
|
23
24
|
},
|
|
24
25
|
"atlassian": {
|
|
25
|
-
"team": "Media
|
|
26
|
+
"team": "Media Experience",
|
|
26
27
|
"inPublicMirror": true,
|
|
27
28
|
"releaseModel": "scheduled",
|
|
28
29
|
"website": {
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"@atlaskit/analytics-gas-types": "^5.0.5",
|
|
35
36
|
"@atlaskit/analytics-namespaced-context": "^6.2.0",
|
|
36
37
|
"@atlaskit/analytics-next": "^8.1.1",
|
|
38
|
+
"@atlaskit/section-message": "^6.0.0",
|
|
37
39
|
"@babel/runtime": "^7.0.0"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
@@ -42,14 +44,13 @@
|
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@atlaskit/docs": "*",
|
|
45
|
-
"@atlaskit/media-test-helpers": "^28.
|
|
46
|
-
"@
|
|
47
|
-
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
47
|
+
"@atlaskit/media-test-helpers": "^28.9.0",
|
|
48
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
48
49
|
"enzyme": "^3.10.0",
|
|
49
50
|
"lodash": "^4.17.15",
|
|
50
51
|
"react": "^16.8.0",
|
|
51
52
|
"react-dom": "^16.8.0",
|
|
52
53
|
"typescript": "3.9.6"
|
|
53
54
|
},
|
|
54
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.
|
|
55
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
55
56
|
}
|