@atlaskit/media-client 36.2.2 → 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 +17 -0
- package/artifacts/package.json +15 -0
- package/check-webp-support/package.json +15 -0
- package/create-media-subject/package.json +15 -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/error/package.json +15 -0
- package/errors/helpers/package.json +15 -0
- package/errors/package.json +15 -0
- package/errors/types/package.json +15 -0
- package/events/package.json +15 -0
- package/file-fetcher/error/package.json +15 -0
- package/file-fetcher/package.json +15 -0
- package/file-state/package.json +15 -0
- package/file-streams-cache/package.json +15 -0
- package/from-observable/package.json +15 -0
- package/get-dimensions-from-blob/package.json +15 -0
- package/global-media-event-emitter/package.json +15 -0
- package/identifier/package.json +15 -0
- package/image-resize-mode-to-file-image-mode/package.json +15 -0
- package/item/package.json +15 -0
- package/media/package.json +15 -0
- package/media-client/package.json +15 -0
- package/media-store/package.json +15 -0
- package/media-store/types/package.json +15 -0
- package/media-subscribable/types/package.json +15 -0
- package/mobile-upload/package.json +15 -0
- package/package.json +3 -3
- package/polling/errors/package.json +15 -0
- package/polling/package.json +15 -0
- package/polling/types/package.json +15 -0
- package/request/errors/package.json +15 -0
- package/request/helpers/package.json +15 -0
- package/request/package.json +15 -0
- package/request/types/package.json +15 -0
- package/stargate-client/package.json +15 -0
- package/upload-controller/package.json +15 -0
- package/uploader/package.json +15 -0
- package/url/package.json +15 -0
|
@@ -96,8 +96,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
96
96
|
return subject.error(error);
|
|
97
97
|
};
|
|
98
98
|
poll.execute( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
99
|
-
var response, fileState;
|
|
100
|
-
return _regenerator.default.wrap(function
|
|
99
|
+
var response, fileState, _t;
|
|
100
|
+
return _regenerator.default.wrap(function (_context) {
|
|
101
101
|
while (1) switch (_context.prev = _context.next) {
|
|
102
102
|
case 0:
|
|
103
103
|
if (forceRefresh) {
|
|
@@ -107,16 +107,16 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
107
107
|
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
_context.next =
|
|
110
|
+
_context.next = 1;
|
|
111
111
|
return _this.dataloader.load({
|
|
112
112
|
id: id,
|
|
113
113
|
collectionName: collectionName,
|
|
114
114
|
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
115
115
|
});
|
|
116
|
-
case
|
|
116
|
+
case 1:
|
|
117
117
|
response = _context.sent;
|
|
118
118
|
if (!(0, _media.isNotFoundMediaItemDetails)(response)) {
|
|
119
|
-
_context.next =
|
|
119
|
+
_context.next = 2;
|
|
120
120
|
break;
|
|
121
121
|
}
|
|
122
122
|
throw new _error.FileFetcherError('emptyItems', {
|
|
@@ -125,9 +125,9 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
125
125
|
occurrenceKey: occurrenceKey,
|
|
126
126
|
traceContext: response.metadataTraceContext
|
|
127
127
|
});
|
|
128
|
-
case
|
|
128
|
+
case 2:
|
|
129
129
|
if (!(0, _detectEmptyFile.isEmptyFile)(response)) {
|
|
130
|
-
_context.next =
|
|
130
|
+
_context.next = 3;
|
|
131
131
|
break;
|
|
132
132
|
}
|
|
133
133
|
throw new _error.FileFetcherError('zeroVersionFile', {
|
|
@@ -136,20 +136,20 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
136
136
|
occurrenceKey: occurrenceKey,
|
|
137
137
|
traceContext: response.metadataTraceContext
|
|
138
138
|
});
|
|
139
|
-
case
|
|
139
|
+
case 3:
|
|
140
140
|
fileState = (0, _fileState2.mapMediaItemToFileState)(id, response);
|
|
141
141
|
subject.next(fileState);
|
|
142
|
-
|
|
143
|
-
_context.next =
|
|
142
|
+
_t = fileState.status;
|
|
143
|
+
_context.next = _t === 'processing' ? 4 : _t === 'processed' ? 5 : 6;
|
|
144
144
|
break;
|
|
145
|
-
case
|
|
145
|
+
case 4:
|
|
146
146
|
// the only case for continuing polling, otherwise this function is run once only
|
|
147
147
|
poll.next();
|
|
148
|
-
return _context.abrupt("
|
|
149
|
-
case
|
|
148
|
+
return _context.abrupt("continue", 6);
|
|
149
|
+
case 5:
|
|
150
150
|
subject.complete();
|
|
151
|
-
return _context.abrupt("
|
|
152
|
-
case
|
|
151
|
+
return _context.abrupt("continue", 6);
|
|
152
|
+
case 6:
|
|
153
153
|
case "end":
|
|
154
154
|
return _context.stop();
|
|
155
155
|
}
|
|
@@ -193,23 +193,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
193
193
|
(0, _defineProperty2.default)(this, "uploadArtifact", /*#__PURE__*/function () {
|
|
194
194
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(id, file, params, collectionName, traceContext) {
|
|
195
195
|
var _yield$_this$mediaApi, data, _yield$_this$mediaApi2, altData, itemDetails;
|
|
196
|
-
return _regenerator.default.wrap(function
|
|
196
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
197
197
|
while (1) switch (_context2.prev = _context2.next) {
|
|
198
198
|
case 0:
|
|
199
|
-
_context2.next =
|
|
199
|
+
_context2.next = 1;
|
|
200
200
|
return _this.mediaApi.uploadArtifact(id, file, params, collectionName, traceContext);
|
|
201
|
-
case
|
|
201
|
+
case 1:
|
|
202
202
|
_yield$_this$mediaApi = _context2.sent;
|
|
203
203
|
data = _yield$_this$mediaApi.data;
|
|
204
|
-
_context2.next =
|
|
204
|
+
_context2.next = 2;
|
|
205
205
|
return _this.mediaApi.getItems([id], collectionName, traceContext);
|
|
206
|
-
case
|
|
206
|
+
case 2:
|
|
207
207
|
_yield$_this$mediaApi2 = _context2.sent;
|
|
208
208
|
altData = _yield$_this$mediaApi2.data;
|
|
209
209
|
itemDetails = altData.items[0].details; // ------------------------------------------------------------
|
|
210
210
|
_this.setFileState(id, (0, _fileState2.mapMediaItemToFileState)(id, itemDetails));
|
|
211
211
|
return _context2.abrupt("return", data);
|
|
212
|
-
case
|
|
212
|
+
case 3:
|
|
213
213
|
case "end":
|
|
214
214
|
return _context2.stop();
|
|
215
215
|
}
|
|
@@ -222,12 +222,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
222
222
|
(0, _defineProperty2.default)(this, "deleteArtifact", /*#__PURE__*/function () {
|
|
223
223
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(id, artifactName, collectionName, traceContext) {
|
|
224
224
|
var file, updatedArtifacts, updatedFileState;
|
|
225
|
-
return _regenerator.default.wrap(function
|
|
225
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
226
226
|
while (1) switch (_context3.prev = _context3.next) {
|
|
227
227
|
case 0:
|
|
228
|
-
_context3.next =
|
|
228
|
+
_context3.next = 1;
|
|
229
229
|
return _this.mediaApi.deleteArtifact(id, artifactName, collectionName, traceContext);
|
|
230
|
-
case
|
|
230
|
+
case 1:
|
|
231
231
|
// Manually remove the artifact from file state instead of re-requesting the entire payload.
|
|
232
232
|
file = _this.store.getState().files[id];
|
|
233
233
|
if (file && file.status === 'processed' && file.artifacts) {
|
|
@@ -238,7 +238,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
238
238
|
});
|
|
239
239
|
_this.setFileState(id, updatedFileState);
|
|
240
240
|
}
|
|
241
|
-
case
|
|
241
|
+
case 2:
|
|
242
242
|
case "end":
|
|
243
243
|
return _context3.stop();
|
|
244
244
|
}
|
|
@@ -250,28 +250,28 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
250
250
|
}());
|
|
251
251
|
(0, _defineProperty2.default)(this, "getOrFetchFileState", /*#__PURE__*/function () {
|
|
252
252
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, collectionName) {
|
|
253
|
-
var fileState;
|
|
254
|
-
return _regenerator.default.wrap(function
|
|
253
|
+
var fileState, _t2;
|
|
254
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
255
255
|
while (1) switch (_context4.prev = _context4.next) {
|
|
256
256
|
case 0:
|
|
257
257
|
fileState = _this.store.getState().files[id];
|
|
258
258
|
if (!(fileState !== null && fileState !== void 0)) {
|
|
259
|
-
_context4.next =
|
|
259
|
+
_context4.next = 1;
|
|
260
260
|
break;
|
|
261
261
|
}
|
|
262
|
-
|
|
263
|
-
_context4.next =
|
|
262
|
+
_t2 = fileState;
|
|
263
|
+
_context4.next = 3;
|
|
264
264
|
break;
|
|
265
|
-
case
|
|
266
|
-
_context4.next =
|
|
265
|
+
case 1:
|
|
266
|
+
_context4.next = 2;
|
|
267
267
|
return _this.getCurrentState(id, {
|
|
268
268
|
collectionName: collectionName
|
|
269
269
|
});
|
|
270
|
-
case
|
|
271
|
-
|
|
272
|
-
case
|
|
273
|
-
return _context4.abrupt("return",
|
|
274
|
-
case
|
|
270
|
+
case 2:
|
|
271
|
+
_t2 = _context4.sent;
|
|
272
|
+
case 3:
|
|
273
|
+
return _context4.abrupt("return", _t2);
|
|
274
|
+
case 4:
|
|
275
275
|
case "end":
|
|
276
276
|
return _context4.stop();
|
|
277
277
|
}
|
|
@@ -285,109 +285,109 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
285
285
|
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(id, collectionName) {
|
|
286
286
|
var _fileState$mediaMetad;
|
|
287
287
|
var fileState, artifactUrlString, artifactUrl, artifactPath, res, arrayBuffer, uint8Array, mvhdBytes, mvhdIndex, i, j, dataView, start, timeScale, duration, videoLength;
|
|
288
|
-
return _regenerator.default.wrap(function
|
|
288
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
289
289
|
while (1) switch (_context5.prev = _context5.next) {
|
|
290
290
|
case 0:
|
|
291
|
-
_context5.next =
|
|
291
|
+
_context5.next = 1;
|
|
292
292
|
return _this.getOrFetchFileState(id, collectionName);
|
|
293
|
-
case
|
|
293
|
+
case 1:
|
|
294
294
|
fileState = _context5.sent;
|
|
295
295
|
if (!(fileState.status !== 'processed' || fileState.mediaType !== 'video' || !fileState.artifacts['video.mp4'])) {
|
|
296
|
-
_context5.next =
|
|
296
|
+
_context5.next = 2;
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
throw new Error('File is not a video');
|
|
300
|
-
case
|
|
300
|
+
case 2:
|
|
301
301
|
if (!('mediaMetadata' in fileState && (_fileState$mediaMetad = fileState.mediaMetadata) !== null && _fileState$mediaMetad !== void 0 && _fileState$mediaMetad.duration)) {
|
|
302
|
-
_context5.next =
|
|
302
|
+
_context5.next = 3;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
305
|
return _context5.abrupt("return", fileState.mediaMetadata.duration);
|
|
306
|
-
case
|
|
307
|
-
_context5.next =
|
|
306
|
+
case 3:
|
|
307
|
+
_context5.next = 4;
|
|
308
308
|
return _this.getArtifactURL(fileState.artifacts, 'video.mp4', collectionName);
|
|
309
|
-
case
|
|
309
|
+
case 4:
|
|
310
310
|
artifactUrlString = _context5.sent;
|
|
311
311
|
artifactUrl = new URL(artifactUrlString);
|
|
312
312
|
artifactPath = "".concat(artifactUrl.pathname).concat(artifactUrl.search);
|
|
313
|
-
_context5.next =
|
|
313
|
+
_context5.next = 5;
|
|
314
314
|
return _this.mediaApi.request(artifactPath, {
|
|
315
315
|
headers: {
|
|
316
316
|
Range: 'bytes=0-199'
|
|
317
317
|
}
|
|
318
318
|
});
|
|
319
|
-
case
|
|
319
|
+
case 5:
|
|
320
320
|
res = _context5.sent;
|
|
321
|
-
_context5.next =
|
|
321
|
+
_context5.next = 6;
|
|
322
322
|
return res.arrayBuffer();
|
|
323
|
-
case
|
|
323
|
+
case 6:
|
|
324
324
|
arrayBuffer = _context5.sent;
|
|
325
325
|
uint8Array = new Uint8Array(arrayBuffer);
|
|
326
326
|
mvhdBytes = new Uint8Array([109, 118, 104, 100]); // "mvhd" in ASCII
|
|
327
327
|
mvhdIndex = -1;
|
|
328
328
|
i = 0;
|
|
329
|
-
case
|
|
329
|
+
case 7:
|
|
330
330
|
if (!(i <= uint8Array.length - mvhdBytes.length)) {
|
|
331
|
-
_context5.next =
|
|
331
|
+
_context5.next = 12;
|
|
332
332
|
break;
|
|
333
333
|
}
|
|
334
334
|
mvhdIndex = i;
|
|
335
335
|
j = 0;
|
|
336
|
-
case
|
|
336
|
+
case 8:
|
|
337
337
|
if (!(j < mvhdBytes.length)) {
|
|
338
|
-
_context5.next =
|
|
338
|
+
_context5.next = 10;
|
|
339
339
|
break;
|
|
340
340
|
}
|
|
341
341
|
if (!(uint8Array[i + j] !== mvhdBytes[j])) {
|
|
342
|
-
_context5.next =
|
|
342
|
+
_context5.next = 9;
|
|
343
343
|
break;
|
|
344
344
|
}
|
|
345
345
|
mvhdIndex = -1;
|
|
346
|
-
return _context5.abrupt("
|
|
347
|
-
case
|
|
346
|
+
return _context5.abrupt("continue", 10);
|
|
347
|
+
case 9:
|
|
348
348
|
j++;
|
|
349
|
-
_context5.next =
|
|
349
|
+
_context5.next = 8;
|
|
350
350
|
break;
|
|
351
|
-
case
|
|
351
|
+
case 10:
|
|
352
352
|
if (!(mvhdIndex !== -1)) {
|
|
353
|
-
_context5.next =
|
|
353
|
+
_context5.next = 11;
|
|
354
354
|
break;
|
|
355
355
|
}
|
|
356
|
-
return _context5.abrupt("
|
|
357
|
-
case
|
|
356
|
+
return _context5.abrupt("continue", 12);
|
|
357
|
+
case 11:
|
|
358
358
|
i++;
|
|
359
|
-
_context5.next =
|
|
359
|
+
_context5.next = 7;
|
|
360
360
|
break;
|
|
361
|
-
case
|
|
361
|
+
case 12:
|
|
362
362
|
if (!(mvhdIndex === -1)) {
|
|
363
|
-
_context5.next =
|
|
363
|
+
_context5.next = 13;
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
366
366
|
throw new Error('Unable to find mvhd bytes');
|
|
367
|
-
case
|
|
367
|
+
case 13:
|
|
368
368
|
// Create DataView for reading big-endian integers
|
|
369
369
|
dataView = new DataView(arrayBuffer);
|
|
370
370
|
start = mvhdIndex + 16; // Skip atom header and version/flags
|
|
371
371
|
// Check if we have enough bytes to read timescale and duration
|
|
372
372
|
if (!(start + 8 > arrayBuffer.byteLength)) {
|
|
373
|
-
_context5.next =
|
|
373
|
+
_context5.next = 14;
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
376
|
return _context5.abrupt("return", 0);
|
|
377
|
-
case
|
|
377
|
+
case 14:
|
|
378
378
|
// flase as second parameter indicates big-endian 32-bit integers
|
|
379
379
|
timeScale = dataView.getUint32(start, false);
|
|
380
380
|
duration = dataView.getUint32(start + 4, false);
|
|
381
381
|
if (!(timeScale === 0)) {
|
|
382
|
-
_context5.next =
|
|
382
|
+
_context5.next = 15;
|
|
383
383
|
break;
|
|
384
384
|
}
|
|
385
385
|
throw new Error('Timescale is invalid');
|
|
386
|
-
case
|
|
386
|
+
case 15:
|
|
387
387
|
// get the video length in seconds
|
|
388
388
|
videoLength = Math.floor(duration / timeScale);
|
|
389
389
|
return _context5.abrupt("return", videoLength);
|
|
390
|
-
case
|
|
390
|
+
case 16:
|
|
391
391
|
case "end":
|
|
392
392
|
return _context5.stop();
|
|
393
393
|
}
|
|
@@ -400,39 +400,39 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
400
400
|
(0, _defineProperty2.default)(this, "getVideoDurations", /*#__PURE__*/function () {
|
|
401
401
|
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(files) {
|
|
402
402
|
var promises, durations;
|
|
403
|
-
return _regenerator.default.wrap(function
|
|
403
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
404
404
|
while (1) switch (_context7.prev = _context7.next) {
|
|
405
405
|
case 0:
|
|
406
406
|
// get all the duration promises
|
|
407
407
|
promises = files.map( /*#__PURE__*/function () {
|
|
408
408
|
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(_ref7) {
|
|
409
|
-
var id, collectionName;
|
|
410
|
-
return _regenerator.default.wrap(function
|
|
409
|
+
var id, collectionName, _t3;
|
|
410
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
411
411
|
while (1) switch (_context6.prev = _context6.next) {
|
|
412
412
|
case 0:
|
|
413
413
|
id = _ref7.id, collectionName = _ref7.collectionName;
|
|
414
414
|
_context6.prev = 1;
|
|
415
|
-
_context6.next =
|
|
415
|
+
_context6.next = 2;
|
|
416
416
|
return _this.getDurationOfVideo(id, collectionName);
|
|
417
|
-
case
|
|
417
|
+
case 2:
|
|
418
418
|
return _context6.abrupt("return", _context6.sent);
|
|
419
|
-
case
|
|
420
|
-
_context6.prev =
|
|
421
|
-
|
|
419
|
+
case 3:
|
|
420
|
+
_context6.prev = 3;
|
|
421
|
+
_t3 = _context6["catch"](1);
|
|
422
422
|
return _context6.abrupt("return", -1);
|
|
423
|
-
case
|
|
423
|
+
case 4:
|
|
424
424
|
case "end":
|
|
425
425
|
return _context6.stop();
|
|
426
426
|
}
|
|
427
|
-
}, _callee6, null, [[1,
|
|
427
|
+
}, _callee6, null, [[1, 3]]);
|
|
428
428
|
}));
|
|
429
429
|
return function (_x13) {
|
|
430
430
|
return _ref8.apply(this, arguments);
|
|
431
431
|
};
|
|
432
432
|
}());
|
|
433
|
-
_context7.next =
|
|
433
|
+
_context7.next = 1;
|
|
434
434
|
return Promise.all(promises);
|
|
435
|
-
case
|
|
435
|
+
case 1:
|
|
436
436
|
durations = _context7.sent;
|
|
437
437
|
return _context7.abrupt("return", durations.reduce(function (acc, curr, i) {
|
|
438
438
|
if (curr !== -1) {
|
|
@@ -441,7 +441,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
441
441
|
}
|
|
442
442
|
return acc;
|
|
443
443
|
}, {}));
|
|
444
|
-
case
|
|
444
|
+
case 2:
|
|
445
445
|
case "end":
|
|
446
446
|
return _context7.stop();
|
|
447
447
|
}
|
|
@@ -548,7 +548,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
548
548
|
var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url, collection, traceContext, anonymizeFilename) {
|
|
549
549
|
var _this3 = this;
|
|
550
550
|
var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
|
|
551
|
-
return _regenerator.default.wrap(function
|
|
551
|
+
return _regenerator.default.wrap(function (_context0) {
|
|
552
552
|
while (1) switch (_context0.prev = _context0.next) {
|
|
553
553
|
case 0:
|
|
554
554
|
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
|
|
@@ -562,12 +562,12 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
562
562
|
preview = new Promise( /*#__PURE__*/function () {
|
|
563
563
|
var _ref0 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(resolve, reject) {
|
|
564
564
|
var blob;
|
|
565
|
-
return _regenerator.default.wrap(function
|
|
565
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
566
566
|
while (1) switch (_context8.prev = _context8.next) {
|
|
567
567
|
case 0:
|
|
568
|
-
_context8.next =
|
|
568
|
+
_context8.next = 1;
|
|
569
569
|
return deferredBlob;
|
|
570
|
-
case
|
|
570
|
+
case 1:
|
|
571
571
|
blob = _context8.sent;
|
|
572
572
|
if (!blob) {
|
|
573
573
|
reject('Could not fetch the blob');
|
|
@@ -576,7 +576,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
576
576
|
value: blob,
|
|
577
577
|
origin: 'remote'
|
|
578
578
|
});
|
|
579
|
-
case
|
|
579
|
+
case 2:
|
|
580
580
|
case "end":
|
|
581
581
|
return _context8.stop();
|
|
582
582
|
}
|
|
@@ -603,20 +603,20 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
603
603
|
this.setFileState(id, fileState);
|
|
604
604
|
return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
605
605
|
var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(resolve, reject) {
|
|
606
|
-
var blob, type, size, file, mediaType, dimensions;
|
|
607
|
-
return _regenerator.default.wrap(function
|
|
606
|
+
var blob, type, size, file, mediaType, dimensions, _t4;
|
|
607
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
608
608
|
while (1) switch (_context9.prev = _context9.next) {
|
|
609
609
|
case 0:
|
|
610
|
-
_context9.next =
|
|
610
|
+
_context9.next = 1;
|
|
611
611
|
return deferredBlob;
|
|
612
|
-
case
|
|
612
|
+
case 1:
|
|
613
613
|
blob = _context9.sent;
|
|
614
614
|
if (blob) {
|
|
615
|
-
_context9.next =
|
|
615
|
+
_context9.next = 2;
|
|
616
616
|
break;
|
|
617
617
|
}
|
|
618
618
|
return _context9.abrupt("return", reject('Could not download remote file'));
|
|
619
|
-
case
|
|
619
|
+
case 2:
|
|
620
620
|
type = blob.type, size = blob.size;
|
|
621
621
|
file = {
|
|
622
622
|
content: blob,
|
|
@@ -638,35 +638,35 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
638
638
|
});
|
|
639
639
|
// we don't want to wait for the file to be upload
|
|
640
640
|
_this3.upload(file, undefined, uploadableFileUpfrontIds, traceContext);
|
|
641
|
-
_context9.prev =
|
|
642
|
-
_context9.next =
|
|
641
|
+
_context9.prev = 3;
|
|
642
|
+
_context9.next = 4;
|
|
643
643
|
return (0, _getDimensionsFromBlob.getDimensionsFromBlob)(mediaType, blob);
|
|
644
|
-
case
|
|
644
|
+
case 4:
|
|
645
645
|
dimensions = _context9.sent;
|
|
646
|
-
_context9.next =
|
|
646
|
+
_context9.next = 6;
|
|
647
647
|
break;
|
|
648
|
-
case
|
|
649
|
-
_context9.prev =
|
|
650
|
-
|
|
651
|
-
reject(
|
|
648
|
+
case 5:
|
|
649
|
+
_context9.prev = 5;
|
|
650
|
+
_t4 = _context9["catch"](3);
|
|
651
|
+
reject(_t4);
|
|
652
652
|
return _context9.abrupt("return");
|
|
653
|
-
case
|
|
653
|
+
case 6:
|
|
654
654
|
resolve({
|
|
655
655
|
dimensions: dimensions,
|
|
656
656
|
mimeType: type,
|
|
657
657
|
uploadableFileUpfrontIds: uploadableFileUpfrontIds
|
|
658
658
|
});
|
|
659
|
-
case
|
|
659
|
+
case 7:
|
|
660
660
|
case "end":
|
|
661
661
|
return _context9.stop();
|
|
662
662
|
}
|
|
663
|
-
}, _callee9, null, [[
|
|
663
|
+
}, _callee9, null, [[3, 5]]);
|
|
664
664
|
}));
|
|
665
665
|
return function (_x20, _x21) {
|
|
666
666
|
return _ref1.apply(this, arguments);
|
|
667
667
|
};
|
|
668
668
|
}()));
|
|
669
|
-
case
|
|
669
|
+
case 1:
|
|
670
670
|
case "end":
|
|
671
671
|
return _context0.stop();
|
|
672
672
|
}
|
|
@@ -745,15 +745,15 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
745
745
|
traceContext,
|
|
746
746
|
url,
|
|
747
747
|
_args1 = arguments;
|
|
748
|
-
return _regenerator.default.wrap(function
|
|
748
|
+
return _regenerator.default.wrap(function (_context1) {
|
|
749
749
|
while (1) switch (_context1.prev = _context1.next) {
|
|
750
750
|
case 0:
|
|
751
751
|
name = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'download';
|
|
752
752
|
collectionName = _args1.length > 2 ? _args1[2] : undefined;
|
|
753
753
|
traceContext = _args1.length > 3 ? _args1[3] : undefined;
|
|
754
|
-
_context1.next =
|
|
754
|
+
_context1.next = 1;
|
|
755
755
|
return this.mediaApi.getFileBinaryURL(id, collectionName);
|
|
756
|
-
case
|
|
756
|
+
case 1:
|
|
757
757
|
url = _context1.sent;
|
|
758
758
|
(0, _downloadUrl.downloadUrl)(url, {
|
|
759
759
|
name: name
|
|
@@ -764,11 +764,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
764
764
|
viewingLevel: 'download'
|
|
765
765
|
});
|
|
766
766
|
// Test the download after initiated the Browser process to catch any potential errors.
|
|
767
|
-
_context1.next =
|
|
767
|
+
_context1.next = 2;
|
|
768
768
|
return this.mediaApi.testUrl(url, {
|
|
769
769
|
traceContext: traceContext
|
|
770
770
|
});
|
|
771
|
-
case
|
|
771
|
+
case 2:
|
|
772
772
|
case "end":
|
|
773
773
|
return _context1.stop();
|
|
774
774
|
}
|
|
@@ -784,26 +784,26 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
784
784
|
value: function () {
|
|
785
785
|
var _registerCopyIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, collectionName) {
|
|
786
786
|
var auth, key, error;
|
|
787
|
-
return _regenerator.default.wrap(function
|
|
787
|
+
return _regenerator.default.wrap(function (_context10) {
|
|
788
788
|
while (1) switch (_context10.prev = _context10.next) {
|
|
789
789
|
case 0:
|
|
790
|
-
_context10.next =
|
|
790
|
+
_context10.next = 1;
|
|
791
791
|
return this.mediaApi.resolveAuth({
|
|
792
792
|
collectionName: collectionName
|
|
793
793
|
});
|
|
794
|
-
case
|
|
794
|
+
case 1:
|
|
795
795
|
auth = _context10.sent;
|
|
796
796
|
key = {
|
|
797
797
|
id: id,
|
|
798
798
|
collectionName: collectionName,
|
|
799
799
|
resolvedAuth: auth
|
|
800
800
|
};
|
|
801
|
-
_context10.next =
|
|
801
|
+
_context10.next = 2;
|
|
802
802
|
return this.copyIntentRegisterationBatcher.load(key);
|
|
803
|
-
case
|
|
803
|
+
case 2:
|
|
804
804
|
error = _context10.sent;
|
|
805
805
|
if (!error) {
|
|
806
|
-
_context10.next =
|
|
806
|
+
_context10.next = 3;
|
|
807
807
|
break;
|
|
808
808
|
}
|
|
809
809
|
// if the error is retryable then it should not be cached
|
|
@@ -811,7 +811,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
811
811
|
this.copyIntentRegisterationBatcher.clear(key);
|
|
812
812
|
}
|
|
813
813
|
throw error;
|
|
814
|
-
case
|
|
814
|
+
case 3:
|
|
815
815
|
case "end":
|
|
816
816
|
return _context10.stop();
|
|
817
817
|
}
|
|
@@ -826,8 +826,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
826
826
|
key: "copyFileWithToken",
|
|
827
827
|
value: function () {
|
|
828
828
|
var _copyFileWithToken = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(source, destination, traceContext) {
|
|
829
|
-
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data;
|
|
830
|
-
return _regenerator.default.wrap(function
|
|
829
|
+
var authProvider, sourceCollection, id, destinationAuthProvider, destinationCollectionName, replaceFileId, occurrenceKey, mediaStore, owner, body, params, _yield$mediaStore$cop, data, _t5;
|
|
830
|
+
return _regenerator.default.wrap(function (_context11) {
|
|
831
831
|
while (1) switch (_context11.prev = _context11.next) {
|
|
832
832
|
case 0:
|
|
833
833
|
authProvider = source.authProvider, sourceCollection = source.collection, id = source.id;
|
|
@@ -835,14 +835,13 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
835
835
|
mediaStore = destination.mediaStore || new _mediaStore.MediaStore({
|
|
836
836
|
authProvider: destinationAuthProvider
|
|
837
837
|
});
|
|
838
|
-
|
|
839
|
-
_context11.next =
|
|
838
|
+
_t5 = _mediaCore.authToOwner;
|
|
839
|
+
_context11.next = 1;
|
|
840
840
|
return authProvider({
|
|
841
841
|
collectionName: sourceCollection
|
|
842
842
|
});
|
|
843
|
-
case
|
|
844
|
-
|
|
845
|
-
owner = (0, _context11.t0)(_context11.t1);
|
|
843
|
+
case 1:
|
|
844
|
+
owner = _t5(_context11.sent);
|
|
846
845
|
body = {
|
|
847
846
|
sourceFile: {
|
|
848
847
|
id: id,
|
|
@@ -855,13 +854,13 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
855
854
|
replaceFileId: replaceFileId,
|
|
856
855
|
occurrenceKey: occurrenceKey
|
|
857
856
|
};
|
|
858
|
-
_context11.next =
|
|
857
|
+
_context11.next = 2;
|
|
859
858
|
return mediaStore.copyFileWithToken(body, params, traceContext);
|
|
860
|
-
case
|
|
859
|
+
case 2:
|
|
861
860
|
_yield$mediaStore$cop = _context11.sent;
|
|
862
861
|
data = _yield$mediaStore$cop.data;
|
|
863
862
|
return _context11.abrupt("return", data);
|
|
864
|
-
case
|
|
863
|
+
case 3:
|
|
865
864
|
case "end":
|
|
866
865
|
return _context11.stop();
|
|
867
866
|
}
|
|
@@ -877,20 +876,20 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
877
876
|
value: function () {
|
|
878
877
|
var _copyFileWithIntent = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(source, destination, traceContext) {
|
|
879
878
|
var res, data;
|
|
880
|
-
return _regenerator.default.wrap(function
|
|
879
|
+
return _regenerator.default.wrap(function (_context12) {
|
|
881
880
|
while (1) switch (_context12.prev = _context12.next) {
|
|
882
881
|
case 0:
|
|
883
|
-
_context12.next =
|
|
882
|
+
_context12.next = 1;
|
|
884
883
|
return this.mediaApi.copyFile(source.id, {
|
|
885
884
|
sourceCollection: source.collection,
|
|
886
885
|
collection: destination.collection,
|
|
887
886
|
replaceFileId: destination.replaceFileId
|
|
888
887
|
}, traceContext, source.clientId);
|
|
889
|
-
case
|
|
888
|
+
case 1:
|
|
890
889
|
res = _context12.sent;
|
|
891
890
|
data = res.data;
|
|
892
891
|
return _context12.abrupt("return", data);
|
|
893
|
-
case
|
|
892
|
+
case 2:
|
|
894
893
|
case "end":
|
|
895
894
|
return _context12.stop();
|
|
896
895
|
}
|
|
@@ -931,8 +930,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
931
930
|
replaceFileState,
|
|
932
931
|
key,
|
|
933
932
|
errorFileState,
|
|
934
|
-
_args13 = arguments
|
|
935
|
-
|
|
933
|
+
_args13 = arguments,
|
|
934
|
+
_t6,
|
|
935
|
+
_t7;
|
|
936
|
+
return _regenerator.default.wrap(function (_context13) {
|
|
936
937
|
while (1) switch (_context13.prev = _context13.next) {
|
|
937
938
|
case 0:
|
|
938
939
|
options = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : {};
|
|
@@ -941,23 +942,23 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
941
942
|
destinationCollectionName = destination.collection, replaceFileId = destination.replaceFileId, occurrenceKey = destination.occurrenceKey;
|
|
942
943
|
preview = options.preview, mimeType = options.mimeType;
|
|
943
944
|
cache = (0, _fileStreamsCache.getFileStreamsCache)();
|
|
944
|
-
_context13.prev =
|
|
945
|
+
_context13.prev = 1;
|
|
945
946
|
if (!(isCopySourceFileWithToken(source) && isCopyDestinationWithToken(destination))) {
|
|
946
|
-
_context13.next =
|
|
947
|
+
_context13.next = 3;
|
|
947
948
|
break;
|
|
948
949
|
}
|
|
949
|
-
_context13.next =
|
|
950
|
+
_context13.next = 2;
|
|
950
951
|
return this.copyFileWithToken(source, destination, traceContext);
|
|
951
|
-
case
|
|
952
|
+
case 2:
|
|
952
953
|
copiedFile = _context13.sent;
|
|
953
|
-
_context13.next =
|
|
954
|
+
_context13.next = 5;
|
|
954
955
|
break;
|
|
955
|
-
case
|
|
956
|
-
_context13.next =
|
|
956
|
+
case 3:
|
|
957
|
+
_context13.next = 4;
|
|
957
958
|
return this.copyFileWithIntent(source, destination, traceContext);
|
|
958
|
-
case
|
|
959
|
+
case 4:
|
|
959
960
|
copiedFile = _context13.sent;
|
|
960
|
-
case
|
|
961
|
+
case 5:
|
|
961
962
|
// if we were passed a "mimeType", we propagate it into copiedFileWithMimeType
|
|
962
963
|
copiedFileWithMimeType = _objectSpread(_objectSpread({}, copiedFile), mimeType ? {
|
|
963
964
|
mimeType: mimeType
|
|
@@ -973,21 +974,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
973
974
|
previewOverride = !(0, _fileState2.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
974
975
|
preview: preview
|
|
975
976
|
} : {};
|
|
976
|
-
|
|
977
|
+
_t6 = !(0, _fileState2.isFinalFileState)(copiedFileState) &&
|
|
977
978
|
// mimeType should always be returned by "copyFileWithToken"
|
|
978
979
|
// but in case it's not, we don't want to penalize "copyFile"
|
|
979
980
|
copiedMimeType;
|
|
980
|
-
if (!
|
|
981
|
-
_context13.next =
|
|
981
|
+
if (!_t6) {
|
|
982
|
+
_context13.next = 7;
|
|
982
983
|
break;
|
|
983
984
|
}
|
|
984
|
-
_context13.next =
|
|
985
|
+
_context13.next = 6;
|
|
985
986
|
return (0, _shouldFetchRemoteFileStates.shouldFetchRemoteFileStates)(mediaType, copiedMimeType, preview);
|
|
986
|
-
case
|
|
987
|
-
|
|
988
|
-
case
|
|
989
|
-
if (!
|
|
990
|
-
_context13.next =
|
|
987
|
+
case 6:
|
|
988
|
+
_t6 = _context13.sent;
|
|
989
|
+
case 7:
|
|
990
|
+
if (!_t6) {
|
|
991
|
+
_context13.next = 8;
|
|
991
992
|
break;
|
|
992
993
|
}
|
|
993
994
|
fileState = _objectSpread(_objectSpread(_objectSpread({}, copiedFileState), (0, _overrideMediaTypeIfUnknown.overrideMediaTypeIfUnknown)(copiedFileState, mediaType)), previewOverride);
|
|
@@ -1008,22 +1009,22 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
1008
1009
|
return subject.complete();
|
|
1009
1010
|
}
|
|
1010
1011
|
});
|
|
1011
|
-
_context13.next =
|
|
1012
|
+
_context13.next = 9;
|
|
1012
1013
|
break;
|
|
1013
|
-
case
|
|
1014
|
+
case 8:
|
|
1014
1015
|
if (!(0, _fileState2.isProcessingFileState)(copiedFileState)) {
|
|
1015
1016
|
_fileState = _objectSpread(_objectSpread({}, copiedFileState), !(0, _fileState2.isErrorFileState)(copiedFileState) && previewOverride);
|
|
1016
1017
|
subject.next(_fileState);
|
|
1017
1018
|
this.setFileState(copiedId, _fileState);
|
|
1018
1019
|
}
|
|
1019
|
-
case
|
|
1020
|
+
case 9:
|
|
1020
1021
|
if (!cache.has(copiedId)) {
|
|
1021
1022
|
(0, _fileStreamsCache.getFileStreamsCache)().set(copiedId, subject);
|
|
1022
1023
|
}
|
|
1023
1024
|
return _context13.abrupt("return", copiedFile);
|
|
1024
|
-
case
|
|
1025
|
-
_context13.prev =
|
|
1026
|
-
|
|
1025
|
+
case 10:
|
|
1026
|
+
_context13.prev = 10;
|
|
1027
|
+
_t7 = _context13["catch"](1);
|
|
1027
1028
|
if (processingSubscription) {
|
|
1028
1029
|
processingSubscription.unsubscribe();
|
|
1029
1030
|
}
|
|
@@ -1031,21 +1032,21 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
1031
1032
|
_fileCache = cache.get(replaceFileId);
|
|
1032
1033
|
replaceFileState = this.store.getState().files[replaceFileId];
|
|
1033
1034
|
if (_fileCache) {
|
|
1034
|
-
_fileCache.error(
|
|
1035
|
+
_fileCache.error(_t7);
|
|
1035
1036
|
} else {
|
|
1036
1037
|
// Create a new subject with the error state for new subscriptions
|
|
1037
|
-
cache.set(id, (0, _createMediaSubject.createMediaSubject)(
|
|
1038
|
+
cache.set(id, (0, _createMediaSubject.createMediaSubject)(_t7));
|
|
1038
1039
|
}
|
|
1039
1040
|
key = replaceFileState ? replaceFileId : id;
|
|
1040
|
-
errorFileState = this.getErrorFileState(
|
|
1041
|
+
errorFileState = this.getErrorFileState(_t7, id, occurrenceKey);
|
|
1041
1042
|
this.setFileState(key, errorFileState);
|
|
1042
1043
|
}
|
|
1043
|
-
throw
|
|
1044
|
-
case
|
|
1044
|
+
throw _t7;
|
|
1045
|
+
case 11:
|
|
1045
1046
|
case "end":
|
|
1046
1047
|
return _context13.stop();
|
|
1047
1048
|
}
|
|
1048
|
-
}, _callee13, this, [[
|
|
1049
|
+
}, _callee13, this, [[1, 10]]);
|
|
1049
1050
|
}));
|
|
1050
1051
|
function copyFile(_x31, _x32) {
|
|
1051
1052
|
return _copyFile.apply(this, arguments);
|