@atlaskit/media-client 36.3.0 → 36.3.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 +10 -0
- package/dist/cjs/client/file-fetcher/index.js +166 -165
- package/dist/cjs/client/media-client.js +14 -14
- package/dist/cjs/client/media-store/MediaStore.js +79 -78
- package/dist/cjs/client/media-store/resolveAuth.js +20 -19
- package/dist/cjs/client/stargate-client.js +4 -4
- package/dist/cjs/uploader/index.js +28 -35
- package/dist/cjs/utils/createCopyIntentRegisterationBatcher.js +16 -16
- package/dist/cjs/utils/createFileDataLoader.js +16 -16
- package/dist/cjs/utils/getDimensionsFromBlob.js +15 -15
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +1 -1
- package/dist/cjs/utils/hashing/hasherCreator.js +18 -18
- package/dist/cjs/utils/mobileUpload/helpers.js +15 -15
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +4 -4
- package/dist/cjs/utils/polling/index.js +18 -18
- package/dist/cjs/utils/request/helpers.js +52 -49
- package/dist/cjs/utils/request/index.js +17 -16
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +18 -18
- package/dist/esm/client/file-fetcher/index.js +166 -165
- package/dist/esm/client/media-client.js +14 -14
- package/dist/esm/client/media-store/MediaStore.js +79 -78
- package/dist/esm/client/media-store/resolveAuth.js +20 -19
- package/dist/esm/client/stargate-client.js +4 -4
- package/dist/esm/uploader/index.js +28 -35
- package/dist/esm/utils/createCopyIntentRegisterationBatcher.js +16 -16
- package/dist/esm/utils/createFileDataLoader.js +16 -16
- package/dist/esm/utils/getDimensionsFromBlob.js +15 -15
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +1 -1
- package/dist/esm/utils/hashing/hasherCreator.js +17 -17
- package/dist/esm/utils/mobileUpload/helpers.js +15 -15
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +4 -4
- package/dist/esm/utils/polling/index.js +18 -18
- package/dist/esm/utils/request/helpers.js +52 -49
- package/dist/esm/utils/request/index.js +17 -16
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +18 -18
- package/package.json +3 -3
|
@@ -79,8 +79,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
79
79
|
return subject.error(error);
|
|
80
80
|
};
|
|
81
81
|
poll.execute( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
82
|
-
var response, fileState;
|
|
83
|
-
return _regeneratorRuntime.wrap(function
|
|
82
|
+
var response, fileState, _t;
|
|
83
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
84
84
|
while (1) switch (_context.prev = _context.next) {
|
|
85
85
|
case 0:
|
|
86
86
|
if (forceRefresh) {
|
|
@@ -90,16 +90,16 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
90
90
|
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
_context.next =
|
|
93
|
+
_context.next = 1;
|
|
94
94
|
return _this.dataloader.load({
|
|
95
95
|
id: id,
|
|
96
96
|
collectionName: collectionName,
|
|
97
97
|
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
98
98
|
});
|
|
99
|
-
case
|
|
99
|
+
case 1:
|
|
100
100
|
response = _context.sent;
|
|
101
101
|
if (!isNotFoundMediaItemDetails(response)) {
|
|
102
|
-
_context.next =
|
|
102
|
+
_context.next = 2;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
105
|
throw new FileFetcherError('emptyItems', {
|
|
@@ -108,9 +108,9 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
108
108
|
occurrenceKey: occurrenceKey,
|
|
109
109
|
traceContext: response.metadataTraceContext
|
|
110
110
|
});
|
|
111
|
-
case
|
|
111
|
+
case 2:
|
|
112
112
|
if (!isEmptyFile(response)) {
|
|
113
|
-
_context.next =
|
|
113
|
+
_context.next = 3;
|
|
114
114
|
break;
|
|
115
115
|
}
|
|
116
116
|
throw new FileFetcherError('zeroVersionFile', {
|
|
@@ -119,20 +119,20 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
119
119
|
occurrenceKey: occurrenceKey,
|
|
120
120
|
traceContext: response.metadataTraceContext
|
|
121
121
|
});
|
|
122
|
-
case
|
|
122
|
+
case 3:
|
|
123
123
|
fileState = mapMediaItemToFileState(id, response);
|
|
124
124
|
subject.next(fileState);
|
|
125
|
-
|
|
126
|
-
_context.next =
|
|
125
|
+
_t = fileState.status;
|
|
126
|
+
_context.next = _t === 'processing' ? 4 : _t === 'processed' ? 5 : 6;
|
|
127
127
|
break;
|
|
128
|
-
case
|
|
128
|
+
case 4:
|
|
129
129
|
// the only case for continuing polling, otherwise this function is run once only
|
|
130
130
|
poll.next();
|
|
131
|
-
return _context.abrupt("
|
|
132
|
-
case
|
|
131
|
+
return _context.abrupt("continue", 6);
|
|
132
|
+
case 5:
|
|
133
133
|
subject.complete();
|
|
134
|
-
return _context.abrupt("
|
|
135
|
-
case
|
|
134
|
+
return _context.abrupt("continue", 6);
|
|
135
|
+
case 6:
|
|
136
136
|
case "end":
|
|
137
137
|
return _context.stop();
|
|
138
138
|
}
|
|
@@ -176,23 +176,23 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
176
176
|
_defineProperty(this, "uploadArtifact", /*#__PURE__*/function () {
|
|
177
177
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, file, params, collectionName, traceContext) {
|
|
178
178
|
var _yield$_this$mediaApi, data, _yield$_this$mediaApi2, altData, itemDetails;
|
|
179
|
-
return _regeneratorRuntime.wrap(function
|
|
179
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
180
180
|
while (1) switch (_context2.prev = _context2.next) {
|
|
181
181
|
case 0:
|
|
182
|
-
_context2.next =
|
|
182
|
+
_context2.next = 1;
|
|
183
183
|
return _this.mediaApi.uploadArtifact(id, file, params, collectionName, traceContext);
|
|
184
|
-
case
|
|
184
|
+
case 1:
|
|
185
185
|
_yield$_this$mediaApi = _context2.sent;
|
|
186
186
|
data = _yield$_this$mediaApi.data;
|
|
187
|
-
_context2.next =
|
|
187
|
+
_context2.next = 2;
|
|
188
188
|
return _this.mediaApi.getItems([id], collectionName, traceContext);
|
|
189
|
-
case
|
|
189
|
+
case 2:
|
|
190
190
|
_yield$_this$mediaApi2 = _context2.sent;
|
|
191
191
|
altData = _yield$_this$mediaApi2.data;
|
|
192
192
|
itemDetails = altData.items[0].details; // ------------------------------------------------------------
|
|
193
193
|
_this.setFileState(id, mapMediaItemToFileState(id, itemDetails));
|
|
194
194
|
return _context2.abrupt("return", data);
|
|
195
|
-
case
|
|
195
|
+
case 3:
|
|
196
196
|
case "end":
|
|
197
197
|
return _context2.stop();
|
|
198
198
|
}
|
|
@@ -205,12 +205,12 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
205
205
|
_defineProperty(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
206
206
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, artifactName, collectionName, traceContext) {
|
|
207
207
|
var file, updatedArtifacts, updatedFileState;
|
|
208
|
-
return _regeneratorRuntime.wrap(function
|
|
208
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
209
209
|
while (1) switch (_context3.prev = _context3.next) {
|
|
210
210
|
case 0:
|
|
211
|
-
_context3.next =
|
|
211
|
+
_context3.next = 1;
|
|
212
212
|
return _this.mediaApi.deleteArtifact(id, artifactName, collectionName, traceContext);
|
|
213
|
-
case
|
|
213
|
+
case 1:
|
|
214
214
|
// Manually remove the artifact from file state instead of re-requesting the entire payload.
|
|
215
215
|
file = _this.store.getState().files[id];
|
|
216
216
|
if (file && file.status === 'processed' && file.artifacts) {
|
|
@@ -221,7 +221,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
221
221
|
});
|
|
222
222
|
_this.setFileState(id, updatedFileState);
|
|
223
223
|
}
|
|
224
|
-
case
|
|
224
|
+
case 2:
|
|
225
225
|
case "end":
|
|
226
226
|
return _context3.stop();
|
|
227
227
|
}
|
|
@@ -233,28 +233,28 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
233
233
|
}());
|
|
234
234
|
_defineProperty(this, "getOrFetchFileState", /*#__PURE__*/function () {
|
|
235
235
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, collectionName) {
|
|
236
|
-
var fileState;
|
|
237
|
-
return _regeneratorRuntime.wrap(function
|
|
236
|
+
var fileState, _t2;
|
|
237
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
238
238
|
while (1) switch (_context4.prev = _context4.next) {
|
|
239
239
|
case 0:
|
|
240
240
|
fileState = _this.store.getState().files[id];
|
|
241
241
|
if (!(fileState !== null && fileState !== void 0)) {
|
|
242
|
-
_context4.next =
|
|
242
|
+
_context4.next = 1;
|
|
243
243
|
break;
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
_context4.next =
|
|
245
|
+
_t2 = fileState;
|
|
246
|
+
_context4.next = 3;
|
|
247
247
|
break;
|
|
248
|
-
case
|
|
249
|
-
_context4.next =
|
|
248
|
+
case 1:
|
|
249
|
+
_context4.next = 2;
|
|
250
250
|
return _this.getCurrentState(id, {
|
|
251
251
|
collectionName: collectionName
|
|
252
252
|
});
|
|
253
|
-
case
|
|
254
|
-
|
|
255
|
-
case
|
|
256
|
-
return _context4.abrupt("return",
|
|
257
|
-
case
|
|
253
|
+
case 2:
|
|
254
|
+
_t2 = _context4.sent;
|
|
255
|
+
case 3:
|
|
256
|
+
return _context4.abrupt("return", _t2);
|
|
257
|
+
case 4:
|
|
258
258
|
case "end":
|
|
259
259
|
return _context4.stop();
|
|
260
260
|
}
|
|
@@ -268,109 +268,109 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
268
268
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName) {
|
|
269
269
|
var _fileState$mediaMetad;
|
|
270
270
|
var fileState, artifactUrlString, artifactUrl, artifactPath, res, arrayBuffer, uint8Array, mvhdBytes, mvhdIndex, i, j, dataView, start, timeScale, duration, videoLength;
|
|
271
|
-
return _regeneratorRuntime.wrap(function
|
|
271
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
272
272
|
while (1) switch (_context5.prev = _context5.next) {
|
|
273
273
|
case 0:
|
|
274
|
-
_context5.next =
|
|
274
|
+
_context5.next = 1;
|
|
275
275
|
return _this.getOrFetchFileState(id, collectionName);
|
|
276
|
-
case
|
|
276
|
+
case 1:
|
|
277
277
|
fileState = _context5.sent;
|
|
278
278
|
if (!(fileState.status !== 'processed' || fileState.mediaType !== 'video' || !fileState.artifacts['video.mp4'])) {
|
|
279
|
-
_context5.next =
|
|
279
|
+
_context5.next = 2;
|
|
280
280
|
break;
|
|
281
281
|
}
|
|
282
282
|
throw new Error('File is not a video');
|
|
283
|
-
case
|
|
283
|
+
case 2:
|
|
284
284
|
if (!('mediaMetadata' in fileState && (_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration)) {
|
|
285
|
-
_context5.next =
|
|
285
|
+
_context5.next = 3;
|
|
286
286
|
break;
|
|
287
287
|
}
|
|
288
288
|
return _context5.abrupt("return", fileState.mediaMetadata.duration);
|
|
289
|
-
case
|
|
290
|
-
_context5.next =
|
|
289
|
+
case 3:
|
|
290
|
+
_context5.next = 4;
|
|
291
291
|
return _this.getArtifactURL(fileState.artifacts, 'video.mp4', collectionName);
|
|
292
|
-
case
|
|
292
|
+
case 4:
|
|
293
293
|
artifactUrlString = _context5.sent;
|
|
294
294
|
artifactUrl = new URL(artifactUrlString);
|
|
295
295
|
artifactPath = "".concat(artifactUrl.pathname).concat(artifactUrl.search);
|
|
296
|
-
_context5.next =
|
|
296
|
+
_context5.next = 5;
|
|
297
297
|
return _this.mediaApi.request(artifactPath, {
|
|
298
298
|
headers: {
|
|
299
299
|
Range: 'bytes=0-199'
|
|
300
300
|
}
|
|
301
301
|
});
|
|
302
|
-
case
|
|
302
|
+
case 5:
|
|
303
303
|
res = _context5.sent;
|
|
304
|
-
_context5.next =
|
|
304
|
+
_context5.next = 6;
|
|
305
305
|
return res.arrayBuffer();
|
|
306
|
-
case
|
|
306
|
+
case 6:
|
|
307
307
|
arrayBuffer = _context5.sent;
|
|
308
308
|
uint8Array = new Uint8Array(arrayBuffer);
|
|
309
309
|
mvhdBytes = new Uint8Array([109, 118, 104, 100]); // "mvhd" in ASCII
|
|
310
310
|
mvhdIndex = -1;
|
|
311
311
|
i = 0;
|
|
312
|
-
case
|
|
312
|
+
case 7:
|
|
313
313
|
if (!(i <= uint8Array.length - mvhdBytes.length)) {
|
|
314
|
-
_context5.next =
|
|
314
|
+
_context5.next = 12;
|
|
315
315
|
break;
|
|
316
316
|
}
|
|
317
317
|
mvhdIndex = i;
|
|
318
318
|
j = 0;
|
|
319
|
-
case
|
|
319
|
+
case 8:
|
|
320
320
|
if (!(j < mvhdBytes.length)) {
|
|
321
|
-
_context5.next =
|
|
321
|
+
_context5.next = 10;
|
|
322
322
|
break;
|
|
323
323
|
}
|
|
324
324
|
if (!(uint8Array[i + j] !== mvhdBytes[j])) {
|
|
325
|
-
_context5.next =
|
|
325
|
+
_context5.next = 9;
|
|
326
326
|
break;
|
|
327
327
|
}
|
|
328
328
|
mvhdIndex = -1;
|
|
329
|
-
return _context5.abrupt("
|
|
330
|
-
case
|
|
329
|
+
return _context5.abrupt("continue", 10);
|
|
330
|
+
case 9:
|
|
331
331
|
j++;
|
|
332
|
-
_context5.next =
|
|
332
|
+
_context5.next = 8;
|
|
333
333
|
break;
|
|
334
|
-
case
|
|
334
|
+
case 10:
|
|
335
335
|
if (!(mvhdIndex !== -1)) {
|
|
336
|
-
_context5.next =
|
|
336
|
+
_context5.next = 11;
|
|
337
337
|
break;
|
|
338
338
|
}
|
|
339
|
-
return _context5.abrupt("
|
|
340
|
-
case
|
|
339
|
+
return _context5.abrupt("continue", 12);
|
|
340
|
+
case 11:
|
|
341
341
|
i++;
|
|
342
|
-
_context5.next =
|
|
342
|
+
_context5.next = 7;
|
|
343
343
|
break;
|
|
344
|
-
case
|
|
344
|
+
case 12:
|
|
345
345
|
if (!(mvhdIndex === -1)) {
|
|
346
|
-
_context5.next =
|
|
346
|
+
_context5.next = 13;
|
|
347
347
|
break;
|
|
348
348
|
}
|
|
349
349
|
throw new Error('Unable to find mvhd bytes');
|
|
350
|
-
case
|
|
350
|
+
case 13:
|
|
351
351
|
// Create DataView for reading big-endian integers
|
|
352
352
|
dataView = new DataView(arrayBuffer);
|
|
353
353
|
start = mvhdIndex + 16; // Skip atom header and version/flags
|
|
354
354
|
// Check if we have enough bytes to read timescale and duration
|
|
355
355
|
if (!(start + 8 > arrayBuffer.byteLength)) {
|
|
356
|
-
_context5.next =
|
|
356
|
+
_context5.next = 14;
|
|
357
357
|
break;
|
|
358
358
|
}
|
|
359
359
|
return _context5.abrupt("return", 0);
|
|
360
|
-
case
|
|
360
|
+
case 14:
|
|
361
361
|
// flase as second parameter indicates big-endian 32-bit integers
|
|
362
362
|
timeScale = dataView.getUint32(start, false);
|
|
363
363
|
duration = dataView.getUint32(start + 4, false);
|
|
364
364
|
if (!(timeScale === 0)) {
|
|
365
|
-
_context5.next =
|
|
365
|
+
_context5.next = 15;
|
|
366
366
|
break;
|
|
367
367
|
}
|
|
368
368
|
throw new Error('Timescale is invalid');
|
|
369
|
-
case
|
|
369
|
+
case 15:
|
|
370
370
|
// get the video length in seconds
|
|
371
371
|
videoLength = Math.floor(duration / timeScale);
|
|
372
372
|
return _context5.abrupt("return", videoLength);
|
|
373
|
-
case
|
|
373
|
+
case 16:
|
|
374
374
|
case "end":
|
|
375
375
|
return _context5.stop();
|
|
376
376
|
}
|
|
@@ -383,39 +383,39 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
383
383
|
_defineProperty(this, "getVideoDurations", /*#__PURE__*/function () {
|
|
384
384
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(files) {
|
|
385
385
|
var promises, durations;
|
|
386
|
-
return _regeneratorRuntime.wrap(function
|
|
386
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
387
387
|
while (1) switch (_context7.prev = _context7.next) {
|
|
388
388
|
case 0:
|
|
389
389
|
// get all the duration promises
|
|
390
390
|
promises = files.map( /*#__PURE__*/function () {
|
|
391
391
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref7) {
|
|
392
|
-
var id, collectionName;
|
|
393
|
-
return _regeneratorRuntime.wrap(function
|
|
392
|
+
var id, collectionName, _t3;
|
|
393
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
394
394
|
while (1) switch (_context6.prev = _context6.next) {
|
|
395
395
|
case 0:
|
|
396
396
|
id = _ref7.id, collectionName = _ref7.collectionName;
|
|
397
397
|
_context6.prev = 1;
|
|
398
|
-
_context6.next =
|
|
398
|
+
_context6.next = 2;
|
|
399
399
|
return _this.getDurationOfVideo(id, collectionName);
|
|
400
|
-
case
|
|
400
|
+
case 2:
|
|
401
401
|
return _context6.abrupt("return", _context6.sent);
|
|
402
|
-
case
|
|
403
|
-
_context6.prev =
|
|
404
|
-
|
|
402
|
+
case 3:
|
|
403
|
+
_context6.prev = 3;
|
|
404
|
+
_t3 = _context6["catch"](1);
|
|
405
405
|
return _context6.abrupt("return", -1);
|
|
406
|
-
case
|
|
406
|
+
case 4:
|
|
407
407
|
case "end":
|
|
408
408
|
return _context6.stop();
|
|
409
409
|
}
|
|
410
|
-
}, _callee6, null, [[1,
|
|
410
|
+
}, _callee6, null, [[1, 3]]);
|
|
411
411
|
}));
|
|
412
412
|
return function (_x13) {
|
|
413
413
|
return _ref8.apply(this, arguments);
|
|
414
414
|
};
|
|
415
415
|
}());
|
|
416
|
-
_context7.next =
|
|
416
|
+
_context7.next = 1;
|
|
417
417
|
return Promise.all(promises);
|
|
418
|
-
case
|
|
418
|
+
case 1:
|
|
419
419
|
durations = _context7.sent;
|
|
420
420
|
return _context7.abrupt("return", durations.reduce(function (acc, curr, i) {
|
|
421
421
|
if (curr !== -1) {
|
|
@@ -424,7 +424,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
424
424
|
}
|
|
425
425
|
return acc;
|
|
426
426
|
}, {}));
|
|
427
|
-
case
|
|
427
|
+
case 2:
|
|
428
428
|
case "end":
|
|
429
429
|
return _context7.stop();
|
|
430
430
|
}
|
|
@@ -531,7 +531,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
531
531
|
var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url, collection, traceContext, anonymizeFilename) {
|
|
532
532
|
var _this3 = this;
|
|
533
533
|
var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
|
|
534
|
-
return _regeneratorRuntime.wrap(function
|
|
534
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
535
535
|
while (1) switch (_context0.prev = _context0.next) {
|
|
536
536
|
case 0:
|
|
537
537
|
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
@@ -545,12 +545,12 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
545
545
|
preview = new Promise( /*#__PURE__*/function () {
|
|
546
546
|
var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(resolve, reject) {
|
|
547
547
|
var blob;
|
|
548
|
-
return _regeneratorRuntime.wrap(function
|
|
548
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
549
549
|
while (1) switch (_context8.prev = _context8.next) {
|
|
550
550
|
case 0:
|
|
551
|
-
_context8.next =
|
|
551
|
+
_context8.next = 1;
|
|
552
552
|
return deferredBlob;
|
|
553
|
-
case
|
|
553
|
+
case 1:
|
|
554
554
|
blob = _context8.sent;
|
|
555
555
|
if (!blob) {
|
|
556
556
|
reject('Could not fetch the blob');
|
|
@@ -559,7 +559,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
559
559
|
value: blob,
|
|
560
560
|
origin: 'remote'
|
|
561
561
|
});
|
|
562
|
-
case
|
|
562
|
+
case 2:
|
|
563
563
|
case "end":
|
|
564
564
|
return _context8.stop();
|
|
565
565
|
}
|
|
@@ -586,20 +586,20 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
586
586
|
this.setFileState(id, fileState);
|
|
587
587
|
return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
588
588
|
var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(resolve, reject) {
|
|
589
|
-
var blob, type, size, file, mediaType, dimensions;
|
|
590
|
-
return _regeneratorRuntime.wrap(function
|
|
589
|
+
var blob, type, size, file, mediaType, dimensions, _t4;
|
|
590
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
591
591
|
while (1) switch (_context9.prev = _context9.next) {
|
|
592
592
|
case 0:
|
|
593
|
-
_context9.next =
|
|
593
|
+
_context9.next = 1;
|
|
594
594
|
return deferredBlob;
|
|
595
|
-
case
|
|
595
|
+
case 1:
|
|
596
596
|
blob = _context9.sent;
|
|
597
597
|
if (blob) {
|
|
598
|
-
_context9.next =
|
|
598
|
+
_context9.next = 2;
|
|
599
599
|
break;
|
|
600
600
|
}
|
|
601
601
|
return _context9.abrupt("return", reject('Could not download remote file'));
|
|
602
|
-
case
|
|
602
|
+
case 2:
|
|
603
603
|
type = blob.type, size = blob.size;
|
|
604
604
|
file = {
|
|
605
605
|
content: blob,
|
|
@@ -621,35 +621,35 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
621
621
|
});
|
|
622
622
|
// we don't want to wait for the file to be upload
|
|
623
623
|
_this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
624
|
-
_context9.prev =
|
|
625
|
-
_context9.next =
|
|
624
|
+
_context9.prev = 3;
|
|
625
|
+
_context9.next = 4;
|
|
626
626
|
return getDimensionsFromBlob(mediaType, blob);
|
|
627
|
-
case
|
|
627
|
+
case 4:
|
|
628
628
|
dimensions = _context9.sent;
|
|
629
|
-
_context9.next =
|
|
629
|
+
_context9.next = 6;
|
|
630
630
|
break;
|
|
631
|
-
case
|
|
632
|
-
_context9.prev =
|
|
633
|
-
|
|
634
|
-
reject(
|
|
631
|
+
case 5:
|
|
632
|
+
_context9.prev = 5;
|
|
633
|
+
_t4 = _context9["catch"](3);
|
|
634
|
+
reject(_t4);
|
|
635
635
|
return _context9.abrupt("return");
|
|
636
|
-
case
|
|
636
|
+
case 6:
|
|
637
637
|
resolve({
|
|
638
638
|
dimensions: dimensions,
|
|
639
639
|
mimeType: type,
|
|
640
640
|
uploadableFileUpfrontIds: uploadableFileUpfrontIds
|
|
641
641
|
});
|
|
642
|
-
case
|
|
642
|
+
case 7:
|
|
643
643
|
case "end":
|
|
644
644
|
return _context9.stop();
|
|
645
645
|
}
|
|
646
|
-
}, _callee9, null, [[
|
|
646
|
+
}, _callee9, null, [[3, 5]]);
|
|
647
647
|
}));
|
|
648
648
|
return function (_x20, _x21) {
|
|
649
649
|
return _ref1.apply(this, arguments);
|
|
650
650
|
};
|
|
651
651
|
}()));
|
|
652
|
-
case
|
|
652
|
+
case 1:
|
|
653
653
|
case "end":
|
|
654
654
|
return _context0.stop();
|
|
655
655
|
}
|
|
@@ -728,15 +728,15 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
728
728
|
traceContext,
|
|
729
729
|
url,
|
|
730
730
|
_args1 = arguments;
|
|
731
|
-
return _regeneratorRuntime.wrap(function
|
|
731
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
732
732
|
while (1) switch (_context1.prev = _context1.next) {
|
|
733
733
|
case 0:
|
|
734
734
|
name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
|
|
735
735
|
collectionName = _args1.length > 2 ? _args1[2] : undefined;
|
|
736
736
|
traceContext = _args1.length > 3 ? _args1[3] : undefined;
|
|
737
|
-
_context1.next =
|
|
737
|
+
_context1.next = 1;
|
|
738
738
|
return this.mediaApi.getFileBinaryURL(id, collectionName);
|
|
739
|
-
case
|
|
739
|
+
case 1:
|
|
740
740
|
url = _context1.sent;
|
|
741
741
|
downloadUrl(url, {
|
|
742
742
|
name: name
|
|
@@ -747,11 +747,11 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
747
747
|
viewingLevel: 'download'
|
|
748
748
|
});
|
|
749
749
|
// Test the download after initiated the Browser process to catch any potential errors.
|
|
750
|
-
_context1.next =
|
|
750
|
+
_context1.next = 2;
|
|
751
751
|
return this.mediaApi.testUrl(url, {
|
|
752
752
|
traceContext: traceContext
|
|
753
753
|
});
|
|
754
|
-
case
|
|
754
|
+
case 2:
|
|
755
755
|
case "end":
|
|
756
756
|
return _context1.stop();
|
|
757
757
|
}
|
|
@@ -767,26 +767,26 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
767
767
|
value: function () {
|
|
768
768
|
var _registerCopyIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(id, collectionName) {
|
|
769
769
|
var auth, key, error;
|
|
770
|
-
return _regeneratorRuntime.wrap(function
|
|
770
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
771
771
|
while (1) switch (_context10.prev = _context10.next) {
|
|
772
772
|
case 0:
|
|
773
|
-
_context10.next =
|
|
773
|
+
_context10.next = 1;
|
|
774
774
|
return this.mediaApi.resolveAuth({
|
|
775
775
|
collectionName: collectionName
|
|
776
776
|
});
|
|
777
|
-
case
|
|
777
|
+
case 1:
|
|
778
778
|
auth = _context10.sent;
|
|
779
779
|
key = {
|
|
780
780
|
id: id,
|
|
781
781
|
collectionName: collectionName,
|
|
782
782
|
resolvedAuth: auth
|
|
783
783
|
};
|
|
784
|
-
_context10.next =
|
|
784
|
+
_context10.next = 2;
|
|
785
785
|
return this.copyIntentRegisterationBatcher.load(key);
|
|
786
|
-
case
|
|
786
|
+
case 2:
|
|
787
787
|
error = _context10.sent;
|
|
788
788
|
if (!error) {
|
|
789
|
-
_context10.next =
|
|
789
|
+
_context10.next = 3;
|
|
790
790
|
break;
|
|
791
791
|
}
|
|
792
792
|
// if the error is retryable then it should not be cached
|
|
@@ -794,7 +794,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
794
794
|
this.copyIntentRegisterationBatcher.clear(key);
|
|
795
795
|
}
|
|
796
796
|
throw error;
|
|
797
|
-
case
|
|
797
|
+
case 3:
|
|
798
798
|
case "end":
|
|
799
799
|
return _context10.stop();
|
|
800
800
|
}
|
|
@@ -809,8 +809,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
809
809
|
key: "copyFileWithToken",
|
|
810
810
|
value: function () {
|
|
811
811
|
var _copyFileWithToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(source, destination, traceContext) {
|
|
812
|
-
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
|
|
813
|
-
return _regeneratorRuntime.wrap(function
|
|
812
|
+
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data, _t5;
|
|
813
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
814
814
|
while (1) switch (_context11.prev = _context11.next) {
|
|
815
815
|
case 0:
|
|
816
816
|
authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
|
|
@@ -818,14 +818,13 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
818
818
|
mediaStore = destination.mediaStore || new MediaApi({
|
|
819
819
|
authProvider: destinationAuthProvider
|
|
820
820
|
});
|
|
821
|
-
|
|
822
|
-
_context11.next =
|
|
821
|
+
_t5 = authToOwner;
|
|
822
|
+
_context11.next = 1;
|
|
823
823
|
return authProvider({
|
|
824
824
|
collectionName: sourceCollection
|
|
825
825
|
});
|
|
826
|
-
case
|
|
827
|
-
|
|
828
|
-
owner = (0, _context11.t0)(_context11.t1);
|
|
826
|
+
case 1:
|
|
827
|
+
owner = _t5(_context11.sent);
|
|
829
828
|
body = {
|
|
830
829
|
sourceFile: {
|
|
831
830
|
id: id,
|
|
@@ -838,13 +837,13 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
838
837
|
replaceFileId: replaceFileId,
|
|
839
838
|
occurrenceKey: occurrenceKey
|
|
840
839
|
};
|
|
841
|
-
_context11.next =
|
|
840
|
+
_context11.next = 2;
|
|
842
841
|
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
843
|
-
case
|
|
842
|
+
case 2:
|
|
844
843
|
_yield$mediaStore$cop = _context11.sent;
|
|
845
844
|
data = _yield$mediaStore$cop.data;
|
|
846
845
|
return _context11.abrupt("return", data);
|
|
847
|
-
case
|
|
846
|
+
case 3:
|
|
848
847
|
case "end":
|
|
849
848
|
return _context11.stop();
|
|
850
849
|
}
|
|
@@ -860,20 +859,20 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
860
859
|
value: function () {
|
|
861
860
|
var _copyFileWithIntent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(source, destination, traceContext) {
|
|
862
861
|
var res, data;
|
|
863
|
-
return _regeneratorRuntime.wrap(function
|
|
862
|
+
return _regeneratorRuntime.wrap(function (_context12) {
|
|
864
863
|
while (1) switch (_context12.prev = _context12.next) {
|
|
865
864
|
case 0:
|
|
866
|
-
_context12.next =
|
|
865
|
+
_context12.next = 1;
|
|
867
866
|
return this.mediaApi.copyFile(source.id, {
|
|
868
867
|
sourceCollection: source.collection,
|
|
869
868
|
collection: destination.collection,
|
|
870
869
|
replaceFileId: destination.replaceFileId
|
|
871
870
|
}, traceContext, source.clientId);
|
|
872
|
-
case
|
|
871
|
+
case 1:
|
|
873
872
|
res = _context12.sent;
|
|
874
873
|
data = res.data;
|
|
875
874
|
return _context12.abrupt("return", data);
|
|
876
|
-
case
|
|
875
|
+
case 2:
|
|
877
876
|
case "end":
|
|
878
877
|
return _context12.stop();
|
|
879
878
|
}
|
|
@@ -914,8 +913,10 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
914
913
|
replaceFileState,
|
|
915
914
|
key,
|
|
916
915
|
errorFileState,
|
|
917
|
-
_args13 = arguments
|
|
918
|
-
|
|
916
|
+
_args13 = arguments,
|
|
917
|
+
_t6,
|
|
918
|
+
_t7;
|
|
919
|
+
return _regeneratorRuntime.wrap(function (_context13) {
|
|
919
920
|
while (1) switch (_context13.prev = _context13.next) {
|
|
920
921
|
case 0:
|
|
921
922
|
options = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
|
|
@@ -924,23 +925,23 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
924
925
|
destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
925
926
|
preview = options.preview, mimeType = options.mimeType;
|
|
926
927
|
cache = getFileStreamsCache();
|
|
927
|
-
_context13.prev =
|
|
928
|
+
_context13.prev = 1;
|
|
928
929
|
if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
|
|
929
|
-
_context13.next =
|
|
930
|
+
_context13.next = 3;
|
|
930
931
|
break;
|
|
931
932
|
}
|
|
932
|
-
_context13.next =
|
|
933
|
+
_context13.next = 2;
|
|
933
934
|
return this.copyFileWithToken(source, destination, traceContext);
|
|
934
|
-
case
|
|
935
|
+
case 2:
|
|
935
936
|
copiedFile = _context13.sent;
|
|
936
|
-
_context13.next =
|
|
937
|
+
_context13.next = 5;
|
|
937
938
|
break;
|
|
938
|
-
case
|
|
939
|
-
_context13.next =
|
|
939
|
+
case 3:
|
|
940
|
+
_context13.next = 4;
|
|
940
941
|
return this.copyFileWithIntent(source, destination, traceContext);
|
|
941
|
-
case
|
|
942
|
+
case 4:
|
|
942
943
|
copiedFile = _context13.sent;
|
|
943
|
-
case
|
|
944
|
+
case 5:
|
|
944
945
|
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
945
946
|
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
946
947
|
mimeType: mimeType
|
|
@@ -956,21 +957,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
956
957
|
previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
|
|
957
958
|
preview: preview
|
|
958
959
|
} : {};
|
|
959
|
-
|
|
960
|
+
_t6 = !isFinalFileState(copiedFileState) &&
|
|
960
961
|
// mimeType should always be returned by "copyFileWithToken"
|
|
961
962
|
// but in case it's not, we don't want to penalize "copyFile"
|
|
962
963
|
copiedMimeType;
|
|
963
|
-
if (!
|
|
964
|
-
_context13.next =
|
|
964
|
+
if (!_t6) {
|
|
965
|
+
_context13.next = 7;
|
|
965
966
|
break;
|
|
966
967
|
}
|
|
967
|
-
_context13.next =
|
|
968
|
+
_context13.next = 6;
|
|
968
969
|
return shouldFetchRemoteFileStates(mediaType, copiedMimeType, preview);
|
|
969
|
-
case
|
|
970
|
-
|
|
971
|
-
case
|
|
972
|
-
if (!
|
|
973
|
-
_context13.next =
|
|
970
|
+
case 6:
|
|
971
|
+
_t6 = _context13.sent;
|
|
972
|
+
case 7:
|
|
973
|
+
if (!_t6) {
|
|
974
|
+
_context13.next = 8;
|
|
974
975
|
break;
|
|
975
976
|
}
|
|
976
977
|
fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), overrideMediaTypeIfUnknown(copiedFileState, mediaType)), previewOverride);
|
|
@@ -991,22 +992,22 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
991
992
|
return subject.complete();
|
|
992
993
|
}
|
|
993
994
|
});
|
|
994
|
-
_context13.next =
|
|
995
|
+
_context13.next = 9;
|
|
995
996
|
break;
|
|
996
|
-
case
|
|
997
|
+
case 8:
|
|
997
998
|
if (!isProcessingFileState(copiedFileState)) {
|
|
998
999
|
_fileState = _objectSpread(_objectSpread({}, copiedFileState), !isErrorFileState(copiedFileState) && previewOverride);
|
|
999
1000
|
subject.next(_fileState);
|
|
1000
1001
|
this.setFileState(copiedId, _fileState);
|
|
1001
1002
|
}
|
|
1002
|
-
case
|
|
1003
|
+
case 9:
|
|
1003
1004
|
if (!cache.has(copiedId)) {
|
|
1004
1005
|
getFileStreamsCache().set(copiedId, subject);
|
|
1005
1006
|
}
|
|
1006
1007
|
return _context13.abrupt("return", copiedFile);
|
|
1007
|
-
case
|
|
1008
|
-
_context13.prev =
|
|
1009
|
-
|
|
1008
|
+
case 10:
|
|
1009
|
+
_context13.prev = 10;
|
|
1010
|
+
_t7 = _context13["catch"](1);
|
|
1010
1011
|
if (processingSubscription) {
|
|
1011
1012
|
processingSubscription.unsubscribe();
|
|
1012
1013
|
}
|
|
@@ -1014,21 +1015,21 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
1014
1015
|
_fileCache = cache.get(replaceFileId);
|
|
1015
1016
|
replaceFileState = this.store.getState().files[replaceFileId];
|
|
1016
1017
|
if (_fileCache) {
|
|
1017
|
-
_fileCache.error(
|
|
1018
|
+
_fileCache.error(_t7);
|
|
1018
1019
|
} else {
|
|
1019
1020
|
// Create a new subject with the error state for new subscriptions
|
|
1020
|
-
cache.set(id, createMediaSubject(
|
|
1021
|
+
cache.set(id, createMediaSubject(_t7));
|
|
1021
1022
|
}
|
|
1022
1023
|
key = replaceFileState ? replaceFileId : id;
|
|
1023
|
-
errorFileState = this.getErrorFileState(
|
|
1024
|
+
errorFileState = this.getErrorFileState(_t7, id, occurrenceKey);
|
|
1024
1025
|
this.setFileState(key, errorFileState);
|
|
1025
1026
|
}
|
|
1026
|
-
throw
|
|
1027
|
-
case
|
|
1027
|
+
throw _t7;
|
|
1028
|
+
case 11:
|
|
1028
1029
|
case "end":
|
|
1029
1030
|
return _context13.stop();
|
|
1030
1031
|
}
|
|
1031
|
-
}, _callee13, this, [[
|
|
1032
|
+
}, _callee13, this, [[1, 10]]);
|
|
1032
1033
|
}));
|
|
1033
1034
|
function copyFile(_x31, _x32) {
|
|
1034
1035
|
return _copyFile.apply(this, arguments);
|