@atlaskit/media-card 74.7.3 → 74.8.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 +19 -0
- package/dist/cjs/card/card.js +99 -108
- package/dist/cjs/card/cardLoader.js +3 -3
- package/dist/cjs/card/cardView.js +6 -7
- package/dist/cjs/card/getCardPreview/helpers.js +108 -117
- package/dist/cjs/card/getCardPreview/index.js +99 -104
- package/dist/cjs/card/inlinePlayer.js +92 -97
- package/dist/cjs/card/inlinePlayerLazy.js +19 -20
- package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/cjs/card/ui/common.js +4 -4
- package/dist/cjs/inline/loader.js +50 -52
- package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +59 -9
- package/dist/cjs/types.js +4 -4
- package/dist/cjs/utils/cardActions/cardActionIconButton.js +2 -3
- package/dist/cjs/utils/cardActions/styles.js +4 -4
- package/dist/cjs/utils/ufoExperiences.js +1 -1
- package/dist/cjs/utils/videoSnapshot.js +41 -44
- package/dist/cjs/utils/viewportDetector.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/card/card.js +6 -7
- package/dist/es2019/card/cardView.js +2 -3
- package/dist/es2019/card/inlinePlayer.js +1 -3
- package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/es2019/card/ui/common.js +3 -3
- package/dist/es2019/inline/loader.js +3 -1
- package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +60 -7
- package/dist/es2019/types.js +3 -3
- package/dist/es2019/utils/cardActions/cardActionIconButton.js +2 -3
- package/dist/es2019/utils/cardActions/styles.js +3 -3
- package/dist/es2019/utils/ufoExperiences.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/card/card.js +99 -109
- package/dist/esm/card/cardView.js +6 -7
- package/dist/esm/card/getCardPreview/helpers.js +108 -117
- package/dist/esm/card/getCardPreview/index.js +99 -104
- package/dist/esm/card/inlinePlayer.js +92 -98
- package/dist/esm/card/inlinePlayerLazy.js +17 -20
- package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
- package/dist/esm/card/ui/common.js +3 -3
- package/dist/esm/inline/loader.js +44 -47
- package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +59 -9
- package/dist/esm/types.js +3 -3
- package/dist/esm/utils/cardActions/cardActionIconButton.js +2 -3
- package/dist/esm/utils/cardActions/styles.js +3 -3
- package/dist/esm/utils/ufoExperiences.js +1 -1
- package/dist/esm/utils/videoSnapshot.js +41 -44
- package/dist/esm/utils/viewportDetector.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/inline/loader.d.ts +1 -0
- package/dist/types/inline/mediaInlineAnalyticsErrorBoundary.d.ts +1 -0
- package/package.json +28 -28
- package/report.api.md +1 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.isSupportedLocalPreview = exports.getCardPreviewFromFilePreview = exports.getCardPreviewFromBackend = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _videoSnapshot = require("../../utils/videoSnapshot");
|
|
11
11
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
12
12
|
var _mediaUi = require("@atlaskit/media-ui");
|
|
13
13
|
var _errors = require("../../errors");
|
|
14
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
15
14
|
/**
|
|
16
15
|
* This method tells the support for the media
|
|
17
16
|
* types covered in getCardPreviewFromFilePreview
|
|
@@ -21,31 +20,29 @@ var isSupportedLocalPreview = function isSupportedLocalPreview(mediaType) {
|
|
|
21
20
|
};
|
|
22
21
|
exports.isSupportedLocalPreview = isSupportedLocalPreview;
|
|
23
22
|
var getImageLocalPreview = /*#__PURE__*/function () {
|
|
24
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
23
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(value) {
|
|
25
24
|
var orientation, dataURI;
|
|
26
|
-
return
|
|
27
|
-
while (1) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return _context.stop();
|
|
48
|
-
}
|
|
25
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
26
|
+
while (1) switch (_context.prev = _context.next) {
|
|
27
|
+
case 0:
|
|
28
|
+
_context.prev = 0;
|
|
29
|
+
_context.next = 3;
|
|
30
|
+
return (0, _mediaUi.getOrientation)(value);
|
|
31
|
+
case 3:
|
|
32
|
+
orientation = _context.sent;
|
|
33
|
+
dataURI = URL.createObjectURL(value);
|
|
34
|
+
return _context.abrupt("return", {
|
|
35
|
+
dataURI: dataURI,
|
|
36
|
+
orientation: orientation,
|
|
37
|
+
source: 'local'
|
|
38
|
+
});
|
|
39
|
+
case 8:
|
|
40
|
+
_context.prev = 8;
|
|
41
|
+
_context.t0 = _context["catch"](0);
|
|
42
|
+
throw new _errors.LocalPreviewError('local-preview-image', _context.t0 instanceof Error ? _context.t0 : undefined);
|
|
43
|
+
case 11:
|
|
44
|
+
case "end":
|
|
45
|
+
return _context.stop();
|
|
49
46
|
}
|
|
50
47
|
}, _callee, null, [[0, 8]]);
|
|
51
48
|
}));
|
|
@@ -54,30 +51,28 @@ var getImageLocalPreview = /*#__PURE__*/function () {
|
|
|
54
51
|
};
|
|
55
52
|
}();
|
|
56
53
|
var getVideoLocalPreview = /*#__PURE__*/function () {
|
|
57
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
54
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(value) {
|
|
58
55
|
var dataURI;
|
|
59
|
-
return
|
|
60
|
-
while (1) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return _context2.stop();
|
|
80
|
-
}
|
|
56
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
57
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
_context2.prev = 0;
|
|
60
|
+
_context2.next = 3;
|
|
61
|
+
return (0, _videoSnapshot.takeSnapshot)(value);
|
|
62
|
+
case 3:
|
|
63
|
+
dataURI = _context2.sent;
|
|
64
|
+
return _context2.abrupt("return", {
|
|
65
|
+
dataURI: dataURI,
|
|
66
|
+
orientation: 1,
|
|
67
|
+
source: 'local'
|
|
68
|
+
});
|
|
69
|
+
case 7:
|
|
70
|
+
_context2.prev = 7;
|
|
71
|
+
_context2.t0 = _context2["catch"](0);
|
|
72
|
+
throw new _errors.LocalPreviewError('local-preview-video', _context2.t0 instanceof Error ? _context2.t0 : undefined);
|
|
73
|
+
case 10:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context2.stop();
|
|
81
76
|
}
|
|
82
77
|
}, _callee2, null, [[0, 7]]);
|
|
83
78
|
}));
|
|
@@ -86,54 +81,52 @@ var getVideoLocalPreview = /*#__PURE__*/function () {
|
|
|
86
81
|
};
|
|
87
82
|
}();
|
|
88
83
|
var getCardPreviewFromFilePreview = /*#__PURE__*/function () {
|
|
89
|
-
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
84
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(filePreview) {
|
|
90
85
|
var value, resolvedFilePreview, _value, type, mediaType;
|
|
91
|
-
return
|
|
92
|
-
while (1) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
86
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
87
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
88
|
+
case 0:
|
|
89
|
+
_context3.prev = 0;
|
|
90
|
+
_context3.next = 3;
|
|
91
|
+
return filePreview;
|
|
92
|
+
case 3:
|
|
93
|
+
resolvedFilePreview = _context3.sent;
|
|
94
|
+
value = resolvedFilePreview.value;
|
|
95
|
+
_context3.next = 10;
|
|
96
|
+
break;
|
|
97
|
+
case 7:
|
|
98
|
+
_context3.prev = 7;
|
|
99
|
+
_context3.t0 = _context3["catch"](0);
|
|
100
|
+
throw new _errors.LocalPreviewError('local-preview-rejected', _context3.t0 instanceof Error ? _context3.t0 : undefined);
|
|
101
|
+
case 10:
|
|
102
|
+
if (!(typeof value === 'string')) {
|
|
103
|
+
_context3.next = 14;
|
|
102
104
|
break;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return _context3.abrupt("return", {
|
|
113
|
-
dataURI: value,
|
|
114
|
-
orientation: 1,
|
|
115
|
-
source: 'local'
|
|
116
|
-
});
|
|
117
|
-
case 14:
|
|
118
|
-
if (!(value instanceof Blob)) {
|
|
119
|
-
_context3.next = 22;
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
_value = value, type = _value.type;
|
|
123
|
-
mediaType = (0, _mediaCommon.getMediaTypeFromMimeType)(type);
|
|
124
|
-
_context3.t1 = mediaType;
|
|
125
|
-
_context3.next = _context3.t1 === 'image' ? 20 : _context3.t1 === 'video' ? 21 : 22;
|
|
105
|
+
}
|
|
106
|
+
return _context3.abrupt("return", {
|
|
107
|
+
dataURI: value,
|
|
108
|
+
orientation: 1,
|
|
109
|
+
source: 'local'
|
|
110
|
+
});
|
|
111
|
+
case 14:
|
|
112
|
+
if (!(value instanceof Blob)) {
|
|
113
|
+
_context3.next = 22;
|
|
126
114
|
break;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
115
|
+
}
|
|
116
|
+
_value = value, type = _value.type;
|
|
117
|
+
mediaType = (0, _mediaCommon.getMediaTypeFromMimeType)(type);
|
|
118
|
+
_context3.t1 = mediaType;
|
|
119
|
+
_context3.next = _context3.t1 === 'image' ? 20 : _context3.t1 === 'video' ? 21 : 22;
|
|
120
|
+
break;
|
|
121
|
+
case 20:
|
|
122
|
+
return _context3.abrupt("return", getImageLocalPreview(value));
|
|
123
|
+
case 21:
|
|
124
|
+
return _context3.abrupt("return", getVideoLocalPreview(value));
|
|
125
|
+
case 22:
|
|
126
|
+
throw new _errors.LocalPreviewError('local-preview-unsupported');
|
|
127
|
+
case 23:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context3.stop();
|
|
137
130
|
}
|
|
138
131
|
}, _callee3, null, [[0, 7]]);
|
|
139
132
|
}));
|
|
@@ -143,30 +136,28 @@ var getCardPreviewFromFilePreview = /*#__PURE__*/function () {
|
|
|
143
136
|
}();
|
|
144
137
|
exports.getCardPreviewFromFilePreview = getCardPreviewFromFilePreview;
|
|
145
138
|
var getCardPreviewFromBackend = /*#__PURE__*/function () {
|
|
146
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
139
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(mediaClient, id, params, traceContext) {
|
|
147
140
|
var blob;
|
|
148
|
-
return
|
|
149
|
-
while (1) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return _context4.stop();
|
|
169
|
-
}
|
|
141
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
142
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
_context4.prev = 0;
|
|
145
|
+
_context4.next = 3;
|
|
146
|
+
return mediaClient.getImage(id, params, undefined, undefined, traceContext);
|
|
147
|
+
case 3:
|
|
148
|
+
blob = _context4.sent;
|
|
149
|
+
return _context4.abrupt("return", {
|
|
150
|
+
dataURI: URL.createObjectURL(blob),
|
|
151
|
+
orientation: 1,
|
|
152
|
+
source: 'remote'
|
|
153
|
+
});
|
|
154
|
+
case 7:
|
|
155
|
+
_context4.prev = 7;
|
|
156
|
+
_context4.t0 = _context4["catch"](0);
|
|
157
|
+
throw new _errors.RemotePreviewError('remote-preview-fetch', _context4.t0 instanceof Error ? _context4.t0 : undefined);
|
|
158
|
+
case 10:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context4.stop();
|
|
170
161
|
}
|
|
171
162
|
}, _callee4, null, [[0, 7]]);
|
|
172
163
|
}));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -33,6 +32,7 @@ Object.defineProperty(exports, "isSupportedLocalPreview", {
|
|
|
33
32
|
}
|
|
34
33
|
});
|
|
35
34
|
exports.shouldResolvePreview = exports.removeCardPreviewFromCache = void 0;
|
|
35
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
36
36
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
37
37
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
38
38
|
var _mediaClient = require("@atlaskit/media-client");
|
|
@@ -43,7 +43,6 @@ var _errors = require("../../errors");
|
|
|
43
43
|
var _dimensionComparer = require("../../utils/dimensionComparer");
|
|
44
44
|
var _filePreviewStatus = require("./filePreviewStatus");
|
|
45
45
|
var _imageRefetchingAnalytics = require("./imageRefetchingAnalytics");
|
|
46
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
47
46
|
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; }
|
|
48
47
|
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; }
|
|
49
48
|
var getCardPreviewFromCache = _cache.default.get;
|
|
@@ -100,95 +99,93 @@ var extendAndCachePreview = function extendAndCachePreview(id, mode, preview, me
|
|
|
100
99
|
* hence the use of the optional callback onLocalPreviewError
|
|
101
100
|
*/
|
|
102
101
|
var getCardPreview = /*#__PURE__*/function () {
|
|
103
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
102
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
104
103
|
var mediaClient, id, _ref$dimensions, dimensions, filePreview, onLocalPreviewError, isRemotePreviewReady, imageUrlParams, mediaBlobUrlAttrs, createAnalyticsEvent, featureFlags, traceContext, mode, cachedPreview, dimensionsAreBigger, localPreview, remotePreview;
|
|
105
|
-
return
|
|
106
|
-
while (1) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
104
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
105
|
+
while (1) switch (_context.prev = _context.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
mediaClient = _ref.mediaClient, id = _ref.id, _ref$dimensions = _ref.dimensions, dimensions = _ref$dimensions === void 0 ? {} : _ref$dimensions, filePreview = _ref.filePreview, onLocalPreviewError = _ref.onLocalPreviewError, isRemotePreviewReady = _ref.isRemotePreviewReady, imageUrlParams = _ref.imageUrlParams, mediaBlobUrlAttrs = _ref.mediaBlobUrlAttrs, createAnalyticsEvent = _ref.createAnalyticsEvent, featureFlags = _ref.featureFlags, traceContext = _ref.traceContext;
|
|
108
|
+
mode = imageUrlParams.mode;
|
|
109
|
+
cachedPreview = _cache.default.get(id, mode);
|
|
110
|
+
dimensionsAreBigger = (0, _dimensionComparer.isBigger)(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions);
|
|
111
|
+
if (!(cachedPreview && !dimensionsAreBigger)) {
|
|
112
|
+
_context.next = 7;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if ((0, _mediaCommon.getMediaFeatureFlag)('memoryCacheLogging', featureFlags)) {
|
|
116
|
+
createAnalyticsEvent && (0, _imageRefetchingAnalytics.fireImageFetchingOperationalEvent)(createAnalyticsEvent, 'cache-hit', {
|
|
117
|
+
fileId: id,
|
|
118
|
+
prevDimensions: cachedPreview.dimensions,
|
|
119
|
+
currentDimensions: dimensions,
|
|
120
|
+
source: cachedPreview.source
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return _context.abrupt("return", cachedPreview);
|
|
124
|
+
case 7:
|
|
125
|
+
_context.prev = 7;
|
|
126
|
+
if (!filePreview) {
|
|
127
|
+
_context.next = 13;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
_context.next = 11;
|
|
131
|
+
return (0, _helpers.getCardPreviewFromFilePreview)(filePreview);
|
|
132
|
+
case 11:
|
|
133
|
+
localPreview = _context.sent;
|
|
134
|
+
return _context.abrupt("return", extendAndCachePreview(id, mode, _objectSpread(_objectSpread({}, localPreview), {}, {
|
|
135
|
+
dimensions: dimensions
|
|
136
|
+
}), mediaBlobUrlAttrs));
|
|
137
|
+
case 13:
|
|
138
|
+
_context.next = 20;
|
|
139
|
+
break;
|
|
140
|
+
case 15:
|
|
141
|
+
_context.prev = 15;
|
|
142
|
+
_context.t0 = _context["catch"](7);
|
|
143
|
+
/**
|
|
144
|
+
* We report the error if:
|
|
145
|
+
* - local preview is supported and fails
|
|
146
|
+
* - local preview is unsupported and remote preview is NOT READY
|
|
147
|
+
* i.e. the function was called for "no reason".
|
|
148
|
+
* We DON'T report the error if:
|
|
149
|
+
* - local preview is unsupported and remote preview IS READY
|
|
150
|
+
* i.e. local preview is available and not supported,
|
|
151
|
+
* but we are after the remote preview instead.
|
|
152
|
+
*/
|
|
153
|
+
if (!(0, _errors.isUnsupportedLocalPreviewError)(_context.t0) || (0, _errors.isUnsupportedLocalPreviewError)(_context.t0) && !isRemotePreviewReady) {
|
|
154
|
+
onLocalPreviewError && onLocalPreviewError(_context.t0);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* No matter the reason why the local preview failed, we break the process
|
|
158
|
+
* if there is no remote preview available
|
|
159
|
+
*/
|
|
160
|
+
if (isRemotePreviewReady) {
|
|
140
161
|
_context.next = 20;
|
|
141
162
|
break;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (isRemotePreviewReady) {
|
|
169
|
-
_context.next = 22;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
throw new _errors.MediaCardError('remote-preview-not-ready');
|
|
173
|
-
case 22:
|
|
174
|
-
_context.next = 24;
|
|
175
|
-
return fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs, traceContext);
|
|
176
|
-
case 24:
|
|
177
|
-
remotePreview = _context.sent;
|
|
178
|
-
if ((0, _mediaCommon.getMediaFeatureFlag)('memoryCacheLogging', featureFlags)) {
|
|
179
|
-
createAnalyticsEvent && (0, _imageRefetchingAnalytics.fireImageFetchingOperationalEvent)(createAnalyticsEvent, 'remote-success', {
|
|
180
|
-
fileId: id,
|
|
181
|
-
prevDimensions: cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions,
|
|
182
|
-
currentDimensions: dimensions,
|
|
183
|
-
dimensionsPercentageDiff: (0, _imageRefetchingAnalytics.calculatePercentageDifference)(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions),
|
|
184
|
-
source: remotePreview.source
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
return _context.abrupt("return", remotePreview);
|
|
188
|
-
case 27:
|
|
189
|
-
case "end":
|
|
190
|
-
return _context.stop();
|
|
191
|
-
}
|
|
163
|
+
}
|
|
164
|
+
throw _context.t0;
|
|
165
|
+
case 20:
|
|
166
|
+
if (isRemotePreviewReady) {
|
|
167
|
+
_context.next = 22;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
throw new _errors.MediaCardError('remote-preview-not-ready');
|
|
171
|
+
case 22:
|
|
172
|
+
_context.next = 24;
|
|
173
|
+
return fetchAndCacheRemotePreview(mediaClient, id, dimensions, imageUrlParams, mediaBlobUrlAttrs, traceContext);
|
|
174
|
+
case 24:
|
|
175
|
+
remotePreview = _context.sent;
|
|
176
|
+
if ((0, _mediaCommon.getMediaFeatureFlag)('memoryCacheLogging', featureFlags)) {
|
|
177
|
+
createAnalyticsEvent && (0, _imageRefetchingAnalytics.fireImageFetchingOperationalEvent)(createAnalyticsEvent, 'remote-success', {
|
|
178
|
+
fileId: id,
|
|
179
|
+
prevDimensions: cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions,
|
|
180
|
+
currentDimensions: dimensions,
|
|
181
|
+
dimensionsPercentageDiff: (0, _imageRefetchingAnalytics.calculatePercentageDifference)(cachedPreview === null || cachedPreview === void 0 ? void 0 : cachedPreview.dimensions, dimensions),
|
|
182
|
+
source: remotePreview.source
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return _context.abrupt("return", remotePreview);
|
|
186
|
+
case 27:
|
|
187
|
+
case "end":
|
|
188
|
+
return _context.stop();
|
|
192
189
|
}
|
|
193
190
|
}, _callee, null, [[7, 15]]);
|
|
194
191
|
}));
|
|
@@ -256,23 +253,21 @@ var isSSRDataPreview = function isSSRDataPreview(preview) {
|
|
|
256
253
|
};
|
|
257
254
|
exports.isSSRDataPreview = isSSRDataPreview;
|
|
258
255
|
var fetchAndCacheRemotePreview = /*#__PURE__*/function () {
|
|
259
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
256
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(mediaClient, id, dimensions, params, mediaBlobUrlAttrs, traceContext) {
|
|
260
257
|
var remotePreview;
|
|
261
|
-
return
|
|
262
|
-
while (1) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
return _context2.stop();
|
|
275
|
-
}
|
|
258
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
259
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
260
|
+
case 0:
|
|
261
|
+
_context2.next = 2;
|
|
262
|
+
return (0, _helpers.getCardPreviewFromBackend)(mediaClient, id, params, traceContext);
|
|
263
|
+
case 2:
|
|
264
|
+
remotePreview = _context2.sent;
|
|
265
|
+
return _context2.abrupt("return", extendAndCachePreview(id, params.mode, _objectSpread(_objectSpread({}, remotePreview), {}, {
|
|
266
|
+
dimensions: dimensions
|
|
267
|
+
}), mediaBlobUrlAttrs));
|
|
268
|
+
case 4:
|
|
269
|
+
case "end":
|
|
270
|
+
return _context2.stop();
|
|
276
271
|
}
|
|
277
272
|
}, _callee2);
|
|
278
273
|
}));
|