@atlaskit/media-client 17.0.0 → 17.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/client/collection-fetcher.js +4 -4
  3. package/dist/cjs/client/file-fetcher/index.js +5 -7
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/uploader/index.js +112 -37
  6. package/dist/cjs/utils/{toMediaSubscribable.js → mediaSubscribable/fromObservable.js} +4 -4
  7. package/dist/cjs/utils/mediaSubscribable/index.js +27 -0
  8. package/dist/cjs/utils/{mediaSubscribableToPromise.js → mediaSubscribable/toPromise.js} +3 -3
  9. package/dist/cjs/utils/mediaSubscribable/types.js +5 -0
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/client/collection-fetcher.js +2 -2
  12. package/dist/es2019/client/file-fetcher/index.js +5 -6
  13. package/dist/es2019/index.js +1 -1
  14. package/dist/es2019/uploader/index.js +13 -7
  15. package/dist/es2019/utils/{toMediaSubscribable.js → mediaSubscribable/fromObservable.js} +3 -3
  16. package/dist/es2019/utils/mediaSubscribable/index.js +2 -0
  17. package/dist/es2019/utils/{mediaSubscribableToPromise.js → mediaSubscribable/toPromise.js} +1 -1
  18. package/dist/es2019/utils/mediaSubscribable/types.js +1 -0
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/client/collection-fetcher.js +3 -3
  21. package/dist/esm/client/file-fetcher/index.js +6 -7
  22. package/dist/esm/client/media-client.js +1 -1
  23. package/dist/esm/client/media-store/index.js +1 -1
  24. package/dist/esm/client/media-store/resolveAuth.js +1 -1
  25. package/dist/esm/client/stargate-client.js +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/uploader/index.js +113 -38
  28. package/dist/esm/utils/createFileDataLoader.js +1 -1
  29. package/dist/esm/utils/getDimensionsFromBlob.js +1 -1
  30. package/dist/esm/utils/getVideoDimensionsFromBlob.js +1 -1
  31. package/dist/esm/utils/hashing/hasherCreator.js +1 -1
  32. package/dist/esm/utils/{toMediaSubscribable.js → mediaSubscribable/fromObservable.js} +3 -3
  33. package/dist/esm/utils/mediaSubscribable/index.js +2 -0
  34. package/dist/esm/utils/{mediaSubscribableToPromise.js → mediaSubscribable/toPromise.js} +1 -1
  35. package/dist/esm/utils/mediaSubscribable/types.js +1 -0
  36. package/dist/esm/utils/mobileUpload/helpers.js +1 -1
  37. package/dist/esm/utils/mobileUpload/stateMachine/index.js +1 -1
  38. package/dist/esm/utils/polling/index.js +1 -1
  39. package/dist/esm/utils/request/helpers.js +1 -1
  40. package/dist/esm/utils/request/index.js +1 -1
  41. package/dist/esm/utils/shouldFetchRemoteFileStates.js +1 -1
  42. package/dist/esm/version.json +1 -1
  43. package/dist/types/client/collection-fetcher.d.ts +1 -1
  44. package/dist/types/client/file-fetcher/index.d.ts +1 -1
  45. package/dist/types/index.d.ts +2 -2
  46. package/dist/types/utils/mediaSubscribable/fromObservable.d.ts +5 -0
  47. package/dist/types/utils/mediaSubscribable/index.d.ts +3 -0
  48. package/dist/types/utils/{mediaSubscribableToPromise.d.ts → mediaSubscribable/toPromise.d.ts} +3 -3
  49. package/dist/types/utils/mediaSubscribable/types.d.ts +16 -0
  50. package/dist/types/utils/safeUnsubscribe.d.ts +1 -1
  51. package/example-helpers/styles.ts +99 -0
  52. package/example-helpers/stylesWrapper.tsx +82 -0
  53. package/package.json +6 -5
  54. package/report.api.md +1389 -0
  55. package/dist/types/utils/toMediaSubscribable.d.ts +0 -20
  56. package/example-helpers/styled.ts +0 -77
@@ -1,4 +1,3 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -8,6 +7,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
7
 
9
8
  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
9
 
10
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
11
11
  import { Subscription } from 'rxjs/Subscription';
12
12
  import { of } from 'rxjs/observable/of';
13
13
  import { map } from 'rxjs/operators/map';
@@ -30,14 +30,13 @@ 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 { mediaSubscribableToPromise } from '../../utils/mediaSubscribableToPromise';
33
+ import { toPromise, fromObservable } from '../../utils/mediaSubscribable';
34
34
  import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
35
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';
41
40
  export { isFileFetcherError, FileFetcherError } from './error';
42
41
  export var FileFetcherImpl = /*#__PURE__*/function () {
43
42
  function FileFetcherImpl(mediaStore) {
@@ -134,17 +133,17 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
134
133
  collectionName: collectionName,
135
134
  occurrenceKey: occurrenceKey
136
135
  }));
137
- return toMediaSubscribable(subject);
136
+ return fromObservable(subject);
138
137
  }
139
138
 
140
- return toMediaSubscribable(getFileStreamsCache().getOrInsert(id, function () {
139
+ return fromObservable(getFileStreamsCache().getOrInsert(id, function () {
141
140
  return _this2.createDownloadFileStream(id, collectionName);
142
141
  }));
143
142
  }
144
143
  }, {
145
144
  key: "getCurrentState",
146
145
  value: function getCurrentState(id, options) {
147
- return mediaSubscribableToPromise(this.getFileState(id, options));
146
+ return toPromise(this.getFileState(id, options));
148
147
  }
149
148
  }, {
150
149
  key: "getArtifactURL",
@@ -432,7 +431,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
432
431
  });
433
432
  }
434
433
 
435
- return toMediaSubscribable(subject);
434
+ return fromObservable(subject);
436
435
  }
437
436
  }, {
438
437
  key: "downloadBinary",
@@ -1,7 +1,7 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import { EventEmitter2 } from 'eventemitter2';
6
6
  import { MediaStore } from './media-store';
7
7
  import { CollectionFetcher } from './collection-fetcher';
@@ -1,8 +1,8 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
5
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
 
7
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
 
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { MediaStoreError } from './error';
4
4
  import { rejectTimeout } from '../../utils/setTimeoutPromise';
5
5
  export var DEFAULT_AUTH_PROVIDER_TIMEOUT = 10000;
@@ -1,7 +1,7 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  export var StargateClient = /*#__PURE__*/function () {
6
6
  function StargateClient(baseUrl) {
7
7
  _classCallCheck(this, StargateClient);
package/dist/esm/index.js CHANGED
@@ -25,7 +25,7 @@ export { isFileIdentifier, isExternalImageIdentifier, isDifferentIdentifier } fr
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
+ export { createMediaSubscribable } from './utils/mediaSubscribable';
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,11 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
9
  import { chunkinator } from '@atlaskit/chunkinator';
4
10
  import { from } from 'rxjs/observable/from';
5
11
  import { concatMap } from 'rxjs/operators/concatMap';
@@ -36,7 +42,7 @@ var hashingFunction = /*#__PURE__*/function () {
36
42
  };
37
43
  }();
38
44
 
39
- var createProbingFunction = function createProbingFunction(store, collectionName) {
45
+ var createProbingFunction = function createProbingFunction(store, deferredUploadId, collectionName) {
40
46
  return /*#__PURE__*/function () {
41
47
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chunks) {
42
48
  var response, results;
@@ -44,19 +50,43 @@ var createProbingFunction = function createProbingFunction(store, collectionName
44
50
  while (1) {
45
51
  switch (_context2.prev = _context2.next) {
46
52
  case 0:
47
- _context2.next = 2;
48
- return store.probeChunks(hashedChunks(chunks), {
49
- collectionName: collectionName
50
- });
53
+ _context2.t0 = store;
54
+ _context2.t1 = hashedChunks(chunks);
55
+ _context2.t2 = collectionName;
56
+
57
+ if (!getMediaFeatureFlag('mediaUploadApiV2', store.featureFlags)) {
58
+ _context2.next = 9;
59
+ break;
60
+ }
61
+
62
+ _context2.next = 6;
63
+ return deferredUploadId;
64
+
65
+ case 6:
66
+ _context2.t3 = _context2.sent;
67
+ _context2.next = 10;
68
+ break;
69
+
70
+ case 9:
71
+ _context2.t3 = undefined;
51
72
 
52
- case 2:
73
+ case 10:
74
+ _context2.t4 = _context2.t3;
75
+ _context2.t5 = {
76
+ collectionName: _context2.t2,
77
+ uploadId: _context2.t4
78
+ };
79
+ _context2.next = 14;
80
+ return _context2.t0.probeChunks.call(_context2.t0, _context2.t1, _context2.t5);
81
+
82
+ case 14:
53
83
  response = _context2.sent;
54
84
  results = response.data.results;
55
85
  return _context2.abrupt("return", Object.values(results).map(function (result) {
56
86
  return result.exists;
57
87
  }));
58
88
 
59
- case 5:
89
+ case 17:
60
90
  case "end":
61
91
  return _context2.stop();
62
92
  }
@@ -70,63 +100,108 @@ var createProbingFunction = function createProbingFunction(store, collectionName
70
100
  }();
71
101
  };
72
102
 
73
- var createUploadingFunction = function createUploadingFunction(store, collectionName) {
74
- return function (chunk) {
75
- return store.uploadChunk(chunk.hash, chunk.blob, {
76
- collectionName: collectionName
77
- });
78
- };
103
+ var createUploadingFunction = function createUploadingFunction(store, deferredUploadId, collectionName) {
104
+ return /*#__PURE__*/function () {
105
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunk) {
106
+ var options;
107
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
108
+ while (1) {
109
+ switch (_context3.prev = _context3.next) {
110
+ case 0:
111
+ if (!getMediaFeatureFlag('mediaUploadApiV2', store.featureFlags)) {
112
+ _context3.next = 8;
113
+ break;
114
+ }
115
+
116
+ _context3.t1 = chunk.partNumber;
117
+ _context3.next = 4;
118
+ return deferredUploadId;
119
+
120
+ case 4:
121
+ _context3.t2 = _context3.sent;
122
+ _context3.t0 = {
123
+ partNumber: _context3.t1,
124
+ uploadId: _context3.t2
125
+ };
126
+ _context3.next = 9;
127
+ break;
128
+
129
+ case 8:
130
+ _context3.t0 = {};
131
+
132
+ case 9:
133
+ options = _context3.t0;
134
+ _context3.next = 12;
135
+ return store.uploadChunk(chunk.hash, chunk.blob, _objectSpread({
136
+ collectionName: collectionName
137
+ }, options));
138
+
139
+ case 12:
140
+ return _context3.abrupt("return", _context3.sent);
141
+
142
+ case 13:
143
+ case "end":
144
+ return _context3.stop();
145
+ }
146
+ }
147
+ }, _callee3);
148
+ }));
149
+
150
+ return function (_x3) {
151
+ return _ref3.apply(this, arguments);
152
+ };
153
+ }();
79
154
  };
80
155
 
81
156
  var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection) {
82
157
  var offset = 0;
83
158
  return /*#__PURE__*/function () {
84
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunks) {
85
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
159
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(chunks) {
160
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
86
161
  while (1) {
87
- switch (_context3.prev = _context3.next) {
162
+ switch (_context4.prev = _context4.next) {
88
163
  case 0:
89
- _context3.t0 = store;
90
- _context3.next = 3;
164
+ _context4.t0 = store;
165
+ _context4.next = 3;
91
166
  return deferredUploadId;
92
167
 
93
168
  case 3:
94
- _context3.t1 = _context3.sent;
95
- _context3.t2 = {
169
+ _context4.t1 = _context4.sent;
170
+ _context4.t2 = {
96
171
  chunks: hashedChunks(chunks),
97
172
  offset: offset
98
173
  };
99
- _context3.t3 = collection;
100
- _context3.next = 8;
101
- return _context3.t0.appendChunksToUpload.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3);
174
+ _context4.t3 = collection;
175
+ _context4.next = 8;
176
+ return _context4.t0.appendChunksToUpload.call(_context4.t0, _context4.t1, _context4.t2, _context4.t3);
102
177
 
103
178
  case 8:
104
179
  offset += chunks.length;
105
180
 
106
181
  case 9:
107
182
  case "end":
108
- return _context3.stop();
183
+ return _context4.stop();
109
184
  }
110
185
  }
111
- }, _callee3);
186
+ }, _callee4);
112
187
  }));
113
188
 
114
- return function (_x3) {
115
- return _ref3.apply(this, arguments);
189
+ return function (_x4) {
190
+ return _ref4.apply(this, arguments);
116
191
  };
117
192
  }();
118
193
  };
119
194
 
120
195
  var createFileFromUpload = /*#__PURE__*/function () {
121
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(file, store, uploadableFileUpfrontIds, uploadId) {
196
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(file, store, uploadableFileUpfrontIds, uploadId) {
122
197
  var collection, name, mimeType, id, occurrenceKey;
123
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
198
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
124
199
  while (1) {
125
- switch (_context4.prev = _context4.next) {
200
+ switch (_context5.prev = _context5.next) {
126
201
  case 0:
127
202
  collection = file.collection, name = file.name, mimeType = file.mimeType;
128
203
  id = uploadableFileUpfrontIds.id, occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
129
- return _context4.abrupt("return", store.createFileFromUpload({
204
+ return _context5.abrupt("return", store.createFileFromUpload({
130
205
  uploadId: uploadId,
131
206
  name: name,
132
207
  mimeType: mimeType
@@ -138,14 +213,14 @@ var createFileFromUpload = /*#__PURE__*/function () {
138
213
 
139
214
  case 3:
140
215
  case "end":
141
- return _context4.stop();
216
+ return _context5.stop();
142
217
  }
143
218
  }
144
- }, _callee4);
219
+ }, _callee5);
145
220
  }));
146
221
 
147
- return function createFileFromUpload(_x4, _x5, _x6, _x7) {
148
- return _ref4.apply(this, arguments);
222
+ return function createFileFromUpload(_x5, _x6, _x7, _x8) {
223
+ return _ref5.apply(this, arguments);
149
224
  };
150
225
  }();
151
226
 
@@ -182,8 +257,8 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
182
257
  probingBatchSize: 100,
183
258
  chunkSize: chunkSize,
184
259
  uploadingConcurrency: 3,
185
- uploadingFunction: createUploadingFunction(store, collection),
186
- probingFunction: createProbingFunction(store, collection),
260
+ uploadingFunction: createUploadingFunction(store, deferredUploadId, collection),
261
+ probingFunction: createProbingFunction(store, deferredUploadId, collection),
187
262
  processingBatchSize: PROCESSING_BATCH_SIZE,
188
263
  processingFunction: createProcessingFunction(store, deferredUploadId, collection)
189
264
  }, {
@@ -1,6 +1,6 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  // import setimmediate to temporary fix dataloader 2.0.0 bug
5
5
  // @see https://github.com/graphql/dataloader/issues/249
6
6
  import 'setimmediate';
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { getImageDimensionsFromBlob } from './getImageDimensionsFromBlob';
4
4
  import { getVideoDimensionsFromBlob } from './getVideoDimensionsFromBlob';
5
5
  export var getDimensionsFromBlob = /*#__PURE__*/function () {
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import VideoSnapshot from 'video-snapshot';
4
4
  export var getVideoDimensionsFromBlob = /*#__PURE__*/function () {
5
5
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  var hasher = null;
4
4
  export var destroyHasher = function destroyHasher() {
5
5
  return hasher = null;
@@ -1,5 +1,5 @@
1
- import { createMediaSubject } from './createMediaSubject';
2
- export function toMediaSubscribable(observable) {
1
+ import { createMediaSubject } from '../createMediaSubject';
2
+ export function fromObservable(observable) {
3
3
  return {
4
4
  subscribe: function subscribe(observer) {
5
5
  var subscription = // This is needed to handle "subscribe" function overload.
@@ -14,5 +14,5 @@ export function toMediaSubscribable(observable) {
14
14
  };
15
15
  }
16
16
  export function createMediaSubscribable(mediaSubscribableItem) {
17
- return toMediaSubscribable(createMediaSubject(mediaSubscribableItem));
17
+ return fromObservable(createMediaSubject(mediaSubscribableItem));
18
18
  }
@@ -0,0 +1,2 @@
1
+ export { toPromise } from './toPromise';
2
+ export { createMediaSubscribable, fromObservable } from './fromObservable';
@@ -6,7 +6,7 @@ import { Subscription } from 'rxjs/Subscription';
6
6
  * @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
7
7
  * @param subscription a default Subscription (this parameter exists for testing purpose)
8
8
  */
9
- export var mediaSubscribableToPromise = function mediaSubscribableToPromise(mediaSubscribable) {
9
+ export var toPromise = function toPromise(mediaSubscribable) {
10
10
  var subscription = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Subscription();
11
11
  return new Promise(function (resolve, reject) {
12
12
  return subscription.add(mediaSubscribable.subscribe({
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { ReplaySubject } from 'rxjs/ReplaySubject';
4
4
  import { from } from 'rxjs/observable/from';
5
5
  import { map } from 'rxjs/operators/map';
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { map } from 'rxjs/operators/map';
4
4
  import { createMachine, interpret } from 'xstate';
5
5
  import { isProcessingFileState } from '../../../models/file-state';
@@ -1,8 +1,8 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
3
  import _createClass from "@babel/runtime/helpers/createClass";
5
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
 
7
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
 
@@ -1,8 +1,8 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
 
7
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
 
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  export { RequestError, isRequestError } from './errors';
4
4
  export { isRateLimitedError } from './helpers';
5
5
  import { createUrl, fetchRetry, createProcessFetchResponse, withAuth } from './helpers';
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { from } from 'rxjs/observable/from';
4
4
  import { isMimeTypeSupportedByBrowser, isMimeTypeSupportedByServer } from '@atlaskit/media-common/mediaTypeUtils';
5
5
  import { getVideoDimensionsFromBlob } from './getVideoDimensionsFromBlob';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "17.0.0",
3
+ "version": "17.1.0",
4
4
  "sideEffects": false
5
5
  }
@@ -2,7 +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
+ import { MediaSubscribable } from '../utils/mediaSubscribable';
6
6
  export interface MediaCollectionFileItemDetails extends FileDetails {
7
7
  occurrenceKey: string;
8
8
  }
@@ -6,8 +6,8 @@ import { MediaFile } from '../../models/media';
6
6
  import { UploadableFile, UploadableFileUpfrontIds } from '../../uploader';
7
7
  import { MediaFileArtifacts } from '../../models/artifacts';
8
8
  import { UploadController } from '../../upload-controller';
9
+ import { MediaSubscribable } from '../../utils/mediaSubscribable';
9
10
  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 {
@@ -45,8 +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
+ export { createMediaSubscribable } from './utils/mediaSubscribable';
49
+ export type { MediaSubscribable, MediaSubscription, MediaObserver, } from './utils/mediaSubscribable';
50
50
  export { RECENTS_COLLECTION, MAX_RESOLUTION } from './constants';
51
51
  /**
52
52
  * @deprecated This export will be removed. Please use one from @atlaskit/media-common or @atlaskit/media-common/mediaTypeUtils
@@ -0,0 +1,5 @@
1
+ import { ReplaySubject } from 'rxjs/ReplaySubject';
2
+ import { MediaSubscribableItem } from '../../models/media-subscribable';
3
+ import { MediaSubscribable } from './types';
4
+ export declare function fromObservable<T>(observable: ReplaySubject<T>): MediaSubscribable<T>;
5
+ export declare function createMediaSubscribable<T extends MediaSubscribableItem>(mediaSubscribableItem?: T | Error): MediaSubscribable<T>;
@@ -0,0 +1,3 @@
1
+ export type { MediaSubscribable, MediaObserver, MediaSubscription, } from './types';
2
+ export { toPromise } from './toPromise';
3
+ export { createMediaSubscribable, fromObservable } from './fromObservable';
@@ -1,10 +1,10 @@
1
1
  import { Subscription } from 'rxjs/Subscription';
2
- import { MediaSubscribable } from './toMediaSubscribable';
3
- import { MediaSubscribableItem } from '../models/media-subscribable';
2
+ import { MediaSubscribable } from './types';
3
+ import { MediaSubscribableItem } from '../../models/media-subscribable';
4
4
  /**
5
5
  * This is a helper to transform the first value emitted by an MediaSubscribable into a Promise.
6
6
  *
7
7
  * @param mediaSubscribable a given MediaSubscribable<MediaSubscribableItem>
8
8
  * @param subscription a default Subscription (this parameter exists for testing purpose)
9
9
  */
10
- export declare const mediaSubscribableToPromise: <T extends MediaSubscribableItem>(mediaSubscribable: MediaSubscribable<T>, subscription?: Subscription) => Promise<T>;
10
+ export declare const toPromise: <T extends MediaSubscribableItem>(mediaSubscribable: MediaSubscribable<T>, subscription?: Subscription) => Promise<T>;
@@ -0,0 +1,16 @@
1
+ export declare type MediaSubscription = {
2
+ unsubscribe: () => void;
3
+ };
4
+ declare type PartialObserver<T> = {
5
+ next?: (value: T) => void;
6
+ error?: (err: any) => void;
7
+ complete?: () => void;
8
+ };
9
+ export declare type NextObserver<T> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'next'>>;
10
+ export declare type ErrorObserver<T> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'error'>>;
11
+ export declare type CompletionObserver<T> = PartialObserver<T> & Required<Pick<PartialObserver<T>, 'complete'>>;
12
+ export declare type MediaObserver<T> = NextObserver<T> | ErrorObserver<T> | CompletionObserver<T> | ((value: T) => void);
13
+ export declare type MediaSubscribable<T> = {
14
+ subscribe(observer?: MediaObserver<T>): MediaSubscription;
15
+ };
16
+ export {};
@@ -1,2 +1,2 @@
1
- import { MediaSubscription } from './toMediaSubscribable';
1
+ import { MediaSubscription } from './mediaSubscribable';
2
2
  export declare const safeUnsubscribe: (subscription: MediaSubscription) => void;