@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
package/dist/es2019/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.
|
|
@@ -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 const isPreviewableType = (type, featureFlags) => {
|
|
3
6
|
// in classic experience, only audio/video/image are previewable
|
|
4
7
|
const defaultPreviewableTypes = ['audio', 'video', 'image'];
|
|
@@ -9,10 +12,9 @@ export const isPreviewableType = (type, featureFlags) => {
|
|
|
9
12
|
}
|
|
10
13
|
return defaultPreviewableTypes.indexOf(type) > -1;
|
|
11
14
|
};
|
|
12
|
-
export
|
|
13
|
-
export let DATA_UNIT;
|
|
14
|
-
(function (DATA_UNIT) {
|
|
15
|
+
export let DATA_UNIT = /*#__PURE__*/function (DATA_UNIT) {
|
|
15
16
|
DATA_UNIT[DATA_UNIT["MB"] = 1048576] = "MB";
|
|
16
17
|
DATA_UNIT[DATA_UNIT["GB"] = 1073741824] = "GB";
|
|
17
18
|
DATA_UNIT[DATA_UNIT["TB"] = 1099511627776] = "TB";
|
|
18
|
-
|
|
19
|
+
return DATA_UNIT;
|
|
20
|
+
}({});
|
|
@@ -5,6 +5,9 @@ import { createHasher } from '../utils/hashing/hasherCreator';
|
|
|
5
5
|
import { UploaderError } from './error';
|
|
6
6
|
import { CHUNK_SIZE, PROCESSING_BATCH_SIZE } from '../constants';
|
|
7
7
|
import { calculateChunkSize, fileSizeError } from './calculateChunkSize';
|
|
8
|
+
|
|
9
|
+
// TODO: Allow to pass multiple files
|
|
10
|
+
|
|
8
11
|
const hashingFunction = async blob => {
|
|
9
12
|
const hasher = await createHasher();
|
|
10
13
|
return hasher.hash(blob);
|
|
@@ -14,6 +14,6 @@ export function fromObservable(observable) {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export function createMediaSubscribable(
|
|
18
|
-
return fromObservable(createMediaSubject(
|
|
17
|
+
export function createMediaSubscribable(item) {
|
|
18
|
+
return fromObservable(createMediaSubject(item));
|
|
19
19
|
}
|
|
@@ -6,15 +6,13 @@ import { Subscription } from 'rxjs/Subscription';
|
|
|
6
6
|
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export const toPromise = (mediaSubscribable, subscription = new Subscription()) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
error
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})));
|
|
20
|
-
};
|
|
9
|
+
export const toPromise = (mediaSubscribable, subscription = new Subscription()) => new Promise((resolve, reject) => subscription.add(mediaSubscribable.subscribe({
|
|
10
|
+
next: state => {
|
|
11
|
+
resolve(state);
|
|
12
|
+
subscription.unsubscribe();
|
|
13
|
+
},
|
|
14
|
+
error: error => {
|
|
15
|
+
reject(error);
|
|
16
|
+
subscription.unsubscribe();
|
|
17
|
+
}
|
|
18
|
+
})));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Implementation obtained from https://github.com/auth0/jwt-decode
|
|
2
|
+
// Copied from https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/13080
|
|
3
|
+
|
|
4
|
+
/* Decodes base64 string into unicode */
|
|
5
|
+
const b64DecodeUnicode = str => {
|
|
6
|
+
return decodeURIComponent(atob(str).replace(/(.)/g, function (m, p) {
|
|
7
|
+
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
8
|
+
if (code.length < 2) {
|
|
9
|
+
code = '0' + code;
|
|
10
|
+
}
|
|
11
|
+
return '%' + code;
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/* Decodes base64url string into unicode */
|
|
16
|
+
const b64Decode = str => {
|
|
17
|
+
let output = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
18
|
+
switch (output.length % 4) {
|
|
19
|
+
case 0:
|
|
20
|
+
break;
|
|
21
|
+
case 2:
|
|
22
|
+
output += '==';
|
|
23
|
+
break;
|
|
24
|
+
case 3:
|
|
25
|
+
output += '=';
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
throw new Error('Illegal base64url string!');
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return b64DecodeUnicode(output);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
return atob(output);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export default function (token) {
|
|
37
|
+
try {
|
|
38
|
+
const body = token.split('.')[1];
|
|
39
|
+
return JSON.parse(b64Decode(body));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e instanceof Error) {
|
|
42
|
+
throw new Error('Invalid token specified: ' + e.message);
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -23,10 +23,10 @@ export var FileFetcherError = /*#__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,
|