@atlaskit/media-client 14.2.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/client/file-fetcher/index.js +1 -1
- package/dist/cjs/client/mobile-upload.js +1 -2
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/utils/imageResizeModeToFileImageMode.js +12 -0
- package/dist/cjs/utils/mobileUpload/helpers.js +2 -2
- package/dist/cjs/utils/mobileUpload/stateMachine/index.js +2 -2
- package/dist/cjs/utils/polling/index.js +8 -15
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/file-fetcher/index.js +2 -2
- package/dist/es2019/client/mobile-upload.js +1 -2
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/utils/imageResizeModeToFileImageMode.js +1 -0
- package/dist/es2019/utils/mobileUpload/helpers.js +3 -3
- package/dist/es2019/utils/mobileUpload/stateMachine/index.js +2 -2
- package/dist/es2019/utils/polling/index.js +7 -9
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/index.js +2 -2
- package/dist/esm/client/mobile-upload.js +1 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/imageResizeModeToFileImageMode.js +3 -0
- package/dist/esm/utils/mobileUpload/helpers.js +3 -3
- package/dist/esm/utils/mobileUpload/stateMachine/index.js +2 -2
- package/dist/esm/utils/polling/index.js +7 -11
- package/dist/esm/version.json +1 -1
- package/dist/types/client/mobile-upload.d.ts +0 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils/imageResizeModeToFileImageMode.d.ts +3 -0
- package/dist/types/utils/mobileUpload/helpers.d.ts +1 -2
- package/dist/types/utils/mobileUpload/stateMachine/index.d.ts +1 -2
- package/dist/types/utils/polling/index.d.ts +8 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 14.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b51fc0a9062`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b51fc0a9062) - New helper to convert ImageResizeMode into FileImageMode
|
|
8
|
+
- [`269ee940b87`](https://bitbucket.org/atlassian/atlassian-frontend/commits/269ee940b87) - redesign error UI on new media card experience
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`fe9ced0cd70`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fe9ced0cd70) - Removed feature flags for polling settings
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 14.2.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -94,7 +94,7 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
94
94
|
(0, _classCallCheck2.default)(this, FileFetcherImpl);
|
|
95
95
|
(0, _defineProperty2.default)(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
96
96
|
var subject = (0, _createFileStateSubject.createFileStateSubject)();
|
|
97
|
-
var poll = new _polling.PollingFunction(
|
|
97
|
+
var poll = new _polling.PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
98
98
|
|
|
99
99
|
poll.onError = function (error) {
|
|
100
100
|
return subject.error(error);
|
|
@@ -22,7 +22,6 @@ var _mobileUpload = require("../utils/mobileUpload");
|
|
|
22
22
|
var MobileUploadImpl = /*#__PURE__*/function () {
|
|
23
23
|
function MobileUploadImpl(mediaStore) {
|
|
24
24
|
(0, _classCallCheck2.default)(this, MobileUploadImpl);
|
|
25
|
-
this.mediaStore = mediaStore;
|
|
26
25
|
this.dataloader = (0, _createFileDataLoader.createFileDataloader)(mediaStore);
|
|
27
26
|
this.servicesCache = (0, _mobileUpload.createServicesCache)();
|
|
28
27
|
}
|
|
@@ -51,7 +50,7 @@ var MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
51
50
|
preview: preview,
|
|
52
51
|
createdAt: createdAt
|
|
53
52
|
};
|
|
54
|
-
var service = (0, _mobileUpload.createMobileUploadService)((0, _mobileUpload.createMobileUploadStateMachine)(this.dataloader, initialState, collectionName
|
|
53
|
+
var service = (0, _mobileUpload.createMobileUploadService)((0, _mobileUpload.createMobileUploadStateMachine)(this.dataloader, initialState, collectionName));
|
|
55
54
|
var subject = (0, _mobileUpload.createMobileFileStateSubject)(service);
|
|
56
55
|
this.servicesCache.put(fileId, service);
|
|
57
56
|
(0, _fileStreamsCache.getFileStreamsCache)().set(fileId, subject);
|
package/dist/cjs/index.js
CHANGED
|
@@ -201,6 +201,12 @@ Object.defineProperty(exports, "PollingError", {
|
|
|
201
201
|
return _errors2.PollingError;
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
|
+
Object.defineProperty(exports, "imageResizeModeToFileImageMode", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
get: function get() {
|
|
207
|
+
return _imageResizeModeToFileImageMode.imageResizeModeToFileImageMode;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
204
210
|
Object.defineProperty(exports, "FileFetcherImpl", {
|
|
205
211
|
enumerable: true,
|
|
206
212
|
get: function get() {
|
|
@@ -371,6 +377,8 @@ var _polling = require("./utils/polling");
|
|
|
371
377
|
|
|
372
378
|
var _errors2 = require("./utils/polling/errors");
|
|
373
379
|
|
|
380
|
+
var _imageResizeModeToFileImageMode = require("./utils/imageResizeModeToFileImageMode");
|
|
381
|
+
|
|
374
382
|
var _fileFetcher = require("./client/file-fetcher");
|
|
375
383
|
|
|
376
384
|
var _collectionFetcher = require("./client/collection-fetcher");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.imageResizeModeToFileImageMode = void 0;
|
|
7
|
+
|
|
8
|
+
var imageResizeModeToFileImageMode = function imageResizeModeToFileImageMode(resizeMode) {
|
|
9
|
+
return resizeMode === 'stretchy-fit' ? 'full-fit' : resizeMode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.imageResizeModeToFileImageMode = imageResizeModeToFileImageMode;
|
|
@@ -37,9 +37,9 @@ var createMobileFileStateSubject = function createMobileFileStateSubject(service
|
|
|
37
37
|
|
|
38
38
|
exports.createMobileFileStateSubject = createMobileFileStateSubject;
|
|
39
39
|
|
|
40
|
-
var createMobileDownloadFileStream = function createMobileDownloadFileStream(dataloader, id, collectionName, occurrenceKey
|
|
40
|
+
var createMobileDownloadFileStream = function createMobileDownloadFileStream(dataloader, id, collectionName, occurrenceKey) {
|
|
41
41
|
var subject = (0, _createFileStateSubject.createFileStateSubject)();
|
|
42
|
-
var poll = new _polling.PollingFunction(
|
|
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) {
|
|
45
45
|
return subject.error(error);
|
|
@@ -32,7 +32,7 @@ var _processingFailed = require("./states/processingFailed");
|
|
|
32
32
|
|
|
33
33
|
var _error = require("./states/error");
|
|
34
34
|
|
|
35
|
-
var createMobileUploadStateMachine = function createMobileUploadStateMachine(dataloader, initialState, collectionName
|
|
35
|
+
var createMobileUploadStateMachine = function createMobileUploadStateMachine(dataloader, initialState, collectionName) {
|
|
36
36
|
return (0, _xstate.createMachine)({
|
|
37
37
|
// Initial state
|
|
38
38
|
initial: initialState.status,
|
|
@@ -85,7 +85,7 @@ var createMobileUploadStateMachine = function createMobileUploadStateMachine(dat
|
|
|
85
85
|
return shouldFetchRemoteFileStates;
|
|
86
86
|
}(),
|
|
87
87
|
fetchRemoteFileStates: function fetchRemoteFileStates(ctx) {
|
|
88
|
-
return (0, _helpers.createMobileDownloadFileStream)(dataloader, ctx.currentFileState.id, collectionName, ctx.currentFileState.occurrenceKey
|
|
88
|
+
return (0, _helpers.createMobileDownloadFileStream)(dataloader, ctx.currentFileState.id, collectionName, ctx.currentFileState.occurrenceKey).pipe((0, _map.map)(function (fileState) {
|
|
89
89
|
return {
|
|
90
90
|
type: 'REMOTE_FILESTATE_RESULT',
|
|
91
91
|
fileState: fileState
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.PollingFunction = exports.defaultPollingOptions =
|
|
8
|
+
exports.PollingFunction = exports.defaultPollingOptions = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
@@ -17,26 +17,19 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
17
17
|
|
|
18
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
19
|
|
|
20
|
-
var _mediaFeatureFlags = require("@atlaskit/media-common/mediaFeatureFlags");
|
|
21
|
-
|
|
22
20
|
var _errors = require("./errors");
|
|
23
21
|
|
|
24
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
25
23
|
|
|
26
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}; // default polling options without using feature flags
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exports.getPollingOptions = getPollingOptions;
|
|
39
|
-
var defaultPollingOptions = getPollingOptions(undefined);
|
|
26
|
+
// default polling options without using feature flags
|
|
27
|
+
var defaultPollingOptions = {
|
|
28
|
+
poll_intervalMs: 3000,
|
|
29
|
+
poll_maxAttempts: 30,
|
|
30
|
+
poll_backoffFactor: 1.25,
|
|
31
|
+
poll_maxIntervalMs: 200000
|
|
32
|
+
};
|
|
40
33
|
/**
|
|
41
34
|
* This class encapsulates polling functionality with the following features:
|
|
42
35
|
*
|
package/dist/cjs/version.json
CHANGED
|
@@ -26,14 +26,14 @@ import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
|
26
26
|
import { createFileStateSubject } from '../../utils/createFileStateSubject';
|
|
27
27
|
import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
28
28
|
import { shouldFetchRemoteFileStates, shouldFetchRemoteFileStatesObservable } from '../../utils/shouldFetchRemoteFileStates';
|
|
29
|
-
import {
|
|
29
|
+
import { PollingFunction } from '../../utils/polling';
|
|
30
30
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
31
31
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
32
32
|
export class FileFetcherImpl {
|
|
33
33
|
constructor(mediaStore) {
|
|
34
34
|
_defineProperty(this, "createDownloadFileStream", (id, collectionName, occurrenceKey) => {
|
|
35
35
|
const subject = createFileStateSubject();
|
|
36
|
-
const poll = new PollingFunction(
|
|
36
|
+
const poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
37
37
|
|
|
38
38
|
poll.onError = error => subject.error(error);
|
|
39
39
|
|
|
@@ -4,7 +4,6 @@ import { createFileDataloader } from '../utils/createFileDataLoader';
|
|
|
4
4
|
import { createServicesCache, createMobileUploadStateMachine, createMobileUploadService, createMobileFileStateSubject } from '../utils/mobileUpload';
|
|
5
5
|
export class MobileUploadImpl {
|
|
6
6
|
constructor(mediaStore) {
|
|
7
|
-
this.mediaStore = mediaStore;
|
|
8
7
|
this.dataloader = createFileDataloader(mediaStore);
|
|
9
8
|
this.servicesCache = createServicesCache();
|
|
10
9
|
}
|
|
@@ -33,7 +32,7 @@ export class MobileUploadImpl {
|
|
|
33
32
|
preview,
|
|
34
33
|
createdAt
|
|
35
34
|
};
|
|
36
|
-
const service = createMobileUploadService(createMobileUploadStateMachine(this.dataloader, initialState, collectionName
|
|
35
|
+
const service = createMobileUploadService(createMobileUploadStateMachine(this.dataloader, initialState, collectionName));
|
|
37
36
|
const subject = createMobileFileStateSubject(service);
|
|
38
37
|
this.servicesCache.put(fileId, service);
|
|
39
38
|
getFileStreamsCache().set(fileId, subject);
|
package/dist/es2019/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { request, RequestError, isRequestError, isRateLimitedError } from './uti
|
|
|
10
10
|
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl } from './utils/request/helpers';
|
|
11
11
|
export { PollingFunction } from './utils/polling';
|
|
12
12
|
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
13
|
+
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
13
14
|
export { FileFetcherImpl, FileFetcherError, isFileFetcherError } from './client/file-fetcher';
|
|
14
15
|
export { CollectionFetcher } from './client/collection-fetcher';
|
|
15
16
|
export { MediaClient } from './client/media-client';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const imageResizeModeToFileImageMode = resizeMode => resizeMode === 'stretchy-fit' ? 'full-fit' : resizeMode;
|
|
@@ -4,16 +4,16 @@ import { map } from 'rxjs/operators/map';
|
|
|
4
4
|
import { mapMediaItemToFileState } from '../../models/file-state';
|
|
5
5
|
import { createFileStateSubject } from '../createFileStateSubject';
|
|
6
6
|
import { isEmptyFile } from '../detectEmptyFile';
|
|
7
|
-
import {
|
|
7
|
+
import { PollingFunction } from '../polling';
|
|
8
8
|
import { MobileUploadError } from './error';
|
|
9
9
|
export const createMobileFileStateSubject = service => {
|
|
10
10
|
const subject = new ReplaySubject(1);
|
|
11
11
|
from(service.start()).pipe(map(state => state.context.currentFileState)).subscribe(subject);
|
|
12
12
|
return subject;
|
|
13
13
|
};
|
|
14
|
-
export const createMobileDownloadFileStream = (dataloader, id, collectionName, occurrenceKey
|
|
14
|
+
export const createMobileDownloadFileStream = (dataloader, id, collectionName, occurrenceKey) => {
|
|
15
15
|
const subject = createFileStateSubject();
|
|
16
|
-
const poll = new PollingFunction(
|
|
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);
|
|
19
19
|
|
|
@@ -8,7 +8,7 @@ import { machineProcessingState } from './states/processing';
|
|
|
8
8
|
import { machineProcessedState } from './states/processed';
|
|
9
9
|
import { machineProcessingFailedState } from './states/processingFailed';
|
|
10
10
|
import { machineErrorState } from './states/error';
|
|
11
|
-
export const createMobileUploadStateMachine = (dataloader, initialState, collectionName
|
|
11
|
+
export const createMobileUploadStateMachine = (dataloader, initialState, collectionName) => createMachine({
|
|
12
12
|
// Initial state
|
|
13
13
|
initial: initialState.status,
|
|
14
14
|
// Context
|
|
@@ -41,7 +41,7 @@ export const createMobileUploadStateMachine = (dataloader, initialState, collect
|
|
|
41
41
|
|
|
42
42
|
return false;
|
|
43
43
|
},
|
|
44
|
-
fetchRemoteFileStates: ctx => createMobileDownloadFileStream(dataloader, ctx.currentFileState.id, collectionName, ctx.currentFileState.occurrenceKey
|
|
44
|
+
fetchRemoteFileStates: ctx => createMobileDownloadFileStream(dataloader, ctx.currentFileState.id, collectionName, ctx.currentFileState.occurrenceKey).pipe(map(fileState => ({
|
|
45
45
|
type: 'REMOTE_FILESTATE_RESULT',
|
|
46
46
|
fileState
|
|
47
47
|
})))
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common/mediaFeatureFlags';
|
|
3
2
|
import { PollingError } from './errors';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const defaultPollingOptions = getPollingOptions(undefined);
|
|
3
|
+
// default polling options without using feature flags
|
|
4
|
+
export const defaultPollingOptions = {
|
|
5
|
+
poll_intervalMs: 3000,
|
|
6
|
+
poll_maxAttempts: 30,
|
|
7
|
+
poll_backoffFactor: 1.25,
|
|
8
|
+
poll_maxIntervalMs: 200000
|
|
9
|
+
};
|
|
12
10
|
/**
|
|
13
11
|
* This class encapsulates polling functionality with the following features:
|
|
14
12
|
*
|
package/dist/es2019/version.json
CHANGED
|
@@ -35,7 +35,7 @@ import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
|
35
35
|
import { createFileStateSubject } from '../../utils/createFileStateSubject';
|
|
36
36
|
import { isMimeTypeSupportedByBrowser, getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
37
37
|
import { shouldFetchRemoteFileStates, shouldFetchRemoteFileStatesObservable } from '../../utils/shouldFetchRemoteFileStates';
|
|
38
|
-
import {
|
|
38
|
+
import { PollingFunction } from '../../utils/polling';
|
|
39
39
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
40
40
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
41
41
|
export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
@@ -46,7 +46,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
46
46
|
|
|
47
47
|
_defineProperty(this, "createDownloadFileStream", function (id, collectionName, occurrenceKey) {
|
|
48
48
|
var subject = createFileStateSubject();
|
|
49
|
-
var poll = new PollingFunction(
|
|
49
|
+
var poll = new PollingFunction(); // ensure subject errors if polling exceeds max iterations or uncaught exception in executor
|
|
50
50
|
|
|
51
51
|
poll.onError = function (error) {
|
|
52
52
|
return subject.error(error);
|
|
@@ -8,7 +8,6 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
8
8
|
function MobileUploadImpl(mediaStore) {
|
|
9
9
|
_classCallCheck(this, MobileUploadImpl);
|
|
10
10
|
|
|
11
|
-
this.mediaStore = mediaStore;
|
|
12
11
|
this.dataloader = createFileDataloader(mediaStore);
|
|
13
12
|
this.servicesCache = createServicesCache();
|
|
14
13
|
}
|
|
@@ -37,7 +36,7 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
37
36
|
preview: preview,
|
|
38
37
|
createdAt: createdAt
|
|
39
38
|
};
|
|
40
|
-
var service = createMobileUploadService(createMobileUploadStateMachine(this.dataloader, initialState, collectionName
|
|
39
|
+
var service = createMobileUploadService(createMobileUploadStateMachine(this.dataloader, initialState, collectionName));
|
|
41
40
|
var subject = createMobileFileStateSubject(service);
|
|
42
41
|
this.servicesCache.put(fileId, service);
|
|
43
42
|
getFileStreamsCache().set(fileId, subject);
|
package/dist/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { request, RequestError, isRequestError, isRateLimitedError } from './uti
|
|
|
10
10
|
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl } from './utils/request/helpers';
|
|
11
11
|
export { PollingFunction } from './utils/polling';
|
|
12
12
|
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
13
|
+
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
13
14
|
export { FileFetcherImpl, FileFetcherError, isFileFetcherError } from './client/file-fetcher';
|
|
14
15
|
export { CollectionFetcher } from './client/collection-fetcher';
|
|
15
16
|
export { MediaClient } from './client/media-client';
|
|
@@ -6,7 +6,7 @@ import { map } from 'rxjs/operators/map';
|
|
|
6
6
|
import { mapMediaItemToFileState } from '../../models/file-state';
|
|
7
7
|
import { createFileStateSubject } from '../createFileStateSubject';
|
|
8
8
|
import { isEmptyFile } from '../detectEmptyFile';
|
|
9
|
-
import {
|
|
9
|
+
import { PollingFunction } from '../polling';
|
|
10
10
|
import { MobileUploadError } from './error';
|
|
11
11
|
export var createMobileFileStateSubject = function createMobileFileStateSubject(service) {
|
|
12
12
|
var subject = new ReplaySubject(1);
|
|
@@ -15,9 +15,9 @@ export var createMobileFileStateSubject = function createMobileFileStateSubject(
|
|
|
15
15
|
})).subscribe(subject);
|
|
16
16
|
return subject;
|
|
17
17
|
};
|
|
18
|
-
export var createMobileDownloadFileStream = function createMobileDownloadFileStream(dataloader, id, collectionName, occurrenceKey
|
|
18
|
+
export var createMobileDownloadFileStream = function createMobileDownloadFileStream(dataloader, id, collectionName, occurrenceKey) {
|
|
19
19
|
var subject = createFileStateSubject();
|
|
20
|
-
var poll = new PollingFunction(
|
|
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) {
|
|
23
23
|
return subject.error(error);
|
|
@@ -10,7 +10,7 @@ import { machineProcessingState } from './states/processing';
|
|
|
10
10
|
import { machineProcessedState } from './states/processed';
|
|
11
11
|
import { machineProcessingFailedState } from './states/processingFailed';
|
|
12
12
|
import { machineErrorState } from './states/error';
|
|
13
|
-
export var createMobileUploadStateMachine = function createMobileUploadStateMachine(dataloader, initialState, collectionName
|
|
13
|
+
export var createMobileUploadStateMachine = function createMobileUploadStateMachine(dataloader, initialState, collectionName) {
|
|
14
14
|
return createMachine({
|
|
15
15
|
// Initial state
|
|
16
16
|
initial: initialState.status,
|
|
@@ -63,7 +63,7 @@ export var createMobileUploadStateMachine = function createMobileUploadStateMach
|
|
|
63
63
|
return shouldFetchRemoteFileStates;
|
|
64
64
|
}(),
|
|
65
65
|
fetchRemoteFileStates: function fetchRemoteFileStates(ctx) {
|
|
66
|
-
return createMobileDownloadFileStream(dataloader, ctx.currentFileState.id, collectionName, ctx.currentFileState.occurrenceKey
|
|
66
|
+
return createMobileDownloadFileStream(dataloader, ctx.currentFileState.id, collectionName, ctx.currentFileState.occurrenceKey).pipe(map(function (fileState) {
|
|
67
67
|
return {
|
|
68
68
|
type: 'REMOTE_FILESTATE_RESULT',
|
|
69
69
|
fileState: fileState
|
|
@@ -8,18 +8,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
8
8
|
|
|
9
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
10
|
|
|
11
|
-
import { getMediaFeatureFlag } from '@atlaskit/media-common/mediaFeatureFlags';
|
|
12
11
|
import { PollingError } from './errors';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}; // default polling options without using feature flags
|
|
21
|
-
|
|
22
|
-
export var defaultPollingOptions = getPollingOptions(undefined);
|
|
12
|
+
// default polling options without using feature flags
|
|
13
|
+
export var defaultPollingOptions = {
|
|
14
|
+
poll_intervalMs: 3000,
|
|
15
|
+
poll_maxAttempts: 30,
|
|
16
|
+
poll_backoffFactor: 1.25,
|
|
17
|
+
poll_maxIntervalMs: 200000
|
|
18
|
+
};
|
|
23
19
|
/**
|
|
24
20
|
* This class encapsulates polling functionality with the following features:
|
|
25
21
|
*
|
package/dist/esm/version.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MobileUpload, MobileUploadStartEvent, MobileUploadProgressEvent, MobileUploadEndEvent, MobileUploadErrorEvent } from '../models/mobile-upload';
|
|
2
2
|
import { MediaStore } from './media-store';
|
|
3
3
|
export declare class MobileUploadImpl implements MobileUpload {
|
|
4
|
-
private readonly mediaStore;
|
|
5
4
|
private readonly dataloader;
|
|
6
5
|
private readonly servicesCache;
|
|
7
6
|
constructor(mediaStore: MediaStore);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ export { PollingFunction } from './utils/polling';
|
|
|
22
22
|
export { isPollingError, PollingError } from './utils/polling/errors';
|
|
23
23
|
export type { Executor, PollingErrorAttributes, PollingErrorReason, } from './utils/polling/types';
|
|
24
24
|
export type { RequestMethod, RequestParams, RequestHeaders, RetryOptions, ClientOptions, RequestMetadata, RequestOptions, CreateUrlOptions, } from './utils/request/types';
|
|
25
|
-
export
|
|
25
|
+
export type { ImageResizeMode } from './utils/imageResizeModeToFileImageMode';
|
|
26
|
+
export { imageResizeModeToFileImageMode } from './utils/imageResizeModeToFileImageMode';
|
|
26
27
|
export { FileFetcherImpl, FileFetcherError, isFileFetcherError, } from './client/file-fetcher';
|
|
27
28
|
export type { CopySourceFile, CopyDestination, CopyFileOptions, FileFetcher, FileFetcherErrorAttributes, FileFetcherErrorReason, } from './client/file-fetcher';
|
|
28
29
|
export { CollectionFetcher } from './client/collection-fetcher';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { MediaStoreGetFileImageParams } from '../client/media-store';
|
|
2
|
+
export declare type ImageResizeMode = 'crop' | 'fit' | 'full-fit' | 'stretchy-fit';
|
|
3
|
+
export declare const imageResizeModeToFileImageMode: (resizeMode?: "crop" | "fit" | "full-fit" | "stretchy-fit" | undefined) => MediaStoreGetFileImageParams['mode'];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MediaFeatureFlags } from '@atlaskit/media-common/mediaFeatureFlags';
|
|
2
1
|
import Dataloader from 'dataloader';
|
|
3
2
|
import { ReplaySubject } from 'rxjs/ReplaySubject';
|
|
4
3
|
import { Interpreter } from 'xstate';
|
|
@@ -6,4 +5,4 @@ import { FileState } from '../../models/file-state';
|
|
|
6
5
|
import { DataloaderKey, DataloaderResult } from '../createFileDataLoader';
|
|
7
6
|
import { StateMachineContext, StateMachineEvent, StateMachineTypestate } from './stateMachine/types';
|
|
8
7
|
export declare const createMobileFileStateSubject: (service: Interpreter<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>) => ReplaySubject<FileState>;
|
|
9
|
-
export declare const createMobileDownloadFileStream: (dataloader: Dataloader<DataloaderKey, DataloaderResult>, id: string, collectionName?: string | undefined, occurrenceKey?: string | undefined
|
|
8
|
+
export declare const createMobileDownloadFileStream: (dataloader: Dataloader<DataloaderKey, DataloaderResult>, id: string, collectionName?: string | undefined, occurrenceKey?: string | undefined) => ReplaySubject<FileState>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { MediaFeatureFlags } from '@atlaskit/media-common/mediaFeatureFlags';
|
|
2
1
|
import DataLoader from 'dataloader';
|
|
3
2
|
import { Interpreter, StateMachine } from 'xstate';
|
|
4
3
|
import { UploadingFileState } from '../../../models/file-state';
|
|
5
4
|
import { DataloaderKey, DataloaderResult } from '../../createFileDataLoader';
|
|
6
5
|
import { StateMachineContext, StateMachineEvent, StateMachineSchema, StateMachineTypestate } from './types';
|
|
7
|
-
export declare const createMobileUploadStateMachine: (dataloader: DataLoader<DataloaderKey, DataloaderResult>, initialState: UploadingFileState, collectionName?: string | undefined
|
|
6
|
+
export declare const createMobileUploadStateMachine: (dataloader: DataLoader<DataloaderKey, DataloaderResult>, initialState: UploadingFileState, collectionName?: string | undefined) => StateMachine<StateMachineContext, any, StateMachineEvent, StateMachineTypestate>;
|
|
8
7
|
export declare function createMobileUploadService(machine: StateMachine<StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate>): Interpreter<StateMachineContext, StateMachineSchema, StateMachineEvent, StateMachineTypestate>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { MediaFeatureFlags, PollingOptions } from '@atlaskit/media-common/mediaFeatureFlags';
|
|
2
1
|
import { Executor } from './types';
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
export interface PollingOptions {
|
|
3
|
+
poll_intervalMs: number;
|
|
4
|
+
poll_maxAttempts: number;
|
|
5
|
+
poll_backoffFactor: number;
|
|
6
|
+
poll_maxIntervalMs: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const defaultPollingOptions: PollingOptions;
|
|
5
9
|
/**
|
|
6
10
|
* This class encapsulates polling functionality with the following features:
|
|
7
11
|
*
|
|
@@ -14,7 +18,7 @@ export declare const defaultPollingOptions: Required<PollingOptions>;
|
|
|
14
18
|
* IMPORTANT! the executor function must explicitly call ".next()" for the next iteration to run
|
|
15
19
|
*/
|
|
16
20
|
export declare class PollingFunction {
|
|
17
|
-
options:
|
|
21
|
+
options: PollingOptions;
|
|
18
22
|
poll_intervalMs: number;
|
|
19
23
|
attempt: number;
|
|
20
24
|
shouldIterate: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.3.0",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"@atlaskit/build-utils": "*",
|
|
52
52
|
"@atlaskit/button": "^16.1.0",
|
|
53
53
|
"@atlaskit/docs": "*",
|
|
54
|
-
"@atlaskit/media-card": "^
|
|
54
|
+
"@atlaskit/media-card": "^72.0.0",
|
|
55
55
|
"@atlaskit/media-core": "^32.2.0",
|
|
56
|
-
"@atlaskit/media-test-helpers": "^28.
|
|
56
|
+
"@atlaskit/media-test-helpers": "^28.8.0",
|
|
57
57
|
"@atlaskit/ssr": "*",
|
|
58
58
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
59
59
|
"@types/deep-equal": "^1.0.1",
|