@atlaskit/media-client 14.4.0 → 15.1.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 +107 -0
- package/dist/cjs/client/collection-fetcher.js +3 -1
- package/dist/cjs/client/file-fetcher/index.js +15 -13
- package/dist/cjs/index.js +10 -17
- package/dist/cjs/utils/{createFileStateSubject.js → createMediaSubject.js} +3 -5
- package/dist/cjs/utils/{observableToPromise.js → mediaSubscribableToPromise.js} +6 -7
- package/dist/cjs/utils/mobileUpload/helpers.js +2 -2
- package/dist/cjs/utils/toMediaSubscribable.js +7 -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 -3
- 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 +4 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/collection-fetcher.js +2 -1
- package/dist/esm/client/file-fetcher/index.js +14 -13
- package/dist/esm/index.js +3 -3
- 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/toMediaSubscribable.js +4 -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/client/media-store/resolveAuth.d.ts +1 -1
- package/dist/types/globalMediaEventEmitter.d.ts +3 -3
- package/dist/types/index.d.ts +4 -5
- package/dist/types/models/file-state.d.ts +1 -1
- package/dist/types/utils/createMediaSubject.d.ts +3 -0
- package/dist/types/utils/imageResizeModeToFileImageMode.d.ts +1 -1
- package/dist/types/utils/mediaSubscribableToPromise.d.ts +10 -0
- package/dist/types/utils/overrideMediaTypeIfUnknown.d.ts +2 -2
- package/dist/types/utils/request/errors.d.ts +1 -1
- package/dist/types/utils/safeUnsubscribe.d.ts +2 -2
- package/dist/types/utils/toMediaSubscribable.d.ts +4 -1
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,112 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 15.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a424e62b264`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a424e62b264) - Changes to support Node 16 Typescript definitions from `@types/node`.
|
|
8
|
+
|
|
9
|
+
## 15.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Export `WithMediaClient` type to resolve a deep import path d.ts reference
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Upgrade to TypeScript 4.2.4
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
20
|
+
## 15.0.0
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- [`fdc41ee7a0b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fdc41ee7a0b) - Stop exposing observableToPromise from media client API.
|
|
25
|
+
mediaSubscribableToPromise is used internally.
|
|
26
|
+
- [`118f3af101f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/118f3af101f) - Media Client APIs has been updated to use MediaSubscribable which provides subscription functionality (similar to RxJs observables).
|
|
27
|
+
It exposes subscribe method that is called with MediaObserver as an argument and returns MediaSubscription.
|
|
28
|
+
MediaSubscription exposes unsubscribe method.
|
|
29
|
+
|
|
30
|
+
getFileState:
|
|
31
|
+
The returned type of this function has changed from RxJs ReplaySubject to MediaSubscribable.
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
import { MediaClient, MediaObserver, MediaSubscribable, MediaSubscription } from '@atlaskit/media-client';
|
|
35
|
+
|
|
36
|
+
const mediaClient = new MediaClient({ authProvider });
|
|
37
|
+
|
|
38
|
+
const fileStateSubscribable: MediaSubscribable<FileState> = mediaClient.file.getFileState(id);
|
|
39
|
+
|
|
40
|
+
const mediaObserver: MediaObserver<FileState> = {
|
|
41
|
+
next: (fileState) => {
|
|
42
|
+
nextCallback(fileState)
|
|
43
|
+
},
|
|
44
|
+
error: (error) => {
|
|
45
|
+
errorCallback(error)
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const subscription: MediaSubscription = fileStateSubscribable.subscribe(mediaObserver);
|
|
50
|
+
|
|
51
|
+
subscription.unsubscribe();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
upload:
|
|
55
|
+
The returned type of this function has changed from RxJs ReplaySubject to MediaSubscribable.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
import { MediaClient, MediaObserver, MediaSubscribable, MediaSubscription } from '@atlaskit/media-client';
|
|
59
|
+
|
|
60
|
+
const mediaClient = new MediaClient({ authProvider });
|
|
61
|
+
|
|
62
|
+
const uploadFileSubscribable: MediaSubscribable<FileState> = mediaClient.file.upload(uploadableFile);
|
|
63
|
+
|
|
64
|
+
const mediaObserver: MediaObserver<FileState> = {
|
|
65
|
+
next: (fileState) => {
|
|
66
|
+
nextCallback(fileState)
|
|
67
|
+
},
|
|
68
|
+
error: (error) => {
|
|
69
|
+
errorCallback(error)
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const subscription: MediaSubscription = uploadFileSubscribable.subscribe(mediaObserver);
|
|
74
|
+
|
|
75
|
+
subscription.unsubscribe();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
getItems:
|
|
79
|
+
The returned type of this function has changed from RxJs ReplaySubject to MediaSubscribable.
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
import { MediaClient, MediaObserver, MediaSubscribable, MediaSubscription } from '@atlaskit/media-client';
|
|
83
|
+
|
|
84
|
+
const mediaClient = new MediaClient({ authProvider });
|
|
85
|
+
|
|
86
|
+
const collectionItemsSubscribable: MediaSubscribable<MediaCollectionItem[]> = mediaClient.collection.getItems(collectionName);
|
|
87
|
+
|
|
88
|
+
const mediaObserver: MediaObserver<MediaCollectionItem[]> = {
|
|
89
|
+
next: (items) => {
|
|
90
|
+
nextCallback(items)
|
|
91
|
+
},
|
|
92
|
+
error: (error) => {
|
|
93
|
+
errorCallback(error)
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const subscription: MediaSubscription = collectionItemsSubscribable.subscribe(mediaObserver);
|
|
98
|
+
|
|
99
|
+
subscription.unsubscribe();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Minor Changes
|
|
103
|
+
|
|
104
|
+
- [`f862d5ae7aa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f862d5ae7aa) - remove RxJs peer dependency
|
|
105
|
+
|
|
106
|
+
### Patch Changes
|
|
107
|
+
|
|
108
|
+
- Updated dependencies
|
|
109
|
+
|
|
3
110
|
## 14.4.0
|
|
4
111
|
|
|
5
112
|
### Minor Changes
|
|
@@ -25,6 +25,8 @@ var _fileStreamsCache = require("../file-streams-cache");
|
|
|
25
25
|
|
|
26
26
|
var _fileState = require("../models/file-state");
|
|
27
27
|
|
|
28
|
+
var _toMediaSubscribable = require("../utils/toMediaSubscribable");
|
|
29
|
+
|
|
28
30
|
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; }
|
|
29
31
|
|
|
30
32
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -114,7 +116,7 @@ var CollectionFetcher = /*#__PURE__*/function () {
|
|
|
114
116
|
}).catch(function (error) {
|
|
115
117
|
return subject.error(error);
|
|
116
118
|
});
|
|
117
|
-
return subject;
|
|
119
|
+
return (0, _toMediaSubscribable.toMediaSubscribable)(subject);
|
|
118
120
|
}
|
|
119
121
|
}, {
|
|
120
122
|
key: "removeFile",
|
|
@@ -69,11 +69,11 @@ var _overrideMediaTypeIfUnknown = require("../../utils/overrideMediaTypeIfUnknow
|
|
|
69
69
|
|
|
70
70
|
var _convertBase64ToBlob = require("../../utils/convertBase64ToBlob");
|
|
71
71
|
|
|
72
|
-
var
|
|
72
|
+
var _mediaSubscribableToPromise = require("../../utils/mediaSubscribableToPromise");
|
|
73
73
|
|
|
74
74
|
var _getDimensionsFromBlob = require("../../utils/getDimensionsFromBlob");
|
|
75
75
|
|
|
76
|
-
var
|
|
76
|
+
var _createMediaSubject = require("../../utils/createMediaSubject");
|
|
77
77
|
|
|
78
78
|
var _mediaTypeUtils = require("@atlaskit/media-common/mediaTypeUtils");
|
|
79
79
|
|
|
@@ -83,6 +83,8 @@ var _polling = require("../../utils/polling");
|
|
|
83
83
|
|
|
84
84
|
var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
85
85
|
|
|
86
|
+
var _toMediaSubscribable = require("../../utils/toMediaSubscribable");
|
|
87
|
+
|
|
86
88
|
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; }
|
|
87
89
|
|
|
88
90
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -93,7 +95,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
93
95
|
|
|
94
96
|
(0, _classCallCheck2.default)(this, FileFetcherImpl);
|
|
95
97
|
(0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
96
|
-
var subject = (0,
|
|
98
|
+
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
97
99
|
var poll = new _polling.PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
98
100
|
|
|
99
101
|
poll.onError = function (error) {
|
|
@@ -175,22 +177,22 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
175
177
|
occurrenceKey = options.occurrenceKey;
|
|
176
178
|
|
|
177
179
|
if (!(0, _uuidValidate.default)(id)) {
|
|
178
|
-
var subject = (0,
|
|
180
|
+
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
179
181
|
subject.error(new _error.FileFetcherError('invalidFileId', id, {
|
|
180
182
|
collectionName: collectionName,
|
|
181
183
|
occurrenceKey: occurrenceKey
|
|
182
184
|
}));
|
|
183
|
-
return subject;
|
|
185
|
+
return (0, _toMediaSubscribable.toMediaSubscribable)(subject);
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
return (0, _fileStreamsCache.getFileStreamsCache)().getOrInsert(id, function () {
|
|
188
|
+
return (0, _toMediaSubscribable.toMediaSubscribable)((0, _fileStreamsCache.getFileStreamsCache)().getOrInsert(id, function () {
|
|
187
189
|
return _this2.createDownloadFileStream(id, collectionName);
|
|
188
|
-
});
|
|
190
|
+
}));
|
|
189
191
|
}
|
|
190
192
|
}, {
|
|
191
193
|
key: "getCurrentState",
|
|
192
194
|
value: function getCurrentState(id, options) {
|
|
193
|
-
return (0,
|
|
195
|
+
return (0, _mediaSubscribableToPromise.mediaSubscribableToPromise)(this.getFileState(id, options));
|
|
194
196
|
}
|
|
195
197
|
}, {
|
|
196
198
|
key: "getArtifactURL",
|
|
@@ -246,7 +248,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
246
248
|
case 0:
|
|
247
249
|
uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection);
|
|
248
250
|
id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
249
|
-
subject = (0,
|
|
251
|
+
subject = (0, _createMediaSubject.createMediaSubject)();
|
|
250
252
|
deferredBlob = fetch(url).then(function (response) {
|
|
251
253
|
return response.blob();
|
|
252
254
|
}).catch(function () {
|
|
@@ -408,7 +410,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
408
410
|
var preview; // TODO [MSW-796]: get file size for base64
|
|
409
411
|
|
|
410
412
|
var mediaType = (0, _getMediaTypeFromUploadableFile.getMediaTypeFromUploadableFile)(file);
|
|
411
|
-
var subject = (0,
|
|
413
|
+
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
412
414
|
var processingSubscription = new _Subscription.Subscription();
|
|
413
415
|
|
|
414
416
|
if (content instanceof Blob) {
|
|
@@ -480,7 +482,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
480
482
|
});
|
|
481
483
|
}
|
|
482
484
|
|
|
483
|
-
return subject;
|
|
485
|
+
return (0, _toMediaSubscribable.toMediaSubscribable)(subject);
|
|
484
486
|
}
|
|
485
487
|
}, {
|
|
486
488
|
key: "downloadBinary",
|
|
@@ -610,7 +612,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
610
612
|
data: copiedFileWithMimeType
|
|
611
613
|
});
|
|
612
614
|
fileCache = cache.get(copiedId);
|
|
613
|
-
subject = fileCache || (0,
|
|
615
|
+
subject = fileCache || (0, _createMediaSubject.createMediaSubject)(); // if we were passed a "preview", we propagate it into the copiedFileState
|
|
614
616
|
|
|
615
617
|
previewOverride = !(0, _fileState.isErrorFileState)(copiedFileState) && !!preview ? {
|
|
616
618
|
preview: preview
|
|
@@ -678,7 +680,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
678
680
|
_fileCache.error(_context6.t3);
|
|
679
681
|
} else {
|
|
680
682
|
// Create a new subject with the error state for new subscriptions
|
|
681
|
-
cache.set(id, (0,
|
|
683
|
+
cache.set(id, (0, _createMediaSubject.createMediaSubject)(_context6.t3));
|
|
682
684
|
}
|
|
683
685
|
}
|
|
684
686
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -99,10 +99,16 @@ Object.defineProperty(exports, "checkWebpSupport", {
|
|
|
99
99
|
return _checkWebpSupport.checkWebpSupport;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
-
Object.defineProperty(exports, "
|
|
102
|
+
Object.defineProperty(exports, "createMediaSubject", {
|
|
103
103
|
enumerable: true,
|
|
104
104
|
get: function get() {
|
|
105
|
-
return
|
|
105
|
+
return _createMediaSubject.createMediaSubject;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "createMediaSubscribable", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function get() {
|
|
111
|
+
return _toMediaSubscribable.createMediaSubscribable;
|
|
106
112
|
}
|
|
107
113
|
});
|
|
108
114
|
Object.defineProperty(exports, "createUrl", {
|
|
@@ -328,12 +334,6 @@ Object.defineProperty(exports, "objectToQueryString", {
|
|
|
328
334
|
return _url.objectToQueryString;
|
|
329
335
|
}
|
|
330
336
|
});
|
|
331
|
-
Object.defineProperty(exports, "observableToPromise", {
|
|
332
|
-
enumerable: true,
|
|
333
|
-
get: function get() {
|
|
334
|
-
return _observableToPromise.observableToPromise;
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
337
|
Object.defineProperty(exports, "request", {
|
|
338
338
|
enumerable: true,
|
|
339
339
|
get: function get() {
|
|
@@ -346,12 +346,6 @@ Object.defineProperty(exports, "safeUnsubscribe", {
|
|
|
346
346
|
return _safeUnsubscribe.safeUnsubscribe;
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
|
-
Object.defineProperty(exports, "toMediaSubscribable", {
|
|
350
|
-
enumerable: true,
|
|
351
|
-
get: function get() {
|
|
352
|
-
return _toMediaSubscribable.toMediaSubscribable;
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
349
|
Object.defineProperty(exports, "uploadFile", {
|
|
356
350
|
enumerable: true,
|
|
357
351
|
get: function get() {
|
|
@@ -403,11 +397,9 @@ var _isImageRemote = require("./utils/isImageRemote");
|
|
|
403
397
|
|
|
404
398
|
var _checkWebpSupport = require("./utils/checkWebpSupport");
|
|
405
399
|
|
|
406
|
-
var _observableToPromise = require("./utils/observableToPromise");
|
|
407
|
-
|
|
408
400
|
var _getDimensionsFromBlob = require("./utils/getDimensionsFromBlob");
|
|
409
401
|
|
|
410
|
-
var
|
|
402
|
+
var _createMediaSubject = require("./utils/createMediaSubject");
|
|
411
403
|
|
|
412
404
|
var _safeUnsubscribe = require("./utils/safeUnsubscribe");
|
|
413
405
|
|
|
@@ -425,6 +417,7 @@ var _constants = require("./constants");
|
|
|
425
417
|
|
|
426
418
|
var _mediaTypeUtils = require("@atlaskit/media-common/mediaTypeUtils");
|
|
427
419
|
|
|
420
|
+
// TODO: remove access to media file stream cache https://product-fabric.atlassian.net/browse/MEX-1417
|
|
428
421
|
// TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
|
|
429
422
|
|
|
430
423
|
/**
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createMediaSubject = createMediaSubject;
|
|
7
7
|
|
|
8
8
|
var _ReplaySubject = require("rxjs/ReplaySubject");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function createMediaSubject(initialState) {
|
|
11
11
|
var subject = new _ReplaySubject.ReplaySubject(1);
|
|
12
12
|
|
|
13
13
|
if (initialState instanceof Error) {
|
|
@@ -17,6 +17,4 @@ var createFileStateSubject = function createFileStateSubject(initialState) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return subject;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.createFileStateSubject = createFileStateSubject;
|
|
20
|
+
}
|
|
@@ -3,21 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.mediaSubscribableToPromise = void 0;
|
|
7
7
|
|
|
8
8
|
var _Subscription = require("rxjs/Subscription");
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* Note that in RxJS 7 ".toPromise()" is deprecated and replaced by "firstValueFrom()/.lastValueFrom()"
|
|
11
|
+
* This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
|
|
13
12
|
*
|
|
14
|
-
* @param
|
|
13
|
+
* @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
|
|
15
14
|
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
16
15
|
*/
|
|
17
|
-
var
|
|
16
|
+
var mediaSubscribableToPromise = function mediaSubscribableToPromise(mediaSubscribable) {
|
|
18
17
|
var subscription = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _Subscription.Subscription();
|
|
19
18
|
return new Promise(function (resolve, reject) {
|
|
20
|
-
return subscription.add(
|
|
19
|
+
return subscription.add(mediaSubscribable.subscribe({
|
|
21
20
|
next: function next(state) {
|
|
22
21
|
resolve(state);
|
|
23
22
|
subscription.unsubscribe();
|
|
@@ -30,4 +29,4 @@ var observableToPromise = function observableToPromise(observable) {
|
|
|
30
29
|
});
|
|
31
30
|
};
|
|
32
31
|
|
|
33
|
-
exports.
|
|
32
|
+
exports.mediaSubscribableToPromise = mediaSubscribableToPromise;
|
|
@@ -19,7 +19,7 @@ var _map = require("rxjs/operators/map");
|
|
|
19
19
|
|
|
20
20
|
var _fileState = require("../../models/file-state");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _createMediaSubject = require("../createMediaSubject");
|
|
23
23
|
|
|
24
24
|
var _detectEmptyFile = require("../detectEmptyFile");
|
|
25
25
|
|
|
@@ -38,7 +38,7 @@ var createMobileFileStateSubject = function createMobileFileStateSubject(service
|
|
|
38
38
|
exports.createMobileFileStateSubject = createMobileFileStateSubject;
|
|
39
39
|
|
|
40
40
|
var createMobileDownloadFileStream = function createMobileDownloadFileStream(dataloader, id, collectionName, occurrenceKey) {
|
|
41
|
-
var subject = (0,
|
|
41
|
+
var subject = (0, _createMediaSubject.createMediaSubject)();
|
|
42
42
|
var poll = new _polling.PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
43
43
|
|
|
44
44
|
poll.onError = function (error) {
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.createMediaSubscribable = createMediaSubscribable;
|
|
6
7
|
exports.toMediaSubscribable = toMediaSubscribable;
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
var _createMediaSubject = require("./createMediaSubject");
|
|
10
|
+
|
|
9
11
|
function toMediaSubscribable(observable) {
|
|
10
12
|
return {
|
|
11
13
|
subscribe: function subscribe(observer) {
|
|
@@ -19,4 +21,8 @@ function toMediaSubscribable(observable) {
|
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function createMediaSubscribable(mediaSubscribableItem) {
|
|
27
|
+
return toMediaSubscribable((0, _createMediaSubject.createMediaSubject)(mediaSubscribableItem));
|
|
22
28
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
2
|
import { getFileStreamsCache } from '../file-streams-cache';
|
|
3
3
|
import { mapMediaFileToFileState } from '../models/file-state';
|
|
4
|
+
import { toMediaSubscribable } from '../utils/toMediaSubscribable';
|
|
4
5
|
export const collectionCache = {};
|
|
5
6
|
|
|
6
7
|
const createCacheEntry = () => ({
|
|
@@ -66,7 +67,7 @@ export class CollectionFetcher {
|
|
|
66
67
|
collection.nextInclusiveStartKey = nextInclusiveStartKey;
|
|
67
68
|
subject.next(collection.items);
|
|
68
69
|
}).catch(error => subject.error(error));
|
|
69
|
-
return subject;
|
|
70
|
+
return toMediaSubscribable(subject);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
async removeFile(id, collectionName, occurrenceKey) {
|
|
@@ -21,18 +21,19 @@ import { createFileDataloader } from '../../utils/createFileDataLoader';
|
|
|
21
21
|
import { getMediaTypeFromUploadableFile } from '../../utils/getMediaTypeFromUploadableFile';
|
|
22
22
|
import { overrideMediaTypeIfUnknown } from '../../utils/overrideMediaTypeIfUnknown';
|
|
23
23
|
import { convertBase64ToBlob } from '../../utils/convertBase64ToBlob';
|
|
24
|
-
import {
|
|
24
|
+
import { mediaSubscribableToPromise } from '../../utils/mediaSubscribableToPromise';
|
|
25
25
|
import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
26
|
-
import {
|
|
26
|
+
import { createMediaSubject } from '../../utils/createMediaSubject';
|
|
27
27
|
import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
28
28
|
import { shouldFetchRemoteFileStates, shouldFetchRemoteFileStatesObservable } from '../../utils/shouldFetchRemoteFileStates';
|
|
29
29
|
import { PollingFunction } from '../../utils/polling';
|
|
30
30
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
31
|
+
import { toMediaSubscribable } from '../../utils/toMediaSubscribable';
|
|
31
32
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
32
33
|
export class FileFetcherImpl {
|
|
33
34
|
constructor(mediaStore) {
|
|
34
35
|
_defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey) => {
|
|
35
|
-
const subject =
|
|
36
|
+
const subject = createMediaSubject();
|
|
36
37
|
const poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
37
38
|
|
|
38
39
|
poll.onError = error => subject.error(error);
|
|
@@ -85,19 +86,19 @@ export class FileFetcherImpl {
|
|
|
85
86
|
} = options;
|
|
86
87
|
|
|
87
88
|
if (!isValidId(id)) {
|
|
88
|
-
const subject =
|
|
89
|
+
const subject = createMediaSubject();
|
|
89
90
|
subject.error(new FileFetcherError('invalidFileId', id, {
|
|
90
91
|
collectionName,
|
|
91
92
|
occurrenceKey
|
|
92
93
|
}));
|
|
93
|
-
return subject;
|
|
94
|
+
return toMediaSubscribable(subject);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
return getFileStreamsCache().getOrInsert(id, () => this.createDownloadFileStream(id, collectionName));
|
|
97
|
+
return toMediaSubscribable(getFileStreamsCache().getOrInsert(id, () => this.createDownloadFileStream(id, collectionName)));
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
getCurrentState(id, options) {
|
|
100
|
-
return
|
|
101
|
+
return mediaSubscribableToPromise(this.getFileState(id, options));
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
getArtifactURL(artifacts, artifactName, collectionName) {
|
|
@@ -140,7 +141,7 @@ export class FileFetcherImpl {
|
|
|
140
141
|
id,
|
|
141
142
|
occurrenceKey
|
|
142
143
|
} = uploadableFileUpfrontIds;
|
|
143
|
-
const subject =
|
|
144
|
+
const subject = createMediaSubject();
|
|
144
145
|
const deferredBlob = fetch(url).then(response => response.blob()).catch(() => undefined);
|
|
145
146
|
const preview = new Promise(async (resolve, reject) => {
|
|
146
147
|
const blob = await deferredBlob;
|
|
@@ -231,7 +232,7 @@ export class FileFetcherImpl {
|
|
|
231
232
|
let preview; // TODO [MSW-796]: get file size for base64
|
|
232
233
|
|
|
233
234
|
const mediaType = getMediaTypeFromUploadableFile(file);
|
|
234
|
-
const subject =
|
|
235
|
+
const subject = createMediaSubject();
|
|
235
236
|
const processingSubscription = new Subscription();
|
|
236
237
|
|
|
237
238
|
if (content instanceof Blob) {
|
|
@@ -306,7 +307,7 @@ export class FileFetcherImpl {
|
|
|
306
307
|
});
|
|
307
308
|
}
|
|
308
309
|
|
|
309
|
-
return subject;
|
|
310
|
+
return toMediaSubscribable(subject);
|
|
310
311
|
}
|
|
311
312
|
|
|
312
313
|
async downloadBinary(id, name = 'download', collectionName) {
|
|
@@ -379,7 +380,7 @@ export class FileFetcherImpl {
|
|
|
379
380
|
data: copiedFileWithMimeType
|
|
380
381
|
});
|
|
381
382
|
const fileCache = cache.get(copiedId);
|
|
382
|
-
const subject = fileCache ||
|
|
383
|
+
const subject = fileCache || createMediaSubject(); // if we were passed a "preview", we propagate it into the copiedFileState
|
|
383
384
|
|
|
384
385
|
const previewOverride = !isErrorFileState(copiedFileState) && !!preview ? {
|
|
385
386
|
preview
|
|
@@ -423,7 +424,7 @@ export class FileFetcherImpl {
|
|
|
423
424
|
fileCache.error(error);
|
|
424
425
|
} else {
|
|
425
426
|
// Create a new subject with the error state for new subscriptions
|
|
426
|
-
cache.set(id,
|
|
427
|
+
cache.set(id, createMediaSubject(error));
|
|
427
428
|
}
|
|
428
429
|
}
|
|
429
430
|
|
package/dist/es2019/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,15 +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 {
|
|
28
|
+
export { createMediaSubscribable } from './utils/toMediaSubscribable';
|
|
29
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.
|
|
30
30
|
|
|
31
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,5 +1,5 @@
|
|
|
1
1
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
2
|
-
export
|
|
2
|
+
export function createMediaSubject(initialState) {
|
|
3
3
|
const subject = new ReplaySubject(1);
|
|
4
4
|
|
|
5
5
|
if (initialState instanceof Error) {
|
|
@@ -9,4 +9,4 @@ export const createFileStateSubject = initialState => {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return subject;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Subscription } from 'rxjs/Subscription';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
|
|
5
|
+
*
|
|
6
|
+
* @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
|
|
7
|
+
* @param subscription a default Subscription (this parameter exists for testing purpose)
|
|
8
|
+
*/
|
|
9
|
+
export const mediaSubscribableToPromise = (mediaSubscribable, subscription = new Subscription()) => {
|
|
10
|
+
return new Promise((resolve, reject) => subscription.add(mediaSubscribable.subscribe({
|
|
11
|
+
next: state => {
|
|
12
|
+
resolve(state);
|
|
13
|
+
subscription.unsubscribe();
|
|
14
|
+
},
|
|
15
|
+
error: error => {
|
|
16
|
+
reject(error);
|
|
17
|
+
subscription.unsubscribe();
|
|
18
|
+
}
|
|
19
|
+
})));
|
|
20
|
+
};
|
|
@@ -2,7 +2,7 @@ import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
|
2
2
|
import { from } from 'rxjs/observable/from';
|
|
3
3
|
import { map } from 'rxjs/operators/map';
|
|
4
4
|
import { mapMediaItemToFileState } from '../../models/file-state';
|
|
5
|
-
import {
|
|
5
|
+
import { createMediaSubject } from '../createMediaSubject';
|
|
6
6
|
import { isEmptyFile } from '../detectEmptyFile';
|
|
7
7
|
import { PollingFunction } from '../polling';
|
|
8
8
|
import { MobileUploadError } from './error';
|
|
@@ -12,7 +12,7 @@ export const createMobileFileStateSubject = service => {
|
|
|
12
12
|
return subject;
|
|
13
13
|
};
|
|
14
14
|
export const createMobileDownloadFileStream = (dataloader, id, collectionName, occurrenceKey) => {
|
|
15
|
-
const subject =
|
|
15
|
+
const subject = createMediaSubject();
|
|
16
16
|
const poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
17
17
|
|
|
18
18
|
poll.onError = error => subject.error(error);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { createMediaSubject } from './createMediaSubject';
|
|
2
2
|
export function toMediaSubscribable(observable) {
|
|
3
3
|
return {
|
|
4
4
|
subscribe: observer => {
|
|
@@ -12,4 +12,7 @@ export function toMediaSubscribable(observable) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
}
|
|
16
|
+
export function createMediaSubscribable(mediaSubscribableItem) {
|
|
17
|
+
return toMediaSubscribable(createMediaSubject(mediaSubscribableItem));
|
|
15
18
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -12,6 +12,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
12
12
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
13
13
|
import { getFileStreamsCache } from '../file-streams-cache';
|
|
14
14
|
import { mapMediaFileToFileState } from '../models/file-state';
|
|
15
|
+
import { toMediaSubscribable } from '../utils/toMediaSubscribable';
|
|
15
16
|
export var collectionCache = {};
|
|
16
17
|
|
|
17
18
|
var createCacheEntry = function createCacheEntry() {
|
|
@@ -97,7 +98,7 @@ export var CollectionFetcher = /*#__PURE__*/function () {
|
|
|
97
98
|
}).catch(function (error) {
|
|
98
99
|
return subject.error(error);
|
|
99
100
|
});
|
|
100
|
-
return subject;
|
|
101
|
+
return toMediaSubscribable(subject);
|
|
101
102
|
}
|
|
102
103
|
}, {
|
|
103
104
|
key: "removeFile",
|
|
@@ -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
|
|
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,15 +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 {
|
|
28
|
+
export { createMediaSubscribable } from './utils/toMediaSubscribable';
|
|
29
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.
|
|
30
30
|
|
|
31
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,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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { createMediaSubject } from './createMediaSubject';
|
|
2
2
|
export function toMediaSubscribable(observable) {
|
|
3
3
|
return {
|
|
4
4
|
subscribe: function subscribe(observer) {
|
|
@@ -12,4 +12,7 @@ export function toMediaSubscribable(observable) {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
}
|
|
16
|
+
export function createMediaSubscribable(mediaSubscribableItem) {
|
|
17
|
+
return toMediaSubscribable(createMediaSubject(mediaSubscribableItem));
|
|
15
18
|
}
|
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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Auth, AuthContext, AuthProvider } from '@atlaskit/media-core';
|
|
2
2
|
export declare const DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
|
|
3
3
|
export declare const resolveAuth: (authProvider: AuthProvider, authContext?: AuthContext | undefined, authProviderTimeout?: number) => Promise<Auth>;
|
|
4
|
-
export declare const resolveInitialAuth: (auth?:
|
|
4
|
+
export declare const resolveInitialAuth: (auth?: Auth | undefined) => Auth;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UploadEventPayloadMap, EventPayloadListener } from './client/events';
|
|
2
2
|
export declare const globalMediaEventEmitter: {
|
|
3
|
-
on<E extends
|
|
4
|
-
off<E_1 extends
|
|
5
|
-
emit<E_2 extends
|
|
3
|
+
on<E extends keyof UploadEventPayloadMap>(event: E, listener: EventPayloadListener<UploadEventPayloadMap, E, any>): void;
|
|
4
|
+
off<E_1 extends keyof UploadEventPayloadMap>(event: E_1, listener: EventPayloadListener<UploadEventPayloadMap, E_1, any>): void;
|
|
5
|
+
emit<E_2 extends keyof UploadEventPayloadMap>(event: E_2, payload: UploadEventPayloadMap[E_2]): boolean | undefined;
|
|
6
6
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -33,21 +33,20 @@ export { StargateClient } from './client/stargate-client';
|
|
|
33
33
|
export type { EdgeData } from './client/stargate-client';
|
|
34
34
|
export { isImageRemote } from './utils/isImageRemote';
|
|
35
35
|
export { checkWebpSupport } from './utils/checkWebpSupport';
|
|
36
|
-
export { observableToPromise } from './utils/observableToPromise';
|
|
37
36
|
export { getDimensionsFromBlob } from './utils/getDimensionsFromBlob';
|
|
38
37
|
export type { Dimensions } from './utils/getDimensionsFromBlob';
|
|
39
|
-
export {
|
|
38
|
+
export { createMediaSubject } from './utils/createMediaSubject';
|
|
40
39
|
export { safeUnsubscribe } from './utils/safeUnsubscribe';
|
|
41
40
|
export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier, } from './identifier';
|
|
42
41
|
export type { Identifier, FileIdentifier, ExternalImageIdentifier, } from './identifier';
|
|
43
42
|
export type { EventPayloadListener, UploadEventPayloadMap, MediaViewedEventPayload, } from './client/events';
|
|
44
43
|
export { withMediaClient, getMediaClient } from './utils/with-media-client-hoc';
|
|
45
|
-
export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, } from './utils/with-media-client-hoc';
|
|
44
|
+
export type { WithMediaClientConfig, WithMediaClientConfigProps, WithMediaClientFunction, WithMediaClient, } from './utils/with-media-client-hoc';
|
|
46
45
|
export { globalMediaEventEmitter } from './globalMediaEventEmitter';
|
|
47
46
|
export { isMediaBlobUrl, getAttrsFromUrl, addFileAttrsToUrl, objectToQueryString, } from './utils/url';
|
|
48
47
|
export type { MediaBlobUrlAttrs } from './utils/url';
|
|
49
|
-
export {
|
|
50
|
-
export type { MediaSubscribable, MediaSubscription, } from './utils/toMediaSubscribable';
|
|
48
|
+
export { createMediaSubscribable } from './utils/toMediaSubscribable';
|
|
49
|
+
export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/toMediaSubscribable';
|
|
51
50
|
export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
|
|
52
51
|
/**
|
|
53
52
|
* @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
|
|
@@ -84,7 +84,7 @@ export declare const isUploadingFileState: (fileState: FileState) => fileState i
|
|
|
84
84
|
export declare const isProcessingFileState: (fileState: FileState) => fileState is ProcessingFileState;
|
|
85
85
|
export declare const isProcessedFileState: (fileState: FileState) => fileState is ProcessedFileState;
|
|
86
86
|
export declare const isErrorFileState: (fileState: FileState) => fileState is ErrorFileState;
|
|
87
|
-
export declare const isPreviewableFileState: (fileState: FileState) => fileState is (UploadingFileState
|
|
87
|
+
export declare const isPreviewableFileState: (fileState: FileState) => fileState is (UploadingFileState | ProcessingFileState | ProcessedFileState | ProcessingFailedState) & PreviewableFileState;
|
|
88
88
|
export declare const isFinalFileState: (fileState: FileState) => fileState is ProcessedFileState | ProcessingFailedState | ErrorFileState;
|
|
89
89
|
export declare const isImageRepresentationReady: (fileState: FileState) => boolean;
|
|
90
90
|
export declare const mapMediaFileToFileState: (mediaFile: MediaStoreResponse<MediaFile>) => FileState;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MediaStoreGetFileImageParams } from '../client/media-store';
|
|
2
2
|
export declare type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
|
|
3
|
-
export declare const imageResizeModeToFileImageMode: (resizeMode?:
|
|
3
|
+
export declare const imageResizeModeToFileImageMode: (resizeMode?: ImageResizeMode | undefined) => MediaStoreGetFileImageParams['mode'];
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { FileState } from '../models/file-state';
|
|
2
2
|
import { MediaType } from '../models/media';
|
|
3
|
-
export declare const overrideMediaTypeIfUnknown: (fileState: FileState, mediaType?:
|
|
4
|
-
mediaType?:
|
|
3
|
+
export declare const overrideMediaTypeIfUnknown: (fileState: FileState, mediaType?: MediaType | undefined) => {
|
|
4
|
+
mediaType?: MediaType | undefined;
|
|
5
5
|
};
|
|
@@ -7,7 +7,7 @@ export declare class RequestError extends BaseMediaClientError<RequestErrorAttri
|
|
|
7
7
|
constructor(reason: RequestErrorReason, metadata?: RequestErrorMetadata | undefined, innerError?: Error | undefined);
|
|
8
8
|
get attributes(): {
|
|
9
9
|
reason: RequestErrorReason;
|
|
10
|
-
method: "
|
|
10
|
+
method: import("./types").RequestMethod | undefined;
|
|
11
11
|
endpoint: string | undefined;
|
|
12
12
|
attempts: number | undefined;
|
|
13
13
|
clientExhaustedRetries: boolean | undefined;
|
|
@@ -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;
|
|
@@ -6,12 +6,15 @@ export declare type MediaSubscription = {
|
|
|
6
6
|
declare type PartialObserver<T extends MediaSubscribableItem> = {
|
|
7
7
|
next?: (value: T) => void;
|
|
8
8
|
error?: (err: any) => void;
|
|
9
|
+
complete?: () => void;
|
|
9
10
|
};
|
|
10
11
|
declare type NextObserver<T extends MediaSubscribableItem> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'next'>>;
|
|
11
12
|
declare type ErrorObserver<T extends MediaSubscribableItem> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'error'>>;
|
|
12
|
-
|
|
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);
|
|
13
15
|
export declare type MediaSubscribable<T extends MediaSubscribableItem> = {
|
|
14
16
|
subscribe(observer?: MediaObserver<T>): MediaSubscription;
|
|
15
17
|
};
|
|
16
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>;
|
|
17
20
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.1.1",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,8 +27,8 @@
|
|
|
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.12.0",
|
|
32
32
|
"@babel/runtime": "^7.0.0",
|
|
33
33
|
"dataloader": "^2.0.0",
|
|
34
34
|
"deep-equal": "^1.0.1",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"lru-fast": "^0.2.2",
|
|
37
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,16 +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.1",
|
|
48
|
+
"react": "^16.8.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@atlaskit/button": "^16.
|
|
51
|
+
"@atlaskit/button": "^16.3.0",
|
|
52
52
|
"@atlaskit/docs": "*",
|
|
53
|
-
"@atlaskit/media-card": "^73.
|
|
54
|
-
"@atlaskit/media-core": "^32.
|
|
55
|
-
"@atlaskit/media-test-helpers": "^29.
|
|
53
|
+
"@atlaskit/media-card": "^73.5.0",
|
|
54
|
+
"@atlaskit/media-core": "^32.3.0",
|
|
55
|
+
"@atlaskit/media-test-helpers": "^29.4.0",
|
|
56
56
|
"@atlaskit/ssr": "*",
|
|
57
57
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
58
58
|
"@types/deep-equal": "^1.0.1",
|
|
@@ -60,12 +60,10 @@
|
|
|
60
60
|
"@types/uuid-validate": "^0.0.0",
|
|
61
61
|
"enzyme": "^3.10.0",
|
|
62
62
|
"fetch-mock": "^8.0.0",
|
|
63
|
-
"jest-fetch-mock": "^3.0.3",
|
|
64
63
|
"react": "^16.8.0",
|
|
65
64
|
"react-dom": "^16.8.0",
|
|
66
|
-
"rxjs": "^5.5.0",
|
|
67
65
|
"styled-components": "^3.2.6",
|
|
68
|
-
"typescript": "
|
|
66
|
+
"typescript": "4.2.4"
|
|
69
67
|
},
|
|
70
68
|
"resolutions": {
|
|
71
69
|
"lru-fast": "0.2.2"
|
|
@@ -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>;
|