@atlaskit/media-card 74.7.2 → 74.7.4

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