@atlaskit/media-client 36.3.0 → 36.3.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 +18 -0
- package/dist/cjs/client/file-fetcher/index.js +181 -169
- package/dist/cjs/client/media-client.js +14 -14
- package/dist/cjs/client/media-store/MediaStore.js +79 -78
- package/dist/cjs/client/media-store/resolveAuth.js +20 -19
- package/dist/cjs/client/stargate-client.js +4 -4
- package/dist/cjs/models/file-state.js +4 -2
- package/dist/cjs/uploader/index.js +28 -35
- package/dist/cjs/utils/createCopyIntentRegisterationBatcher.js +16 -16
- package/dist/cjs/utils/createFileDataLoader.js +16 -16
- package/dist/cjs/utils/getDimensionsFromBlob.js +15 -15
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +1 -1
- package/dist/cjs/utils/hashing/hasherCreator.js +18 -18
- package/dist/cjs/utils/mobileUpload/helpers.js +15 -15
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +4 -4
- package/dist/cjs/utils/polling/index.js +18 -18
- package/dist/cjs/utils/request/helpers.js +52 -49
- package/dist/cjs/utils/request/index.js +17 -16
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +18 -18
- package/dist/es2019/client/file-fetcher/index.js +12 -4
- package/dist/es2019/models/file-state.js +4 -2
- package/dist/esm/client/file-fetcher/index.js +181 -169
- package/dist/esm/client/media-client.js +14 -14
- package/dist/esm/client/media-store/MediaStore.js +79 -78
- package/dist/esm/client/media-store/resolveAuth.js +20 -19
- package/dist/esm/client/stargate-client.js +4 -4
- package/dist/esm/models/file-state.js +4 -2
- package/dist/esm/uploader/index.js +28 -35
- package/dist/esm/utils/createCopyIntentRegisterationBatcher.js +16 -16
- package/dist/esm/utils/createFileDataLoader.js +16 -16
- package/dist/esm/utils/getDimensionsFromBlob.js +15 -15
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +1 -1
- package/dist/esm/utils/hashing/hasherCreator.js +17 -17
- package/dist/esm/utils/mobileUpload/helpers.js +15 -15
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +4 -4
- package/dist/esm/utils/polling/index.js +18 -18
- package/dist/esm/utils/request/helpers.js +52 -49
- package/dist/esm/utils/request/index.js +17 -16
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +18 -18
- package/dist/types/models/file-state.d.ts +1 -0
- package/dist/types/models/media.d.ts +2 -0
- package/dist/types-ts4.5/models/file-state.d.ts +1 -0
- package/dist/types-ts4.5/models/media.d.ts +2 -0
- package/package.json +6 -6
|
@@ -87,25 +87,26 @@ export function extendHeaders(headers, auth, traceContext) {
|
|
|
87
87
|
export function createMapResponseToJson(metadata) {
|
|
88
88
|
return /*#__PURE__*/function () {
|
|
89
89
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
|
|
90
|
-
|
|
90
|
+
var _t;
|
|
91
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
91
92
|
while (1) switch (_context.prev = _context.next) {
|
|
92
93
|
case 0:
|
|
93
94
|
_context.prev = 0;
|
|
94
|
-
_context.next =
|
|
95
|
+
_context.next = 1;
|
|
95
96
|
return response.json();
|
|
96
|
-
case
|
|
97
|
+
case 1:
|
|
97
98
|
return _context.abrupt("return", _context.sent);
|
|
98
|
-
case
|
|
99
|
-
_context.prev =
|
|
100
|
-
|
|
99
|
+
case 2:
|
|
100
|
+
_context.prev = 2;
|
|
101
|
+
_t = _context["catch"](0);
|
|
101
102
|
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
102
103
|
statusCode: response.status
|
|
103
|
-
}),
|
|
104
|
-
case
|
|
104
|
+
}), _t instanceof Error ? _t : undefined);
|
|
105
|
+
case 3:
|
|
105
106
|
case "end":
|
|
106
107
|
return _context.stop();
|
|
107
108
|
}
|
|
108
|
-
}, _callee, null, [[0,
|
|
109
|
+
}, _callee, null, [[0, 2]]);
|
|
109
110
|
}));
|
|
110
111
|
return function (_x) {
|
|
111
112
|
return _ref5.apply(this, arguments);
|
|
@@ -115,25 +116,26 @@ export function createMapResponseToJson(metadata) {
|
|
|
115
116
|
export function createMapResponseToBlob(metadata) {
|
|
116
117
|
return /*#__PURE__*/function () {
|
|
117
118
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(response) {
|
|
118
|
-
|
|
119
|
+
var _t2;
|
|
120
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
119
121
|
while (1) switch (_context2.prev = _context2.next) {
|
|
120
122
|
case 0:
|
|
121
123
|
_context2.prev = 0;
|
|
122
|
-
_context2.next =
|
|
124
|
+
_context2.next = 1;
|
|
123
125
|
return response.blob();
|
|
124
|
-
case
|
|
126
|
+
case 1:
|
|
125
127
|
return _context2.abrupt("return", _context2.sent);
|
|
126
|
-
case
|
|
127
|
-
_context2.prev =
|
|
128
|
-
|
|
128
|
+
case 2:
|
|
129
|
+
_context2.prev = 2;
|
|
130
|
+
_t2 = _context2["catch"](0);
|
|
129
131
|
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
130
132
|
statusCode: response.status
|
|
131
|
-
}),
|
|
132
|
-
case
|
|
133
|
+
}), _t2 instanceof Error ? _t2 : undefined);
|
|
134
|
+
case 3:
|
|
133
135
|
case "end":
|
|
134
136
|
return _context2.stop();
|
|
135
137
|
}
|
|
136
|
-
}, _callee2, null, [[0,
|
|
138
|
+
}, _callee2, null, [[0, 2]]);
|
|
137
139
|
}));
|
|
138
140
|
return function (_x2) {
|
|
139
141
|
return _ref6.apply(this, arguments);
|
|
@@ -173,8 +175,9 @@ function _fetchRetry() {
|
|
|
173
175
|
timeoutInMs,
|
|
174
176
|
lastError,
|
|
175
177
|
waitAndBumpTimeout,
|
|
176
|
-
_args4 = arguments
|
|
177
|
-
|
|
178
|
+
_args4 = arguments,
|
|
179
|
+
_t3;
|
|
180
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
178
181
|
while (1) switch (_context4.prev = _context4.next) {
|
|
179
182
|
case 0:
|
|
180
183
|
overwriteOptions = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
|
@@ -184,15 +187,15 @@ function _fetchRetry() {
|
|
|
184
187
|
timeoutInMs = startTimeoutInMs;
|
|
185
188
|
waitAndBumpTimeout = /*#__PURE__*/function () {
|
|
186
189
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
187
|
-
return _regeneratorRuntime.wrap(function
|
|
190
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
188
191
|
while (1) switch (_context3.prev = _context3.next) {
|
|
189
192
|
case 0:
|
|
190
|
-
_context3.next =
|
|
193
|
+
_context3.next = 1;
|
|
191
194
|
return waitPromise(timeoutInMs);
|
|
192
|
-
case
|
|
195
|
+
case 1:
|
|
193
196
|
timeoutInMs *= factor;
|
|
194
197
|
attempts += 1;
|
|
195
|
-
case
|
|
198
|
+
case 2:
|
|
196
199
|
case "end":
|
|
197
200
|
return _context3.stop();
|
|
198
201
|
}
|
|
@@ -202,58 +205,58 @@ function _fetchRetry() {
|
|
|
202
205
|
return _ref7.apply(this, arguments);
|
|
203
206
|
};
|
|
204
207
|
}();
|
|
205
|
-
case
|
|
208
|
+
case 1:
|
|
206
209
|
if (!(attempts < maxAttempts)) {
|
|
207
|
-
_context4.next =
|
|
210
|
+
_context4.next = 8;
|
|
208
211
|
break;
|
|
209
212
|
}
|
|
210
|
-
_context4.prev =
|
|
211
|
-
_context4.next =
|
|
213
|
+
_context4.prev = 2;
|
|
214
|
+
_context4.next = 3;
|
|
212
215
|
return functionToRetry();
|
|
213
|
-
case
|
|
216
|
+
case 3:
|
|
214
217
|
return _context4.abrupt("return", _context4.sent);
|
|
215
|
-
case
|
|
216
|
-
_context4.prev =
|
|
217
|
-
|
|
218
|
-
lastError =
|
|
218
|
+
case 4:
|
|
219
|
+
_context4.prev = 4;
|
|
220
|
+
_t3 = _context4["catch"](2);
|
|
221
|
+
lastError = _t3;
|
|
219
222
|
|
|
220
223
|
// don't retry if request was aborted by user
|
|
221
|
-
if (!isAbortedRequestError(
|
|
222
|
-
_context4.next =
|
|
224
|
+
if (!isAbortedRequestError(_t3)) {
|
|
225
|
+
_context4.next = 5;
|
|
223
226
|
break;
|
|
224
227
|
}
|
|
225
|
-
throw new RequestError('clientAbortedRequest', metadata,
|
|
226
|
-
case
|
|
227
|
-
if (shouldRetryError(
|
|
228
|
-
_context4.next =
|
|
228
|
+
throw new RequestError('clientAbortedRequest', metadata, _t3);
|
|
229
|
+
case 5:
|
|
230
|
+
if (shouldRetryError(_t3)) {
|
|
231
|
+
_context4.next = 6;
|
|
229
232
|
break;
|
|
230
233
|
}
|
|
231
|
-
throw
|
|
232
|
-
case
|
|
233
|
-
_context4.next =
|
|
234
|
+
throw _t3;
|
|
235
|
+
case 6:
|
|
236
|
+
_context4.next = 7;
|
|
234
237
|
return waitAndBumpTimeout();
|
|
235
|
-
case
|
|
236
|
-
_context4.next =
|
|
238
|
+
case 7:
|
|
239
|
+
_context4.next = 1;
|
|
237
240
|
break;
|
|
238
|
-
case
|
|
241
|
+
case 8:
|
|
239
242
|
if (!isRequestError(lastError)) {
|
|
240
|
-
_context4.next =
|
|
243
|
+
_context4.next = 9;
|
|
241
244
|
break;
|
|
242
245
|
}
|
|
243
246
|
throw cloneRequestError(lastError, {
|
|
244
247
|
attempts: attempts,
|
|
245
248
|
clientExhaustedRetries: true
|
|
246
249
|
});
|
|
247
|
-
case
|
|
250
|
+
case 9:
|
|
248
251
|
throw new RequestError('serverUnexpectedError', _objectSpread(_objectSpread({}, metadata), {}, {
|
|
249
252
|
attempts: attempts,
|
|
250
253
|
clientExhaustedRetries: true
|
|
251
254
|
}), lastError);
|
|
252
|
-
case
|
|
255
|
+
case 10:
|
|
253
256
|
case "end":
|
|
254
257
|
return _context4.stop();
|
|
255
258
|
}
|
|
256
|
-
}, _callee4, null, [[
|
|
259
|
+
}, _callee4, null, [[2, 4]]);
|
|
257
260
|
}));
|
|
258
261
|
return _fetchRetry.apply(this, arguments);
|
|
259
262
|
}
|
|
@@ -32,8 +32,9 @@ function _request() {
|
|
|
32
32
|
shouldRetryError,
|
|
33
33
|
_getNavigator2,
|
|
34
34
|
doFetchWithPathBasedUrl,
|
|
35
|
-
_args = arguments
|
|
36
|
-
|
|
35
|
+
_args = arguments,
|
|
36
|
+
_t;
|
|
37
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
37
38
|
while (1) switch (_context.prev = _context.next) {
|
|
38
39
|
case 0:
|
|
39
40
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
@@ -56,7 +57,7 @@ function _request() {
|
|
|
56
57
|
}).then(createProcessFetchResponse(metadata));
|
|
57
58
|
};
|
|
58
59
|
if (!fg('platform_media_retry_edge_error')) {
|
|
59
|
-
_context.next =
|
|
60
|
+
_context.next = 5;
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
63
|
shouldRetryError = function shouldRetryError(err) {
|
|
@@ -66,18 +67,18 @@ function _request() {
|
|
|
66
67
|
}
|
|
67
68
|
return defaultShouldRetryError(err);
|
|
68
69
|
};
|
|
69
|
-
_context.prev =
|
|
70
|
-
_context.next =
|
|
70
|
+
_context.prev = 1;
|
|
71
|
+
_context.next = 2;
|
|
71
72
|
return fetchRetry(doFetch, metadata, _objectSpread(_objectSpread({}, retryOptions), {}, {
|
|
72
73
|
shouldRetryError: shouldRetryError
|
|
73
74
|
}));
|
|
74
|
-
case
|
|
75
|
+
case 2:
|
|
75
76
|
return _context.abrupt("return", _context.sent);
|
|
76
|
-
case
|
|
77
|
-
_context.prev =
|
|
78
|
-
|
|
79
|
-
if (!(isFetchNetworkError(
|
|
80
|
-
_context.next =
|
|
77
|
+
case 3:
|
|
78
|
+
_context.prev = 3;
|
|
79
|
+
_t = _context["catch"](1);
|
|
80
|
+
if (!(isFetchNetworkError(_t) && (_getNavigator2 = getNavigator()) !== null && _getNavigator2 !== void 0 && _getNavigator2.userAgent.includes('Edg/'))) {
|
|
81
|
+
_context.next = 4;
|
|
81
82
|
break;
|
|
82
83
|
}
|
|
83
84
|
doFetchWithPathBasedUrl = function doFetchWithPathBasedUrl() {
|
|
@@ -91,15 +92,15 @@ function _request() {
|
|
|
91
92
|
}).then(createProcessFetchResponse(metadata));
|
|
92
93
|
};
|
|
93
94
|
return _context.abrupt("return", fetchRetry(doFetchWithPathBasedUrl, metadata, retryOptions));
|
|
94
|
-
case
|
|
95
|
-
throw
|
|
96
|
-
case
|
|
95
|
+
case 4:
|
|
96
|
+
throw _t;
|
|
97
|
+
case 5:
|
|
97
98
|
return _context.abrupt("return", fetchRetry(doFetch, metadata, retryOptions));
|
|
98
|
-
case
|
|
99
|
+
case 6:
|
|
99
100
|
case "end":
|
|
100
101
|
return _context.stop();
|
|
101
102
|
}
|
|
102
|
-
}, _callee, null, [[
|
|
103
|
+
}, _callee, null, [[1, 3]]);
|
|
103
104
|
}));
|
|
104
105
|
return _request.apply(this, arguments);
|
|
105
106
|
}
|
|
@@ -19,49 +19,49 @@ export function shouldFetchRemoteFileStates(_x, _x2, _x3) {
|
|
|
19
19
|
}
|
|
20
20
|
function _shouldFetchRemoteFileStates() {
|
|
21
21
|
_shouldFetchRemoteFileStates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaType, mimeType, preview) {
|
|
22
|
-
var content, _yield$getVideoDimens, width, height;
|
|
23
|
-
return _regeneratorRuntime.wrap(function
|
|
22
|
+
var content, _yield$getVideoDimens, width, height, _t;
|
|
23
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
24
24
|
while (1) switch (_context.prev = _context.next) {
|
|
25
25
|
case 0:
|
|
26
26
|
if (!((mediaType === 'doc' || !isMimeTypeSupportedByBrowser(mimeType) || !preview) && isMimeTypeSupportedByServer(mimeType))) {
|
|
27
|
-
_context.next =
|
|
27
|
+
_context.next = 1;
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
return _context.abrupt("return", true);
|
|
31
|
-
case
|
|
31
|
+
case 1:
|
|
32
32
|
if (!(mediaType === 'video' && !!preview)) {
|
|
33
|
-
_context.next =
|
|
33
|
+
_context.next = 6;
|
|
34
34
|
break;
|
|
35
35
|
}
|
|
36
|
-
_context.next =
|
|
36
|
+
_context.next = 2;
|
|
37
37
|
return preview;
|
|
38
|
-
case
|
|
38
|
+
case 2:
|
|
39
39
|
content = _context.sent.value;
|
|
40
40
|
if (content instanceof Blob) {
|
|
41
|
-
_context.next =
|
|
41
|
+
_context.next = 3;
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
return _context.abrupt("return", false);
|
|
45
|
-
case
|
|
46
|
-
_context.prev =
|
|
47
|
-
_context.next =
|
|
45
|
+
case 3:
|
|
46
|
+
_context.prev = 3;
|
|
47
|
+
_context.next = 4;
|
|
48
48
|
return getVideoDimensionsFromBlob(content);
|
|
49
|
-
case
|
|
49
|
+
case 4:
|
|
50
50
|
_yield$getVideoDimens = _context.sent;
|
|
51
51
|
width = _yield$getVideoDimens.width;
|
|
52
52
|
height = _yield$getVideoDimens.height;
|
|
53
53
|
return _context.abrupt("return", !width && !height);
|
|
54
|
-
case
|
|
55
|
-
_context.prev =
|
|
56
|
-
|
|
54
|
+
case 5:
|
|
55
|
+
_context.prev = 5;
|
|
56
|
+
_t = _context["catch"](3);
|
|
57
57
|
return _context.abrupt("return", true);
|
|
58
|
-
case
|
|
58
|
+
case 6:
|
|
59
59
|
return _context.abrupt("return", false);
|
|
60
|
-
case
|
|
60
|
+
case 7:
|
|
61
61
|
case "end":
|
|
62
62
|
return _context.stop();
|
|
63
63
|
}
|
|
64
|
-
}, _callee, null, [[
|
|
64
|
+
}, _callee, null, [[3, 5]]);
|
|
65
65
|
}));
|
|
66
66
|
return _shouldFetchRemoteFileStates.apply(this, arguments);
|
|
67
67
|
}
|
|
@@ -25,6 +25,7 @@ export type MediaFile = {
|
|
|
25
25
|
readonly abuseClassification?: AbuseClassification;
|
|
26
26
|
readonly mediaMetadata?: FileMediaMetadata;
|
|
27
27
|
readonly failReason?: ProcessingFailReason;
|
|
28
|
+
readonly previewCdnUrl?: string;
|
|
28
29
|
};
|
|
29
30
|
export type MediaItemDetails = {
|
|
30
31
|
readonly mediaType: MediaType;
|
|
@@ -40,6 +41,7 @@ export type MediaItemDetails = {
|
|
|
40
41
|
readonly abuseClassification?: AbuseClassification;
|
|
41
42
|
readonly mediaMetadata?: FileMediaMetadata;
|
|
42
43
|
readonly failReason?: ProcessingFailReason;
|
|
44
|
+
readonly previewCdnUrl?: string;
|
|
43
45
|
};
|
|
44
46
|
export type NotFoundMediaItemDetails = {
|
|
45
47
|
readonly id: string;
|
|
@@ -25,6 +25,7 @@ export type MediaFile = {
|
|
|
25
25
|
readonly abuseClassification?: AbuseClassification;
|
|
26
26
|
readonly mediaMetadata?: FileMediaMetadata;
|
|
27
27
|
readonly failReason?: ProcessingFailReason;
|
|
28
|
+
readonly previewCdnUrl?: string;
|
|
28
29
|
};
|
|
29
30
|
export type MediaItemDetails = {
|
|
30
31
|
readonly mediaType: MediaType;
|
|
@@ -40,6 +41,7 @@ export type MediaItemDetails = {
|
|
|
40
41
|
readonly abuseClassification?: AbuseClassification;
|
|
41
42
|
readonly mediaMetadata?: FileMediaMetadata;
|
|
42
43
|
readonly failReason?: ProcessingFailReason;
|
|
44
|
+
readonly previewCdnUrl?: string;
|
|
43
45
|
};
|
|
44
46
|
export type NotFoundMediaItemDetails = {
|
|
45
47
|
readonly id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "36.3.
|
|
3
|
+
"version": "36.3.2",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"xstate": "4.20.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@atlaskit/media-core": "^37.
|
|
49
|
-
"@atlaskit/media-state": "^2.
|
|
48
|
+
"@atlaskit/media-core": "^37.1.0",
|
|
49
|
+
"@atlaskit/media-state": "^2.2.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@atlaskit/media-core": "^37.
|
|
53
|
-
"@atlaskit/media-state": "^2.
|
|
52
|
+
"@atlaskit/media-core": "^37.1.0",
|
|
53
|
+
"@atlaskit/media-state": "^2.2.0",
|
|
54
54
|
"@atlaskit/ssr": "workspace:^",
|
|
55
|
-
"@atlaskit/tokens": "^13.
|
|
55
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
56
56
|
"@atlassian/a11y-jest-testing": "^0.11.0",
|
|
57
57
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|
|
58
58
|
"@emotion/react": "^11.7.1",
|