@atlaskit/media-client 33.3.2 → 33.4.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 +9 -0
- package/dist/cjs/client/file-fetcher/index.js +213 -180
- package/dist/cjs/client/media-client.js +1 -2
- package/dist/cjs/client/media-store/MediaStore.js +233 -130
- package/dist/cjs/models/document.js +1 -0
- package/dist/cjs/utils/hashing/hasherCreator.js +1 -2
- package/dist/cjs/utils/hashing/simpleHasher.js +1 -2
- package/dist/es2019/client/file-fetcher/index.js +20 -0
- package/dist/es2019/client/media-store/MediaStore.js +57 -0
- package/dist/es2019/models/document.js +0 -0
- package/dist/esm/client/file-fetcher/index.js +213 -180
- package/dist/esm/client/media-store/MediaStore.js +233 -130
- package/dist/esm/models/document.js +0 -0
- package/dist/types/client/file-fetcher/index.d.ts +3 -1
- package/dist/types/client/media-store/MediaStore.d.ts +4 -0
- package/dist/types/client/media-store/types.d.ts +9 -0
- package/dist/types/models/document.d.ts +54 -0
- package/dist/types-ts4.5/client/file-fetcher/index.d.ts +3 -1
- package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +4 -0
- package/dist/types-ts4.5/client/media-store/types.d.ts +9 -0
- package/dist/types-ts4.5/models/document.d.ts +54 -0
- package/package.json +2 -2
|
@@ -218,112 +218,145 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
218
218
|
return _ref2.apply(this, arguments);
|
|
219
219
|
};
|
|
220
220
|
}());
|
|
221
|
-
(0, _defineProperty2.default)(this, "
|
|
222
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, collectionName) {
|
|
223
|
-
var
|
|
221
|
+
(0, _defineProperty2.default)(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
222
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, params, collectionName, traceContext) {
|
|
223
|
+
var file, updatedArtifacts, updatedFileState;
|
|
224
224
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
225
225
|
while (1) switch (_context3.prev = _context3.next) {
|
|
226
|
+
case 0:
|
|
227
|
+
if (!(process.env.NODE_ENV === 'test')) {
|
|
228
|
+
_context3.next = 3;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
_context3.next = 3;
|
|
232
|
+
return _this.mediaApi.deleteArtifact(id, params, collectionName, traceContext);
|
|
233
|
+
case 3:
|
|
234
|
+
// Manually remove the artifact from file state instead of re-requesting the entire payload.
|
|
235
|
+
file = _this.store.getState().files[id];
|
|
236
|
+
if (file && file.status === 'processed' && file.artifacts) {
|
|
237
|
+
updatedArtifacts = _objectSpread({}, file.artifacts);
|
|
238
|
+
delete updatedArtifacts[params.artifactName];
|
|
239
|
+
updatedFileState = _objectSpread(_objectSpread({}, file), {}, {
|
|
240
|
+
artifacts: updatedArtifacts
|
|
241
|
+
});
|
|
242
|
+
_this.setFileState(id, updatedFileState);
|
|
243
|
+
}
|
|
244
|
+
case 5:
|
|
245
|
+
case "end":
|
|
246
|
+
return _context3.stop();
|
|
247
|
+
}
|
|
248
|
+
}, _callee3);
|
|
249
|
+
}));
|
|
250
|
+
return function (_x6, _x7, _x8, _x9) {
|
|
251
|
+
return _ref3.apply(this, arguments);
|
|
252
|
+
};
|
|
253
|
+
}());
|
|
254
|
+
(0, _defineProperty2.default)(this, "getOrFetchFileState", /*#__PURE__*/function () {
|
|
255
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, collectionName) {
|
|
256
|
+
var fileState;
|
|
257
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
258
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
226
259
|
case 0:
|
|
227
260
|
fileState = _this.store.getState().files[id];
|
|
228
261
|
if (!(fileState !== null && fileState !== void 0)) {
|
|
229
|
-
|
|
262
|
+
_context4.next = 5;
|
|
230
263
|
break;
|
|
231
264
|
}
|
|
232
|
-
|
|
233
|
-
|
|
265
|
+
_context4.t0 = fileState;
|
|
266
|
+
_context4.next = 8;
|
|
234
267
|
break;
|
|
235
268
|
case 5:
|
|
236
|
-
|
|
269
|
+
_context4.next = 7;
|
|
237
270
|
return _this.getCurrentState(id, {
|
|
238
271
|
collectionName: collectionName
|
|
239
272
|
});
|
|
240
273
|
case 7:
|
|
241
|
-
|
|
274
|
+
_context4.t0 = _context4.sent;
|
|
242
275
|
case 8:
|
|
243
|
-
return
|
|
276
|
+
return _context4.abrupt("return", _context4.t0);
|
|
244
277
|
case 9:
|
|
245
278
|
case "end":
|
|
246
|
-
return
|
|
279
|
+
return _context4.stop();
|
|
247
280
|
}
|
|
248
|
-
},
|
|
281
|
+
}, _callee4);
|
|
249
282
|
}));
|
|
250
|
-
return function (
|
|
251
|
-
return
|
|
283
|
+
return function (_x0, _x1) {
|
|
284
|
+
return _ref4.apply(this, arguments);
|
|
252
285
|
};
|
|
253
286
|
}());
|
|
254
287
|
(0, _defineProperty2.default)(this, "getDurationOfVideo", /*#__PURE__*/function () {
|
|
255
|
-
var
|
|
288
|
+
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName) {
|
|
256
289
|
var fileState, artifactUrlString, artifactUrl, artifactPath, res, arrayBuffer, uint8Array, mvhdBytes, mvhdIndex, i, j, dataView, start, timeScale, duration, videoLength;
|
|
257
|
-
return _regenerator.default.wrap(function
|
|
258
|
-
while (1) switch (
|
|
290
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
291
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
259
292
|
case 0:
|
|
260
|
-
|
|
293
|
+
_context5.next = 2;
|
|
261
294
|
return _this.getOrFetchFileState(id, collectionName);
|
|
262
295
|
case 2:
|
|
263
|
-
fileState =
|
|
296
|
+
fileState = _context5.sent;
|
|
264
297
|
if (!(fileState.status !== 'processed' || fileState.mediaType !== 'video' || !fileState.artifacts['video.mp4'])) {
|
|
265
|
-
|
|
298
|
+
_context5.next = 5;
|
|
266
299
|
break;
|
|
267
300
|
}
|
|
268
301
|
throw new Error('File is not a video');
|
|
269
302
|
case 5:
|
|
270
|
-
|
|
303
|
+
_context5.next = 7;
|
|
271
304
|
return _this.getArtifactURL(fileState.artifacts, 'video.mp4');
|
|
272
305
|
case 7:
|
|
273
|
-
artifactUrlString =
|
|
306
|
+
artifactUrlString = _context5.sent;
|
|
274
307
|
artifactUrl = new URL(artifactUrlString);
|
|
275
308
|
artifactPath = "".concat(artifactUrl.pathname).concat(artifactUrl.search);
|
|
276
|
-
|
|
309
|
+
_context5.next = 12;
|
|
277
310
|
return _this.mediaApi.request(artifactPath, {
|
|
278
311
|
headers: {
|
|
279
312
|
Range: 'bytes=0-199'
|
|
280
313
|
}
|
|
281
314
|
});
|
|
282
315
|
case 12:
|
|
283
|
-
res =
|
|
284
|
-
|
|
316
|
+
res = _context5.sent;
|
|
317
|
+
_context5.next = 15;
|
|
285
318
|
return res.arrayBuffer();
|
|
286
319
|
case 15:
|
|
287
|
-
arrayBuffer =
|
|
320
|
+
arrayBuffer = _context5.sent;
|
|
288
321
|
uint8Array = new Uint8Array(arrayBuffer);
|
|
289
322
|
mvhdBytes = new Uint8Array([109, 118, 104, 100]); // "mvhd" in ASCII
|
|
290
323
|
mvhdIndex = -1;
|
|
291
324
|
i = 0;
|
|
292
325
|
case 20:
|
|
293
326
|
if (!(i <= uint8Array.length - mvhdBytes.length)) {
|
|
294
|
-
|
|
327
|
+
_context5.next = 35;
|
|
295
328
|
break;
|
|
296
329
|
}
|
|
297
330
|
mvhdIndex = i;
|
|
298
331
|
j = 0;
|
|
299
332
|
case 23:
|
|
300
333
|
if (!(j < mvhdBytes.length)) {
|
|
301
|
-
|
|
334
|
+
_context5.next = 30;
|
|
302
335
|
break;
|
|
303
336
|
}
|
|
304
337
|
if (!(uint8Array[i + j] !== mvhdBytes[j])) {
|
|
305
|
-
|
|
338
|
+
_context5.next = 27;
|
|
306
339
|
break;
|
|
307
340
|
}
|
|
308
341
|
mvhdIndex = -1;
|
|
309
|
-
return
|
|
342
|
+
return _context5.abrupt("break", 30);
|
|
310
343
|
case 27:
|
|
311
344
|
j++;
|
|
312
|
-
|
|
345
|
+
_context5.next = 23;
|
|
313
346
|
break;
|
|
314
347
|
case 30:
|
|
315
348
|
if (!(mvhdIndex !== -1)) {
|
|
316
|
-
|
|
349
|
+
_context5.next = 32;
|
|
317
350
|
break;
|
|
318
351
|
}
|
|
319
|
-
return
|
|
352
|
+
return _context5.abrupt("break", 35);
|
|
320
353
|
case 32:
|
|
321
354
|
i++;
|
|
322
|
-
|
|
355
|
+
_context5.next = 20;
|
|
323
356
|
break;
|
|
324
357
|
case 35:
|
|
325
358
|
if (!(mvhdIndex === -1)) {
|
|
326
|
-
|
|
359
|
+
_context5.next = 37;
|
|
327
360
|
break;
|
|
328
361
|
}
|
|
329
362
|
throw new Error('Unable to find mvhd bytes');
|
|
@@ -333,71 +366,71 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
333
366
|
start = mvhdIndex + 16; // Skip atom header and version/flags
|
|
334
367
|
// Check if we have enough bytes to read timescale and duration
|
|
335
368
|
if (!(start + 8 > arrayBuffer.byteLength)) {
|
|
336
|
-
|
|
369
|
+
_context5.next = 41;
|
|
337
370
|
break;
|
|
338
371
|
}
|
|
339
|
-
return
|
|
372
|
+
return _context5.abrupt("return", 0);
|
|
340
373
|
case 41:
|
|
341
374
|
// flase as second parameter indicates big-endian 32-bit integers
|
|
342
375
|
timeScale = dataView.getUint32(start, false);
|
|
343
376
|
duration = dataView.getUint32(start + 4, false);
|
|
344
377
|
if (!(timeScale === 0)) {
|
|
345
|
-
|
|
378
|
+
_context5.next = 45;
|
|
346
379
|
break;
|
|
347
380
|
}
|
|
348
381
|
throw new Error('Timescale is invalid');
|
|
349
382
|
case 45:
|
|
350
383
|
// get the video length in seconds
|
|
351
384
|
videoLength = Math.floor(duration / timeScale);
|
|
352
|
-
return
|
|
385
|
+
return _context5.abrupt("return", videoLength);
|
|
353
386
|
case 47:
|
|
354
387
|
case "end":
|
|
355
|
-
return
|
|
388
|
+
return _context5.stop();
|
|
356
389
|
}
|
|
357
|
-
},
|
|
390
|
+
}, _callee5);
|
|
358
391
|
}));
|
|
359
|
-
return function (
|
|
360
|
-
return
|
|
392
|
+
return function (_x10, _x11) {
|
|
393
|
+
return _ref5.apply(this, arguments);
|
|
361
394
|
};
|
|
362
395
|
}());
|
|
363
396
|
(0, _defineProperty2.default)(this, "getVideoDurations", /*#__PURE__*/function () {
|
|
364
|
-
var
|
|
397
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(files) {
|
|
365
398
|
var promises, durations;
|
|
366
|
-
return _regenerator.default.wrap(function
|
|
367
|
-
while (1) switch (
|
|
399
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
400
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
368
401
|
case 0:
|
|
369
402
|
// get all the duration promises
|
|
370
403
|
promises = files.map( /*#__PURE__*/function () {
|
|
371
|
-
var
|
|
404
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref7) {
|
|
372
405
|
var id, collectionName;
|
|
373
|
-
return _regenerator.default.wrap(function
|
|
374
|
-
while (1) switch (
|
|
406
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
407
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
375
408
|
case 0:
|
|
376
|
-
id =
|
|
377
|
-
|
|
378
|
-
|
|
409
|
+
id = _ref7.id, collectionName = _ref7.collectionName;
|
|
410
|
+
_context6.prev = 1;
|
|
411
|
+
_context6.next = 4;
|
|
379
412
|
return _this.getDurationOfVideo(id, collectionName);
|
|
380
413
|
case 4:
|
|
381
|
-
return
|
|
414
|
+
return _context6.abrupt("return", _context6.sent);
|
|
382
415
|
case 7:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return
|
|
416
|
+
_context6.prev = 7;
|
|
417
|
+
_context6.t0 = _context6["catch"](1);
|
|
418
|
+
return _context6.abrupt("return", -1);
|
|
386
419
|
case 10:
|
|
387
420
|
case "end":
|
|
388
|
-
return
|
|
421
|
+
return _context6.stop();
|
|
389
422
|
}
|
|
390
|
-
},
|
|
423
|
+
}, _callee6, null, [[1, 7]]);
|
|
391
424
|
}));
|
|
392
|
-
return function (
|
|
393
|
-
return
|
|
425
|
+
return function (_x13) {
|
|
426
|
+
return _ref8.apply(this, arguments);
|
|
394
427
|
};
|
|
395
428
|
}());
|
|
396
|
-
|
|
429
|
+
_context7.next = 3;
|
|
397
430
|
return Promise.all(promises);
|
|
398
431
|
case 3:
|
|
399
|
-
durations =
|
|
400
|
-
return
|
|
432
|
+
durations = _context7.sent;
|
|
433
|
+
return _context7.abrupt("return", durations.reduce(function (acc, curr, i) {
|
|
401
434
|
if (curr !== -1) {
|
|
402
435
|
var _id = files[i].id;
|
|
403
436
|
acc[_id] = curr;
|
|
@@ -406,12 +439,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
406
439
|
}, {}));
|
|
407
440
|
case 5:
|
|
408
441
|
case "end":
|
|
409
|
-
return
|
|
442
|
+
return _context7.stop();
|
|
410
443
|
}
|
|
411
|
-
},
|
|
444
|
+
}, _callee7);
|
|
412
445
|
}));
|
|
413
|
-
return function (
|
|
414
|
-
return
|
|
446
|
+
return function (_x12) {
|
|
447
|
+
return _ref6.apply(this, arguments);
|
|
415
448
|
};
|
|
416
449
|
}());
|
|
417
450
|
this.mediaApi = mediaApi;
|
|
@@ -479,8 +512,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
479
512
|
descriptors: descriptors
|
|
480
513
|
}, {
|
|
481
514
|
collection: collection
|
|
482
|
-
}, traceContext).then(function (
|
|
483
|
-
var data =
|
|
515
|
+
}, traceContext).then(function (_ref9) {
|
|
516
|
+
var data = _ref9.data;
|
|
484
517
|
return data;
|
|
485
518
|
});
|
|
486
519
|
}
|
|
@@ -506,11 +539,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
506
539
|
}, {
|
|
507
540
|
key: "uploadExternal",
|
|
508
541
|
value: function () {
|
|
509
|
-
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
542
|
+
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url, collection, traceContext) {
|
|
510
543
|
var _this3 = this;
|
|
511
544
|
var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
|
|
512
|
-
return _regenerator.default.wrap(function
|
|
513
|
-
while (1) switch (
|
|
545
|
+
return _regenerator.default.wrap(function _callee0$(_context0) {
|
|
546
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
514
547
|
case 0:
|
|
515
548
|
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
516
549
|
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
@@ -521,15 +554,15 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
521
554
|
return undefined;
|
|
522
555
|
});
|
|
523
556
|
preview = new Promise( /*#__PURE__*/function () {
|
|
524
|
-
var
|
|
557
|
+
var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(resolve, reject) {
|
|
525
558
|
var blob;
|
|
526
|
-
return _regenerator.default.wrap(function
|
|
527
|
-
while (1) switch (
|
|
559
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
560
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
528
561
|
case 0:
|
|
529
|
-
|
|
562
|
+
_context8.next = 2;
|
|
530
563
|
return deferredBlob;
|
|
531
564
|
case 2:
|
|
532
|
-
blob =
|
|
565
|
+
blob = _context8.sent;
|
|
533
566
|
if (!blob) {
|
|
534
567
|
reject('Could not fetch the blob');
|
|
535
568
|
}
|
|
@@ -539,12 +572,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
539
572
|
});
|
|
540
573
|
case 5:
|
|
541
574
|
case "end":
|
|
542
|
-
return
|
|
575
|
+
return _context8.stop();
|
|
543
576
|
}
|
|
544
|
-
},
|
|
577
|
+
}, _callee8);
|
|
545
578
|
}));
|
|
546
|
-
return function (
|
|
547
|
-
return
|
|
579
|
+
return function (_x17, _x18) {
|
|
580
|
+
return _ref0.apply(this, arguments);
|
|
548
581
|
};
|
|
549
582
|
}());
|
|
550
583
|
name = url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
|
|
@@ -562,21 +595,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
562
595
|
// we save it into the cache as soon as possible, in case someone subscribes
|
|
563
596
|
(0, _fileStreamsCache.getFileStreamsCache)().set(id, subject);
|
|
564
597
|
this.setFileState(id, fileState);
|
|
565
|
-
return
|
|
566
|
-
var
|
|
598
|
+
return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
599
|
+
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(resolve, reject) {
|
|
567
600
|
var blob, type, size, file, mediaType, dimensions;
|
|
568
|
-
return _regenerator.default.wrap(function
|
|
569
|
-
while (1) switch (
|
|
601
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
602
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
570
603
|
case 0:
|
|
571
|
-
|
|
604
|
+
_context9.next = 2;
|
|
572
605
|
return deferredBlob;
|
|
573
606
|
case 2:
|
|
574
|
-
blob =
|
|
607
|
+
blob = _context9.sent;
|
|
575
608
|
if (blob) {
|
|
576
|
-
|
|
609
|
+
_context9.next = 5;
|
|
577
610
|
break;
|
|
578
611
|
}
|
|
579
|
-
return
|
|
612
|
+
return _context9.abrupt("return", reject('Could not download remote file'));
|
|
580
613
|
case 5:
|
|
581
614
|
type = blob.type, size = blob.size;
|
|
582
615
|
file = {
|
|
@@ -599,18 +632,18 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
599
632
|
});
|
|
600
633
|
// we don't want to wait for the file to be upload
|
|
601
634
|
_this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
602
|
-
|
|
603
|
-
|
|
635
|
+
_context9.prev = 10;
|
|
636
|
+
_context9.next = 13;
|
|
604
637
|
return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
|
|
605
638
|
case 13:
|
|
606
|
-
dimensions =
|
|
607
|
-
|
|
639
|
+
dimensions = _context9.sent;
|
|
640
|
+
_context9.next = 20;
|
|
608
641
|
break;
|
|
609
642
|
case 16:
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
reject(
|
|
613
|
-
return
|
|
643
|
+
_context9.prev = 16;
|
|
644
|
+
_context9.t0 = _context9["catch"](10);
|
|
645
|
+
reject(_context9.t0);
|
|
646
|
+
return _context9.abrupt("return");
|
|
614
647
|
case 20:
|
|
615
648
|
resolve({
|
|
616
649
|
dimensions: dimensions,
|
|
@@ -619,21 +652,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
619
652
|
});
|
|
620
653
|
case 21:
|
|
621
654
|
case "end":
|
|
622
|
-
return
|
|
655
|
+
return _context9.stop();
|
|
623
656
|
}
|
|
624
|
-
},
|
|
657
|
+
}, _callee9, null, [[10, 16]]);
|
|
625
658
|
}));
|
|
626
|
-
return function (
|
|
627
|
-
return
|
|
659
|
+
return function (_x19, _x20) {
|
|
660
|
+
return _ref1.apply(this, arguments);
|
|
628
661
|
};
|
|
629
662
|
}()));
|
|
630
663
|
case 11:
|
|
631
664
|
case "end":
|
|
632
|
-
return
|
|
665
|
+
return _context0.stop();
|
|
633
666
|
}
|
|
634
|
-
},
|
|
667
|
+
}, _callee0, this);
|
|
635
668
|
}));
|
|
636
|
-
function uploadExternal(
|
|
669
|
+
function uploadExternal(_x14, _x15, _x16) {
|
|
637
670
|
return _uploadExternal.apply(this, arguments);
|
|
638
671
|
}
|
|
639
672
|
return uploadExternal;
|
|
@@ -700,22 +733,22 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
700
733
|
}, {
|
|
701
734
|
key: "downloadBinary",
|
|
702
735
|
value: function () {
|
|
703
|
-
var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
736
|
+
var _downloadBinary = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee1(id) {
|
|
704
737
|
var name,
|
|
705
738
|
collectionName,
|
|
706
739
|
traceContext,
|
|
707
740
|
url,
|
|
708
|
-
|
|
709
|
-
return _regenerator.default.wrap(function
|
|
710
|
-
while (1) switch (
|
|
741
|
+
_args1 = arguments;
|
|
742
|
+
return _regenerator.default.wrap(function _callee1$(_context1) {
|
|
743
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
711
744
|
case 0:
|
|
712
|
-
name =
|
|
713
|
-
collectionName =
|
|
714
|
-
traceContext =
|
|
715
|
-
|
|
745
|
+
name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
|
|
746
|
+
collectionName = _args1.length > 2 ? _args1[2] : undefined;
|
|
747
|
+
traceContext = _args1.length > 3 ? _args1[3] : undefined;
|
|
748
|
+
_context1.next = 5;
|
|
716
749
|
return this.mediaApi.getFileBinaryURL(id, collectionName);
|
|
717
750
|
case 5:
|
|
718
|
-
url =
|
|
751
|
+
url = _context1.sent;
|
|
719
752
|
(0, _downloadUrl.downloadUrl)(url, {
|
|
720
753
|
name: name
|
|
721
754
|
});
|
|
@@ -725,17 +758,17 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
725
758
|
viewingLevel: 'download'
|
|
726
759
|
});
|
|
727
760
|
// Test the download after initiated the Browser process to catch any potential errors.
|
|
728
|
-
|
|
761
|
+
_context1.next = 10;
|
|
729
762
|
return this.mediaApi.testUrl(url, {
|
|
730
763
|
traceContext: traceContext
|
|
731
764
|
});
|
|
732
765
|
case 10:
|
|
733
766
|
case "end":
|
|
734
|
-
return
|
|
767
|
+
return _context1.stop();
|
|
735
768
|
}
|
|
736
|
-
},
|
|
769
|
+
}, _callee1, this);
|
|
737
770
|
}));
|
|
738
|
-
function downloadBinary(
|
|
771
|
+
function downloadBinary(_x21) {
|
|
739
772
|
return _downloadBinary.apply(this, arguments);
|
|
740
773
|
}
|
|
741
774
|
return downloadBinary;
|
|
@@ -743,28 +776,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
743
776
|
}, {
|
|
744
777
|
key: "registerCopyIntent",
|
|
745
778
|
value: function () {
|
|
746
|
-
var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
779
|
+
var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, collectionName) {
|
|
747
780
|
var auth, key, error;
|
|
748
|
-
return _regenerator.default.wrap(function
|
|
749
|
-
while (1) switch (
|
|
781
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
782
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
750
783
|
case 0:
|
|
751
|
-
|
|
784
|
+
_context10.next = 2;
|
|
752
785
|
return this.mediaApi.resolveAuth({
|
|
753
786
|
collectionName: collectionName
|
|
754
787
|
});
|
|
755
788
|
case 2:
|
|
756
|
-
auth =
|
|
789
|
+
auth = _context10.sent;
|
|
757
790
|
key = {
|
|
758
791
|
id: id,
|
|
759
792
|
collectionName: collectionName,
|
|
760
793
|
resolvedAuth: auth
|
|
761
794
|
};
|
|
762
|
-
|
|
795
|
+
_context10.next = 6;
|
|
763
796
|
return this.copyIntentRegisterationBatcher.load(key);
|
|
764
797
|
case 6:
|
|
765
|
-
error =
|
|
798
|
+
error = _context10.sent;
|
|
766
799
|
if (!error) {
|
|
767
|
-
|
|
800
|
+
_context10.next = 10;
|
|
768
801
|
break;
|
|
769
802
|
}
|
|
770
803
|
// if the error is retryable then it should not be cached
|
|
@@ -774,11 +807,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
774
807
|
throw error;
|
|
775
808
|
case 10:
|
|
776
809
|
case "end":
|
|
777
|
-
return
|
|
810
|
+
return _context10.stop();
|
|
778
811
|
}
|
|
779
|
-
},
|
|
812
|
+
}, _callee10, this);
|
|
780
813
|
}));
|
|
781
|
-
function registerCopyIntent(
|
|
814
|
+
function registerCopyIntent(_x22, _x23) {
|
|
782
815
|
return _registerCopyIntent.apply(this, arguments);
|
|
783
816
|
}
|
|
784
817
|
return registerCopyIntent;
|
|
@@ -786,24 +819,24 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
786
819
|
}, {
|
|
787
820
|
key: "copyFileWithToken",
|
|
788
821
|
value: function () {
|
|
789
|
-
var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
822
|
+
var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(source, destination, traceContext) {
|
|
790
823
|
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
|
|
791
|
-
return _regenerator.default.wrap(function
|
|
792
|
-
while (1) switch (
|
|
824
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
825
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
793
826
|
case 0:
|
|
794
827
|
authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
|
|
795
828
|
destinationAuthProvider = destination.authProvider, destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
796
829
|
mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
|
|
797
830
|
authProvider: destinationAuthProvider
|
|
798
831
|
});
|
|
799
|
-
|
|
800
|
-
|
|
832
|
+
_context11.t0 = _mediaCore.authToOwner;
|
|
833
|
+
_context11.next = 6;
|
|
801
834
|
return authProvider({
|
|
802
835
|
collectionName: sourceCollection
|
|
803
836
|
});
|
|
804
837
|
case 6:
|
|
805
|
-
|
|
806
|
-
owner = (0,
|
|
838
|
+
_context11.t1 = _context11.sent;
|
|
839
|
+
owner = (0, _context11.t0)(_context11.t1);
|
|
807
840
|
body = {
|
|
808
841
|
sourceFile: {
|
|
809
842
|
id: id,
|
|
@@ -816,19 +849,19 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
816
849
|
replaceFileId: replaceFileId,
|
|
817
850
|
occurrenceKey: occurrenceKey
|
|
818
851
|
};
|
|
819
|
-
|
|
852
|
+
_context11.next = 12;
|
|
820
853
|
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
821
854
|
case 12:
|
|
822
|
-
_yield$mediaStore$cop =
|
|
855
|
+
_yield$mediaStore$cop = _context11.sent;
|
|
823
856
|
data = _yield$mediaStore$cop.data;
|
|
824
|
-
return
|
|
857
|
+
return _context11.abrupt("return", data);
|
|
825
858
|
case 15:
|
|
826
859
|
case "end":
|
|
827
|
-
return
|
|
860
|
+
return _context11.stop();
|
|
828
861
|
}
|
|
829
|
-
},
|
|
862
|
+
}, _callee11);
|
|
830
863
|
}));
|
|
831
|
-
function copyFileWithToken(
|
|
864
|
+
function copyFileWithToken(_x24, _x25, _x26) {
|
|
832
865
|
return _copyFileWithToken.apply(this, arguments);
|
|
833
866
|
}
|
|
834
867
|
return copyFileWithToken;
|
|
@@ -836,28 +869,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
836
869
|
}, {
|
|
837
870
|
key: "copyFileWithIntent",
|
|
838
871
|
value: function () {
|
|
839
|
-
var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
872
|
+
var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(source, destination, traceContext) {
|
|
840
873
|
var res, data;
|
|
841
|
-
return _regenerator.default.wrap(function
|
|
842
|
-
while (1) switch (
|
|
874
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
875
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
843
876
|
case 0:
|
|
844
|
-
|
|
877
|
+
_context12.next = 2;
|
|
845
878
|
return this.mediaApi.copyFile(source.id, {
|
|
846
879
|
sourceCollection: source.collection,
|
|
847
880
|
collection: destination.collection,
|
|
848
881
|
replaceFileId: destination.replaceFileId
|
|
849
882
|
}, traceContext);
|
|
850
883
|
case 2:
|
|
851
|
-
res =
|
|
884
|
+
res = _context12.sent;
|
|
852
885
|
data = res.data;
|
|
853
|
-
return
|
|
886
|
+
return _context12.abrupt("return", data);
|
|
854
887
|
case 5:
|
|
855
888
|
case "end":
|
|
856
|
-
return
|
|
889
|
+
return _context12.stop();
|
|
857
890
|
}
|
|
858
|
-
},
|
|
891
|
+
}, _callee12, this);
|
|
859
892
|
}));
|
|
860
|
-
function copyFileWithIntent(
|
|
893
|
+
function copyFileWithIntent(_x27, _x28, _x29) {
|
|
861
894
|
return _copyFileWithIntent.apply(this, arguments);
|
|
862
895
|
}
|
|
863
896
|
return copyFileWithIntent;
|
|
@@ -865,7 +898,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
865
898
|
}, {
|
|
866
899
|
key: "copyFile",
|
|
867
900
|
value: function () {
|
|
868
|
-
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
901
|
+
var _copyFile = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(source, destination) {
|
|
869
902
|
var _this5 = this;
|
|
870
903
|
var options,
|
|
871
904
|
traceContext,
|
|
@@ -892,32 +925,32 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
892
925
|
replaceFileState,
|
|
893
926
|
key,
|
|
894
927
|
errorFileState,
|
|
895
|
-
|
|
896
|
-
return _regenerator.default.wrap(function
|
|
897
|
-
while (1) switch (
|
|
928
|
+
_args13 = arguments;
|
|
929
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
930
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
898
931
|
case 0:
|
|
899
|
-
options =
|
|
900
|
-
traceContext =
|
|
932
|
+
options = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
|
|
933
|
+
traceContext = _args13.length > 3 ? _args13[3] : undefined;
|
|
901
934
|
id = source.id;
|
|
902
935
|
destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
903
936
|
preview = options.preview, mimeType = options.mimeType;
|
|
904
937
|
cache = (0, _fileStreamsCache.getFileStreamsCache)();
|
|
905
|
-
|
|
938
|
+
_context13.prev = 6;
|
|
906
939
|
if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
|
|
907
|
-
|
|
940
|
+
_context13.next = 13;
|
|
908
941
|
break;
|
|
909
942
|
}
|
|
910
|
-
|
|
943
|
+
_context13.next = 10;
|
|
911
944
|
return this.copyFileWithToken(source, destination, traceContext);
|
|
912
945
|
case 10:
|
|
913
|
-
copiedFile =
|
|
914
|
-
|
|
946
|
+
copiedFile = _context13.sent;
|
|
947
|
+
_context13.next = 16;
|
|
915
948
|
break;
|
|
916
949
|
case 13:
|
|
917
|
-
|
|
950
|
+
_context13.next = 15;
|
|
918
951
|
return this.copyFileWithIntent(source, destination, traceContext);
|
|
919
952
|
case 15:
|
|
920
|
-
copiedFile =
|
|
953
|
+
copiedFile = _context13.sent;
|
|
921
954
|
case 16:
|
|
922
955
|
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
923
956
|
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
@@ -934,21 +967,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
934
967
|
previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
935
968
|
preview: preview
|
|
936
969
|
} : {};
|
|
937
|
-
|
|
970
|
+
_context13.t0 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
|
|
938
971
|
// mimeType should always be returned by "copyFileWithToken"
|
|
939
972
|
// but in case it's not, we don't want to penalize "copyFile"
|
|
940
973
|
copiedMimeType;
|
|
941
|
-
if (!
|
|
942
|
-
|
|
974
|
+
if (!_context13.t0) {
|
|
975
|
+
_context13.next = 28;
|
|
943
976
|
break;
|
|
944
977
|
}
|
|
945
|
-
|
|
978
|
+
_context13.next = 27;
|
|
946
979
|
return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
|
|
947
980
|
case 27:
|
|
948
|
-
|
|
981
|
+
_context13.t0 = _context13.sent;
|
|
949
982
|
case 28:
|
|
950
|
-
if (!
|
|
951
|
-
|
|
983
|
+
if (!_context13.t0) {
|
|
984
|
+
_context13.next = 35;
|
|
952
985
|
break;
|
|
953
986
|
}
|
|
954
987
|
fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride);
|
|
@@ -969,7 +1002,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
969
1002
|
return subject.complete();
|
|
970
1003
|
}
|
|
971
1004
|
});
|
|
972
|
-
|
|
1005
|
+
_context13.next = 36;
|
|
973
1006
|
break;
|
|
974
1007
|
case 35:
|
|
975
1008
|
if (!(0, _fileState2.isProcessingFileState)(copiedFileState)) {
|
|
@@ -981,10 +1014,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
981
1014
|
if (!cache.has(copiedId)) {
|
|
982
1015
|
(0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
|
|
983
1016
|
}
|
|
984
|
-
return
|
|
1017
|
+
return _context13.abrupt("return", copiedFile);
|
|
985
1018
|
case 40:
|
|
986
|
-
|
|
987
|
-
|
|
1019
|
+
_context13.prev = 40;
|
|
1020
|
+
_context13.t1 = _context13["catch"](6);
|
|
988
1021
|
if (processingSubscription) {
|
|
989
1022
|
processingSubscription.unsubscribe();
|
|
990
1023
|
}
|
|
@@ -992,23 +1025,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
992
1025
|
_fileCache = cache.get(replaceFileId);
|
|
993
1026
|
replaceFileState = this.store.getState().files[replaceFileId];
|
|
994
1027
|
if (_fileCache) {
|
|
995
|
-
_fileCache.error(
|
|
1028
|
+
_fileCache.error(_context13.t1);
|
|
996
1029
|
} else {
|
|
997
1030
|
// Create a new subject with the error state for new subscriptions
|
|
998
|
-
cache.set(id, (0, _createMediaSubject.createMediaSubject)(
|
|
1031
|
+
cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context13.t1));
|
|
999
1032
|
}
|
|
1000
1033
|
key = replaceFileState ? replaceFileId : id;
|
|
1001
|
-
errorFileState = this.getErrorFileState(
|
|
1034
|
+
errorFileState = this.getErrorFileState(_context13.t1, id, occurrenceKey);
|
|
1002
1035
|
this.setFileState(key, errorFileState);
|
|
1003
1036
|
}
|
|
1004
|
-
throw
|
|
1037
|
+
throw _context13.t1;
|
|
1005
1038
|
case 45:
|
|
1006
1039
|
case "end":
|
|
1007
|
-
return
|
|
1040
|
+
return _context13.stop();
|
|
1008
1041
|
}
|
|
1009
|
-
},
|
|
1042
|
+
}, _callee13, this, [[6, 40]]);
|
|
1010
1043
|
}));
|
|
1011
|
-
function copyFile(
|
|
1044
|
+
function copyFile(_x30, _x31) {
|
|
1012
1045
|
return _copyFile.apply(this, arguments);
|
|
1013
1046
|
}
|
|
1014
1047
|
return copyFile;
|