@atlaskit/media-client 20.2.1 → 21.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/cjs/client/file-fetcher/error.js +4 -4
- package/dist/cjs/client/file-fetcher/index.js +275 -287
- package/dist/cjs/client/media-client.js +48 -34
- package/dist/cjs/client/media-store/index.js +367 -314
- package/dist/cjs/client/media-store/resolveAuth.js +30 -32
- package/dist/cjs/client/stargate-client.js +14 -16
- package/dist/cjs/index.js +6 -13
- package/dist/cjs/models/media.js +8 -9
- package/dist/cjs/uploader/error.js +4 -4
- package/dist/cjs/uploader/index.js +88 -96
- package/dist/cjs/utils/convertBase64ToBlob.js +2 -2
- package/dist/cjs/utils/createFileDataLoader.js +67 -70
- package/dist/cjs/utils/getDimensionsFromBlob.js +23 -25
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/cjs/utils/hashing/hasherCreator.js +32 -34
- package/dist/cjs/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/cjs/utils/mobileUpload/error.js +4 -4
- package/dist/cjs/utils/mobileUpload/helpers.js +41 -43
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/cjs/utils/parseJwt.js +52 -0
- package/dist/cjs/utils/polling/index.js +40 -42
- package/dist/cjs/utils/request/errors.js +9 -9
- package/dist/cjs/utils/request/helpers.js +143 -155
- package/dist/cjs/utils/request/index.js +24 -26
- package/dist/cjs/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +1 -3
- package/dist/es2019/client/media-client.js +3 -2
- package/dist/es2019/client/media-store/index.js +58 -15
- package/dist/es2019/index.js +2 -3
- package/dist/es2019/models/media.js +6 -4
- package/dist/es2019/uploader/index.js +3 -0
- package/dist/es2019/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/es2019/utils/mediaSubscribable/toPromise.js +10 -12
- package/dist/es2019/utils/parseJwt.js +46 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/error.js +4 -4
- package/dist/esm/client/file-fetcher/index.js +273 -286
- package/dist/esm/client/media-client.js +46 -32
- package/dist/esm/client/media-store/index.js +367 -314
- package/dist/esm/client/media-store/resolveAuth.js +30 -32
- package/dist/esm/client/stargate-client.js +14 -16
- package/dist/esm/index.js +2 -3
- package/dist/esm/models/media.js +6 -6
- package/dist/esm/uploader/error.js +4 -4
- package/dist/esm/uploader/index.js +89 -96
- package/dist/esm/utils/convertBase64ToBlob.js +2 -2
- package/dist/esm/utils/createFileDataLoader.js +65 -69
- package/dist/esm/utils/getDimensionsFromBlob.js +23 -25
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +24 -26
- package/dist/esm/utils/hashing/hasherCreator.js +28 -30
- package/dist/esm/utils/mediaSubscribable/fromObservable.js +2 -2
- package/dist/esm/utils/mobileUpload/error.js +4 -4
- package/dist/esm/utils/mobileUpload/helpers.js +41 -43
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +14 -16
- package/dist/esm/utils/parseJwt.js +46 -0
- package/dist/esm/utils/polling/index.js +40 -42
- package/dist/esm/utils/request/errors.js +9 -9
- package/dist/esm/utils/request/helpers.js +143 -155
- package/dist/esm/utils/request/index.js +24 -26
- package/dist/esm/utils/shouldFetchRemoteFileStates.js +39 -41
- package/dist/esm/version.json +1 -1
- package/dist/types/client/__mocks__/media-client.d.ts +0 -2
- package/dist/types/client/file-fetcher/index.d.ts +4 -4
- package/dist/types/client/media-client.d.ts +1 -2
- package/dist/types/client/media-store/index.d.ts +17 -13
- package/dist/types/index.d.ts +4 -6
- package/dist/types/models/file-state.d.ts +2 -2
- package/dist/types/models/media.d.ts +1 -21
- package/dist/types/utils/createFileDataLoader.d.ts +2 -2
- package/dist/types/utils/createMediaSubject.d.ts +2 -2
- package/dist/types/utils/detectEmptyFile.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +3 -3
- package/dist/types/utils/mediaSubscribable/toPromise.d.ts +2 -2
- package/dist/types/utils/mediaSubscribable/types.d.ts +9 -8
- package/dist/types/utils/parseJwt.d.ts +1 -0
- package/package.json +2 -2
- package/report.api.md +77 -126
- package/dist/cjs/client/collection-fetcher.js +0 -98
- package/dist/cjs/models/media-subscribable.js +0 -5
- package/dist/cjs/utils/deprecatedEndpointError.js +0 -43
- package/dist/es2019/client/collection-fetcher.js +0 -38
- package/dist/es2019/models/media-subscribable.js +0 -1
- package/dist/es2019/utils/deprecatedEndpointError.js +0 -20
- package/dist/esm/client/collection-fetcher.js +0 -89
- package/dist/esm/models/media-subscribable.js +0 -1
- package/dist/esm/utils/deprecatedEndpointError.js +0 -34
- package/dist/types/client/collection-fetcher.d.ts +0 -42
- package/dist/types/models/media-subscribable.d.ts +0 -3
- package/dist/types/utils/deprecatedEndpointError.d.ts +0 -16
|
@@ -9,39 +9,37 @@ export var resolveAuth = /*#__PURE__*/function () {
|
|
|
9
9
|
auth,
|
|
10
10
|
_args = arguments;
|
|
11
11
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
-
while (1) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
authProviderTimeout = _args.length > 2 && _args[2] !== undefined ? _args[2] : DEFAULT_AUTH_PROVIDER_TIMEOUT;
|
|
15
|
+
_context.prev = 1;
|
|
16
|
+
_context.next = 4;
|
|
17
|
+
return Promise.race([authProvider(authContext), rejectTimeout(authProviderTimeout, new MediaStoreError('authProviderTimedOut'))]);
|
|
18
|
+
case 4:
|
|
19
|
+
auth = _context.sent;
|
|
20
|
+
_context.next = 12;
|
|
21
|
+
break;
|
|
22
|
+
case 7:
|
|
23
|
+
_context.prev = 7;
|
|
24
|
+
_context.t0 = _context["catch"](1);
|
|
25
|
+
if (!(_context.t0 instanceof MediaStoreError)) {
|
|
26
|
+
_context.next = 11;
|
|
22
27
|
break;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new MediaStoreError('emptyAuth');
|
|
39
|
-
case 14:
|
|
40
|
-
return _context.abrupt("return", auth);
|
|
41
|
-
case 15:
|
|
42
|
-
case "end":
|
|
43
|
-
return _context.stop();
|
|
44
|
-
}
|
|
28
|
+
}
|
|
29
|
+
throw _context.t0;
|
|
30
|
+
case 11:
|
|
31
|
+
throw new MediaStoreError('failedAuthProvider', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
32
|
+
case 12:
|
|
33
|
+
if (auth) {
|
|
34
|
+
_context.next = 14;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
throw new MediaStoreError('emptyAuth');
|
|
38
|
+
case 14:
|
|
39
|
+
return _context.abrupt("return", auth);
|
|
40
|
+
case 15:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context.stop();
|
|
45
43
|
}
|
|
46
44
|
}, _callee, null, [[1, 7]]);
|
|
47
45
|
}));
|
|
@@ -12,22 +12,20 @@ export var StargateClient = /*#__PURE__*/function () {
|
|
|
12
12
|
value: function () {
|
|
13
13
|
var _fetchToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(clientId) {
|
|
14
14
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
|
-
while (1) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return _context.stop();
|
|
30
|
-
}
|
|
15
|
+
while (1) switch (_context.prev = _context.next) {
|
|
16
|
+
case 0:
|
|
17
|
+
_context.next = 2;
|
|
18
|
+
return fetch("".concat(this.baseUrl, "/media/auth/smartedge"), {
|
|
19
|
+
credentials: 'include',
|
|
20
|
+
headers: {
|
|
21
|
+
'x-client-id': clientId
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
case 2:
|
|
25
|
+
return _context.abrupt("return", _context.sent.json());
|
|
26
|
+
case 3:
|
|
27
|
+
case "end":
|
|
28
|
+
return _context.stop();
|
|
31
29
|
}
|
|
32
30
|
}, _callee, this);
|
|
33
31
|
}));
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { MediaStore, MediaStoreError, isMediaStoreError, getMediaEnvironment, getMediaRegion } from './client/media-store';
|
|
2
2
|
export { UploadController } from './upload-controller';
|
|
3
|
-
export { isPreviewableType
|
|
3
|
+
export { isPreviewableType } from './models/media';
|
|
4
4
|
export { getArtifactUrl } from './models/artifacts';
|
|
5
5
|
export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
|
|
6
6
|
export { isUploadingFileState, isProcessingFileState, isProcessedFileState, isErrorFileState, isPreviewableFileState, isFinalFileState, isImageRepresentationReady, mapMediaFileToFileState, mapMediaItemToFileState } from './models/file-state';
|
|
@@ -11,7 +11,6 @@ export { PollingFunction } from './utils/polling';
|
|
|
11
11
|
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
12
12
|
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
13
13
|
export { FileFetcherImpl, FileFetcherError, isFileFetcherError } from './client/file-fetcher';
|
|
14
|
-
export { CollectionFetcher } from './client/collection-fetcher';
|
|
15
14
|
export { MediaClient } from './client/media-client';
|
|
16
15
|
export { StargateClient } from './client/stargate-client';
|
|
17
16
|
export { isImageRemote } from './utils/isImageRemote';
|
|
@@ -23,7 +22,7 @@ export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier } fr
|
|
|
23
22
|
export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
|
|
24
23
|
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
25
24
|
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString } from './utils/url';
|
|
26
|
-
export { createMediaSubscribable } from './utils/mediaSubscribable';
|
|
25
|
+
export { createMediaSubscribable, fromObservable } from './utils/mediaSubscribable';
|
|
27
26
|
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
|
|
28
27
|
|
|
29
28
|
// TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
|
package/dist/esm/models/media.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
2
|
+
|
|
3
|
+
// Warning! You can't add new media file processing status!
|
|
4
|
+
// See packages/media/media-core/src/__tests__/cache-backward-compatibility.spec.ts
|
|
2
5
|
export var isPreviewableType = function isPreviewableType(type, featureFlags) {
|
|
3
6
|
// in classic experience, only audio/video/image are previewable
|
|
4
7
|
var defaultPreviewableTypes = ['audio', 'video', 'image'];
|
|
@@ -9,12 +12,9 @@ export var isPreviewableType = function isPreviewableType(type, featureFlags) {
|
|
|
9
12
|
}
|
|
10
13
|
return defaultPreviewableTypes.indexOf(type) > -1;
|
|
11
14
|
};
|
|
12
|
-
export var
|
|
13
|
-
return !!mediaCollectionItem['mediaType'] && !!mediaCollectionItem['mimeType'] && !!mediaCollectionItem['processingStatus'];
|
|
14
|
-
};
|
|
15
|
-
export var DATA_UNIT;
|
|
16
|
-
(function (DATA_UNIT) {
|
|
15
|
+
export var DATA_UNIT = /*#__PURE__*/function (DATA_UNIT) {
|
|
17
16
|
DATA_UNIT[DATA_UNIT["MB"] = 1048576] = "MB";
|
|
18
17
|
DATA_UNIT[DATA_UNIT["GB"] = 1073741824] = "GB";
|
|
19
18
|
DATA_UNIT[DATA_UNIT["TB"] = 1099511627776] = "TB";
|
|
20
|
-
|
|
19
|
+
return DATA_UNIT;
|
|
20
|
+
}({});
|
|
@@ -23,10 +23,10 @@ export var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
23
23
|
get: function get() {
|
|
24
24
|
var reason = this.reason,
|
|
25
25
|
id = this.id,
|
|
26
|
-
_this$metadata = this.metadata
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
occurrenceKey = _this$
|
|
26
|
+
_this$metadata = this.metadata,
|
|
27
|
+
_this$metadata2 = _this$metadata === void 0 ? {} : _this$metadata,
|
|
28
|
+
collectionName = _this$metadata2.collectionName,
|
|
29
|
+
occurrenceKey = _this$metadata2.occurrenceKey;
|
|
30
30
|
return {
|
|
31
31
|
reason: reason,
|
|
32
32
|
id: id,
|
|
@@ -7,22 +7,23 @@ import { createHasher } from '../utils/hashing/hasherCreator';
|
|
|
7
7
|
import { UploaderError } from './error';
|
|
8
8
|
import { CHUNK_SIZE, PROCESSING_BATCH_SIZE } from '../constants';
|
|
9
9
|
import { calculateChunkSize, fileSizeError } from './calculateChunkSize';
|
|
10
|
+
|
|
11
|
+
// TODO: Allow to pass multiple files
|
|
12
|
+
|
|
10
13
|
var hashingFunction = /*#__PURE__*/function () {
|
|
11
14
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
|
|
12
15
|
var hasher;
|
|
13
16
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
14
|
-
while (1) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return _context.stop();
|
|
25
|
-
}
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
_context.next = 2;
|
|
20
|
+
return createHasher();
|
|
21
|
+
case 2:
|
|
22
|
+
hasher = _context.sent;
|
|
23
|
+
return _context.abrupt("return", hasher.hash(blob));
|
|
24
|
+
case 4:
|
|
25
|
+
case "end":
|
|
26
|
+
return _context.stop();
|
|
26
27
|
}
|
|
27
28
|
}, _callee);
|
|
28
29
|
}));
|
|
@@ -35,29 +36,27 @@ var createProbingFunction = function createProbingFunction(store, deferredUpload
|
|
|
35
36
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunks) {
|
|
36
37
|
var response, results;
|
|
37
38
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
38
|
-
while (1) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return _context2.stop();
|
|
60
|
-
}
|
|
39
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context2.t0 = store;
|
|
42
|
+
_context2.t1 = hashedChunks(chunks);
|
|
43
|
+
_context2.next = 4;
|
|
44
|
+
return deferredUploadId;
|
|
45
|
+
case 4:
|
|
46
|
+
_context2.t2 = _context2.sent;
|
|
47
|
+
_context2.t3 = collectionName;
|
|
48
|
+
_context2.t4 = traceContext;
|
|
49
|
+
_context2.next = 9;
|
|
50
|
+
return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t2, _context2.t3, _context2.t4);
|
|
51
|
+
case 9:
|
|
52
|
+
response = _context2.sent;
|
|
53
|
+
results = response.data.results;
|
|
54
|
+
return _context2.abrupt("return", Object.values(results).map(function (result) {
|
|
55
|
+
return result.exists;
|
|
56
|
+
}));
|
|
57
|
+
case 12:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context2.stop();
|
|
61
60
|
}
|
|
62
61
|
}, _callee2);
|
|
63
62
|
}));
|
|
@@ -70,27 +69,25 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
|
|
|
70
69
|
return /*#__PURE__*/function () {
|
|
71
70
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunk) {
|
|
72
71
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
73
|
-
while (1) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return _context3.stop();
|
|
93
|
-
}
|
|
72
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
_context3.t0 = store;
|
|
75
|
+
_context3.t1 = chunk.hash;
|
|
76
|
+
_context3.t2 = chunk.blob;
|
|
77
|
+
_context3.next = 5;
|
|
78
|
+
return deferredUploadId;
|
|
79
|
+
case 5:
|
|
80
|
+
_context3.t3 = _context3.sent;
|
|
81
|
+
_context3.t4 = chunk.partNumber;
|
|
82
|
+
_context3.t5 = collectionName;
|
|
83
|
+
_context3.t6 = traceContext;
|
|
84
|
+
_context3.next = 11;
|
|
85
|
+
return _context3.t0.uploadChunk.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5, _context3.t6);
|
|
86
|
+
case 11:
|
|
87
|
+
return _context3.abrupt("return", _context3.sent);
|
|
88
|
+
case 12:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context3.stop();
|
|
94
91
|
}
|
|
95
92
|
}, _callee3);
|
|
96
93
|
}));
|
|
@@ -104,28 +101,26 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
|
|
|
104
101
|
return /*#__PURE__*/function () {
|
|
105
102
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(chunks) {
|
|
106
103
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
107
|
-
while (1) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return _context4.stop();
|
|
128
|
-
}
|
|
104
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
_context4.t0 = store;
|
|
107
|
+
_context4.next = 3;
|
|
108
|
+
return deferredUploadId;
|
|
109
|
+
case 3:
|
|
110
|
+
_context4.t1 = _context4.sent;
|
|
111
|
+
_context4.t2 = {
|
|
112
|
+
chunks: hashedChunks(chunks),
|
|
113
|
+
offset: offset
|
|
114
|
+
};
|
|
115
|
+
_context4.t3 = collection;
|
|
116
|
+
_context4.t4 = traceContext;
|
|
117
|
+
_context4.next = 9;
|
|
118
|
+
return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3, _context4.t4);
|
|
119
|
+
case 9:
|
|
120
|
+
offset += chunks.length;
|
|
121
|
+
case 10:
|
|
122
|
+
case "end":
|
|
123
|
+
return _context4.stop();
|
|
129
124
|
}
|
|
130
125
|
}, _callee4);
|
|
131
126
|
}));
|
|
@@ -138,24 +133,22 @@ var createFileFromUpload = /*#__PURE__*/function () {
|
|
|
138
133
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId, traceContext) {
|
|
139
134
|
var collection, name, mimeType, id, occurrenceKey;
|
|
140
135
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
141
|
-
while (1) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return _context5.stop();
|
|
158
|
-
}
|
|
136
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
collection = file.collection, name = file.name, mimeType = file.mimeType;
|
|
139
|
+
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
140
|
+
return _context5.abrupt("return", store.createFileFromUpload({
|
|
141
|
+
uploadId: uploadId,
|
|
142
|
+
name: name,
|
|
143
|
+
mimeType: mimeType
|
|
144
|
+
}, {
|
|
145
|
+
occurrenceKey: occurrenceKey,
|
|
146
|
+
collection: collection,
|
|
147
|
+
replaceFileId: id
|
|
148
|
+
}, traceContext));
|
|
149
|
+
case 3:
|
|
150
|
+
case "end":
|
|
151
|
+
return _context5.stop();
|
|
159
152
|
}
|
|
160
153
|
}, _callee5);
|
|
161
154
|
}));
|
|
@@ -3,7 +3,7 @@ export var convertBase64ToBlob = function convertBase64ToBlob(base64) {
|
|
|
3
3
|
var base64Data = base64.split(',')[1];
|
|
4
4
|
var byteCharacters = atob(base64Data);
|
|
5
5
|
var byteArrays = [];
|
|
6
|
-
var _loop = function _loop(
|
|
6
|
+
var _loop = function _loop() {
|
|
7
7
|
var slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
8
8
|
var byteNumbers = slice.split('').map(function (_, i) {
|
|
9
9
|
return slice.charCodeAt(i);
|
|
@@ -12,7 +12,7 @@ export var convertBase64ToBlob = function convertBase64ToBlob(base64) {
|
|
|
12
12
|
byteArrays.push(byteArray);
|
|
13
13
|
};
|
|
14
14
|
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
15
|
-
_loop(
|
|
15
|
+
_loop();
|
|
16
16
|
}
|
|
17
17
|
return new Blob(byteArrays, {
|
|
18
18
|
type: 'image/jpeg'
|
|
@@ -47,76 +47,72 @@ export function createBatchLoadingFunc(mediaStore) {
|
|
|
47
47
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(keys) {
|
|
48
48
|
var nonCollectionName, fileIdsByCollection, items;
|
|
49
49
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
50
|
-
while (1) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var fileIds = acc[collectionName] || [];
|
|
50
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
nonCollectionName = '__media-single-file-collection__';
|
|
53
|
+
fileIdsByCollection = keys.reduce(function (acc, key) {
|
|
54
|
+
var collectionName = key.collectionName || nonCollectionName;
|
|
55
|
+
var fileIds = acc[collectionName] || [];
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
case "end":
|
|
118
|
-
return _context2.stop();
|
|
119
|
-
}
|
|
57
|
+
// de-duplicate ids in collection
|
|
58
|
+
if (fileIds.indexOf(key.id) === -1) {
|
|
59
|
+
fileIds.push(key.id);
|
|
60
|
+
}
|
|
61
|
+
acc[collectionName] = fileIds;
|
|
62
|
+
return acc;
|
|
63
|
+
}, {});
|
|
64
|
+
items = [];
|
|
65
|
+
_context2.next = 5;
|
|
66
|
+
return Promise.all(Object.keys(fileIdsByCollection).map( /*#__PURE__*/function () {
|
|
67
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionNameKey) {
|
|
68
|
+
var metadataTraceContext, fileIds, collectionName, response, itemsWithMetadataTraceContext;
|
|
69
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
70
|
+
while (1) switch (_context.prev = _context.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
metadataTraceContext = {
|
|
73
|
+
traceId: getRandomHex(8),
|
|
74
|
+
spanId: getRandomHex(8)
|
|
75
|
+
};
|
|
76
|
+
fileIds = fileIdsByCollection[collectionNameKey];
|
|
77
|
+
collectionName = collectionNameKey === nonCollectionName ? undefined : collectionNameKey;
|
|
78
|
+
_context.prev = 3;
|
|
79
|
+
_context.next = 6;
|
|
80
|
+
return mediaStore.getItems(fileIds, collectionName, metadataTraceContext);
|
|
81
|
+
case 6:
|
|
82
|
+
response = _context.sent;
|
|
83
|
+
itemsWithMetadataTraceContext = response.data.items.map(function (item) {
|
|
84
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
85
|
+
metadataTraceContext: metadataTraceContext
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
items.push.apply(items, _toConsumableArray(itemsWithMetadataTraceContext));
|
|
89
|
+
_context.next = 14;
|
|
90
|
+
break;
|
|
91
|
+
case 11:
|
|
92
|
+
_context.prev = 11;
|
|
93
|
+
_context.t0 = _context["catch"](3);
|
|
94
|
+
fileIds.forEach(function (fileId) {
|
|
95
|
+
items.push({
|
|
96
|
+
id: fileId,
|
|
97
|
+
collection: collectionName,
|
|
98
|
+
error: _context.t0
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
case 14:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee, null, [[3, 11]]);
|
|
106
|
+
}));
|
|
107
|
+
return function (_x2) {
|
|
108
|
+
return _ref2.apply(this, arguments);
|
|
109
|
+
};
|
|
110
|
+
}()));
|
|
111
|
+
case 5:
|
|
112
|
+
return _context2.abrupt("return", getItemsFromKeys(keys, items));
|
|
113
|
+
case 6:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context2.stop();
|
|
120
116
|
}
|
|
121
117
|
}, _callee2);
|
|
122
118
|
}));
|
|
@@ -6,31 +6,29 @@ export var getDimensionsFromBlob = /*#__PURE__*/function () {
|
|
|
6
6
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaType, blob) {
|
|
7
7
|
var url;
|
|
8
8
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
|
-
while (1) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return _context.stop();
|
|
33
|
-
}
|
|
9
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10
|
+
case 0:
|
|
11
|
+
_context.t0 = mediaType;
|
|
12
|
+
_context.next = _context.t0 === 'image' ? 3 : _context.t0 === 'video' ? 11 : 12;
|
|
13
|
+
break;
|
|
14
|
+
case 3:
|
|
15
|
+
url = URL.createObjectURL(blob);
|
|
16
|
+
_context.prev = 4;
|
|
17
|
+
_context.next = 7;
|
|
18
|
+
return getImageDimensionsFromBlob(url);
|
|
19
|
+
case 7:
|
|
20
|
+
return _context.abrupt("return", _context.sent);
|
|
21
|
+
case 8:
|
|
22
|
+
_context.prev = 8;
|
|
23
|
+
URL.revokeObjectURL(url);
|
|
24
|
+
return _context.finish(8);
|
|
25
|
+
case 11:
|
|
26
|
+
return _context.abrupt("return", getVideoDimensionsFromBlob(blob));
|
|
27
|
+
case 12:
|
|
28
|
+
throw new Error("Can't extract dimensions from ".concat(mediaType));
|
|
29
|
+
case 13:
|
|
30
|
+
case "end":
|
|
31
|
+
return _context.stop();
|
|
34
32
|
}
|
|
35
33
|
}, _callee, null, [[4,, 8, 11]]);
|
|
36
34
|
}));
|