@atlaskit/smart-card 22.1.0 → 22.2.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 (44) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/__tests_external__/index.js +53 -0
  3. package/dist/cjs/__tests_external__/page-objects/BaseCard.js +115 -0
  4. package/dist/cjs/__tests_external__/page-objects/BlockCard.js +43 -0
  5. package/dist/cjs/__tests_external__/page-objects/EmbedCard.js +43 -0
  6. package/dist/cjs/__tests_external__/page-objects/InlineCard.js +43 -0
  7. package/dist/cjs/__tests_external__/test-cases/card.js +27 -0
  8. package/dist/cjs/__tests_external__/test-cases/embed.js +27 -0
  9. package/dist/cjs/__tests_external__/test-cases/inline.js +27 -0
  10. package/dist/cjs/__tests_external__/test-cases/types.js +5 -0
  11. package/dist/cjs/state/hooks/usePrefetch.js +26 -14
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/cjs/view/CardWithUrl/loader.js +10 -10
  14. package/dist/cjs/view/InlineCard/IconAndTitleLayout/styled.js +2 -2
  15. package/dist/es2019/__tests_external__/index.js +6 -0
  16. package/dist/es2019/__tests_external__/page-objects/BaseCard.js +61 -0
  17. package/dist/es2019/__tests_external__/page-objects/BlockCard.js +8 -0
  18. package/dist/es2019/__tests_external__/page-objects/EmbedCard.js +8 -0
  19. package/dist/es2019/__tests_external__/page-objects/InlineCard.js +8 -0
  20. package/dist/es2019/__tests_external__/test-cases/card.js +14 -0
  21. package/dist/es2019/__tests_external__/test-cases/embed.js +14 -0
  22. package/dist/es2019/__tests_external__/test-cases/inline.js +14 -0
  23. package/dist/es2019/__tests_external__/test-cases/types.js +1 -0
  24. package/dist/es2019/state/hooks/usePrefetch.js +9 -4
  25. package/dist/es2019/version.json +1 -1
  26. package/dist/es2019/view/CardWithUrl/loader.js +10 -10
  27. package/dist/es2019/view/InlineCard/IconAndTitleLayout/styled.js +0 -2
  28. package/dist/esm/__tests_external__/index.js +6 -0
  29. package/dist/esm/__tests_external__/page-objects/BaseCard.js +101 -0
  30. package/dist/esm/__tests_external__/page-objects/BlockCard.js +28 -0
  31. package/dist/esm/__tests_external__/page-objects/EmbedCard.js +28 -0
  32. package/dist/esm/__tests_external__/page-objects/InlineCard.js +28 -0
  33. package/dist/esm/__tests_external__/test-cases/card.js +16 -0
  34. package/dist/esm/__tests_external__/test-cases/embed.js +16 -0
  35. package/dist/esm/__tests_external__/test-cases/inline.js +16 -0
  36. package/dist/esm/__tests_external__/test-cases/types.js +1 -0
  37. package/dist/esm/state/hooks/usePrefetch.js +26 -14
  38. package/dist/esm/version.json +1 -1
  39. package/dist/esm/view/CardWithUrl/loader.js +10 -10
  40. package/dist/esm/view/InlineCard/IconAndTitleLayout/styled.js +2 -2
  41. package/dist/types/view/Card/index.d.ts +1 -1
  42. package/dist/types/view/HoverCard/index.d.ts +1 -1
  43. package/package.json +22 -22
  44. package/report.api.md +1 -1
@@ -0,0 +1,14 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { BlockCardPageObject } from '../page-objects/BlockCard';
3
+ export const blockSmartLinkRendersTestCase = ({
4
+ url,
5
+ status = 'resolved'
6
+ }) => new InProductTestCase({
7
+ title: 'Block Smart Link is visible in the resolved state',
8
+ id: 'block-smart-link-resolved',
9
+ assertions: cy => {
10
+ const blockCard = new BlockCardPageObject(cy);
11
+ blockCard.assertHrefRendered(url);
12
+ blockCard.expectCardReady(1, status);
13
+ }
14
+ });
@@ -0,0 +1,14 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { EmbedCardPageObject } from '../page-objects/EmbedCard';
3
+ export const embedSmartLinkRendersTestCase = ({
4
+ url,
5
+ status = 'resolved'
6
+ }) => new InProductTestCase({
7
+ title: 'Embed Smart Link is visible in the resolved state',
8
+ id: 'embed-smart-link-resolved',
9
+ assertions: cy => {
10
+ const embedCard = new EmbedCardPageObject(cy);
11
+ embedCard.assertHrefRendered(url);
12
+ embedCard.expectCardReady(1, status);
13
+ }
14
+ });
@@ -0,0 +1,14 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { InlineCardPageObject } from '../page-objects/InlineCard';
3
+ export const inlineSmartLinkRendersTestCase = ({
4
+ url,
5
+ status = 'resolved'
6
+ }) => new InProductTestCase({
7
+ title: 'Inline Smart Link is visible in the resolved state',
8
+ id: 'inline-smart-link-resolved',
9
+ assertions: cy => {
10
+ const inlineCard = new InlineCardPageObject(cy);
11
+ inlineCard.assertHrefRendered(url);
12
+ inlineCard.expectCardReady(1, status);
13
+ }
14
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -10,15 +10,20 @@ export function usePrefetch(url) {
10
10
  const {
11
11
  dispatch,
12
12
  getState
13
- } = store;
13
+ } = store || {};
14
14
  const {
15
15
  client
16
- } = connections;
16
+ } = connections || {};
17
17
  return useCallback(async () => {
18
- // If the link is already being prefetched, the prefetch store
18
+ // If smartlink context props are undefined do nothing.
19
+ if (!store || !prefetchStore || !connections) {
20
+ return;
21
+ } // If the link is already being prefetched, the prefetch store
19
22
  // should have a flag set against the URL. The prefetch store is purposefully
20
23
  // separate from the UI in order to ensure no rendering takes place;
21
24
  // all mutations which occur are purely store-based mutations.
25
+
26
+
22
27
  const isPrefetching = prefetchStore[url]; // If the link has already been registered in the store, then it no
23
28
  // longer needs to be prefetched, as the normal flow of a link being in
24
29
  // the viewport and being fetched is now in motion.
@@ -59,5 +64,5 @@ export function usePrefetch(url) {
59
64
  // mutations yet, the link will behave like a 'brand new' link.
60
65
  }
61
66
  }
62
- }, [prefetchStore, url, getState, client, dispatch]);
67
+ }, [store, prefetchStore, connections, url, getState, client, dispatch]);
63
68
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "22.1.0",
3
+ "version": "22.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -55,16 +55,12 @@ export function CardWithURLRenderer(props) {
55
55
  const logError = useCallback((error, info) => {
56
56
  const {
57
57
  componentStack
58
- } = info; // NB: APIErrors are thrown in response to Object Resolver Service.
59
- // In these cases, control is handed back to the Editor. We do not
58
+ } = info; // NB: APIErrors are thrown in response to Object Resolver Service. We do not
60
59
  // fire an event for these, as they do not cover failed UI render events.
60
+ // The rest of the errors caught here are unexpected, and correlate
61
+ // to the reliability of the smart-card front-end components.
61
62
 
62
- if (error.name === 'APIError') {
63
- throw error;
64
- } // NB: the rest of the errors caught here are unexpected, and correlate
65
- // to the reliability of the smart-card front-end components. We instrument
66
- // these in order to measure our front-end reliability.
67
- else {
63
+ if (error.name !== 'APIError') {
68
64
  const errorInfo = {
69
65
  componentStack
70
66
  };
@@ -74,7 +70,11 @@ export function CardWithURLRenderer(props) {
74
70
  error,
75
71
  errorInfo
76
72
  });
77
- }
73
+ } // Rethrow to hand control to the consumer of Smart-card.
74
+ // In the case of editor this allows the Smart Link to fallback to a blue link.
75
+
76
+
77
+ throw error;
78
78
  }, [analytics.ui, appearance, id]);
79
79
 
80
80
  if (!url) {
@@ -112,5 +112,5 @@ export function CardWithURLRenderer(props) {
112
112
  }
113
113
 
114
114
  const ErrorFallback = () => {
115
- return /*#__PURE__*/React.createElement("span", null);
115
+ return null;
116
116
  };
@@ -64,14 +64,12 @@ export const LozengeWrapper = styled.span`
64
64
  vertical-align: 1px;
65
65
  & > span {
66
66
  margin-left: 4px;
67
- padding: 2px 0 2px 0;
68
67
  }
69
68
  `; // TODO: Replace overrides with proper AtlasKit solution.
70
69
 
71
70
  export const LozengeBlockWrapper = styled.span`
72
71
  & > span {
73
72
  margin-left: 4px;
74
- padding: 2px 0 2px 0;
75
73
  }
76
74
  `;
77
75
  export const RightIconPositionWrapper = styled.span`
@@ -0,0 +1,6 @@
1
+ export { InlineCardPageObject } from './page-objects/InlineCard';
2
+ export { BlockCardPageObject } from './page-objects/BlockCard';
3
+ export { EmbedCardPageObject } from './page-objects/EmbedCard';
4
+ export { inlineSmartLinkRendersTestCase } from './test-cases/inline';
5
+ export { blockSmartLinkRendersTestCase } from './test-cases/card';
6
+ export { embedSmartLinkRendersTestCase } from './test-cases/embed';
@@ -0,0 +1,101 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
+
8
+ 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); }; }
9
+
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+
12
+ import { InProductTestPageObject } from '@atlaskit/in-product-testing';
13
+ export var BaseCardPageObject = /*#__PURE__*/function (_InProductTestPageObj) {
14
+ _inherits(BaseCardPageObject, _InProductTestPageObj);
15
+
16
+ var _super = _createSuper(BaseCardPageObject);
17
+
18
+ function BaseCardPageObject(cy, appearance) {
19
+ var _this;
20
+
21
+ _classCallCheck(this, BaseCardPageObject);
22
+
23
+ _this = _super.call(this, cy);
24
+ _this.cy = cy;
25
+ _this.appearance = appearance;
26
+ return _this;
27
+ }
28
+
29
+ _createClass(BaseCardPageObject, [{
30
+ key: "_toSelector",
31
+ value: function _toSelector(appearance, status) {
32
+ var viewSelector = status.replace(/_/g, '-');
33
+ return this.toTestId("".concat(appearance, "-card-").concat(viewSelector, "-view"));
34
+ }
35
+ }, {
36
+ key: "expectCardReady",
37
+ value: function expectCardReady() {
38
+ var _this2 = this;
39
+
40
+ var numOfCards = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
41
+ var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'resolved';
42
+
43
+ var selector = this._toSelector(this.appearance, status);
44
+
45
+ return this.cy // NOTE: `timeout` used since Smart Links rely on a network response.
46
+ .get(selector, {
47
+ timeout: BaseCardPageObject.CARD_TIMEOUT
48
+ }).should('have.length', numOfCards).each(function (element) {
49
+ _this2.cy.wrap(element) // NOTE: `be.visible` is used to ensure the file is still visible
50
+ // whilst it is being uploaded.
51
+ .should('be.visible');
52
+ });
53
+ }
54
+ }, {
55
+ key: "expectCardNotExists",
56
+ value: function expectCardNotExists() {
57
+ var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'resolved';
58
+
59
+ var selector = this._toSelector(this.appearance, status);
60
+
61
+ return this.cy.get(selector).should('not.exist');
62
+ }
63
+ }, {
64
+ key: "findCardNth",
65
+ value: function findCardNth() {
66
+ var nth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
67
+ var status = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'resolved';
68
+
69
+ var selector = this._toSelector(this.appearance, status);
70
+
71
+ return this.cy // NOTE: `timeout` used since Smart Links rely on a network response.
72
+ .get(selector, {
73
+ timeout: BaseCardPageObject.CARD_TIMEOUT
74
+ }).should('have.length.at.least', nth).should('be.visible').eq(nth - 1);
75
+ }
76
+ }, {
77
+ key: "assertHrefRendered",
78
+ value: function assertHrefRendered(url) {
79
+ return this.cy.get("a[href=\"".concat(url, "\"]"), {
80
+ timeout: BaseCardPageObject.CARD_TIMEOUT
81
+ }).should('be.visible');
82
+ }
83
+ }, {
84
+ key: "assertHrefNotRendered",
85
+ value: function assertHrefNotRendered(url) {
86
+ return this.cy.get("a[href=\"".concat(url, "\"]"), {
87
+ timeout: BaseCardPageObject.CARD_TIMEOUT
88
+ }).should('not.exist');
89
+ }
90
+ }, {
91
+ key: "click",
92
+ value: function click() {
93
+ var status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'resolved';
94
+ return this.findCardNth(1, status).click();
95
+ }
96
+ }]);
97
+
98
+ return BaseCardPageObject;
99
+ }(InProductTestPageObject);
100
+
101
+ _defineProperty(BaseCardPageObject, "CARD_TIMEOUT", 15000);
@@ -0,0 +1,28 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ 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); }; }
8
+
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+
11
+ import { BaseCardPageObject } from './BaseCard';
12
+ export var BlockCardPageObject = /*#__PURE__*/function (_BaseCardPageObject) {
13
+ _inherits(BlockCardPageObject, _BaseCardPageObject);
14
+
15
+ var _super = _createSuper(BlockCardPageObject);
16
+
17
+ function BlockCardPageObject(cy) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, BlockCardPageObject);
21
+
22
+ _this = _super.call(this, cy, 'block');
23
+ _this.cy = cy;
24
+ return _this;
25
+ }
26
+
27
+ return _createClass(BlockCardPageObject);
28
+ }(BaseCardPageObject);
@@ -0,0 +1,28 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ 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); }; }
8
+
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+
11
+ import { BaseCardPageObject } from './BaseCard';
12
+ export var EmbedCardPageObject = /*#__PURE__*/function (_BaseCardPageObject) {
13
+ _inherits(EmbedCardPageObject, _BaseCardPageObject);
14
+
15
+ var _super = _createSuper(EmbedCardPageObject);
16
+
17
+ function EmbedCardPageObject(cy) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, EmbedCardPageObject);
21
+
22
+ _this = _super.call(this, cy, 'embed');
23
+ _this.cy = cy;
24
+ return _this;
25
+ }
26
+
27
+ return _createClass(EmbedCardPageObject);
28
+ }(BaseCardPageObject);
@@ -0,0 +1,28 @@
1
+ import _createClass from "@babel/runtime/helpers/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ 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); }; }
8
+
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+
11
+ import { BaseCardPageObject } from './BaseCard';
12
+ export var InlineCardPageObject = /*#__PURE__*/function (_BaseCardPageObject) {
13
+ _inherits(InlineCardPageObject, _BaseCardPageObject);
14
+
15
+ var _super = _createSuper(InlineCardPageObject);
16
+
17
+ function InlineCardPageObject(cy) {
18
+ var _this;
19
+
20
+ _classCallCheck(this, InlineCardPageObject);
21
+
22
+ _this = _super.call(this, cy, 'inline');
23
+ _this.cy = cy;
24
+ return _this;
25
+ }
26
+
27
+ return _createClass(InlineCardPageObject);
28
+ }(BaseCardPageObject);
@@ -0,0 +1,16 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { BlockCardPageObject } from '../page-objects/BlockCard';
3
+ export var blockSmartLinkRendersTestCase = function blockSmartLinkRendersTestCase(_ref) {
4
+ var url = _ref.url,
5
+ _ref$status = _ref.status,
6
+ status = _ref$status === void 0 ? 'resolved' : _ref$status;
7
+ return new InProductTestCase({
8
+ title: 'Block Smart Link is visible in the resolved state',
9
+ id: 'block-smart-link-resolved',
10
+ assertions: function assertions(cy) {
11
+ var blockCard = new BlockCardPageObject(cy);
12
+ blockCard.assertHrefRendered(url);
13
+ blockCard.expectCardReady(1, status);
14
+ }
15
+ });
16
+ };
@@ -0,0 +1,16 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { EmbedCardPageObject } from '../page-objects/EmbedCard';
3
+ export var embedSmartLinkRendersTestCase = function embedSmartLinkRendersTestCase(_ref) {
4
+ var url = _ref.url,
5
+ _ref$status = _ref.status,
6
+ status = _ref$status === void 0 ? 'resolved' : _ref$status;
7
+ return new InProductTestCase({
8
+ title: 'Embed Smart Link is visible in the resolved state',
9
+ id: 'embed-smart-link-resolved',
10
+ assertions: function assertions(cy) {
11
+ var embedCard = new EmbedCardPageObject(cy);
12
+ embedCard.assertHrefRendered(url);
13
+ embedCard.expectCardReady(1, status);
14
+ }
15
+ });
16
+ };
@@ -0,0 +1,16 @@
1
+ import { InProductTestCase } from '@atlaskit/in-product-testing';
2
+ import { InlineCardPageObject } from '../page-objects/InlineCard';
3
+ export var inlineSmartLinkRendersTestCase = function inlineSmartLinkRendersTestCase(_ref) {
4
+ var url = _ref.url,
5
+ _ref$status = _ref.status,
6
+ status = _ref$status === void 0 ? 'resolved' : _ref$status;
7
+ return new InProductTestCase({
8
+ title: 'Inline Smart Link is visible in the resolved state',
9
+ id: 'inline-smart-link-resolved',
10
+ assertions: function assertions(cy) {
11
+ var inlineCard = new InlineCardPageObject(cy);
12
+ inlineCard.assertHrefRendered(url);
13
+ inlineCard.expectCardReady(1, status);
14
+ }
15
+ });
16
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -9,15 +9,27 @@ export function usePrefetch(url) {
9
9
  prefetchStore = _useSmartLinkContext.prefetchStore,
10
10
  connections = _useSmartLinkContext.connections;
11
11
 
12
- var dispatch = store.dispatch,
13
- getState = store.getState;
14
- var client = connections.client;
12
+ var _ref = store || {},
13
+ dispatch = _ref.dispatch,
14
+ getState = _ref.getState;
15
+
16
+ var _ref2 = connections || {},
17
+ client = _ref2.client;
18
+
15
19
  return useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
16
20
  var isPrefetching, isFetching, needsPrefetch, response;
17
21
  return _regeneratorRuntime.wrap(function _callee$(_context) {
18
22
  while (1) {
19
23
  switch (_context.prev = _context.next) {
20
24
  case 0:
25
+ if (!(!store || !prefetchStore || !connections)) {
26
+ _context.next = 2;
27
+ break;
28
+ }
29
+
30
+ return _context.abrupt("return");
31
+
32
+ case 2:
21
33
  // If the link is already being prefetched, the prefetch store
22
34
  // should have a flag set against the URL. The prefetch store is purposefully
23
35
  // separate from the UI in order to ensure no rendering takes place;
@@ -31,7 +43,7 @@ export function usePrefetch(url) {
31
43
  needsPrefetch = !isPrefetching && !isFetching;
32
44
 
33
45
  if (!needsPrefetch) {
34
- _context.next = 14;
46
+ _context.next = 16;
35
47
  break;
36
48
  }
37
49
 
@@ -43,11 +55,11 @@ export function usePrefetch(url) {
43
55
  // requests by domain (as usual) to ensure we minimize the amount of connections
44
56
  // we create between browser -> ORS when making network requests.
45
57
 
46
- _context.prev = 5;
47
- _context.next = 8;
58
+ _context.prev = 7;
59
+ _context.next = 10;
48
60
  return client.prefetchData(url);
49
61
 
50
- case 8:
62
+ case 10:
51
63
  response = _context.sent;
52
64
 
53
65
  // Once the data comes back, we put the link in the `resolved` status. This ensures
@@ -66,18 +78,18 @@ export function usePrefetch(url) {
66
78
  }, undefined, undefined, 'resolved'));
67
79
  }
68
80
 
69
- _context.next = 14;
81
+ _context.next = 16;
70
82
  break;
71
83
 
72
- case 12:
73
- _context.prev = 12;
74
- _context.t0 = _context["catch"](5);
75
-
76
84
  case 14:
85
+ _context.prev = 14;
86
+ _context.t0 = _context["catch"](7);
87
+
88
+ case 16:
77
89
  case "end":
78
90
  return _context.stop();
79
91
  }
80
92
  }
81
- }, _callee, null, [[5, 12]]);
82
- })), [prefetchStore, url, getState, client, dispatch]);
93
+ }, _callee, null, [[7, 14]]);
94
+ })), [store, prefetchStore, connections, url, getState, client, dispatch]);
83
95
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "22.1.0",
3
+ "version": "22.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -59,16 +59,12 @@ export function CardWithURLRenderer(props) {
59
59
  }, [appearance, createAnalyticsEvent]);
60
60
  var analytics = useSmartLinkAnalytics(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
61
61
  var logError = useCallback(function (error, info) {
62
- var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service.
63
- // In these cases, control is handed back to the Editor. We do not
62
+ var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service. We do not
64
63
  // fire an event for these, as they do not cover failed UI render events.
64
+ // The rest of the errors caught here are unexpected, and correlate
65
+ // to the reliability of the smart-card front-end components.
65
66
 
66
- if (error.name === 'APIError') {
67
- throw error;
68
- } // NB: the rest of the errors caught here are unexpected, and correlate
69
- // to the reliability of the smart-card front-end components. We instrument
70
- // these in order to measure our front-end reliability.
71
- else {
67
+ if (error.name !== 'APIError') {
72
68
  var errorInfo = {
73
69
  componentStack: componentStack
74
70
  };
@@ -78,7 +74,11 @@ export function CardWithURLRenderer(props) {
78
74
  error: error,
79
75
  errorInfo: errorInfo
80
76
  });
81
- }
77
+ } // Rethrow to hand control to the consumer of Smart-card.
78
+ // In the case of editor this allows the Smart Link to fallback to a blue link.
79
+
80
+
81
+ throw error;
82
82
  }, [analytics.ui, appearance, id]);
83
83
 
84
84
  if (!url) {
@@ -116,5 +116,5 @@ export function CardWithURLRenderer(props) {
116
116
  }
117
117
 
118
118
  var ErrorFallback = function ErrorFallback() {
119
- return /*#__PURE__*/React.createElement("span", null);
119
+ return null;
120
120
  };
@@ -21,9 +21,9 @@ export var EmojiWrapper = styled.span(_templateObject2 || (_templateObject2 = _t
21
21
 
22
22
  export var IconTitleWrapper = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n white-space: pre-wrap;\n word-break: break-all;\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
23
23
 
24
- export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n & > span {\n margin-left: 4px;\n padding: 2px 0 2px 0;\n }\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
24
+ export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n & > span {\n margin-left: 4px;\n }\n"]))); // TODO: Replace overrides with proper AtlasKit solution.
25
25
 
26
- export var LozengeBlockWrapper = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n & > span {\n margin-left: 4px;\n padding: 2px 0 2px 0;\n }\n"])));
26
+ export var LozengeBlockWrapper = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n & > span {\n margin-left: 4px;\n }\n"])));
27
27
  export var RightIconPositionWrapper = styled.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: 2px;\n margin-right: 4px;\n position: relative;\n display: inline-block;\n"]))); // The following components are used to absolutely position icons in the vertical center.
28
28
  // - IconPositionWrapper: the `relative` parent which has no height in itself.
29
29
  // - IconEmptyWrapper: the child which forces `IconPositionWrapper` to have a height.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "id" | "placeholder" | "onError" | "onClick" | "analyticsContext" | "key" | "url" | "ui" | "showActions" | "showHoverPreview" | "onResolve" | "platform" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "id" | "placeholder" | "onError" | "onClick" | "analyticsContext" | "key" | "ui" | "showActions" | "showHoverPreview" | "onResolve" | "platform" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { HoverCardProps } from './types';
3
- export declare const HoverCard: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").PropsWithChildren<HoverCardProps>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "id" | "analyticsContext" | "key" | "url"> & import("react").RefAttributes<any>>;
3
+ export declare const HoverCard: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").PropsWithChildren<HoverCardProps>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "id" | "analyticsContext" | "key"> & import("react").RefAttributes<any>>;