@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/card/card.js +99 -108
  3. package/dist/cjs/card/cardLoader.js +3 -3
  4. package/dist/cjs/card/cardView.js +6 -7
  5. package/dist/cjs/card/getCardPreview/helpers.js +108 -117
  6. package/dist/cjs/card/getCardPreview/index.js +99 -104
  7. package/dist/cjs/card/inlinePlayer.js +92 -97
  8. package/dist/cjs/card/inlinePlayerLazy.js +19 -20
  9. package/dist/cjs/card/media-card-analytics-error-boundary.js +1 -1
  10. package/dist/cjs/card/ui/common.js +4 -4
  11. package/dist/cjs/inline/loader.js +50 -52
  12. package/dist/cjs/inline/mediaInlineAnalyticsErrorBoundary.js +59 -9
  13. package/dist/cjs/types.js +4 -4
  14. package/dist/cjs/utils/cardActions/cardActionIconButton.js +2 -3
  15. package/dist/cjs/utils/cardActions/styles.js +4 -4
  16. package/dist/cjs/utils/ufoExperiences.js +1 -1
  17. package/dist/cjs/utils/videoSnapshot.js +41 -44
  18. package/dist/cjs/utils/viewportDetector.js +1 -1
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/card/card.js +6 -7
  21. package/dist/es2019/card/cardView.js +2 -3
  22. package/dist/es2019/card/inlinePlayer.js +1 -3
  23. package/dist/es2019/card/media-card-analytics-error-boundary.js +1 -1
  24. package/dist/es2019/card/ui/common.js +3 -3
  25. package/dist/es2019/inline/loader.js +3 -1
  26. package/dist/es2019/inline/mediaInlineAnalyticsErrorBoundary.js +60 -7
  27. package/dist/es2019/types.js +3 -3
  28. package/dist/es2019/utils/cardActions/cardActionIconButton.js +2 -3
  29. package/dist/es2019/utils/cardActions/styles.js +3 -3
  30. package/dist/es2019/utils/ufoExperiences.js +1 -1
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/card/card.js +99 -109
  33. package/dist/esm/card/cardView.js +6 -7
  34. package/dist/esm/card/getCardPreview/helpers.js +108 -117
  35. package/dist/esm/card/getCardPreview/index.js +99 -104
  36. package/dist/esm/card/inlinePlayer.js +92 -98
  37. package/dist/esm/card/inlinePlayerLazy.js +17 -20
  38. package/dist/esm/card/media-card-analytics-error-boundary.js +1 -1
  39. package/dist/esm/card/ui/common.js +3 -3
  40. package/dist/esm/inline/loader.js +44 -47
  41. package/dist/esm/inline/mediaInlineAnalyticsErrorBoundary.js +59 -9
  42. package/dist/esm/types.js +3 -3
  43. package/dist/esm/utils/cardActions/cardActionIconButton.js +2 -3
  44. package/dist/esm/utils/cardActions/styles.js +3 -3
  45. package/dist/esm/utils/ufoExperiences.js +1 -1
  46. package/dist/esm/utils/videoSnapshot.js +41 -44
  47. package/dist/esm/utils/viewportDetector.js +1 -1
  48. package/dist/esm/version.json +1 -1
  49. package/dist/types/inline/loader.d.ts +1 -0
  50. package/dist/types/inline/mediaInlineAnalyticsErrorBoundary.d.ts +1 -0
  51. package/package.json +28 -28
  52. package/report.api.md +1 -0
@@ -1,4 +1,3 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
@@ -8,7 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
8
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
9
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
10
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
11
- 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; }
10
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
12
11
  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; }
13
12
  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; }
14
13
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -41,22 +40,16 @@ import { getMediaCardCursor } from '../utils/getMediaCardCursor';
41
40
  import { completeUfoExperience, startUfoExperience } from '../utils/ufoExperiences';
42
41
  import { generateUniqueId } from '../utils/generateUniqueId';
43
42
  var packageName = "@atlaskit/media-card";
44
- var packageVersion = "74.7.3";
43
+ var packageVersion = "74.8.0";
45
44
  export var CardBase = /*#__PURE__*/function (_Component) {
46
45
  _inherits(CardBase, _Component);
47
46
  var _super = _createSuper(CardBase);
48
- // An internalOccurrenceKey is a randomly generated value to differentiate various instances
49
- // of Cards regardless of whether it shares the same file (either internal or external)
50
-
51
- // We initialise timeElapsedTillCommenced
52
- // to avoid extra branching on a possibly undefined value.
53
-
54
- // Generate unique traceId for file
55
-
56
47
  function CardBase(props) {
57
48
  var _this;
58
49
  _classCallCheck(this, CardBase);
59
50
  _this = _super.call(this, props);
51
+ // An internalOccurrenceKey is a randomly generated value to differentiate various instances
52
+ // of Cards regardless of whether it shares the same file (either internal or external)
60
53
  _defineProperty(_assertThisInitialized(_this), "internalOccurrenceKey", generateUniqueId());
61
54
  _defineProperty(_assertThisInitialized(_this), "hasBeenMounted", false);
62
55
  _defineProperty(_assertThisInitialized(_this), "fileStateFlags", {
@@ -71,7 +64,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
71
64
  status: 'unknown'
72
65
  }
73
66
  });
67
+ // We initialise timeElapsedTillCommenced
68
+ // to avoid extra branching on a possibly undefined value.
74
69
  _defineProperty(_assertThisInitialized(_this), "timeElapsedTillCommenced", performance.now());
70
+ // Generate unique traceId for file
75
71
  _defineProperty(_assertThisInitialized(_this), "traceContext", {
76
72
  traceId: getRandomHex(8)
77
73
  });
@@ -137,31 +133,29 @@ export var CardBase = /*#__PURE__*/function (_Component) {
137
133
  });
138
134
  });
139
135
  _defineProperty(_assertThisInitialized(_this), "refetchSSRPreview", /*#__PURE__*/function () {
140
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(identifier) {
136
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier) {
141
137
  var cardPreview, wrappedError;
142
- return _regeneratorRuntime().wrap(function _callee$(_context) {
143
- while (1) {
144
- switch (_context.prev = _context.next) {
145
- case 0:
146
- _context.prev = 0;
147
- _context.next = 3;
148
- return _this.fetchAndCacheRemotePreview(identifier);
149
- case 3:
150
- cardPreview = _context.sent;
151
- _this.safeSetState({
152
- cardPreview: cardPreview
153
- });
154
- _context.next = 11;
155
- break;
156
- case 7:
157
- _context.prev = 7;
158
- _context.t0 = _context["catch"](0);
159
- wrappedError = ensureMediaCardError('remote-preview-fetch-ssr', _context.t0, true);
160
- _this.fireNonCriticalErrorEvent(wrappedError);
161
- case 11:
162
- case "end":
163
- return _context.stop();
164
- }
138
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
139
+ while (1) switch (_context.prev = _context.next) {
140
+ case 0:
141
+ _context.prev = 0;
142
+ _context.next = 3;
143
+ return _this.fetchAndCacheRemotePreview(identifier);
144
+ case 3:
145
+ cardPreview = _context.sent;
146
+ _this.safeSetState({
147
+ cardPreview: cardPreview
148
+ });
149
+ _context.next = 11;
150
+ break;
151
+ case 7:
152
+ _context.prev = 7;
153
+ _context.t0 = _context["catch"](0);
154
+ wrappedError = ensureMediaCardError('remote-preview-fetch-ssr', _context.t0, true);
155
+ _this.fireNonCriticalErrorEvent(wrappedError);
156
+ case 11:
157
+ case "end":
158
+ return _context.stop();
165
159
  }
166
160
  }, _callee, null, [[0, 7]]);
167
161
  }));
@@ -170,45 +164,43 @@ export var CardBase = /*#__PURE__*/function (_Component) {
170
164
  };
171
165
  }());
172
166
  _defineProperty(_assertThisInitialized(_this), "resolveUpfrontPreview", /*#__PURE__*/function () {
173
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(identifier) {
167
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(identifier) {
174
168
  var requestedDimensions, cardPreview, currentDimensions, areValidRequestedDimensions;
175
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
176
- while (1) {
177
- switch (_context2.prev = _context2.next) {
178
- case 0:
179
- requestedDimensions = _objectSpread({}, _this.props.dimensions);
180
- _context2.prev = 1;
181
- _context2.next = 4;
182
- return _this.fetchAndCacheRemotePreview(identifier);
183
- case 4:
184
- cardPreview = _context2.sent;
185
- currentDimensions = _this.props.dimensions;
186
- areValidRequestedDimensions = !isBigger(requestedDimensions, currentDimensions); // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
187
- // the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
188
- // to trigger a normal preview fetch.
189
- if (areValidRequestedDimensions) {
190
- _this.safeSetState({
191
- cardPreview: cardPreview,
192
- wasResolvedUpfrontPreview: true
193
- });
194
- } else {
195
- _this.safeSetState({
196
- wasResolvedUpfrontPreview: true
197
- });
198
- }
199
- _context2.next = 13;
200
- break;
201
- case 10:
202
- _context2.prev = 10;
203
- _context2.t0 = _context2["catch"](1);
169
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
170
+ while (1) switch (_context2.prev = _context2.next) {
171
+ case 0:
172
+ requestedDimensions = _objectSpread({}, _this.props.dimensions);
173
+ _context2.prev = 1;
174
+ _context2.next = 4;
175
+ return _this.fetchAndCacheRemotePreview(identifier);
176
+ case 4:
177
+ cardPreview = _context2.sent;
178
+ currentDimensions = _this.props.dimensions;
179
+ areValidRequestedDimensions = !isBigger(requestedDimensions, currentDimensions); // If there are new and bigger dimensions in the props, and the upfront preview is still resolving,
180
+ // the fetched preview is no longer valid, and thus, we dismiss it and set the flag wasResolvedUpfrontPreview = true
181
+ // to trigger a normal preview fetch.
182
+ if (areValidRequestedDimensions) {
204
183
  _this.safeSetState({
184
+ cardPreview: cardPreview,
205
185
  wasResolvedUpfrontPreview: true
206
186
  });
207
- // NO need to log error. If this call fails, a refetch will happen after
208
- case 13:
209
- case "end":
210
- return _context2.stop();
211
- }
187
+ } else {
188
+ _this.safeSetState({
189
+ wasResolvedUpfrontPreview: true
190
+ });
191
+ }
192
+ _context2.next = 13;
193
+ break;
194
+ case 10:
195
+ _context2.prev = 10;
196
+ _context2.t0 = _context2["catch"](1);
197
+ _this.safeSetState({
198
+ wasResolvedUpfrontPreview: true
199
+ });
200
+ // NO need to log error. If this call fails, a refetch will happen after
201
+ case 13:
202
+ case "end":
203
+ return _context2.stop();
212
204
  }
213
205
  }, _callee2, null, [[1, 10]]);
214
206
  }));
@@ -224,45 +216,43 @@ export var CardBase = /*#__PURE__*/function (_Component) {
224
216
  return fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
225
217
  });
226
218
  _defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
227
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(identifier, fileState) {
219
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(identifier, fileState) {
228
220
  var params, cardPreview, wrappedError;
229
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
230
- while (1) {
231
- switch (_context3.prev = _context3.next) {
232
- case 0:
233
- _context3.prev = 0;
234
- params = _this.getCardPreviewParams(identifier, fileState);
235
- _context3.next = 4;
236
- return getCardPreview(params);
237
- case 4:
238
- cardPreview = _context3.sent;
221
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
222
+ while (1) switch (_context3.prev = _context3.next) {
223
+ case 0:
224
+ _context3.prev = 0;
225
+ params = _this.getCardPreviewParams(identifier, fileState);
226
+ _context3.next = 4;
227
+ return getCardPreview(params);
228
+ case 4:
229
+ cardPreview = _context3.sent;
230
+ _this.safeSetState({
231
+ cardPreview: cardPreview
232
+ });
233
+ _context3.next = 12;
234
+ break;
235
+ case 8:
236
+ _context3.prev = 8;
237
+ _context3.t0 = _context3["catch"](0);
238
+ wrappedError = ensureMediaCardError('preview-fetch', _context3.t0); // If remote preview fails, we set status 'error'
239
+ // If local preview fails (i.e, no remote preview available),
240
+ // we can stay in the same status until there is a remote preview available
241
+ // If it's any other error we set status 'error'
242
+ if (isLocalPreviewError(wrappedError)) {
243
+ // This error should already been logged inside the getCardPreview. No need to log it here.
244
+ _this.safeSetState({
245
+ isBannedLocalPreview: true
246
+ });
247
+ } else {
239
248
  _this.safeSetState({
240
- cardPreview: cardPreview
249
+ status: 'error',
250
+ error: wrappedError
241
251
  });
242
- _context3.next = 12;
243
- break;
244
- case 8:
245
- _context3.prev = 8;
246
- _context3.t0 = _context3["catch"](0);
247
- wrappedError = ensureMediaCardError('preview-fetch', _context3.t0); // If remote preview fails, we set status 'error'
248
- // If local preview fails (i.e, no remote preview available),
249
- // we can stay in the same status until there is a remote preview available
250
- // If it's any other error we set status 'error'
251
- if (isLocalPreviewError(wrappedError)) {
252
- // This error should already been logged inside the getCardPreview. No need to log it here.
253
- _this.safeSetState({
254
- isBannedLocalPreview: true
255
- });
256
- } else {
257
- _this.safeSetState({
258
- status: 'error',
259
- error: wrappedError
260
- });
261
- }
262
- case 12:
263
- case "end":
264
- return _context3.stop();
265
- }
252
+ }
253
+ case 12:
254
+ case "end":
255
+ return _context3.stop();
266
256
  }
267
257
  }, _callee3, null, [[0, 8]]);
268
258
  }));
@@ -611,9 +601,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
611
601
  var _this$props9 = _this.props,
612
602
  ssr = _this$props9.ssr,
613
603
  identifier = _this$props9.identifier;
614
- var _this$state$cardPrevi = _this.state.cardPreview;
615
- _this$state$cardPrevi = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi;
616
- var dataURI = _this$state$cardPrevi.dataURI;
604
+ var _this$state$cardPrevi = _this.state.cardPreview,
605
+ _this$state$cardPrevi2 = _this$state$cardPrevi === void 0 ? {} : _this$state$cardPrevi,
606
+ dataURI = _this$state$cardPrevi2.dataURI;
617
607
  return isFileIdentifier(identifier) && ssr === 'server' && /*#__PURE__*/React.createElement(StoreSSRDataScript, {
618
608
  identifier: identifier,
619
609
  dataURI: dataURI,
@@ -87,6 +87,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
87
87
  });
88
88
  onImageError && onImageError(cardPreview);
89
89
  });
90
+ // If the dimensions.width is a percentage, we need to transform it
91
+ // into a pixel value in order to get the right breakpoints applied.
90
92
  _defineProperty(_assertThisInitialized(_this), "saveElementWidth", function () {
91
93
  var dimensions = _this.props.dimensions;
92
94
  if (!dimensions) {
@@ -352,9 +354,6 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
352
354
  var width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || defaultImageCardDimensions.width;
353
355
  return calcBreakpointSize(parseInt("".concat(width), 10));
354
356
  }
355
-
356
- // If the dimensions.width is a percentage, we need to transform it
357
- // into a pixel value in order to get the right breakpoints applied.
358
357
  }, {
359
358
  key: "render",
360
359
  value: function render() {
@@ -459,10 +458,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
459
458
  value: function renderImageRenderer() {
460
459
  var _this$props9 = this.props,
461
460
  cardPreview = _this$props9.cardPreview,
462
- _this$props9$metadata = _this$props9.metadata;
463
- _this$props9$metadata = _this$props9$metadata === void 0 ? {} : _this$props9$metadata;
464
- var _this$props9$metadata2 = _this$props9$metadata.mediaType,
465
- mediaType = _this$props9$metadata2 === void 0 ? 'unknown' : _this$props9$metadata2,
461
+ _this$props9$metadata = _this$props9.metadata,
462
+ _this$props9$metadata2 = _this$props9$metadata === void 0 ? {} : _this$props9$metadata,
463
+ _this$props9$metadata3 = _this$props9$metadata2.mediaType,
464
+ mediaType = _this$props9$metadata3 === void 0 ? 'unknown' : _this$props9$metadata3,
466
465
  alt = _this$props9.alt,
467
466
  resizeMode = _this$props9.resizeMode,
468
467
  onDisplayImage = _this$props9.onDisplayImage,
@@ -1,6 +1,5 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
- 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; }
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  import { takeSnapshot } from '../../utils/videoSnapshot';
5
4
  import { getMediaTypeFromMimeType } from '@atlaskit/media-common';
6
5
  import { getOrientation } from '@atlaskit/media-ui';
@@ -13,31 +12,29 @@ export var isSupportedLocalPreview = function isSupportedLocalPreview(mediaType)
13
12
  return mediaType === 'image' || mediaType === 'video';
14
13
  };
15
14
  var getImageLocalPreview = /*#__PURE__*/function () {
16
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value) {
15
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
17
16
  var orientation, dataURI;
18
- return _regeneratorRuntime().wrap(function _callee$(_context) {
19
- while (1) {
20
- switch (_context.prev = _context.next) {
21
- case 0:
22
- _context.prev = 0;
23
- _context.next = 3;
24
- return getOrientation(value);
25
- case 3:
26
- orientation = _context.sent;
27
- dataURI = URL.createObjectURL(value);
28
- return _context.abrupt("return", {
29
- dataURI: dataURI,
30
- orientation: orientation,
31
- source: 'local'
32
- });
33
- case 8:
34
- _context.prev = 8;
35
- _context.t0 = _context["catch"](0);
36
- throw new LocalPreviewError('local-preview-image', _context.t0 instanceof Error ? _context.t0 : undefined);
37
- case 11:
38
- case "end":
39
- return _context.stop();
40
- }
17
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ _context.prev = 0;
21
+ _context.next = 3;
22
+ return getOrientation(value);
23
+ case 3:
24
+ orientation = _context.sent;
25
+ dataURI = URL.createObjectURL(value);
26
+ return _context.abrupt("return", {
27
+ dataURI: dataURI,
28
+ orientation: orientation,
29
+ source: 'local'
30
+ });
31
+ case 8:
32
+ _context.prev = 8;
33
+ _context.t0 = _context["catch"](0);
34
+ throw new LocalPreviewError('local-preview-image', _context.t0 instanceof Error ? _context.t0 : undefined);
35
+ case 11:
36
+ case "end":
37
+ return _context.stop();
41
38
  }
42
39
  }, _callee, null, [[0, 8]]);
43
40
  }));
@@ -46,30 +43,28 @@ var getImageLocalPreview = /*#__PURE__*/function () {
46
43
  };
47
44
  }();
48
45
  var getVideoLocalPreview = /*#__PURE__*/function () {
49
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(value) {
46
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value) {
50
47
  var dataURI;
51
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
52
- while (1) {
53
- switch (_context2.prev = _context2.next) {
54
- case 0:
55
- _context2.prev = 0;
56
- _context2.next = 3;
57
- return takeSnapshot(value);
58
- case 3:
59
- dataURI = _context2.sent;
60
- return _context2.abrupt("return", {
61
- dataURI: dataURI,
62
- orientation: 1,
63
- source: 'local'
64
- });
65
- case 7:
66
- _context2.prev = 7;
67
- _context2.t0 = _context2["catch"](0);
68
- throw new LocalPreviewError('local-preview-video', _context2.t0 instanceof Error ? _context2.t0 : undefined);
69
- case 10:
70
- case "end":
71
- return _context2.stop();
72
- }
48
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
49
+ while (1) switch (_context2.prev = _context2.next) {
50
+ case 0:
51
+ _context2.prev = 0;
52
+ _context2.next = 3;
53
+ return takeSnapshot(value);
54
+ case 3:
55
+ dataURI = _context2.sent;
56
+ return _context2.abrupt("return", {
57
+ dataURI: dataURI,
58
+ orientation: 1,
59
+ source: 'local'
60
+ });
61
+ case 7:
62
+ _context2.prev = 7;
63
+ _context2.t0 = _context2["catch"](0);
64
+ throw new LocalPreviewError('local-preview-video', _context2.t0 instanceof Error ? _context2.t0 : undefined);
65
+ case 10:
66
+ case "end":
67
+ return _context2.stop();
73
68
  }
74
69
  }, _callee2, null, [[0, 7]]);
75
70
  }));
@@ -78,54 +73,52 @@ var getVideoLocalPreview = /*#__PURE__*/function () {
78
73
  };
79
74
  }();
80
75
  export var getCardPreviewFromFilePreview = /*#__PURE__*/function () {
81
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(filePreview) {
76
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(filePreview) {
82
77
  var value, resolvedFilePreview, _value, type, mediaType;
83
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
84
- while (1) {
85
- switch (_context3.prev = _context3.next) {
86
- case 0:
87
- _context3.prev = 0;
88
- _context3.next = 3;
89
- return filePreview;
90
- case 3:
91
- resolvedFilePreview = _context3.sent;
92
- value = resolvedFilePreview.value;
93
- _context3.next = 10;
78
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
79
+ while (1) switch (_context3.prev = _context3.next) {
80
+ case 0:
81
+ _context3.prev = 0;
82
+ _context3.next = 3;
83
+ return filePreview;
84
+ case 3:
85
+ resolvedFilePreview = _context3.sent;
86
+ value = resolvedFilePreview.value;
87
+ _context3.next = 10;
88
+ break;
89
+ case 7:
90
+ _context3.prev = 7;
91
+ _context3.t0 = _context3["catch"](0);
92
+ throw new LocalPreviewError('local-preview-rejected', _context3.t0 instanceof Error ? _context3.t0 : undefined);
93
+ case 10:
94
+ if (!(typeof value === 'string')) {
95
+ _context3.next = 14;
94
96
  break;
95
- case 7:
96
- _context3.prev = 7;
97
- _context3.t0 = _context3["catch"](0);
98
- throw new LocalPreviewError('local-preview-rejected', _context3.t0 instanceof Error ? _context3.t0 : undefined);
99
- case 10:
100
- if (!(typeof value === 'string')) {
101
- _context3.next = 14;
102
- break;
103
- }
104
- return _context3.abrupt("return", {
105
- dataURI: value,
106
- orientation: 1,
107
- source: 'local'
108
- });
109
- case 14:
110
- if (!(value instanceof Blob)) {
111
- _context3.next = 22;
112
- break;
113
- }
114
- _value = value, type = _value.type;
115
- mediaType = getMediaTypeFromMimeType(type);
116
- _context3.t1 = mediaType;
117
- _context3.next = _context3.t1 === 'image' ? 20 : _context3.t1 === 'video' ? 21 : 22;
97
+ }
98
+ return _context3.abrupt("return", {
99
+ dataURI: value,
100
+ orientation: 1,
101
+ source: 'local'
102
+ });
103
+ case 14:
104
+ if (!(value instanceof Blob)) {
105
+ _context3.next = 22;
118
106
  break;
119
- case 20:
120
- return _context3.abrupt("return", getImageLocalPreview(value));
121
- case 21:
122
- return _context3.abrupt("return", getVideoLocalPreview(value));
123
- case 22:
124
- throw new LocalPreviewError('local-preview-unsupported');
125
- case 23:
126
- case "end":
127
- return _context3.stop();
128
- }
107
+ }
108
+ _value = value, type = _value.type;
109
+ mediaType = getMediaTypeFromMimeType(type);
110
+ _context3.t1 = mediaType;
111
+ _context3.next = _context3.t1 === 'image' ? 20 : _context3.t1 === 'video' ? 21 : 22;
112
+ break;
113
+ case 20:
114
+ return _context3.abrupt("return", getImageLocalPreview(value));
115
+ case 21:
116
+ return _context3.abrupt("return", getVideoLocalPreview(value));
117
+ case 22:
118
+ throw new LocalPreviewError('local-preview-unsupported');
119
+ case 23:
120
+ case "end":
121
+ return _context3.stop();
129
122
  }
130
123
  }, _callee3, null, [[0, 7]]);
131
124
  }));
@@ -134,30 +127,28 @@ export var getCardPreviewFromFilePreview = /*#__PURE__*/function () {
134
127
  };
135
128
  }();
136
129
  export var getCardPreviewFromBackend = /*#__PURE__*/function () {
137
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(mediaClient, id, params, traceContext) {
130
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(mediaClient, id, params, traceContext) {
138
131
  var blob;
139
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
140
- while (1) {
141
- switch (_context4.prev = _context4.next) {
142
- case 0:
143
- _context4.prev = 0;
144
- _context4.next = 3;
145
- return mediaClient.getImage(id, params, undefined, undefined, traceContext);
146
- case 3:
147
- blob = _context4.sent;
148
- return _context4.abrupt("return", {
149
- dataURI: URL.createObjectURL(blob),
150
- orientation: 1,
151
- source: 'remote'
152
- });
153
- case 7:
154
- _context4.prev = 7;
155
- _context4.t0 = _context4["catch"](0);
156
- throw new RemotePreviewError('remote-preview-fetch', _context4.t0 instanceof Error ? _context4.t0 : undefined);
157
- case 10:
158
- case "end":
159
- return _context4.stop();
160
- }
132
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
133
+ while (1) switch (_context4.prev = _context4.next) {
134
+ case 0:
135
+ _context4.prev = 0;
136
+ _context4.next = 3;
137
+ return mediaClient.getImage(id, params, undefined, undefined, traceContext);
138
+ case 3:
139
+ blob = _context4.sent;
140
+ return _context4.abrupt("return", {
141
+ dataURI: URL.createObjectURL(blob),
142
+ orientation: 1,
143
+ source: 'remote'
144
+ });
145
+ case 7:
146
+ _context4.prev = 7;
147
+ _context4.t0 = _context4["catch"](0);
148
+ throw new RemotePreviewError('remote-preview-fetch', _context4.t0 instanceof Error ? _context4.t0 : undefined);
149
+ case 10:
150
+ case "end":
151
+ return _context4.stop();
161
152
  }
162
153
  }, _callee4, null, [[0, 7]]);
163
154
  }));