@atlaskit/media-client 20.2.1 → 21.1.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 +35 -0
- package/dist/cjs/client/file-fetcher/error.js +4 -4
- package/dist/cjs/client/file-fetcher/index.js +275 -287
- package/dist/cjs/client/media-client.js +48 -34
- package/dist/cjs/client/media-store/index.js +367 -314
- package/dist/cjs/client/media-store/resolveAuth.js +30 -32
- package/dist/cjs/client/stargate-client.js +14 -16
- package/dist/cjs/index.js +6 -13
- package/dist/cjs/models/media.js +8 -9
- package/dist/cjs/uploader/error.js +4 -4
- package/dist/cjs/uploader/index.js +88 -96
- package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
- package/dist/cjs/utils/createFileDataLoader.js +67 -70
- package/dist/cjs/utils/getDimensionsFromBlob.js +23 -25
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/cjs/utils/hashing/hasherCreator.js +32 -34
- package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/cjs/utils/mobileUpload/error.js +4 -4
- package/dist/cjs/utils/mobileUpload/helpers.js +41 -43
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/cjs/utils/parseJwt.js +52 -0
- package/dist/cjs/utils/polling/index.js +40 -42
- package/dist/cjs/utils/request/errors.js +9 -9
- package/dist/cjs/utils/request/helpers.js +143 -155
- package/dist/cjs/utils/request/index.js +24 -26
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +1 -3
- package/dist/es2019/client/media-client.js +3 -2
- package/dist/es2019/client/media-store/index.js +58 -15
- package/dist/es2019/index.js +2 -3
- package/dist/es2019/models/media.js +6 -4
- package/dist/es2019/uploader/index.js +3 -0
- package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/es2019/utils/mediaSubscribable/toPromise.js +10 -12
- package/dist/es2019/utils/parseJwt.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/error.js +4 -4
- package/dist/esm/client/file-fetcher/index.js +273 -286
- package/dist/esm/client/media-client.js +46 -32
- package/dist/esm/client/media-store/index.js +367 -314
- package/dist/esm/client/media-store/resolveAuth.js +30 -32
- package/dist/esm/client/stargate-client.js +14 -16
- package/dist/esm/index.js +2 -3
- package/dist/esm/models/media.js +6 -6
- package/dist/esm/uploader/error.js +4 -4
- package/dist/esm/uploader/index.js +89 -96
- package/dist/esm/utils/convertBase64ToBlob.js +2 -2
- package/dist/esm/utils/createFileDataLoader.js +65 -69
- package/dist/esm/utils/getDimensionsFromBlob.js +23 -25
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/esm/utils/hashing/hasherCreator.js +28 -30
- package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/esm/utils/mobileUpload/error.js +4 -4
- package/dist/esm/utils/mobileUpload/helpers.js +41 -43
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/esm/utils/parseJwt.js +46 -0
- package/dist/esm/utils/polling/index.js +40 -42
- package/dist/esm/utils/request/errors.js +9 -9
- package/dist/esm/utils/request/helpers.js +143 -155
- package/dist/esm/utils/request/index.js +24 -26
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/esm/version.json +1 -1
- package/dist/types/client/__mocks__/media-client.d.ts +0 -2
- package/dist/types/client/file-fetcher/index.d.ts +4 -4
- package/dist/types/client/media-client.d.ts +1 -2
- package/dist/types/client/media-store/index.d.ts +17 -13
- package/dist/types/index.d.ts +4 -6
- package/dist/types/models/file-state.d.ts +2 -2
- package/dist/types/models/media.d.ts +1 -21
- package/dist/types/utils/createFileDataLoader.d.ts +2 -2
- package/dist/types/utils/createMediaSubject.d.ts +2 -2
- package/dist/types/utils/detectEmptyFile.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +3 -3
- package/dist/types/utils/mediaSubscribable/toPromise.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/types.d.ts +9 -8
- package/dist/types/utils/parseJwt.d.ts +1 -0
- package/package.json +2 -2
- package/report.api.md +77 -126
- package/dist/cjs/client/collection-fetcher.js +0 -98
- package/dist/cjs/models/media-subscribable.js +0 -5
- package/dist/cjs/utils/deprecatedEndpointError.js +0 -43
- package/dist/es2019/client/collection-fetcher.js +0 -38
- package/dist/es2019/models/media-subscribable.js +0 -1
- package/dist/es2019/utils/deprecatedEndpointError.js +0 -20
- package/dist/esm/client/collection-fetcher.js +0 -89
- package/dist/esm/models/media-subscribable.js +0 -1
- package/dist/esm/utils/deprecatedEndpointError.js +0 -34
- package/dist/types/client/collection-fetcher.d.ts +0 -42
- package/dist/types/models/media-subscribable.d.ts +0 -3
- package/dist/types/utils/deprecatedEndpointError.d.ts +0 -16
|
@@ -95,26 +95,24 @@ export function mapResponseToJson(_x) {
|
|
|
95
95
|
function _mapResponseToJson() {
|
|
96
96
|
_mapResponseToJson = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(response) {
|
|
97
97
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
98
|
-
while (1) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return _context3.stop();
|
|
117
|
-
}
|
|
98
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
99
|
+
case 0:
|
|
100
|
+
// eslint-disable-next-line no-console
|
|
101
|
+
console.warn('Helper is deprecated and will be remove in the next major version');
|
|
102
|
+
_context3.prev = 1;
|
|
103
|
+
_context3.next = 4;
|
|
104
|
+
return response.json();
|
|
105
|
+
case 4:
|
|
106
|
+
return _context3.abrupt("return", _context3.sent);
|
|
107
|
+
case 7:
|
|
108
|
+
_context3.prev = 7;
|
|
109
|
+
_context3.t0 = _context3["catch"](1);
|
|
110
|
+
throw new RequestError('serverInvalidBody', {
|
|
111
|
+
statusCode: response.status
|
|
112
|
+
}, _context3.t0 instanceof Error ? _context3.t0 : undefined);
|
|
113
|
+
case 10:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context3.stop();
|
|
118
116
|
}
|
|
119
117
|
}, _callee3, null, [[1, 7]]);
|
|
120
118
|
}));
|
|
@@ -131,26 +129,24 @@ export function mapResponseToBlob(_x2) {
|
|
|
131
129
|
function _mapResponseToBlob() {
|
|
132
130
|
_mapResponseToBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(response) {
|
|
133
131
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
134
|
-
while (1) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return _context4.stop();
|
|
153
|
-
}
|
|
132
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
// eslint-disable-next-line no-console
|
|
135
|
+
console.warn('Helper is deprecated and will be remove in the next major version');
|
|
136
|
+
_context4.prev = 1;
|
|
137
|
+
_context4.next = 4;
|
|
138
|
+
return response.blob();
|
|
139
|
+
case 4:
|
|
140
|
+
return _context4.abrupt("return", _context4.sent);
|
|
141
|
+
case 7:
|
|
142
|
+
_context4.prev = 7;
|
|
143
|
+
_context4.t0 = _context4["catch"](1);
|
|
144
|
+
throw new RequestError('serverInvalidBody', {
|
|
145
|
+
statusCode: response.status
|
|
146
|
+
}, _context4.t0 instanceof Error ? _context4.t0 : undefined);
|
|
147
|
+
case 10:
|
|
148
|
+
case "end":
|
|
149
|
+
return _context4.stop();
|
|
154
150
|
}
|
|
155
151
|
}, _callee4, null, [[1, 7]]);
|
|
156
152
|
}));
|
|
@@ -165,24 +161,22 @@ export function createMapResponseToJson(metadata) {
|
|
|
165
161
|
return /*#__PURE__*/function () {
|
|
166
162
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(response) {
|
|
167
163
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
168
|
-
while (1) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return _context.stop();
|
|
185
|
-
}
|
|
164
|
+
while (1) switch (_context.prev = _context.next) {
|
|
165
|
+
case 0:
|
|
166
|
+
_context.prev = 0;
|
|
167
|
+
_context.next = 3;
|
|
168
|
+
return response.json();
|
|
169
|
+
case 3:
|
|
170
|
+
return _context.abrupt("return", _context.sent);
|
|
171
|
+
case 6:
|
|
172
|
+
_context.prev = 6;
|
|
173
|
+
_context.t0 = _context["catch"](0);
|
|
174
|
+
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
175
|
+
statusCode: response.status
|
|
176
|
+
}), _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
177
|
+
case 9:
|
|
178
|
+
case "end":
|
|
179
|
+
return _context.stop();
|
|
186
180
|
}
|
|
187
181
|
}, _callee, null, [[0, 6]]);
|
|
188
182
|
}));
|
|
@@ -195,24 +189,22 @@ export function createMapResponseToBlob(metadata) {
|
|
|
195
189
|
return /*#__PURE__*/function () {
|
|
196
190
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(response) {
|
|
197
191
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
198
|
-
while (1) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return _context2.stop();
|
|
215
|
-
}
|
|
192
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
193
|
+
case 0:
|
|
194
|
+
_context2.prev = 0;
|
|
195
|
+
_context2.next = 3;
|
|
196
|
+
return response.blob();
|
|
197
|
+
case 3:
|
|
198
|
+
return _context2.abrupt("return", _context2.sent);
|
|
199
|
+
case 6:
|
|
200
|
+
_context2.prev = 6;
|
|
201
|
+
_context2.t0 = _context2["catch"](0);
|
|
202
|
+
throw new RequestError('serverInvalidBody', _objectSpread(_objectSpread(_objectSpread({}, metadata), extractMediaHeaders(response)), {}, {
|
|
203
|
+
statusCode: response.status
|
|
204
|
+
}), _context2.t0 instanceof Error ? _context2.t0 : undefined);
|
|
205
|
+
case 9:
|
|
206
|
+
case "end":
|
|
207
|
+
return _context2.stop();
|
|
216
208
|
}
|
|
217
209
|
}, _callee2, null, [[0, 6]]);
|
|
218
210
|
}));
|
|
@@ -251,87 +243,83 @@ function _fetchRetry() {
|
|
|
251
243
|
waitAndBumpTimeout,
|
|
252
244
|
_args6 = arguments;
|
|
253
245
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
254
|
-
while (1) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
_context6.prev = 13;
|
|
296
|
-
_context6.t0 = _context6["catch"](7);
|
|
297
|
-
lastError = _context6.t0;
|
|
246
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
247
|
+
case 0:
|
|
248
|
+
overwriteOptions = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : {};
|
|
249
|
+
options = _objectSpread(_objectSpread({}, DEFAULT_RETRY_OPTIONS), overwriteOptions);
|
|
250
|
+
startTimeoutInMs = options.startTimeoutInMs, maxAttempts = options.maxAttempts, factor = options.factor;
|
|
251
|
+
attempts = 0;
|
|
252
|
+
timeoutInMs = startTimeoutInMs;
|
|
253
|
+
waitAndBumpTimeout = /*#__PURE__*/function () {
|
|
254
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
255
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
256
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
257
|
+
case 0:
|
|
258
|
+
_context5.next = 2;
|
|
259
|
+
return waitPromise(timeoutInMs);
|
|
260
|
+
case 2:
|
|
261
|
+
timeoutInMs *= factor;
|
|
262
|
+
attempts += 1;
|
|
263
|
+
case 4:
|
|
264
|
+
case "end":
|
|
265
|
+
return _context5.stop();
|
|
266
|
+
}
|
|
267
|
+
}, _callee5);
|
|
268
|
+
}));
|
|
269
|
+
return function waitAndBumpTimeout() {
|
|
270
|
+
return _ref7.apply(this, arguments);
|
|
271
|
+
};
|
|
272
|
+
}();
|
|
273
|
+
case 6:
|
|
274
|
+
if (!(attempts < maxAttempts)) {
|
|
275
|
+
_context6.next = 24;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
_context6.prev = 7;
|
|
279
|
+
_context6.next = 10;
|
|
280
|
+
return functionToRetry();
|
|
281
|
+
case 10:
|
|
282
|
+
return _context6.abrupt("return", _context6.sent);
|
|
283
|
+
case 13:
|
|
284
|
+
_context6.prev = 13;
|
|
285
|
+
_context6.t0 = _context6["catch"](7);
|
|
286
|
+
lastError = _context6.t0;
|
|
298
287
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
break;
|
|
303
|
-
}
|
|
304
|
-
throw new RequestError('clientAbortedRequest', metadata, _context6.t0);
|
|
305
|
-
case 18:
|
|
306
|
-
if (!(!isFetchNetworkError(_context6.t0) && !isRequestError(_context6.t0) || isRequestError(_context6.t0) && (!_context6.t0.metadata || !_context6.t0.metadata.statusCode || _context6.t0.metadata.statusCode < 500))) {
|
|
307
|
-
_context6.next = 20;
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
throw _context6.t0;
|
|
311
|
-
case 20:
|
|
312
|
-
_context6.next = 22;
|
|
313
|
-
return waitAndBumpTimeout();
|
|
314
|
-
case 22:
|
|
315
|
-
_context6.next = 6;
|
|
288
|
+
// don't retry if request was aborted by user
|
|
289
|
+
if (!isAbortedRequestError(_context6.t0)) {
|
|
290
|
+
_context6.next = 18;
|
|
316
291
|
break;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
292
|
+
}
|
|
293
|
+
throw new RequestError('clientAbortedRequest', metadata, _context6.t0);
|
|
294
|
+
case 18:
|
|
295
|
+
if (!(!isFetchNetworkError(_context6.t0) && !isRequestError(_context6.t0) || isRequestError(_context6.t0) && (!_context6.t0.metadata || !_context6.t0.metadata.statusCode || _context6.t0.metadata.statusCode < 500))) {
|
|
296
|
+
_context6.next = 20;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
throw _context6.t0;
|
|
300
|
+
case 20:
|
|
301
|
+
_context6.next = 22;
|
|
302
|
+
return waitAndBumpTimeout();
|
|
303
|
+
case 22:
|
|
304
|
+
_context6.next = 6;
|
|
305
|
+
break;
|
|
306
|
+
case 24:
|
|
307
|
+
if (!isRequestError(lastError)) {
|
|
308
|
+
_context6.next = 26;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
throw cloneRequestError(lastError, {
|
|
312
|
+
attempts: attempts,
|
|
313
|
+
clientExhaustedRetries: true
|
|
314
|
+
});
|
|
315
|
+
case 26:
|
|
316
|
+
throw new RequestError('serverUnexpectedError', _objectSpread(_objectSpread({}, metadata), {}, {
|
|
317
|
+
attempts: attempts,
|
|
318
|
+
clientExhaustedRetries: true
|
|
319
|
+
}), lastError);
|
|
320
|
+
case 27:
|
|
321
|
+
case "end":
|
|
322
|
+
return _context6.stop();
|
|
335
323
|
}
|
|
336
324
|
}, _callee6, null, [[7, 13]]);
|
|
337
325
|
}));
|
|
@@ -25,33 +25,31 @@ function _request() {
|
|
|
25
25
|
doFetch,
|
|
26
26
|
_args = arguments;
|
|
27
27
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
|
-
while (1) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
while (1) switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
31
|
+
controller = _args.length > 2 ? _args[2] : undefined;
|
|
32
|
+
_options$method = options.method, method = _options$method === void 0 ? 'GET' : _options$method, endpoint = options.endpoint, auth = options.auth, params = options.params, headers = options.headers, body = options.body, _options$clientOption = options.clientOptions, clientOptions = _options$clientOption === void 0 ? {} : _options$clientOption, traceContext = options.traceContext;
|
|
33
|
+
retryOptions = clientOptions.retryOptions;
|
|
34
|
+
metadata = {
|
|
35
|
+
method: method,
|
|
36
|
+
endpoint: endpoint,
|
|
37
|
+
traceContext: traceContext
|
|
38
|
+
}; // TODO BMPT-918: add client timeout feature behing a FF (using clientOptions.clientTimeout + Promise.race)
|
|
39
|
+
doFetch = function doFetch() {
|
|
40
|
+
return fetch(createUrl(url, {
|
|
41
|
+
params: params
|
|
42
|
+
}), {
|
|
36
43
|
method: method,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
headers: extendHeaders(headers, auth, traceContext),
|
|
47
|
-
signal: controller && controller.signal
|
|
48
|
-
}).then(createProcessFetchResponse(metadata));
|
|
49
|
-
};
|
|
50
|
-
return _context.abrupt("return", fetchRetry(doFetch, metadata, retryOptions));
|
|
51
|
-
case 7:
|
|
52
|
-
case "end":
|
|
53
|
-
return _context.stop();
|
|
54
|
-
}
|
|
44
|
+
body: body,
|
|
45
|
+
headers: extendHeaders(headers, auth, traceContext),
|
|
46
|
+
signal: controller && controller.signal
|
|
47
|
+
}).then(createProcessFetchResponse(metadata));
|
|
48
|
+
};
|
|
49
|
+
return _context.abrupt("return", fetchRetry(doFetch, metadata, retryOptions));
|
|
50
|
+
case 7:
|
|
51
|
+
case "end":
|
|
52
|
+
return _context.stop();
|
|
55
53
|
}
|
|
56
54
|
}, _callee);
|
|
57
55
|
}));
|
|
@@ -22,47 +22,45 @@ function _shouldFetchRemoteFileStates() {
|
|
|
22
22
|
_shouldFetchRemoteFileStates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaType, mimeType, preview) {
|
|
23
23
|
var content, _yield$getVideoDimens, width, height;
|
|
24
24
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25
|
-
while (1) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return _context.stop();
|
|
65
|
-
}
|
|
25
|
+
while (1) switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
if (!((mediaType === 'doc' || !isMimeTypeSupportedByBrowser(mimeType) || !preview) && isMimeTypeSupportedByServer(mimeType))) {
|
|
28
|
+
_context.next = 2;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return _context.abrupt("return", true);
|
|
32
|
+
case 2:
|
|
33
|
+
if (!(mediaType === 'video' && !!preview)) {
|
|
34
|
+
_context.next = 20;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
_context.next = 5;
|
|
38
|
+
return preview;
|
|
39
|
+
case 5:
|
|
40
|
+
content = _context.sent.value;
|
|
41
|
+
if (content instanceof Blob) {
|
|
42
|
+
_context.next = 8;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return _context.abrupt("return", false);
|
|
46
|
+
case 8:
|
|
47
|
+
_context.prev = 8;
|
|
48
|
+
_context.next = 11;
|
|
49
|
+
return getVideoDimensionsFromBlob(content);
|
|
50
|
+
case 11:
|
|
51
|
+
_yield$getVideoDimens = _context.sent;
|
|
52
|
+
width = _yield$getVideoDimens.width;
|
|
53
|
+
height = _yield$getVideoDimens.height;
|
|
54
|
+
return _context.abrupt("return", !width && !height);
|
|
55
|
+
case 17:
|
|
56
|
+
_context.prev = 17;
|
|
57
|
+
_context.t0 = _context["catch"](8);
|
|
58
|
+
return _context.abrupt("return", true);
|
|
59
|
+
case 20:
|
|
60
|
+
return _context.abrupt("return", false);
|
|
61
|
+
case 21:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context.stop();
|
|
66
64
|
}
|
|
67
65
|
}, _callee, null, [[8, 17]]);
|
|
68
66
|
}));
|
package/dist/esm/version.json
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
2
|
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
3
|
-
import { CollectionFetcher } from '../collection-fetcher';
|
|
4
3
|
import { FileFetcher } from '../file-fetcher';
|
|
5
4
|
export declare class MediaClient {
|
|
6
5
|
readonly config: MediaClientConfig;
|
|
7
|
-
readonly collection: CollectionFetcher;
|
|
8
6
|
readonly file: FileFetcher;
|
|
9
7
|
constructor(config: MediaClientConfig);
|
|
10
8
|
getImage: jest.Mock<any, any>;
|
|
@@ -29,10 +29,10 @@ export declare type ExternalUploadPayload = {
|
|
|
29
29
|
dimensions: Dimensions;
|
|
30
30
|
};
|
|
31
31
|
export interface FileFetcher {
|
|
32
|
-
getFileState(id: string, options?: GetFileOptions): MediaSubscribable
|
|
32
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
33
33
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
34
34
|
touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
|
|
35
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable
|
|
35
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable;
|
|
36
36
|
uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
|
|
37
37
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
38
38
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
@@ -44,7 +44,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
44
44
|
private readonly featureFlags?;
|
|
45
45
|
private readonly dataloader;
|
|
46
46
|
constructor(mediaStore: MediaStore, featureFlags?: MediaFeatureFlags | undefined);
|
|
47
|
-
getFileState(id: string, options?: GetFileOptions): MediaSubscribable
|
|
47
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable;
|
|
48
48
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
49
49
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
50
50
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
@@ -55,7 +55,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
55
55
|
private getUploadingFileStateBase;
|
|
56
56
|
private uploadAwlaysPullFileStates;
|
|
57
57
|
private uploadConditionallyPullFileStates;
|
|
58
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable
|
|
58
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext, featureFlags?: MediaFeatureFlags): MediaSubscribable;
|
|
59
59
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
60
60
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
|
|
61
61
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MediaClientConfig } from '@atlaskit/media-core';
|
|
2
2
|
import { MediaFeatureFlags, MediaTraceContext } from '@atlaskit/media-common';
|
|
3
3
|
import { MediaStore, MediaStoreGetFileImageParams, ImageMetadata } from './media-store';
|
|
4
|
-
import { CollectionFetcher } from './collection-fetcher';
|
|
5
4
|
import { FileFetcher } from './file-fetcher';
|
|
6
5
|
import { UploadEventPayloadMap, EventPayloadListener } from './events';
|
|
7
6
|
import { StargateClient } from './stargate-client';
|
|
@@ -10,7 +9,6 @@ export declare class MediaClient {
|
|
|
10
9
|
readonly mediaClientConfig: MediaClientConfig;
|
|
11
10
|
readonly featureFlags?: MediaFeatureFlags | undefined;
|
|
12
11
|
readonly mediaStore: MediaStore;
|
|
13
|
-
readonly collection: CollectionFetcher;
|
|
14
12
|
readonly file: FileFetcher;
|
|
15
13
|
readonly stargate: StargateClient;
|
|
16
14
|
private readonly eventEmitter;
|
|
@@ -22,6 +20,7 @@ export declare class MediaClient {
|
|
|
22
20
|
getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
23
21
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
|
|
24
22
|
mobileUploadPromise(): Promise<MobileUpload>;
|
|
23
|
+
removeFileFromCollection(id: string, collectionName: string, occurrenceKey?: string, traceContext?: MediaTraceContext): Promise<void>;
|
|
25
24
|
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
26
25
|
off<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E>): void;
|
|
27
26
|
emit<E extends keyof UploadEventPayloadMap>(event: E, payload: UploadEventPayloadMap[E]): boolean;
|