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