@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
package/CHANGELOG.md
CHANGED
|
@@ -15,7 +15,5 @@ Object.defineProperty(exports, "withMediaAnalyticsContext", {
|
|
|
15
15
|
return _withMediaAnalyticsContext.withMediaAnalyticsContext;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
|
|
19
18
|
var _withMediaAnalyticsContext = require("./withMediaAnalyticsContext");
|
|
20
|
-
|
|
21
19
|
var _constants = require("./constants");
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.withMediaAnalyticsContext = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
19
|
-
|
|
20
13
|
var _MediaAnalyticsContext = require("@atlaskit/analytics-namespaced-context/MediaAnalyticsContext");
|
|
21
|
-
|
|
22
14
|
var _mediaFeatureFlags = require("../mediaFeatureFlags");
|
|
23
|
-
|
|
24
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
-
|
|
30
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
-
|
|
32
19
|
var getFilteredFeatureFlags = function getFilteredFeatureFlags(keys, featureFlags) {
|
|
33
20
|
return keys.reduce(function (result, key) {
|
|
34
21
|
return _objectSpread(_objectSpread({}, result), {}, (0, _defineProperty2.default)({}, key, (0, _mediaFeatureFlags.getMediaFeatureFlag)(key, featureFlags)));
|
|
35
22
|
}, {});
|
|
36
23
|
};
|
|
24
|
+
|
|
37
25
|
/**
|
|
38
26
|
* HOC for attaching MediaAnalyticsContext to a top-level React Component.
|
|
39
27
|
*
|
|
@@ -46,8 +34,6 @@ var getFilteredFeatureFlags = function getFilteredFeatureFlags(keys, featureFlag
|
|
|
46
34
|
*
|
|
47
35
|
* @see packages/analytics/analytics-next/src/hocs/withAnalyticsContext.tsx
|
|
48
36
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
37
|
var withMediaAnalyticsContext = function withMediaAnalyticsContext(contextPublicAttributes) {
|
|
52
38
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
53
39
|
return function (WrappedComponent) {
|
|
@@ -68,10 +54,10 @@ var withMediaAnalyticsContext = function withMediaAnalyticsContext(contextPublic
|
|
|
68
54
|
ref: ref
|
|
69
55
|
})));
|
|
70
56
|
});
|
|
71
|
-
WithMediaAnalyticsContext.displayName = "WithMediaAnalyticsContext(".concat(
|
|
57
|
+
WithMediaAnalyticsContext.displayName = "WithMediaAnalyticsContext(".concat(
|
|
58
|
+
// @ts-ignore displayName doesn't exist on type
|
|
72
59
|
WrappedComponent.displayName || WrappedComponent.name, ")");
|
|
73
60
|
return WithMediaAnalyticsContext;
|
|
74
61
|
};
|
|
75
62
|
};
|
|
76
|
-
|
|
77
63
|
exports.withMediaAnalyticsContext = withMediaAnalyticsContext;
|
package/dist/cjs/docs/index.js
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createMediaUseOnlyNotice = createMediaUseOnlyNotice;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _sectionMessage = _interopRequireDefault(require("@atlaskit/section-message"));
|
|
13
|
-
|
|
14
10
|
function AlternativePackagesMessage(_ref) {
|
|
15
11
|
var alternatePackages = _ref.alternatePackages;
|
|
16
|
-
|
|
17
12
|
if (!alternatePackages) {
|
|
18
13
|
return null;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
if (alternatePackages.length === 1) {
|
|
22
16
|
return /*#__PURE__*/_react.default.createElement("p", null, "Consider using", ' ', /*#__PURE__*/_react.default.createElement("a", {
|
|
23
17
|
href: alternatePackages[0].link
|
|
24
18
|
}, alternatePackages[0].name), ' ', "instead.");
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
return /*#__PURE__*/_react.default.createElement("p", null, "Consider using one of these packages instead:", /*#__PURE__*/_react.default.createElement("ul", null, alternatePackages.map(function (p) {
|
|
28
21
|
return /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement("a", {
|
|
29
22
|
href: p.link
|
|
30
23
|
}, p.name));
|
|
31
24
|
})));
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
function createMediaUseOnlyNotice(componentName, alternatePackages) {
|
|
35
27
|
return /*#__PURE__*/_react.default.createElement(_sectionMessage.default, {
|
|
36
28
|
title: "Internal Media Use Only",
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createRxjsNotice = createRxjsNotice;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _sectionMessage = _interopRequireDefault(require("@atlaskit/section-message"));
|
|
13
|
-
|
|
14
10
|
function createRxjsNotice(componentName) {
|
|
15
11
|
return /*#__PURE__*/_react.default.createElement(_sectionMessage.default, {
|
|
16
12
|
title: "RxJS compatilbity",
|
package/dist/cjs/downloadUrl.js
CHANGED
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.downloadUrl = void 0;
|
|
7
|
-
|
|
8
7
|
var downloadUrl = function downloadUrl(url, options) {
|
|
9
8
|
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
|
|
10
9
|
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
11
10
|
var iframeName = 'media-download-iframe';
|
|
12
11
|
var link = document.createElement('a');
|
|
13
12
|
var iframe = document.getElementById(iframeName);
|
|
14
|
-
|
|
15
13
|
if (!iframe) {
|
|
16
14
|
iframe = document.createElement('iframe');
|
|
17
15
|
iframe.style.display = 'none';
|
|
@@ -19,17 +17,13 @@ var downloadUrl = function downloadUrl(url, options) {
|
|
|
19
17
|
iframe.name = iframeName;
|
|
20
18
|
document.body.appendChild(iframe);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
link.href = url;
|
|
24
|
-
|
|
25
21
|
if (options && options.name) {
|
|
26
22
|
link.download = options.name;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
link.target = isIE11 || isSafari ? '_blank' : iframeName;
|
|
30
25
|
document.body.appendChild(link);
|
|
31
26
|
link.click();
|
|
32
27
|
document.body.removeChild(link);
|
|
33
28
|
};
|
|
34
|
-
|
|
35
29
|
exports.downloadUrl = downloadUrl;
|
package/dist/cjs/index.js
CHANGED
|
@@ -153,15 +153,9 @@ Object.defineProperty(exports, "withMediaAnalyticsContext", {
|
|
|
153
153
|
return _withMediaAnalyticsContext.withMediaAnalyticsContext;
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
|
-
|
|
157
156
|
var _downloadUrl = require("./downloadUrl");
|
|
158
|
-
|
|
159
157
|
var _mediaFeatureFlags = require("./mediaFeatureFlags");
|
|
160
|
-
|
|
161
158
|
var _withMediaAnalyticsContext = require("./analytics/withMediaAnalyticsContext");
|
|
162
|
-
|
|
163
159
|
var _constants = require("./analytics/constants");
|
|
164
|
-
|
|
165
160
|
var _mediaTypeUtils = require("./mediaTypeUtils");
|
|
166
|
-
|
|
167
161
|
var _helpers = require("./utils/helpers");
|
|
@@ -4,15 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getLocalMediaFeatureFlag = void 0;
|
|
7
|
-
|
|
8
7
|
// window.localStorage is easier to mock in tests if wrapped in this module
|
|
9
8
|
var getLocalMediaFeatureFlag = function getLocalMediaFeatureFlag(key) {
|
|
10
9
|
try {
|
|
11
10
|
return typeof window !== 'undefined' && window.localStorage ? window.localStorage.getItem(key) : null;
|
|
12
|
-
} catch (e) {
|
|
11
|
+
} catch (e) {
|
|
12
|
+
// do nothing, return null by default
|
|
13
13
|
}
|
|
14
|
-
|
|
15
14
|
return null;
|
|
16
15
|
};
|
|
17
|
-
|
|
18
16
|
exports.getLocalMediaFeatureFlag = getLocalMediaFeatureFlag;
|
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.filterFeatureFlagNames = exports.filterFeatureFlagKeysAllProducts = exports.defaultMediaFeatureFlags = exports.areEqualFeatureFlags = void 0;
|
|
9
8
|
exports.getMediaFeatureFlag = getMediaFeatureFlag;
|
|
10
9
|
exports.useMemoizeFeatureFlags = exports.mapAndFilterFeatureFlagNames = void 0;
|
|
11
|
-
|
|
12
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
11
|
var _react = require("react");
|
|
15
|
-
|
|
16
12
|
var _mediaFeatureFlagLocal = require("../mediaFeatureFlag-local");
|
|
17
|
-
|
|
18
13
|
var _types = require("./types");
|
|
19
|
-
|
|
20
14
|
var _productKeys = require("./productKeys");
|
|
21
|
-
|
|
22
15
|
var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
|
|
23
16
|
if (!ffA && !ffB) {
|
|
24
17
|
return true;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
19
|
if (!ffA || !ffB) {
|
|
28
20
|
return false;
|
|
29
21
|
}
|
|
30
|
-
|
|
31
22
|
var results = {
|
|
32
23
|
newCardExperience: ffA.newCardExperience === ffB.newCardExperience,
|
|
33
24
|
captions: ffA.captions === ffB.captions,
|
|
@@ -44,47 +35,39 @@ var areEqualFeatureFlags = function areEqualFeatureFlags(ffA, ffB) {
|
|
|
44
35
|
return result;
|
|
45
36
|
});
|
|
46
37
|
};
|
|
47
|
-
|
|
48
38
|
exports.areEqualFeatureFlags = areEqualFeatureFlags;
|
|
49
|
-
|
|
50
39
|
var filterFeatureFlagNames = function filterFeatureFlagNames(flags) {
|
|
51
40
|
var pairs = Object.entries(flags);
|
|
52
41
|
return pairs.filter(function (_ref) {
|
|
53
42
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
_key = _ref2[0],
|
|
44
|
+
value = _ref2[1];
|
|
57
45
|
return !!value;
|
|
58
46
|
}).map(function (_ref3) {
|
|
59
47
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 1),
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
key = _ref4[0];
|
|
62
49
|
return key;
|
|
63
50
|
});
|
|
64
51
|
};
|
|
52
|
+
|
|
65
53
|
/**
|
|
66
54
|
* Takes a record of {Media Feature Flag Names → boolean} and a supported product name.
|
|
67
55
|
* Returns the corresponding product’s Launch Darkly Keys for each of the flags set as true in the input record.
|
|
68
56
|
* */
|
|
69
|
-
|
|
70
|
-
|
|
71
57
|
exports.filterFeatureFlagNames = filterFeatureFlagNames;
|
|
72
|
-
|
|
73
58
|
var mapAndFilterFeatureFlagNames = function mapAndFilterFeatureFlagNames(flags, product) {
|
|
74
59
|
var mediaFeatureFlags = filterFeatureFlagNames(flags);
|
|
75
60
|
return mediaFeatureFlags.map(function (key) {
|
|
76
61
|
return (0, _productKeys.getProductKeys)()[product][key];
|
|
77
62
|
});
|
|
78
|
-
};
|
|
63
|
+
};
|
|
79
64
|
|
|
65
|
+
// TODO(MEX-1547): This is temporary solution to just return the launch darkly feature flags for all products.
|
|
80
66
|
/**
|
|
81
67
|
* Takes a record of {Media Feature Flag Names → boolean}.
|
|
82
68
|
* Returns the Launch Darkly Keys from all products for each of the flags set as true in the input record.
|
|
83
69
|
* */
|
|
84
|
-
|
|
85
|
-
|
|
86
70
|
exports.mapAndFilterFeatureFlagNames = mapAndFilterFeatureFlagNames;
|
|
87
|
-
|
|
88
71
|
var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllProducts(flags) {
|
|
89
72
|
var filteredFlags = filterFeatureFlagNames(flags);
|
|
90
73
|
var ldFeatureFlags = [];
|
|
@@ -96,9 +79,9 @@ var filterFeatureFlagKeysAllProducts = function filterFeatureFlagKeysAllProducts
|
|
|
96
79
|
return ldFeatureFlags.filter(function (flag) {
|
|
97
80
|
return flag !== '';
|
|
98
81
|
});
|
|
99
|
-
};
|
|
100
|
-
|
|
82
|
+
};
|
|
101
83
|
|
|
84
|
+
// default values defined here, not necessary for components to know directly as they should use the function below
|
|
102
85
|
exports.filterFeatureFlagKeysAllProducts = filterFeatureFlagKeysAllProducts;
|
|
103
86
|
var defaultMediaFeatureFlags = {
|
|
104
87
|
newCardExperience: false,
|
|
@@ -114,6 +97,7 @@ var defaultMediaFeatureFlags = {
|
|
|
114
97
|
memoryCacheLogging: false,
|
|
115
98
|
fetchFileStateAfterUpload: false
|
|
116
99
|
};
|
|
100
|
+
|
|
117
101
|
/**
|
|
118
102
|
* Public accessor from components to fallback to defaults if flags not passed,
|
|
119
103
|
* otherwise whatever product has set will be returned.
|
|
@@ -124,33 +108,24 @@ var defaultMediaFeatureFlags = {
|
|
|
124
108
|
*
|
|
125
109
|
* (you will see a warning in console if override used)
|
|
126
110
|
* */
|
|
127
|
-
|
|
128
111
|
exports.defaultMediaFeatureFlags = defaultMediaFeatureFlags;
|
|
129
|
-
|
|
130
112
|
function getMediaFeatureFlag(flagName, featureFlags) {
|
|
131
113
|
var devOverride = (0, _mediaFeatureFlagLocal.getLocalMediaFeatureFlag)(flagName);
|
|
132
|
-
|
|
133
114
|
if (devOverride !== null) {
|
|
134
115
|
try {
|
|
135
116
|
return JSON.parse(devOverride);
|
|
136
117
|
} catch (e) {}
|
|
137
118
|
}
|
|
138
|
-
|
|
139
119
|
if (featureFlags) {
|
|
140
120
|
return flagName in featureFlags ? featureFlags[flagName] : defaultMediaFeatureFlags[flagName];
|
|
141
121
|
}
|
|
142
|
-
|
|
143
122
|
return defaultMediaFeatureFlags[flagName];
|
|
144
123
|
}
|
|
145
|
-
|
|
146
124
|
var useMemoizeFeatureFlags = function useMemoizeFeatureFlags(featureFlags) {
|
|
147
125
|
var ref = (0, _react.useRef)();
|
|
148
|
-
|
|
149
126
|
if (!areEqualFeatureFlags(featureFlags, ref.current)) {
|
|
150
127
|
ref.current = featureFlags;
|
|
151
128
|
}
|
|
152
|
-
|
|
153
129
|
return ref.current;
|
|
154
130
|
};
|
|
155
|
-
|
|
156
131
|
exports.useMemoizeFeatureFlags = useMemoizeFeatureFlags;
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.supportedProducts = void 0;
|
|
7
7
|
// Media feature flags - type and defaults defined here in one source of truth
|
|
8
|
+
|
|
8
9
|
// With this type we ensure the object will contain all the flags
|
|
10
|
+
|
|
9
11
|
var supportedProducts = ['confluence', 'jira'];
|
|
10
12
|
exports.supportedProducts = supportedProducts;
|
|
@@ -70,35 +70,25 @@ Object.defineProperty(exports, "isVideoMimeTypeSupportedByServer", {
|
|
|
70
70
|
return _isMimeTypeSupportedByServer.isVideoMimeTypeSupportedByServer;
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
-
|
|
74
73
|
var _isArchive = require("./isArchive");
|
|
75
|
-
|
|
76
74
|
var _isMimeTypeSupportedByBrowser = require("./isMimeTypeSupportedByBrowser");
|
|
77
|
-
|
|
78
75
|
var _isMimeTypeSupportedByServer = require("./isMimeTypeSupportedByServer");
|
|
79
|
-
|
|
80
76
|
var getMediaTypeFromMimeType = function getMediaTypeFromMimeType(mimeType) {
|
|
81
77
|
if ((0, _isArchive.isArchive)(mimeType)) {
|
|
82
78
|
return 'archive';
|
|
83
79
|
}
|
|
84
|
-
|
|
85
80
|
if ((0, _isMimeTypeSupportedByBrowser.isImageMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isImageMimeTypeSupportedByServer)(mimeType)) {
|
|
86
81
|
return 'image';
|
|
87
82
|
}
|
|
88
|
-
|
|
89
83
|
if ((0, _isMimeTypeSupportedByBrowser.isDocumentMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isDocumentMimeTypeSupportedByServer)(mimeType)) {
|
|
90
84
|
return 'doc';
|
|
91
85
|
}
|
|
92
|
-
|
|
93
86
|
if ((0, _isMimeTypeSupportedByBrowser.isAudioMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isAudioMimeTypeSupportedByServer)(mimeType)) {
|
|
94
87
|
return 'audio';
|
|
95
88
|
}
|
|
96
|
-
|
|
97
89
|
if ((0, _isMimeTypeSupportedByBrowser.isVideoMimeTypeSupportedByBrowser)(mimeType) || (0, _isMimeTypeSupportedByServer.isVideoMimeTypeSupportedByServer)(mimeType)) {
|
|
98
90
|
return 'video';
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
return 'unknown';
|
|
102
93
|
};
|
|
103
|
-
|
|
104
94
|
exports.getMediaTypeFromMimeType = getMediaTypeFromMimeType;
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isArchive = void 0;
|
|
7
|
-
|
|
8
7
|
// Based on https://en.wikipedia.org/wiki/List_of_archive_formats
|
|
9
8
|
var isArchive = function isArchive(mimeType) {
|
|
10
9
|
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
10
|
};
|
|
12
|
-
|
|
13
11
|
exports.isArchive = isArchive;
|
|
@@ -4,24 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isVideoMimeTypeSupportedByBrowser = exports.isMimeTypeSupportedByBrowser = exports.isImageMimeTypeSupportedByBrowser = exports.isDocumentMimeTypeSupportedByBrowser = exports.isAudioMimeTypeSupportedByBrowser = void 0;
|
|
7
|
-
|
|
8
7
|
// Based on https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
|
|
9
8
|
var isImageMimeTypeSupportedByBrowser = function isImageMimeTypeSupportedByBrowser(mimeType) {
|
|
10
|
-
return ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp'
|
|
9
|
+
return ['image/apng', 'image/bmp', 'image/gif', 'image/x-icon', 'image/jpeg', 'image/png', 'image/webp'
|
|
10
|
+
//'image/svg+xml', // Removed because of https://product-fabric.atlassian.net/browse/BMPT-625
|
|
11
11
|
].indexOf(mimeType.toLowerCase()) > -1;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
13
|
exports.isImageMimeTypeSupportedByBrowser = isImageMimeTypeSupportedByBrowser;
|
|
15
|
-
|
|
16
14
|
var isDocumentMimeTypeSupportedByBrowser = function isDocumentMimeTypeSupportedByBrowser(mimeType) {
|
|
17
15
|
return mimeType.toLowerCase() === 'application/pdf';
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
exports.isDocumentMimeTypeSupportedByBrowser = isDocumentMimeTypeSupportedByBrowser;
|
|
21
|
-
|
|
22
18
|
var isAudioMimeTypeSupportedByBrowser = function isAudioMimeTypeSupportedByBrowser(mimeType) {
|
|
23
19
|
return ['audio/aac', 'audio/flac', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/x-ogg', 'audio/wav', 'audio/x-wav'].indexOf(mimeType.toLowerCase()) > -1;
|
|
24
20
|
};
|
|
21
|
+
|
|
25
22
|
/**
|
|
26
23
|
* For backward compatilbity, we assume MP4/MOV is natively supported.
|
|
27
24
|
* TODO: Improve detection of supported video formats by the browser.
|
|
@@ -31,18 +28,12 @@ var isAudioMimeTypeSupportedByBrowser = function isAudioMimeTypeSupportedByBrows
|
|
|
31
28
|
* - https://product-fabric.atlassian.net/browse/EDM-634
|
|
32
29
|
* - https://product-fabric.atlassian.net/browse/EDM-426
|
|
33
30
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
31
|
exports.isAudioMimeTypeSupportedByBrowser = isAudioMimeTypeSupportedByBrowser;
|
|
37
|
-
|
|
38
32
|
var isVideoMimeTypeSupportedByBrowser = function isVideoMimeTypeSupportedByBrowser(mimeType) {
|
|
39
33
|
return ['video/mp4', 'video/quicktime'].indexOf(mimeType.toLowerCase()) > -1;
|
|
40
34
|
};
|
|
41
|
-
|
|
42
35
|
exports.isVideoMimeTypeSupportedByBrowser = isVideoMimeTypeSupportedByBrowser;
|
|
43
|
-
|
|
44
36
|
var isMimeTypeSupportedByBrowser = function isMimeTypeSupportedByBrowser(mimeType) {
|
|
45
37
|
return isDocumentMimeTypeSupportedByBrowser(mimeType) || isImageMimeTypeSupportedByBrowser(mimeType) || isAudioMimeTypeSupportedByBrowser(mimeType) || isVideoMimeTypeSupportedByBrowser(mimeType);
|
|
46
38
|
};
|
|
47
|
-
|
|
48
39
|
exports.isMimeTypeSupportedByBrowser = isMimeTypeSupportedByBrowser;
|
|
@@ -4,54 +4,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isVideoMimeTypeSupportedByServer = exports.isUnknownMimeTypeSupportedByServer = exports.isMimeTypeSupportedByServer = exports.isImageMimeTypeSupportedByServer = exports.isDocumentMimeTypeSupportedByServer = exports.isAudioMimeTypeSupportedByServer = void 0;
|
|
7
|
-
|
|
8
7
|
// Based on https://developer.atlassian.com/platform/media/learning/file-previews/
|
|
9
8
|
var isImageMimeTypeSupportedByServer = function isImageMimeTypeSupportedByServer(mimeType) {
|
|
10
9
|
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
10
|
};
|
|
12
|
-
|
|
13
11
|
exports.isImageMimeTypeSupportedByServer = isImageMimeTypeSupportedByServer;
|
|
14
|
-
|
|
15
12
|
var isDocumentMimeTypeSupportedByServer = function isDocumentMimeTypeSupportedByServer(mimeType) {
|
|
16
|
-
return [
|
|
17
|
-
|
|
18
|
-
'application/vnd.
|
|
19
|
-
|
|
20
|
-
'application/
|
|
21
|
-
|
|
22
|
-
'application/vnd.ms-
|
|
23
|
-
|
|
24
|
-
'application/
|
|
25
|
-
|
|
26
|
-
'
|
|
27
|
-
|
|
13
|
+
return [
|
|
14
|
+
// Adobe PDF
|
|
15
|
+
'application/pdf', 'application/x-pdf', 'application/acrobat', 'applications/vnd.pdf', 'text/pdf', 'text/x-pdf',
|
|
16
|
+
// Adobe Illustrator
|
|
17
|
+
'application/vnd.adobe.illustrator',
|
|
18
|
+
// Microsoft Office
|
|
19
|
+
'application/vnd.ms-office',
|
|
20
|
+
// Microsoft Word
|
|
21
|
+
'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',
|
|
22
|
+
// Microsoft Excel
|
|
23
|
+
'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',
|
|
24
|
+
// Microsoft Powerpoint
|
|
25
|
+
'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',
|
|
26
|
+
// OpenOffice
|
|
27
|
+
'application/vnd.sun.xml.writer', 'application/vnd.sun.xml.writer.template',
|
|
28
|
+
// OpenDocument
|
|
29
|
+
'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',
|
|
30
|
+
// WordPerfect
|
|
31
|
+
'application/vnd.wordperfect',
|
|
32
|
+
// Text files
|
|
33
|
+
'text/csv', 'text/x-diff', 'text/x-perl', 'text/x-python', 'text/x-ruby', 'text/rtf', 'text/richtext', 'text/plain', 'application/txt',
|
|
34
|
+
// Rich text
|
|
35
|
+
'application/rtf', 'application/x-rtf',
|
|
36
|
+
// PostScript
|
|
28
37
|
'application/postscript'].indexOf(mimeType.toLowerCase()) > -1;
|
|
29
38
|
};
|
|
30
|
-
|
|
31
39
|
exports.isDocumentMimeTypeSupportedByServer = isDocumentMimeTypeSupportedByServer;
|
|
32
|
-
|
|
33
40
|
var isAudioMimeTypeSupportedByServer = function isAudioMimeTypeSupportedByServer(mimeType) {
|
|
34
41
|
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
42
|
};
|
|
36
|
-
|
|
37
43
|
exports.isAudioMimeTypeSupportedByServer = isAudioMimeTypeSupportedByServer;
|
|
38
|
-
|
|
39
44
|
var isVideoMimeTypeSupportedByServer = function isVideoMimeTypeSupportedByServer(mimeType) {
|
|
40
45
|
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
|
-
};
|
|
42
|
-
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
43
|
-
|
|
46
|
+
};
|
|
44
47
|
|
|
48
|
+
// BMPT-620: The backend momentarily returns this mimeType for cloud files imported via dt-api-mediapicker
|
|
49
|
+
// Once these cloud files are processed they are receiving a more relevant mimeType
|
|
45
50
|
exports.isVideoMimeTypeSupportedByServer = isVideoMimeTypeSupportedByServer;
|
|
46
|
-
|
|
47
51
|
var isUnknownMimeTypeSupportedByServer = function isUnknownMimeTypeSupportedByServer(mimeType) {
|
|
48
52
|
return ['binary/octet-stream'].indexOf(mimeType.toLowerCase()) > -1;
|
|
49
53
|
};
|
|
50
|
-
|
|
51
54
|
exports.isUnknownMimeTypeSupportedByServer = isUnknownMimeTypeSupportedByServer;
|
|
52
|
-
|
|
53
55
|
var isMimeTypeSupportedByServer = function isMimeTypeSupportedByServer(mimeType) {
|
|
54
56
|
return isImageMimeTypeSupportedByServer(mimeType) || isDocumentMimeTypeSupportedByServer(mimeType) || isAudioMimeTypeSupportedByServer(mimeType) || isVideoMimeTypeSupportedByServer(mimeType) || isUnknownMimeTypeSupportedByServer(mimeType);
|
|
55
57
|
};
|
|
56
|
-
|
|
57
58
|
exports.isMimeTypeSupportedByServer = isMimeTypeSupportedByServer;
|