@atlaskit/media-client 14.3.1 → 15.0.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 +106 -0
- package/dist/cjs/client/collection-fetcher.js +6 -4
- package/dist/cjs/client/file-fetcher/error.js +1 -1
- package/dist/cjs/client/file-fetcher/index.js +22 -20
- package/dist/cjs/client/media-store/error.js +1 -1
- package/dist/cjs/client/media-store/index.js +3 -3
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/identifier.js +1 -1
- package/dist/cjs/index.js +127 -120
- package/dist/cjs/models/errors/helpers.js +1 -1
- package/dist/cjs/models/errors/index.js +8 -6
- package/dist/cjs/models/file-state.js +3 -3
- package/dist/cjs/models/media-subscribable.js +5 -0
- package/dist/cjs/models/media.js +1 -1
- package/dist/cjs/utils/createFileDataLoader.js +2 -1
- package/dist/cjs/utils/{createFileStateSubject.js → createMediaSubject.js} +3 -5
- package/dist/cjs/utils/detectEmptyFile.js +1 -1
- package/dist/cjs/utils/hashing/hasherCreator.js +1 -1
- package/dist/cjs/utils/{observableToPromise.js → mediaSubscribableToPromise.js} +6 -7
- package/dist/cjs/utils/mobileUpload/error.js +1 -1
- package/dist/cjs/utils/mobileUpload/helpers.js +3 -3
- package/dist/cjs/utils/mobileUpload/index.js +10 -10
- package/dist/cjs/utils/mobileUpload/stateMachine/states/uploading.js +2 -2
- package/dist/cjs/utils/polling/errors.js +1 -1
- package/dist/cjs/utils/polling/index.js +3 -3
- package/dist/cjs/utils/request/errors.js +1 -1
- package/dist/cjs/utils/request/helpers.js +15 -15
- package/dist/cjs/utils/request/index.js +5 -5
- package/dist/cjs/utils/setTimeoutPromise.js +1 -1
- package/dist/cjs/utils/toMediaSubscribable.js +28 -0
- package/dist/cjs/utils/url.js +3 -3
- package/dist/cjs/utils/with-media-client-hoc.js +3 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/collection-fetcher.js +2 -1
- package/dist/es2019/client/file-fetcher/index.js +13 -12
- package/dist/es2019/index.js +3 -2
- package/dist/es2019/models/media-subscribable.js +1 -0
- package/dist/es2019/utils/{createFileStateSubject.js → createMediaSubject.js} +2 -2
- package/dist/es2019/utils/mediaSubscribableToPromise.js +20 -0
- package/dist/es2019/utils/mobileUpload/helpers.js +2 -2
- package/dist/es2019/utils/toMediaSubscribable.js +18 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/collection-fetcher.js +4 -3
- package/dist/esm/client/file-fetcher/index.js +16 -15
- package/dist/esm/client/media-store/index.js +2 -2
- package/dist/esm/index.js +3 -2
- package/dist/esm/models/errors/index.js +2 -1
- package/dist/esm/models/file-state.js +2 -2
- package/dist/esm/models/media-subscribable.js +1 -0
- package/dist/esm/utils/{createFileStateSubject.js → createMediaSubject.js} +2 -2
- package/dist/esm/utils/{observableToPromise.js → mediaSubscribableToPromise.js} +5 -6
- package/dist/esm/utils/mobileUpload/helpers.js +2 -2
- package/dist/esm/utils/mobileUpload/stateMachine/states/uploading.js +2 -2
- package/dist/esm/utils/polling/index.js +2 -2
- package/dist/esm/utils/request/helpers.js +2 -2
- package/dist/esm/utils/toMediaSubscribable.js +18 -0
- package/dist/esm/utils/url.js +2 -2
- package/dist/esm/utils/with-media-client-hoc.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/client/collection-fetcher.d.ts +2 -1
- package/dist/types/client/file-fetcher/index.d.ts +5 -5
- package/dist/types/index.d.ts +4 -2
- package/dist/types/models/media-subscribable.d.ts +3 -0
- package/dist/types/utils/createMediaSubject.d.ts +3 -0
- package/dist/types/utils/mediaSubscribableToPromise.d.ts +10 -0
- package/dist/types/utils/safeUnsubscribe.d.ts +2 -2
- package/dist/types/utils/toMediaSubscribable.d.ts +20 -0
- package/package.json +11 -13
- package/dist/es2019/utils/observableToPromise.js +0 -21
- package/dist/types/utils/createFileStateSubject.d.ts +0 -3
- package/dist/types/utils/observableToPromise.d.ts +0 -10
|
@@ -4,9 +4,9 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
|
|
11
11
|
import { Subscription } from 'rxjs/Subscription';
|
|
12
12
|
import { of } from 'rxjs/observable/of';
|
|
@@ -30,13 +30,14 @@ import { createFileDataloader } from '../../utils/createFileDataLoader';
|
|
|
30
30
|
import { getMediaTypeFromUploadableFile } from '../../utils/getMediaTypeFromUploadableFile';
|
|
31
31
|
import { overrideMediaTypeIfUnknown } from '../../utils/overrideMediaTypeIfUnknown';
|
|
32
32
|
import { convertBase64ToBlob } from '../../utils/convertBase64ToBlob';
|
|
33
|
-
import {
|
|
33
|
+
import { mediaSubscribableToPromise } from '../../utils/mediaSubscribableToPromise';
|
|
34
34
|
import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
35
|
-
import {
|
|
35
|
+
import { createMediaSubject } from '../../utils/createMediaSubject';
|
|
36
36
|
import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
37
37
|
import { shouldFetchRemoteFileStates, shouldFetchRemoteFileStatesObservable } from '../../utils/shouldFetchRemoteFileStates';
|
|
38
38
|
import { PollingFunction } from '../../utils/polling';
|
|
39
39
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
40
|
+
import { toMediaSubscribable } from '../../utils/toMediaSubscribable';
|
|
40
41
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
41
42
|
export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
42
43
|
function FileFetcherImpl(mediaStore) {
|
|
@@ -45,7 +46,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
45
46
|
_classCallCheck(this, FileFetcherImpl);
|
|
46
47
|
|
|
47
48
|
_defineProperty(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
48
|
-
var subject =
|
|
49
|
+
var subject = createMediaSubject();
|
|
49
50
|
var poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
50
51
|
|
|
51
52
|
poll.onError = function (error) {
|
|
@@ -128,22 +129,22 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
128
129
|
occurrenceKey = options.occurrenceKey;
|
|
129
130
|
|
|
130
131
|
if (!isValidId(id)) {
|
|
131
|
-
var subject =
|
|
132
|
+
var subject = createMediaSubject();
|
|
132
133
|
subject.error(new FileFetcherError('invalidFileId', id, {
|
|
133
134
|
collectionName: collectionName,
|
|
134
135
|
occurrenceKey: occurrenceKey
|
|
135
136
|
}));
|
|
136
|
-
return subject;
|
|
137
|
+
return toMediaSubscribable(subject);
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
return getFileStreamsCache().getOrInsert(id, function () {
|
|
140
|
+
return toMediaSubscribable(getFileStreamsCache().getOrInsert(id, function () {
|
|
140
141
|
return _this2.createDownloadFileStream(id, collectionName);
|
|
141
|
-
});
|
|
142
|
+
}));
|
|
142
143
|
}
|
|
143
144
|
}, {
|
|
144
145
|
key: "getCurrentState",
|
|
145
146
|
value: function getCurrentState(id, options) {
|
|
146
|
-
return
|
|
147
|
+
return mediaSubscribableToPromise(this.getFileState(id, options));
|
|
147
148
|
}
|
|
148
149
|
}, {
|
|
149
150
|
key: "getArtifactURL",
|
|
@@ -199,7 +200,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
199
200
|
case 0:
|
|
200
201
|
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection);
|
|
201
202
|
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
202
|
-
subject =
|
|
203
|
+
subject = createMediaSubject();
|
|
203
204
|
deferredBlob = fetch(url).then(function (response) {
|
|
204
205
|
return response.blob();
|
|
205
206
|
}).catch(function () {
|
|
@@ -361,7 +362,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
361
362
|
var preview; // TODO [MSW-796]: get file size for base64
|
|
362
363
|
|
|
363
364
|
var mediaType = getMediaTypeFromUploadableFile(file);
|
|
364
|
-
var subject =
|
|
365
|
+
var subject = createMediaSubject();
|
|
365
366
|
var processingSubscription = new Subscription();
|
|
366
367
|
|
|
367
368
|
if (content instanceof Blob) {
|
|
@@ -433,7 +434,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
433
434
|
});
|
|
434
435
|
}
|
|
435
436
|
|
|
436
|
-
return subject;
|
|
437
|
+
return toMediaSubscribable(subject);
|
|
437
438
|
}
|
|
438
439
|
}, {
|
|
439
440
|
key: "downloadBinary",
|
|
@@ -562,7 +563,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
562
563
|
data: copiedFileWithMimeType
|
|
563
564
|
});
|
|
564
565
|
fileCache = cache.get(copiedId);
|
|
565
|
-
subject = fileCache ||
|
|
566
|
+
subject = fileCache || createMediaSubject(); // if we were passed a "preview", we propagate it into the copiedFileState
|
|
566
567
|
|
|
567
568
|
previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
|
|
568
569
|
preview: preview
|
|
@@ -630,7 +631,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
630
631
|
_fileCache.error(_context6.t3);
|
|
631
632
|
} else {
|
|
632
633
|
// Create a new subject with the error state for new subscriptions
|
|
633
|
-
cache.set(id,
|
|
634
|
+
cache.set(id, createMediaSubject(_context6.t3));
|
|
634
635
|
}
|
|
635
636
|
}
|
|
636
637
|
|
|
@@ -4,9 +4,9 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
|
|
11
11
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
12
12
|
import { getArtifactUrl } from '../../models/artifacts';
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { isPreviewableType, isMediaCollectionItemFullDetails } from './models/me
|
|
|
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';
|
|
7
|
+
// TODO: remove access to media file stream cache https://product-fabric.atlassian.net/browse/MEX-1417
|
|
7
8
|
export { getFileStreamsCache, StreamsCache } from './file-streams-cache';
|
|
8
9
|
export { uploadFile } from './uploader';
|
|
9
10
|
export { request, RequestError, isRequestError, isRateLimitedError } from './utils/request';
|
|
@@ -17,14 +18,14 @@ export { MediaClient } from './client/media-client';
|
|
|
17
18
|
export { StargateClient } from './client/stargate-client';
|
|
18
19
|
export { isImageRemote } from './utils/isImageRemote';
|
|
19
20
|
export { checkWebpSupport } from './utils/checkWebpSupport';
|
|
20
|
-
export { observableToPromise } from './utils/observableToPromise';
|
|
21
21
|
export { getDimensionsFromBlob } from './utils/getDimensionsFromBlob';
|
|
22
|
-
export {
|
|
22
|
+
export { createMediaSubject } from './utils/createMediaSubject';
|
|
23
23
|
export { safeUnsubscribe } from './utils/safeUnsubscribe';
|
|
24
24
|
export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier } from './identifier';
|
|
25
25
|
export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
|
|
26
26
|
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
27
27
|
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString } from './utils/url';
|
|
28
|
+
export { createMediaSubscribable } from './utils/toMediaSubscribable';
|
|
28
29
|
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants'; // TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
|
|
29
30
|
|
|
30
31
|
import { getMediaTypeFromMimeType as _getMediaTypeFromMimeType, isImageMimeTypeSupportedByBrowser as _isImageMimeTypeSupportedByBrowser, isDocumentMimeTypeSupportedByBrowser as _isDocumentMimeTypeSupportedByBrowser, isMimeTypeSupportedByBrowser as _isMimeTypeSupportedByBrowser, isImageMimeTypeSupportedByServer as _isImageMimeTypeSupportedByServer, isDocumentMimeTypeSupportedByServer as _isDocumentMimeTypeSupportedByServer, isAudioMimeTypeSupportedByServer as _isAudioMimeTypeSupportedByServer, isVideoMimeTypeSupportedByServer as _isVideoMimeTypeSupportedByServer, isUnknownMimeTypeSupportedByServer as _isUnknownMimeTypeSupportedByServer, isMimeTypeSupportedByServer as _isMimeTypeSupportedByServer } from '@atlaskit/media-common/mediaTypeUtils';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
@@ -36,5 +37,5 @@ export var BaseMediaClientError = /*#__PURE__*/function (_Error) {
|
|
|
36
37
|
return _this;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
return BaseMediaClientError;
|
|
40
|
+
return _createClass(BaseMediaClientError);
|
|
40
41
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
export var isUploadingFileState = function isUploadingFileState(fileState) {
|
|
8
8
|
return fileState.status === 'uploading';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
export
|
|
2
|
+
export function createMediaSubject(initialState) {
|
|
3
3
|
var subject = new ReplaySubject(1);
|
|
4
4
|
|
|
5
5
|
if (initialState instanceof Error) {
|
|
@@ -9,4 +9,4 @@ export var createFileStateSubject = function createFileStateSubject(initialState
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return subject;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Subscription } from 'rxjs/Subscription';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Note that in RxJS 7 ".toPromise()" is deprecated and replaced by "firstValueFrom()/.lastValueFrom()"
|
|
4
|
+
* This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
|
|
7
7
|
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
export var observableToPromise = function observableToPromise(observable) {
|
|
9
|
+
export var mediaSubscribableToPromise = function mediaSubscribableToPromise(mediaSubscribable) {
|
|
11
10
|
var subscription = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Subscription();
|
|
12
11
|
return new Promise(function (resolve, reject) {
|
|
13
|
-
return subscription.add(
|
|
12
|
+
return subscription.add(mediaSubscribable.subscribe({
|
|
14
13
|
next: function next(state) {
|
|
15
14
|
resolve(state);
|
|
16
15
|
subscription.unsubscribe();
|
|
@@ -4,7 +4,7 @@ import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
|
4
4
|
import { from } from 'rxjs/observable/from';
|
|
5
5
|
import { map } from 'rxjs/operators/map';
|
|
6
6
|
import { mapMediaItemToFileState } from '../../models/file-state';
|
|
7
|
-
import {
|
|
7
|
+
import { createMediaSubject } from '../createMediaSubject';
|
|
8
8
|
import { isEmptyFile } from '../detectEmptyFile';
|
|
9
9
|
import { PollingFunction } from '../polling';
|
|
10
10
|
import { MobileUploadError } from './error';
|
|
@@ -16,7 +16,7 @@ export var createMobileFileStateSubject = function createMobileFileStateSubject(
|
|
|
16
16
|
return subject;
|
|
17
17
|
};
|
|
18
18
|
export var createMobileDownloadFileStream = function createMobileDownloadFileStream(dataloader, id, collectionName, occurrenceKey) {
|
|
19
|
-
var subject =
|
|
19
|
+
var subject = createMediaSubject();
|
|
20
20
|
var poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
21
21
|
|
|
22
22
|
poll.onError = function (error) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { assign } from 'xstate';
|
|
8
8
|
import { isUploadingFileState } from '../../../../models/file-state';
|
|
@@ -4,9 +4,9 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
|
|
11
11
|
import { PollingError } from './errors';
|
|
12
12
|
// default polling options without using feature flags
|
|
@@ -2,9 +2,9 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
9
|
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
10
10
|
import { parse, stringify } from 'query-string';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createMediaSubject } from './createMediaSubject';
|
|
2
|
+
export function toMediaSubscribable(observable) {
|
|
3
|
+
return {
|
|
4
|
+
subscribe: function subscribe(observer) {
|
|
5
|
+
var subscription = // This is needed to handle "subscribe" function overload.
|
|
6
|
+
// It allows accepting a single "next" callback function as an argument.
|
|
7
|
+
observer instanceof Function ? observable.subscribe(observer) : observable.subscribe(observer);
|
|
8
|
+
return {
|
|
9
|
+
unsubscribe: function unsubscribe() {
|
|
10
|
+
subscription.unsubscribe();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function createMediaSubscribable(mediaSubscribableItem) {
|
|
17
|
+
return toMediaSubscribable(createMediaSubject(mediaSubscribableItem));
|
|
18
|
+
}
|
package/dist/esm/utils/url.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
var mediaBlobUrlIdentifier = 'media-blob-url';
|
|
8
8
|
export var isMediaBlobUrl = function isMediaBlobUrl(url) {
|
|
@@ -5,6 +5,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
+
var _excluded = ["mediaClientConfig"];
|
|
8
9
|
|
|
9
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
11
|
|
|
@@ -55,7 +56,7 @@ export var withMediaClient = function withMediaClient(Component, featureFlags) {
|
|
|
55
56
|
// TODO MPT-315: clean up after we move mediaClientConfig into FileIdentifier
|
|
56
57
|
var _this$props = this.props,
|
|
57
58
|
mediaClientConfig = _this$props.mediaClientConfig,
|
|
58
|
-
otherProps = _objectWithoutProperties(_this$props,
|
|
59
|
+
otherProps = _objectWithoutProperties(_this$props, _excluded);
|
|
59
60
|
|
|
60
61
|
var mediaClient = !mediaClientConfig ? createEmptyMediaClient(featureFlags) : getMediaClient(mediaClientConfig, featureFlags);
|
|
61
62
|
return /*#__PURE__*/React.createElement(Component, _extends({}, otherProps, {
|
package/dist/esm/version.json
CHANGED
|
@@ -2,6 +2,7 @@ import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
|
2
2
|
import { FileDetails, FileItem } from '../models/item';
|
|
3
3
|
import { MediaCollectionItem } from '../models/media';
|
|
4
4
|
import { MediaStore, MediaStoreGetCollectionItemsParams } from './media-store';
|
|
5
|
+
import { MediaSubscribable } from '../utils/toMediaSubscribable';
|
|
5
6
|
export interface MediaCollectionFileItemDetails extends FileDetails {
|
|
6
7
|
occurrenceKey: string;
|
|
7
8
|
}
|
|
@@ -28,7 +29,7 @@ export declare class CollectionFetcher {
|
|
|
28
29
|
private createFileStateObserver;
|
|
29
30
|
private populateCache;
|
|
30
31
|
private removeFromCache;
|
|
31
|
-
getItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams):
|
|
32
|
+
getItems(collectionName: string, params?: MediaStoreGetCollectionItemsParams): MediaSubscribable<MediaCollectionItem[]>;
|
|
32
33
|
removeFile(id: string, collectionName: string, occurrenceKey?: string): Promise<void>;
|
|
33
34
|
loadNextPage(collectionName: string, params?: MediaStoreGetCollectionItemsParams): Promise<void>;
|
|
34
35
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
1
|
import 'setimmediate';
|
|
3
2
|
import { AuthProvider } from '@atlaskit/media-core';
|
|
4
3
|
import { MediaStore, MediaStoreCopyFileWithTokenParams, TouchedFiles, TouchFileDescriptor } from '../media-store';
|
|
@@ -8,6 +7,7 @@ import { UploadableFile, UploadableFileUpfrontIds } from '../../uploader';
|
|
|
8
7
|
import { MediaFileArtifacts } from '../../models/artifacts';
|
|
9
8
|
import { UploadController } from '../../upload-controller';
|
|
10
9
|
import { Dimensions } from '../../utils/getDimensionsFromBlob';
|
|
10
|
+
import { MediaSubscribable } from '../../utils/toMediaSubscribable';
|
|
11
11
|
export type { FileFetcherErrorAttributes, FileFetcherErrorReason, } from './error';
|
|
12
12
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
13
13
|
export interface CopySourceFile {
|
|
@@ -28,10 +28,10 @@ export declare type ExternalUploadPayload = {
|
|
|
28
28
|
dimensions: Dimensions;
|
|
29
29
|
};
|
|
30
30
|
export interface FileFetcher {
|
|
31
|
-
getFileState(id: string, options?: GetFileOptions):
|
|
31
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
|
|
32
32
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
33
33
|
touchFiles(descriptors: TouchFileDescriptor[], collection?: string): Promise<TouchedFiles>;
|
|
34
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds):
|
|
34
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds): MediaSubscribable<FileState>;
|
|
35
35
|
uploadExternal(url: string, collection?: string): Promise<ExternalUploadPayload>;
|
|
36
36
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
37
37
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
@@ -42,7 +42,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
42
42
|
private readonly mediaStore;
|
|
43
43
|
private readonly dataloader;
|
|
44
44
|
constructor(mediaStore: MediaStore);
|
|
45
|
-
getFileState(id: string, options?: GetFileOptions):
|
|
45
|
+
getFileState(id: string, options?: GetFileOptions): MediaSubscribable<FileState>;
|
|
46
46
|
getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
|
|
47
47
|
getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
|
|
48
48
|
getFileBinaryURL(id: string, collectionName?: string): Promise<string>;
|
|
@@ -50,7 +50,7 @@ export declare class FileFetcherImpl implements FileFetcher {
|
|
|
50
50
|
touchFiles(descriptors: TouchFileDescriptor[], collection?: string): Promise<TouchedFiles>;
|
|
51
51
|
private generateUploadableFileUpfrontIds;
|
|
52
52
|
uploadExternal(url: string, collection?: string): Promise<ExternalUploadPayload>;
|
|
53
|
-
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds):
|
|
53
|
+
upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds): MediaSubscribable<FileState>;
|
|
54
54
|
downloadBinary(id: string, name?: string, collectionName?: string): Promise<void>;
|
|
55
55
|
copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions): Promise<MediaFile>;
|
|
56
56
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { AbortFunction } from './upload-controller';
|
|
|
5
5
|
export type { MediaItemType, FileItem, FileProcessingStatus, MediaArtifact, Artifacts, FileDetails, } from './models/item';
|
|
6
6
|
export { isPreviewableType, isMediaCollectionItemFullDetails, } from './models/media';
|
|
7
7
|
export type { MediaFileProcessingStatus, MediaType, MediaFile, MediaCollection, MediaCollectionItems, MediaCollectionItem, MediaCollectionItemMinimalDetails, MediaCollectionItemFullDetails, MediaRepresentations, MediaCollectionItemDetails, MediaUpload, MediaChunksProbe, } from './models/media';
|
|
8
|
+
export type { MediaSubscribableItem } from './models/media-subscribable';
|
|
8
9
|
export { getArtifactUrl } from './models/artifacts';
|
|
9
10
|
export type { MediaFileArtifact, MediaFileArtifacts } from './models/artifacts';
|
|
10
11
|
export { isMediaClientError, getMediaClientErrorReason } from './models/errors';
|
|
@@ -32,10 +33,9 @@ export { StargateClient } from './client/stargate-client';
|
|
|
32
33
|
export type { EdgeData } from './client/stargate-client';
|
|
33
34
|
export { isImageRemote } from './utils/isImageRemote';
|
|
34
35
|
export { checkWebpSupport } from './utils/checkWebpSupport';
|
|
35
|
-
export { observableToPromise } from './utils/observableToPromise';
|
|
36
36
|
export { getDimensionsFromBlob } from './utils/getDimensionsFromBlob';
|
|
37
37
|
export type { Dimensions } from './utils/getDimensionsFromBlob';
|
|
38
|
-
export {
|
|
38
|
+
export { createMediaSubject } from './utils/createMediaSubject';
|
|
39
39
|
export { safeUnsubscribe } from './utils/safeUnsubscribe';
|
|
40
40
|
export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier, } from './identifier';
|
|
41
41
|
export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './identifier';
|
|
@@ -45,6 +45,8 @@ export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClient
|
|
|
45
45
|
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
46
46
|
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
|
|
47
47
|
export type { MediaBlobUrlAttrs } from './utils/url';
|
|
48
|
+
export { createMediaSubscribable } from './utils/toMediaSubscribable';
|
|
49
|
+
export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/toMediaSubscribable';
|
|
48
50
|
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
|
|
49
51
|
/**
|
|
50
52
|
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Subscription } from 'rxjs/Subscription';
|
|
2
|
+
import { MediaSubscribable } from './toMediaSubscribable';
|
|
3
|
+
import { MediaSubscribableItem } from '../models/media-subscribable';
|
|
4
|
+
/**
|
|
5
|
+
* This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
|
|
6
|
+
*
|
|
7
|
+
* @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
|
|
8
|
+
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
9
|
+
*/
|
|
10
|
+
export declare const mediaSubscribableToPromise: <T extends MediaSubscribableItem>(mediaSubscribable: MediaSubscribable<T>, subscription?: Subscription) => Promise<T>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const safeUnsubscribe: (subscription:
|
|
1
|
+
import { MediaSubscription } from './toMediaSubscribable';
|
|
2
|
+
export declare const safeUnsubscribe: (subscription: MediaSubscription) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
+
import { MediaSubscribableItem } from './../models/media-subscribable';
|
|
3
|
+
export declare type MediaSubscription = {
|
|
4
|
+
unsubscribe: () => void;
|
|
5
|
+
};
|
|
6
|
+
declare type PartialObserver<T extends MediaSubscribableItem> = {
|
|
7
|
+
next?: (value: T) => void;
|
|
8
|
+
error?: (err: any) => void;
|
|
9
|
+
complete?: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare type NextObserver<T extends MediaSubscribableItem> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'next'>>;
|
|
12
|
+
declare type ErrorObserver<T extends MediaSubscribableItem> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'error'>>;
|
|
13
|
+
declare type CompletionObserver<T extends MediaSubscribableItem> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'complete'>>;
|
|
14
|
+
export declare type MediaObserver<T extends MediaSubscribableItem> = NextObserver<T> | ErrorObserver<T> | CompletionObserver<T> | ((value: T) => void);
|
|
15
|
+
export declare type MediaSubscribable<T extends MediaSubscribableItem> = {
|
|
16
|
+
subscribe(observer?: MediaObserver<T>): MediaSubscription;
|
|
17
|
+
};
|
|
18
|
+
export declare function toMediaSubscribable<T extends MediaSubscribableItem>(observable: ReplaySubject<T>): MediaSubscribable<T>;
|
|
19
|
+
export declare function createMediaSubscribable<T extends MediaSubscribableItem>(mediaSubscribableItem?: T | Error): MediaSubscribable<T>;
|
|
20
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,15 +27,16 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/chunkinator": "^3.
|
|
31
|
-
"@atlaskit/media-common": "^2.
|
|
30
|
+
"@atlaskit/chunkinator": "^3.1.0",
|
|
31
|
+
"@atlaskit/media-common": "^2.11.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
33
33
|
"dataloader": "^2.0.0",
|
|
34
34
|
"deep-equal": "^1.0.1",
|
|
35
35
|
"eventemitter2": "^4.1.0",
|
|
36
36
|
"lru-fast": "^0.2.2",
|
|
37
|
-
"query-string": "^
|
|
37
|
+
"query-string": "^6.14.1",
|
|
38
38
|
"rusha": "^0.8.13",
|
|
39
|
+
"rxjs": "^5.5.0",
|
|
39
40
|
"setimmediate": "^1.0.5",
|
|
40
41
|
"uuid": "^3.1.0",
|
|
41
42
|
"uuid-validate": "^0.0.3",
|
|
@@ -43,17 +44,15 @@
|
|
|
43
44
|
"xstate": "^4.20.0"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
|
-
"@atlaskit/media-core": "^32.
|
|
47
|
-
"react": "^16.8.0"
|
|
48
|
-
"rxjs": "^5.5.0"
|
|
47
|
+
"@atlaskit/media-core": "^32.3.0",
|
|
48
|
+
"react": "^16.8.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@atlaskit/
|
|
52
|
-
"@atlaskit/button": "^16.1.0",
|
|
51
|
+
"@atlaskit/button": "^16.2.0",
|
|
53
52
|
"@atlaskit/docs": "*",
|
|
54
|
-
"@atlaskit/media-card": "^
|
|
55
|
-
"@atlaskit/media-core": "^32.
|
|
56
|
-
"@atlaskit/media-test-helpers": "^
|
|
53
|
+
"@atlaskit/media-card": "^73.4.0",
|
|
54
|
+
"@atlaskit/media-core": "^32.3.0",
|
|
55
|
+
"@atlaskit/media-test-helpers": "^29.3.0",
|
|
57
56
|
"@atlaskit/ssr": "*",
|
|
58
57
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
59
58
|
"@types/deep-equal": "^1.0.1",
|
|
@@ -64,7 +63,6 @@
|
|
|
64
63
|
"jest-fetch-mock": "^3.0.3",
|
|
65
64
|
"react": "^16.8.0",
|
|
66
65
|
"react-dom": "^16.8.0",
|
|
67
|
-
"rxjs": "^5.5.0",
|
|
68
66
|
"styled-components": "^3.2.6",
|
|
69
67
|
"typescript": "3.9.6"
|
|
70
68
|
},
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Subscription } from 'rxjs/Subscription';
|
|
2
|
-
/**
|
|
3
|
-
* We're using this custom helper in place of ".toPromise()" to transform the first value emitted by an Observable or Subject into a Promise.
|
|
4
|
-
* Note that in RxJS 7 ".toPromise()" is deprecated and replaced by "firstValueFrom()/.lastValueFrom()"
|
|
5
|
-
*
|
|
6
|
-
* @param observable a given Observable<T> or Subject<T>
|
|
7
|
-
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const observableToPromise = (observable, subscription = new Subscription()) => {
|
|
11
|
-
return new Promise((resolve, reject) => subscription.add(observable.subscribe({
|
|
12
|
-
next: state => {
|
|
13
|
-
resolve(state);
|
|
14
|
-
subscription.unsubscribe();
|
|
15
|
-
},
|
|
16
|
-
error: error => {
|
|
17
|
-
reject(error);
|
|
18
|
-
subscription.unsubscribe();
|
|
19
|
-
}
|
|
20
|
-
})));
|
|
21
|
-
};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
import { FileState } from '../models/file-state';
|
|
3
|
-
export declare const createFileStateSubject: (initialState?: Error | import("../models/file-state").UploadingFileState | import("../models/file-state").ProcessingFileState | import("../models/file-state").ProcessedFileState | import("../models/file-state").ProcessingFailedState | import("../models/file-state").ErrorFileState | undefined) => ReplaySubject<FileState>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs/Observable';
|
|
2
|
-
import { Subscription } from 'rxjs/Subscription';
|
|
3
|
-
/**
|
|
4
|
-
* We're using this custom helper in place of ".toPromise()" to transform the first value emitted by an Observable or Subject into a Promise.
|
|
5
|
-
* Note that in RxJS 7 ".toPromise()" is deprecated and replaced by "firstValueFrom()/.lastValueFrom()"
|
|
6
|
-
*
|
|
7
|
-
* @param observable a given Observable<T> or Subject<T>
|
|
8
|
-
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
9
|
-
*/
|
|
10
|
-
export declare const observableToPromise: <T>(observable: Observable<T>, subscription?: Subscription) => Promise<T>;
|