@atlaskit/media-client 17.1.3 → 18.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/cjs/client/media-client.js +2 -2
- package/dist/cjs/client/media-store/index.js +22 -11
- package/dist/cjs/client/mobile-upload.js +1 -1
- package/dist/cjs/file-streams-cache.js +2 -2
- package/dist/cjs/index.js +0 -9
- package/dist/cjs/utils/getVideoDimensionsFromBlob.js +23 -19
- package/dist/cjs/utils/mobileUpload/servicesCache.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/media-client.js +2 -2
- package/dist/es2019/client/media-store/index.js +14 -5
- package/dist/es2019/client/mobile-upload.js +1 -1
- package/dist/es2019/file-streams-cache.js +2 -2
- package/dist/es2019/index.js +0 -2
- package/dist/es2019/utils/getVideoDimensionsFromBlob.js +21 -7
- package/dist/es2019/utils/mobileUpload/servicesCache.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/media-client.js +2 -2
- package/dist/esm/client/media-store/index.js +19 -10
- package/dist/esm/client/mobile-upload.js +1 -1
- package/dist/esm/file-streams-cache.js +2 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/utils/getVideoDimensionsFromBlob.js +21 -16
- package/dist/esm/utils/mobileUpload/servicesCache.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/client/media-client.d.ts +1 -1
- package/dist/types/client/media-store/index.d.ts +8 -1
- package/dist/types/file-streams-cache.d.ts +2 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/utils/getVideoDimensionsFromBlob.d.ts +3 -4
- package/dist/types/utils/mobileUpload/servicesCache.d.ts +2 -2
- package/dist/types/utils/request/helpers.d.ts +1 -1
- package/dist/types-ts4.0/client/media-client.d.ts +1 -1
- package/dist/types-ts4.0/client/media-store/index.d.ts +8 -1
- package/dist/types-ts4.0/file-streams-cache.d.ts +2 -2
- package/dist/types-ts4.0/index.d.ts +0 -1
- package/dist/types-ts4.0/utils/getVideoDimensionsFromBlob.d.ts +3 -4
- package/dist/types-ts4.0/utils/mobileUpload/servicesCache.d.ts +2 -2
- package/dist/types-ts4.0/utils/request/helpers.d.ts +1 -1
- package/example-helpers/styles.ts +9 -8
- package/package.json +14 -12
- package/report.api.md +807 -517
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 18.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`2c402e87213`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2c402e87213) - [Experimental] Add traceId in media card get image request.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`bf8302c838a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bf8302c838a) - Implemented internal functionality to create local video preview.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 18.0.0
|
|
15
|
+
|
|
16
|
+
### Major Changes
|
|
17
|
+
|
|
18
|
+
- [`37ff149ab87`](https://bitbucket.org/atlassian/atlassian-frontend/commits/37ff149ab87) - Remove exposing StreamsCache class
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [`153829bfcb3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/153829bfcb3) - Upgrade caching algorithm library lru-fast to lru_map.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 17.1.3
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -51,8 +51,8 @@ var MediaClient = /*#__PURE__*/function () {
|
|
|
51
51
|
|
|
52
52
|
(0, _createClass2.default)(MediaClient, [{
|
|
53
53
|
key: "getImage",
|
|
54
|
-
value: function getImage(id, params, controller, fetchMaxRes) {
|
|
55
|
-
return this.mediaStore.getImage(id, params, controller, fetchMaxRes);
|
|
54
|
+
value: function getImage(id, params, controller, fetchMaxRes, traceId) {
|
|
55
|
+
return this.mediaStore.getImage(id, params, controller, fetchMaxRes, traceId);
|
|
56
56
|
}
|
|
57
57
|
}, {
|
|
58
58
|
key: "getImageUrl",
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "MediaStoreError", {
|
|
|
12
12
|
return _error.MediaStoreError;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
exports.getMediaRegion = exports.getMediaEnvironment = void 0;
|
|
15
|
+
exports.getMediaRegion = exports.getMediaEnvironment = exports.ZipkinHeaderKeys = void 0;
|
|
16
16
|
Object.defineProperty(exports, "isMediaStoreError", {
|
|
17
17
|
enumerable: true,
|
|
18
18
|
get: function get() {
|
|
@@ -30,6 +30,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
30
30
|
|
|
31
31
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
32
32
|
|
|
33
|
+
var _mediaCommon = require("@atlaskit/media-common");
|
|
34
|
+
|
|
33
35
|
var _constants = require("../../constants");
|
|
34
36
|
|
|
35
37
|
var _artifacts = require("../../models/artifacts");
|
|
@@ -70,6 +72,14 @@ var jsonHeaders = {
|
|
|
70
72
|
Accept: 'application/json',
|
|
71
73
|
'Content-Type': 'application/json'
|
|
72
74
|
};
|
|
75
|
+
var ZipkinHeaderKeys = {
|
|
76
|
+
traceId: 'x-b3-traceid',
|
|
77
|
+
spanId: 'x-b3-spanid',
|
|
78
|
+
parentSpanId: 'x-b3-parentspanid',
|
|
79
|
+
sampled: 'x-b3-sampled',
|
|
80
|
+
flags: 'x-b3-flags'
|
|
81
|
+
};
|
|
82
|
+
exports.ZipkinHeaderKeys = ZipkinHeaderKeys;
|
|
73
83
|
|
|
74
84
|
var MediaStore = /*#__PURE__*/function () {
|
|
75
85
|
function MediaStore(config, featureFlags) {
|
|
@@ -495,7 +505,9 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
495
505
|
}, {
|
|
496
506
|
key: "getImage",
|
|
497
507
|
value: function () {
|
|
498
|
-
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, params, controller, fetchMaxRes) {
|
|
508
|
+
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(id, params, controller, fetchMaxRes, traceId) {
|
|
509
|
+
var _ref4;
|
|
510
|
+
|
|
499
511
|
var isWebpSupported, headers, metadata, options;
|
|
500
512
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
501
513
|
while (1) {
|
|
@@ -503,11 +515,10 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
503
515
|
case 0:
|
|
504
516
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
505
517
|
isWebpSupported = false;
|
|
518
|
+
headers = !!traceId ? (_ref4 = {}, (0, _defineProperty2.default)(_ref4, ZipkinHeaderKeys.traceId, traceId), (0, _defineProperty2.default)(_ref4, ZipkinHeaderKeys.spanId, (0, _mediaCommon.getRandomHex)(16)), _ref4) : {};
|
|
506
519
|
|
|
507
520
|
if (isWebpSupported) {
|
|
508
|
-
headers =
|
|
509
|
-
accept: 'image/webp,image/*,*/*;q=0.8'
|
|
510
|
-
};
|
|
521
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
511
522
|
}
|
|
512
523
|
|
|
513
524
|
metadata = {
|
|
@@ -523,7 +534,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
523
534
|
});
|
|
524
535
|
return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then((0, _helpers.createMapResponseToBlob)(metadata)));
|
|
525
536
|
|
|
526
|
-
case
|
|
537
|
+
case 6:
|
|
527
538
|
case "end":
|
|
528
539
|
return _context7.stop();
|
|
529
540
|
}
|
|
@@ -531,7 +542,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
531
542
|
}, _callee7, this);
|
|
532
543
|
}));
|
|
533
544
|
|
|
534
|
-
function getImage(_x15, _x16, _x17, _x18) {
|
|
545
|
+
function getImage(_x15, _x16, _x17, _x18, _x19) {
|
|
535
546
|
return _getImage.apply(this, arguments);
|
|
536
547
|
}
|
|
537
548
|
|
|
@@ -576,7 +587,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
576
587
|
}, _callee8, this);
|
|
577
588
|
}));
|
|
578
589
|
|
|
579
|
-
function getItems(
|
|
590
|
+
function getItems(_x20, _x21) {
|
|
580
591
|
return _getItems.apply(this, arguments);
|
|
581
592
|
}
|
|
582
593
|
|
|
@@ -611,7 +622,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
611
622
|
}, _callee9, this);
|
|
612
623
|
}));
|
|
613
624
|
|
|
614
|
-
function getImageMetadata(
|
|
625
|
+
function getImageMetadata(_x22, _x23) {
|
|
615
626
|
return _getImageMetadata.apply(this, arguments);
|
|
616
627
|
}
|
|
617
628
|
|
|
@@ -648,7 +659,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
648
659
|
}, _callee10, this);
|
|
649
660
|
}));
|
|
650
661
|
|
|
651
|
-
function appendChunksToUpload(
|
|
662
|
+
function appendChunksToUpload(_x24, _x25, _x26) {
|
|
652
663
|
return _appendChunksToUpload.apply(this, arguments);
|
|
653
664
|
}
|
|
654
665
|
|
|
@@ -733,7 +744,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
733
744
|
}, _callee11, this);
|
|
734
745
|
}));
|
|
735
746
|
|
|
736
|
-
function request(
|
|
747
|
+
function request(_x27) {
|
|
737
748
|
return _request2.apply(this, arguments);
|
|
738
749
|
}
|
|
739
750
|
|
|
@@ -52,7 +52,7 @@ var MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
52
52
|
};
|
|
53
53
|
var service = (0, _mobileUpload.createMobileUploadService)((0, _mobileUpload.createMobileUploadStateMachine)(this.dataloader, initialState, collectionName));
|
|
54
54
|
var subject = (0, _mobileUpload.createMobileFileStateSubject)(service);
|
|
55
|
-
this.servicesCache.
|
|
55
|
+
this.servicesCache.set(fileId, service);
|
|
56
56
|
(0, _fileStreamsCache.getFileStreamsCache)().set(fileId, subject);
|
|
57
57
|
}
|
|
58
58
|
}, {
|
|
@@ -44,12 +44,12 @@ var StreamsCache = /*#__PURE__*/function () {
|
|
|
44
44
|
}, {
|
|
45
45
|
key: "removeAll",
|
|
46
46
|
value: function removeAll() {
|
|
47
|
-
this.streams.
|
|
47
|
+
this.streams.clear();
|
|
48
48
|
}
|
|
49
49
|
}, {
|
|
50
50
|
key: "remove",
|
|
51
51
|
value: function remove(id) {
|
|
52
|
-
this.streams.
|
|
52
|
+
this.streams.delete(id);
|
|
53
53
|
}
|
|
54
54
|
}, {
|
|
55
55
|
key: "size",
|
package/dist/cjs/index.js
CHANGED
|
@@ -75,12 +75,6 @@ Object.defineProperty(exports, "StargateClient", {
|
|
|
75
75
|
return _stargateClient.StargateClient;
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
Object.defineProperty(exports, "StreamsCache", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: function get() {
|
|
81
|
-
return _fileStreamsCache.StreamsCache;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
78
|
Object.defineProperty(exports, "UploadController", {
|
|
85
79
|
enumerable: true,
|
|
86
80
|
get: function get() {
|
|
@@ -377,8 +371,6 @@ var _errors = require("./models/errors");
|
|
|
377
371
|
|
|
378
372
|
var _fileState = require("./models/file-state");
|
|
379
373
|
|
|
380
|
-
var _fileStreamsCache = require("./file-streams-cache");
|
|
381
|
-
|
|
382
374
|
var _uploader = require("./uploader");
|
|
383
375
|
|
|
384
376
|
var _request = require("./utils/request");
|
|
@@ -423,7 +415,6 @@ var _constants = require("./constants");
|
|
|
423
415
|
|
|
424
416
|
var _mediaTypeUtils = require("@atlaskit/media-common/mediaTypeUtils");
|
|
425
417
|
|
|
426
|
-
// TODO: remove access to media file stream cache https://product-fabric.atlassian.net/browse/MEX-1417
|
|
427
418
|
// TODO MEX-659 Remove these exports when all the usages from media-client are replaced with media-common.
|
|
428
419
|
|
|
429
420
|
/**
|
|
@@ -11,35 +11,39 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
11
11
|
|
|
12
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
13
|
|
|
14
|
-
var _videoSnapshot = _interopRequireDefault(require("video-snapshot"));
|
|
15
|
-
|
|
16
14
|
var getVideoDimensionsFromBlob = /*#__PURE__*/function () {
|
|
17
15
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(blob) {
|
|
18
|
-
var snapshoter,
|
|
19
|
-
_args = arguments;
|
|
20
16
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
21
17
|
while (1) {
|
|
22
18
|
switch (_context.prev = _context.next) {
|
|
23
19
|
case 0:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
21
|
+
var url = URL.createObjectURL(blob);
|
|
22
|
+
var video = document.createElement('video');
|
|
23
|
+
video.preload = 'metadata';
|
|
24
|
+
video.src = url;
|
|
25
|
+
video.muted = true; // loadedmetadata, loadeddata, play, playing
|
|
26
|
+
|
|
27
|
+
video.addEventListener('loadedmetadata', function timeupdateHandler() {
|
|
28
|
+
video.removeEventListener('loadedmetadata', timeupdateHandler);
|
|
29
|
+
resolve({
|
|
30
|
+
width: video.videoWidth,
|
|
31
|
+
height: video.videoHeight
|
|
32
|
+
});
|
|
33
|
+
URL.revokeObjectURL(url);
|
|
34
|
+
});
|
|
35
|
+
video.addEventListener('error', function () {
|
|
36
|
+
reject(new Error('failed to load video'));
|
|
37
|
+
URL.revokeObjectURL(url);
|
|
38
|
+
});
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
case 1:
|
|
38
42
|
case "end":
|
|
39
43
|
return _context.stop();
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
|
-
}, _callee
|
|
46
|
+
}, _callee);
|
|
43
47
|
}));
|
|
44
48
|
|
|
45
49
|
return function getVideoDimensionsFromBlob(_x) {
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createServicesCache = createServicesCache;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _lru_map = require("lru_map");
|
|
9
9
|
|
|
10
10
|
function createServicesCache() {
|
|
11
|
-
return new
|
|
11
|
+
return new _lru_map.LRUMap(100);
|
|
12
12
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -20,8 +20,8 @@ export class MediaClient {
|
|
|
20
20
|
this.stargate = new StargateClient(mediaClientConfig.stargateBaseUrl);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
getImage(id, params, controller, fetchMaxRes) {
|
|
24
|
-
return this.mediaStore.getImage(id, params, controller, fetchMaxRes);
|
|
23
|
+
getImage(id, params, controller, fetchMaxRes, traceId) {
|
|
24
|
+
return this.mediaStore.getImage(id, params, controller, fetchMaxRes, traceId);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
getImageUrl(id, params) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { getRandomHex } from '@atlaskit/media-common';
|
|
2
3
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
3
4
|
import { getArtifactUrl } from '../../models/artifacts';
|
|
4
5
|
import { request } from '../../utils/request';
|
|
@@ -31,6 +32,13 @@ const jsonHeaders = {
|
|
|
31
32
|
Accept: 'application/json',
|
|
32
33
|
'Content-Type': 'application/json'
|
|
33
34
|
};
|
|
35
|
+
export const ZipkinHeaderKeys = {
|
|
36
|
+
traceId: 'x-b3-traceid',
|
|
37
|
+
spanId: 'x-b3-spanid',
|
|
38
|
+
parentSpanId: 'x-b3-parentspanid',
|
|
39
|
+
sampled: 'x-b3-sampled',
|
|
40
|
+
flags: 'x-b3-flags'
|
|
41
|
+
};
|
|
34
42
|
export class MediaStore {
|
|
35
43
|
constructor(config, featureFlags) {
|
|
36
44
|
_defineProperty(this, "resolveAuth", authContext => resolveAuth(this.config.authProvider, authContext));
|
|
@@ -270,15 +278,16 @@ export class MediaStore {
|
|
|
270
278
|
return createUrl(`${auth.baseUrl}${artifactUrl}`, options);
|
|
271
279
|
}
|
|
272
280
|
|
|
273
|
-
async getImage(id, params, controller, fetchMaxRes) {
|
|
281
|
+
async getImage(id, params, controller, fetchMaxRes, traceId) {
|
|
274
282
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
275
283
|
const isWebpSupported = false;
|
|
276
|
-
let headers
|
|
284
|
+
let headers = !!traceId ? {
|
|
285
|
+
[ZipkinHeaderKeys.traceId]: traceId,
|
|
286
|
+
[ZipkinHeaderKeys.spanId]: getRandomHex(16)
|
|
287
|
+
} : {};
|
|
277
288
|
|
|
278
289
|
if (isWebpSupported) {
|
|
279
|
-
headers =
|
|
280
|
-
accept: 'image/webp,image/*,*/*;q=0.8'
|
|
281
|
-
};
|
|
290
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
282
291
|
}
|
|
283
292
|
|
|
284
293
|
const metadata = {
|
|
@@ -34,7 +34,7 @@ export class MobileUploadImpl {
|
|
|
34
34
|
};
|
|
35
35
|
const service = createMobileUploadService(createMobileUploadStateMachine(this.dataloader, initialState, collectionName));
|
|
36
36
|
const subject = createMobileFileStateSubject(service);
|
|
37
|
-
this.servicesCache.
|
|
37
|
+
this.servicesCache.set(fileId, service);
|
|
38
38
|
getFileStreamsCache().set(fileId, subject);
|
|
39
39
|
}
|
|
40
40
|
|
package/dist/es2019/index.js
CHANGED
|
@@ -4,8 +4,6 @@ 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
|
|
8
|
-
export { StreamsCache } from './file-streams-cache';
|
|
9
7
|
export { uploadFile } from './uploader';
|
|
10
8
|
export { request, RequestError, isRequestError, isRateLimitedError } from './utils/request';
|
|
11
9
|
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl } from './utils/request/helpers';
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export const getVideoDimensionsFromBlob = async blob => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const url = URL.createObjectURL(blob);
|
|
4
|
+
const video = document.createElement('video');
|
|
5
|
+
video.preload = 'metadata';
|
|
6
|
+
video.src = url;
|
|
7
|
+
video.muted = true; // loadedmetadata, loadeddata, play, playing
|
|
8
|
+
|
|
9
|
+
video.addEventListener('loadedmetadata', function timeupdateHandler() {
|
|
10
|
+
video.removeEventListener('loadedmetadata', timeupdateHandler);
|
|
11
|
+
resolve({
|
|
12
|
+
width: video.videoWidth,
|
|
13
|
+
height: video.videoHeight
|
|
14
|
+
});
|
|
15
|
+
URL.revokeObjectURL(url);
|
|
16
|
+
});
|
|
17
|
+
video.addEventListener('error', () => {
|
|
18
|
+
reject(new Error('failed to load video'));
|
|
19
|
+
URL.revokeObjectURL(url);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
8
22
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -28,8 +28,8 @@ export var MediaClient = /*#__PURE__*/function () {
|
|
|
28
28
|
|
|
29
29
|
_createClass(MediaClient, [{
|
|
30
30
|
key: "getImage",
|
|
31
|
-
value: function getImage(id, params, controller, fetchMaxRes) {
|
|
32
|
-
return this.mediaStore.getImage(id, params, controller, fetchMaxRes);
|
|
31
|
+
value: function getImage(id, params, controller, fetchMaxRes, traceId) {
|
|
32
|
+
return this.mediaStore.getImage(id, params, controller, fetchMaxRes, traceId);
|
|
33
33
|
}
|
|
34
34
|
}, {
|
|
35
35
|
key: "getImageUrl",
|
|
@@ -8,6 +8,7 @@ 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
|
|
11
|
+
import { getRandomHex } from '@atlaskit/media-common';
|
|
11
12
|
import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
|
|
12
13
|
import { getArtifactUrl } from '../../models/artifacts';
|
|
13
14
|
import { request as _request } from '../../utils/request';
|
|
@@ -38,6 +39,13 @@ var jsonHeaders = {
|
|
|
38
39
|
Accept: 'application/json',
|
|
39
40
|
'Content-Type': 'application/json'
|
|
40
41
|
};
|
|
42
|
+
export var ZipkinHeaderKeys = {
|
|
43
|
+
traceId: 'x-b3-traceid',
|
|
44
|
+
spanId: 'x-b3-spanid',
|
|
45
|
+
parentSpanId: 'x-b3-parentspanid',
|
|
46
|
+
sampled: 'x-b3-sampled',
|
|
47
|
+
flags: 'x-b3-flags'
|
|
48
|
+
};
|
|
41
49
|
export var MediaStore = /*#__PURE__*/function () {
|
|
42
50
|
function MediaStore(config, featureFlags) {
|
|
43
51
|
var _this = this;
|
|
@@ -465,7 +473,9 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
465
473
|
}, {
|
|
466
474
|
key: "getImage",
|
|
467
475
|
value: function () {
|
|
468
|
-
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes) {
|
|
476
|
+
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params, controller, fetchMaxRes, traceId) {
|
|
477
|
+
var _ref4;
|
|
478
|
+
|
|
469
479
|
var isWebpSupported, headers, metadata, options;
|
|
470
480
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
471
481
|
while (1) {
|
|
@@ -473,11 +483,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
473
483
|
case 0:
|
|
474
484
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
475
485
|
isWebpSupported = false;
|
|
486
|
+
headers = !!traceId ? (_ref4 = {}, _defineProperty(_ref4, ZipkinHeaderKeys.traceId, traceId), _defineProperty(_ref4, ZipkinHeaderKeys.spanId, getRandomHex(16)), _ref4) : {};
|
|
476
487
|
|
|
477
488
|
if (isWebpSupported) {
|
|
478
|
-
headers =
|
|
479
|
-
accept: 'image/webp,image/*,*/*;q=0.8'
|
|
480
|
-
};
|
|
489
|
+
headers.accept = 'image/webp,image/*,*/*;q=0.8';
|
|
481
490
|
}
|
|
482
491
|
|
|
483
492
|
metadata = {
|
|
@@ -493,7 +502,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
493
502
|
});
|
|
494
503
|
return _context7.abrupt("return", this.request("/file/".concat(id, "/image"), options, controller).then(createMapResponseToBlob(metadata)));
|
|
495
504
|
|
|
496
|
-
case
|
|
505
|
+
case 6:
|
|
497
506
|
case "end":
|
|
498
507
|
return _context7.stop();
|
|
499
508
|
}
|
|
@@ -501,7 +510,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
501
510
|
}, _callee7, this);
|
|
502
511
|
}));
|
|
503
512
|
|
|
504
|
-
function getImage(_x15, _x16, _x17, _x18) {
|
|
513
|
+
function getImage(_x15, _x16, _x17, _x18, _x19) {
|
|
505
514
|
return _getImage.apply(this, arguments);
|
|
506
515
|
}
|
|
507
516
|
|
|
@@ -546,7 +555,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
546
555
|
}, _callee8, this);
|
|
547
556
|
}));
|
|
548
557
|
|
|
549
|
-
function getItems(
|
|
558
|
+
function getItems(_x20, _x21) {
|
|
550
559
|
return _getItems.apply(this, arguments);
|
|
551
560
|
}
|
|
552
561
|
|
|
@@ -581,7 +590,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
581
590
|
}, _callee9, this);
|
|
582
591
|
}));
|
|
583
592
|
|
|
584
|
-
function getImageMetadata(
|
|
593
|
+
function getImageMetadata(_x22, _x23) {
|
|
585
594
|
return _getImageMetadata.apply(this, arguments);
|
|
586
595
|
}
|
|
587
596
|
|
|
@@ -618,7 +627,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
618
627
|
}, _callee10, this);
|
|
619
628
|
}));
|
|
620
629
|
|
|
621
|
-
function appendChunksToUpload(
|
|
630
|
+
function appendChunksToUpload(_x24, _x25, _x26) {
|
|
622
631
|
return _appendChunksToUpload.apply(this, arguments);
|
|
623
632
|
}
|
|
624
633
|
|
|
@@ -703,7 +712,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
703
712
|
}, _callee11, this);
|
|
704
713
|
}));
|
|
705
714
|
|
|
706
|
-
function request(
|
|
715
|
+
function request(_x27) {
|
|
707
716
|
return _request2.apply(this, arguments);
|
|
708
717
|
}
|
|
709
718
|
|
|
@@ -38,7 +38,7 @@ export var MobileUploadImpl = /*#__PURE__*/function () {
|
|
|
38
38
|
};
|
|
39
39
|
var service = createMobileUploadService(createMobileUploadStateMachine(this.dataloader, initialState, collectionName));
|
|
40
40
|
var subject = createMobileFileStateSubject(service);
|
|
41
|
-
this.servicesCache.
|
|
41
|
+
this.servicesCache.set(fileId, service);
|
|
42
42
|
getFileStreamsCache().set(fileId, subject);
|
|
43
43
|
}
|
|
44
44
|
}, {
|
|
@@ -34,12 +34,12 @@ export var StreamsCache = /*#__PURE__*/function () {
|
|
|
34
34
|
}, {
|
|
35
35
|
key: "removeAll",
|
|
36
36
|
value: function removeAll() {
|
|
37
|
-
this.streams.
|
|
37
|
+
this.streams.clear();
|
|
38
38
|
}
|
|
39
39
|
}, {
|
|
40
40
|
key: "remove",
|
|
41
41
|
value: function remove(id) {
|
|
42
|
-
this.streams.
|
|
42
|
+
this.streams.delete(id);
|
|
43
43
|
}
|
|
44
44
|
}, {
|
|
45
45
|
key: "size",
|
package/dist/esm/index.js
CHANGED
|
@@ -4,8 +4,6 @@ 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
|
|
8
|
-
export { StreamsCache } from './file-streams-cache';
|
|
9
7
|
export { uploadFile } from './uploader';
|
|
10
8
|
export { request, RequestError, isRequestError, isRateLimitedError } from './utils/request';
|
|
11
9
|
export { isAbortedRequestError, mapResponseToJson, mapResponseToBlob, mapResponseToVoid, createUrl } from './utils/request/helpers';
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import VideoSnapshot from 'video-snapshot';
|
|
4
3
|
export var getVideoDimensionsFromBlob = /*#__PURE__*/function () {
|
|
5
4
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(blob) {
|
|
6
|
-
var snapshoter,
|
|
7
|
-
_args = arguments;
|
|
8
5
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
6
|
while (1) {
|
|
10
7
|
switch (_context.prev = _context.next) {
|
|
11
8
|
case 0:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
10
|
+
var url = URL.createObjectURL(blob);
|
|
11
|
+
var video = document.createElement('video');
|
|
12
|
+
video.preload = 'metadata';
|
|
13
|
+
video.src = url;
|
|
14
|
+
video.muted = true; // loadedmetadata, loadeddata, play, playing
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
video.addEventListener('loadedmetadata', function timeupdateHandler() {
|
|
17
|
+
video.removeEventListener('loadedmetadata', timeupdateHandler);
|
|
18
|
+
resolve({
|
|
19
|
+
width: video.videoWidth,
|
|
20
|
+
height: video.videoHeight
|
|
21
|
+
});
|
|
22
|
+
URL.revokeObjectURL(url);
|
|
23
|
+
});
|
|
24
|
+
video.addEventListener('error', function () {
|
|
25
|
+
reject(new Error('failed to load video'));
|
|
26
|
+
URL.revokeObjectURL(url);
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
19
29
|
|
|
20
|
-
case
|
|
21
|
-
_context.prev = 5;
|
|
22
|
-
snapshoter.end();
|
|
23
|
-
return _context.finish(5);
|
|
24
|
-
|
|
25
|
-
case 8:
|
|
30
|
+
case 1:
|
|
26
31
|
case "end":
|
|
27
32
|
return _context.stop();
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
}, _callee
|
|
35
|
+
}, _callee);
|
|
31
36
|
}));
|
|
32
37
|
|
|
33
38
|
return function getVideoDimensionsFromBlob(_x) {
|
package/dist/esm/version.json
CHANGED
|
@@ -17,7 +17,7 @@ export declare class MediaClient {
|
|
|
17
17
|
private mobileUpload?;
|
|
18
18
|
readonly config: MediaClientConfig;
|
|
19
19
|
constructor(mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags | undefined);
|
|
20
|
-
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean): Promise<Blob>;
|
|
20
|
+
getImage(id: string, params?: MediaStoreGetFileImageParams, controller?: AbortController, fetchMaxRes?: boolean, traceId?: string): Promise<Blob>;
|
|
21
21
|
getImageUrl(id: string, params?: MediaStoreGetFileImageParams): Promise<string>;
|
|
22
22
|
getImageUrlSync(id: string, params?: MediaStoreGetFileImageParams): string;
|
|
23
23
|
getImageMetadata(id: string, params?: MediaStoreGetFileImageParams): Promise<ImageMetadata>;
|