@atlaskit/smart-card 18.0.22 → 19.0.2

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 (255) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/cjs/client/index.js +6 -379
  3. package/dist/cjs/constants.js +4 -4
  4. package/dist/cjs/extractors/embed/index.js +2 -2
  5. package/dist/cjs/index.js +7 -13
  6. package/dist/cjs/state/actions/constants.js +1 -13
  7. package/dist/cjs/state/actions/index.js +20 -22
  8. package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +2 -2
  9. package/dist/cjs/state/config/index.js +2 -2
  10. package/dist/cjs/state/helpers.js +1 -9
  11. package/dist/cjs/state/hooks/usePrefetch.js +2 -2
  12. package/dist/cjs/state/index.js +4 -4
  13. package/dist/cjs/state/renderers/index.js +2 -2
  14. package/dist/cjs/state/store/index.js +5 -5
  15. package/dist/cjs/utils/mocks.js +2 -2
  16. package/dist/cjs/utils/test-utils.js +2 -2
  17. package/dist/cjs/version.json +1 -1
  18. package/dist/cjs/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +6 -2
  19. package/dist/cjs/view/CardWithUrl/component-lazy/LazyLazilyRenderCard.js +15 -2
  20. package/dist/cjs/view/CardWithUrl/loader.js +5 -7
  21. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +2 -2
  22. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +1 -0
  23. package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +3 -2
  24. package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +1 -0
  25. package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +1 -0
  26. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +1 -0
  27. package/dist/cjs/view/FlexibleCard/components/blocks/preview-block/index.js +1 -0
  28. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +1 -0
  29. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +2 -1
  30. package/dist/cjs/view/FlexibleCard/components/container/index.js +19 -6
  31. package/dist/cjs/view/FlexibleCard/components/container/layered-link/index.js +5 -0
  32. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +2 -2
  33. package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +2 -2
  34. package/dist/cjs/view/FlexibleCard/components/elements/date-time/index.js +2 -2
  35. package/dist/cjs/view/FlexibleCard/components/elements/icon/index.js +2 -2
  36. package/dist/cjs/view/FlexibleCard/components/elements/index.js +2 -2
  37. package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +3 -3
  38. package/dist/cjs/view/FlexibleCard/components/elements/lozenge/index.js +2 -2
  39. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +2 -2
  40. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +2 -2
  41. package/dist/es2019/client/index.js +1 -214
  42. package/dist/es2019/constants.js +4 -4
  43. package/dist/es2019/extractors/embed/index.js +1 -1
  44. package/dist/es2019/index.js +4 -4
  45. package/dist/es2019/state/actions/constants.js +0 -6
  46. package/dist/es2019/state/actions/index.js +4 -4
  47. package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +1 -1
  48. package/dist/es2019/state/config/index.js +1 -1
  49. package/dist/es2019/state/helpers.js +0 -5
  50. package/dist/es2019/state/hooks/usePrefetch.js +1 -1
  51. package/dist/es2019/state/index.js +1 -1
  52. package/dist/es2019/state/renderers/index.js +1 -1
  53. package/dist/es2019/state/store/index.js +2 -2
  54. package/dist/es2019/utils/mocks.js +1 -1
  55. package/dist/es2019/utils/test-utils.js +1 -1
  56. package/dist/es2019/version.json +1 -1
  57. package/dist/es2019/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +6 -3
  58. package/dist/es2019/view/CardWithUrl/component-lazy/LazyLazilyRenderCard.js +8 -2
  59. package/dist/es2019/view/CardWithUrl/loader.js +5 -7
  60. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +2 -2
  61. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +1 -0
  62. package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +3 -2
  63. package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +1 -0
  64. package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +1 -0
  65. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +1 -0
  66. package/dist/es2019/view/FlexibleCard/components/blocks/preview-block/index.js +1 -0
  67. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +1 -0
  68. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +2 -1
  69. package/dist/es2019/view/FlexibleCard/components/container/index.js +19 -6
  70. package/dist/es2019/view/FlexibleCard/components/container/layered-link/index.js +5 -0
  71. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +2 -2
  72. package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +2 -2
  73. package/dist/es2019/view/FlexibleCard/components/elements/date-time/index.js +2 -2
  74. package/dist/es2019/view/FlexibleCard/components/elements/icon/index.js +2 -2
  75. package/dist/es2019/view/FlexibleCard/components/elements/index.js +2 -2
  76. package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +3 -3
  77. package/dist/es2019/view/FlexibleCard/components/elements/lozenge/index.js +2 -2
  78. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +2 -2
  79. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +2 -2
  80. package/dist/esm/client/index.js +1 -360
  81. package/dist/esm/constants.js +4 -4
  82. package/dist/esm/extractors/embed/index.js +1 -1
  83. package/dist/esm/index.js +4 -4
  84. package/dist/esm/state/actions/constants.js +0 -6
  85. package/dist/esm/state/actions/index.js +4 -4
  86. package/dist/esm/state/analytics/useSmartLinkAnalytics.js +1 -1
  87. package/dist/esm/state/config/index.js +1 -1
  88. package/dist/esm/state/helpers.js +0 -5
  89. package/dist/esm/state/hooks/usePrefetch.js +1 -1
  90. package/dist/esm/state/index.js +1 -1
  91. package/dist/esm/state/renderers/index.js +1 -1
  92. package/dist/esm/state/store/index.js +2 -2
  93. package/dist/esm/utils/mocks.js +1 -1
  94. package/dist/esm/utils/test-utils.js +1 -1
  95. package/dist/esm/version.json +1 -1
  96. package/dist/esm/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.js +6 -3
  97. package/dist/esm/view/CardWithUrl/component-lazy/LazyLazilyRenderCard.js +8 -2
  98. package/dist/esm/view/CardWithUrl/loader.js +5 -7
  99. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +2 -2
  100. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +1 -0
  101. package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +3 -2
  102. package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +1 -0
  103. package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +1 -0
  104. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +1 -0
  105. package/dist/esm/view/FlexibleCard/components/blocks/preview-block/index.js +1 -0
  106. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +1 -0
  107. package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +2 -1
  108. package/dist/esm/view/FlexibleCard/components/container/index.js +19 -6
  109. package/dist/esm/view/FlexibleCard/components/container/layered-link/index.js +5 -0
  110. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +2 -2
  111. package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +2 -2
  112. package/dist/esm/view/FlexibleCard/components/elements/date-time/index.js +2 -2
  113. package/dist/esm/view/FlexibleCard/components/elements/icon/index.js +2 -2
  114. package/dist/esm/view/FlexibleCard/components/elements/index.js +2 -2
  115. package/dist/esm/view/FlexibleCard/components/elements/link/index.js +3 -3
  116. package/dist/esm/view/FlexibleCard/components/elements/lozenge/index.js +2 -2
  117. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +2 -2
  118. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +2 -2
  119. package/dist/types/__tests_external__/page-objects/BaseCard.d.ts +1 -2
  120. package/dist/types/client/index.d.ts +1 -18
  121. package/dist/types/constants.d.ts +4 -4
  122. package/dist/types/extractors/block/index.d.ts +1 -1
  123. package/dist/types/extractors/common/title-prefix/extractTitlePrefix.d.ts +1 -1
  124. package/dist/types/extractors/flexible/icon/extract-icon-renderer.d.ts +1 -1
  125. package/dist/types/extractors/flexible/icon/index.d.ts +1 -1
  126. package/dist/types/extractors/flexible/index.d.ts +1 -1
  127. package/dist/types/extractors/inline/index.d.ts +1 -1
  128. package/dist/types/index.d.ts +6 -6
  129. package/dist/types/model/invoke-opts.d.ts +1 -14
  130. package/dist/types/state/actions/constants.d.ts +0 -6
  131. package/dist/types/state/actions/types.d.ts +2 -13
  132. package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +1 -2
  133. package/dist/types/state/config/index.d.ts +1 -1
  134. package/dist/types/state/helpers.d.ts +1 -3
  135. package/dist/types/state/hooks/useSmartLink.d.ts +6 -6
  136. package/dist/types/state/index.d.ts +3 -3
  137. package/dist/types/state/reducers/types.d.ts +1 -1
  138. package/dist/types/state/renderers/index.d.ts +1 -1
  139. package/dist/types/state/store/index.d.ts +2 -2
  140. package/dist/types/state/types.d.ts +1 -1
  141. package/dist/types/types.d.ts +2 -2
  142. package/dist/types/utils/analytics/analytics.d.ts +1 -1
  143. package/dist/types/utils/analytics/index.d.ts +1 -2
  144. package/dist/types/utils/performance.d.ts +1 -1
  145. package/dist/types/view/BlockCard/types.d.ts +1 -1
  146. package/dist/types/view/Card/types.d.ts +2 -3
  147. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +2 -2
  148. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +43 -0
  149. package/dist/types/view/FlexibleCard/components/blocks/action-group/index.d.ts +1 -0
  150. package/dist/types/view/FlexibleCard/components/blocks/action-group/types.d.ts +25 -0
  151. package/dist/types/view/FlexibleCard/components/blocks/block/index.d.ts +3 -2
  152. package/dist/types/view/FlexibleCard/components/blocks/element-group/index.d.ts +1 -0
  153. package/dist/types/view/FlexibleCard/components/blocks/footer-block/index.d.ts +1 -0
  154. package/dist/types/view/FlexibleCard/components/blocks/footer-block/types.d.ts +8 -2
  155. package/dist/types/view/FlexibleCard/components/blocks/metadata-block/index.d.ts +1 -0
  156. package/dist/types/view/FlexibleCard/components/blocks/metadata-block/types.d.ts +22 -2
  157. package/dist/types/view/FlexibleCard/components/blocks/preview-block/index.d.ts +1 -0
  158. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +1 -0
  159. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +6 -2
  160. package/dist/types/view/FlexibleCard/components/blocks/title-block/index.d.ts +2 -1
  161. package/dist/types/view/FlexibleCard/components/blocks/title-block/types.d.ts +63 -13
  162. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +68 -2
  163. package/dist/types/view/FlexibleCard/components/common/loading-skeleton/types.d.ts +5 -0
  164. package/dist/types/view/FlexibleCard/components/container/index.d.ts +5 -1
  165. package/dist/types/view/FlexibleCard/components/container/layered-link/index.d.ts +5 -0
  166. package/dist/types/view/FlexibleCard/components/container/types.d.ts +20 -10
  167. package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +2 -2
  168. package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +12 -0
  169. package/dist/types/view/FlexibleCard/components/elements/badge/index.d.ts +2 -2
  170. package/dist/types/view/FlexibleCard/components/elements/badge/types.d.ts +10 -0
  171. package/dist/types/view/FlexibleCard/components/elements/date-time/index.d.ts +2 -2
  172. package/dist/types/view/FlexibleCard/components/elements/date-time/types.d.ts +6 -0
  173. package/dist/types/view/FlexibleCard/components/elements/icon/index.d.ts +2 -2
  174. package/dist/types/view/FlexibleCard/components/elements/icon/types.d.ts +16 -3
  175. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -2
  176. package/dist/types/view/FlexibleCard/components/elements/link/index.d.ts +3 -3
  177. package/dist/types/view/FlexibleCard/components/elements/link/types.d.ts +21 -1
  178. package/dist/types/view/FlexibleCard/components/elements/lozenge/index.d.ts +2 -2
  179. package/dist/types/view/FlexibleCard/components/elements/lozenge/types.d.ts +6 -0
  180. package/dist/types/view/FlexibleCard/components/elements/media/index.d.ts +2 -2
  181. package/dist/types/view/FlexibleCard/components/elements/media/types.d.ts +6 -0
  182. package/dist/types/view/FlexibleCard/components/elements/text/index.d.ts +2 -2
  183. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +10 -0
  184. package/dist/types/view/FlexibleCard/components/elements/types.d.ts +11 -0
  185. package/dist/types/view/FlexibleCard/components/types.d.ts +1 -0
  186. package/dist/types/view/FlexibleCard/types.d.ts +73 -3
  187. package/dist/types/view/FlexibleCard/utils.d.ts +1 -1
  188. package/dist/types/view/InlineCard/types.d.ts +1 -1
  189. package/dist/types/view/__mocks__/intersection-observer.d.ts +3 -0
  190. package/docs-helpers/flexible-ui-action-item.tsx +6 -0
  191. package/docs-helpers/flexible-ui-actions-prop.tsx +6 -0
  192. package/docs-helpers/flexible-ui-element-item.tsx +6 -0
  193. package/docs-helpers/flexible-ui-prop.tsx +6 -0
  194. package/docs-helpers/flexible-ui.tsx +28 -0
  195. package/package.json +3 -9
  196. package/dist/cjs/client/api.js +0 -119
  197. package/dist/cjs/client/errors.js +0 -55
  198. package/dist/cjs/client/types/index.js +0 -5
  199. package/dist/cjs/client/types/requests.js +0 -5
  200. package/dist/cjs/client/types/responses.js +0 -31
  201. package/dist/cjs/client/utils/environments.js +0 -47
  202. package/dist/cjs/providers/editor/index.js +0 -283
  203. package/dist/cjs/providers/editor/transformer.js +0 -84
  204. package/dist/cjs/providers/editor/types.js +0 -5
  205. package/dist/cjs/state/actions/helpers.js +0 -18
  206. package/dist/cjs/state/context/index.js +0 -34
  207. package/dist/cjs/state/context/provider.js +0 -74
  208. package/dist/cjs/state/context/types.js +0 -5
  209. package/dist/cjs/state/reducers/index.js +0 -89
  210. package/dist/cjs/state/store/types.js +0 -5
  211. package/dist/es2019/client/api.js +0 -38
  212. package/dist/es2019/client/errors.js +0 -19
  213. package/dist/es2019/client/types/index.js +0 -1
  214. package/dist/es2019/client/types/requests.js +0 -1
  215. package/dist/es2019/client/types/responses.js +0 -19
  216. package/dist/es2019/client/utils/environments.js +0 -33
  217. package/dist/es2019/providers/editor/index.js +0 -82
  218. package/dist/es2019/providers/editor/transformer.js +0 -53
  219. package/dist/es2019/providers/editor/types.js +0 -1
  220. package/dist/es2019/state/actions/helpers.js +0 -8
  221. package/dist/es2019/state/context/index.js +0 -14
  222. package/dist/es2019/state/context/provider.js +0 -51
  223. package/dist/es2019/state/context/types.js +0 -1
  224. package/dist/es2019/state/reducers/index.js +0 -74
  225. package/dist/es2019/state/store/types.js +0 -1
  226. package/dist/esm/client/api.js +0 -98
  227. package/dist/esm/client/errors.js +0 -40
  228. package/dist/esm/client/types/index.js +0 -1
  229. package/dist/esm/client/types/requests.js +0 -1
  230. package/dist/esm/client/types/responses.js +0 -19
  231. package/dist/esm/client/utils/environments.js +0 -33
  232. package/dist/esm/providers/editor/index.js +0 -257
  233. package/dist/esm/providers/editor/transformer.js +0 -73
  234. package/dist/esm/providers/editor/types.js +0 -1
  235. package/dist/esm/state/actions/helpers.js +0 -9
  236. package/dist/esm/state/context/index.js +0 -14
  237. package/dist/esm/state/context/provider.js +0 -50
  238. package/dist/esm/state/context/types.js +0 -1
  239. package/dist/esm/state/reducers/index.js +0 -69
  240. package/dist/esm/state/store/types.js +0 -1
  241. package/dist/types/client/api.d.ts +0 -5
  242. package/dist/types/client/errors.d.ts +0 -9
  243. package/dist/types/client/types/index.d.ts +0 -13
  244. package/dist/types/client/types/requests.d.ts +0 -9
  245. package/dist/types/client/types/responses.d.ts +0 -19
  246. package/dist/types/client/utils/environments.d.ts +0 -12
  247. package/dist/types/providers/editor/index.d.ts +0 -22
  248. package/dist/types/providers/editor/transformer.d.ts +0 -8
  249. package/dist/types/providers/editor/types.d.ts +0 -19
  250. package/dist/types/state/actions/helpers.d.ts +0 -2
  251. package/dist/types/state/context/index.d.ts +0 -8
  252. package/dist/types/state/context/provider.d.ts +0 -5
  253. package/dist/types/state/context/types.d.ts +0 -39
  254. package/dist/types/state/reducers/index.d.ts +0 -4
  255. package/dist/types/state/store/types.d.ts +0 -18
@@ -63,9 +63,9 @@ var getMaxLines = function getMaxLines(maxLines) {
63
63
  return maxLines;
64
64
  };
65
65
  /**
66
- * An element that represent.
67
- * @public
68
- * @param {LinkProps} LinkProps - The props necessary for the Icon element.
66
+ * A base element that represent an anchor.
67
+ * @internal
68
+ * @param {LinkProps} LinkProps - The props necessary for the Link element.
69
69
  * @see LinkIcon
70
70
  */
71
71
 
@@ -19,8 +19,8 @@ var _templateObject;
19
19
 
20
20
  var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n line-height: inherit;\n"])));
21
21
  /**
22
- * An element that displays a Lozenge.
23
- * @public
22
+ * A base element that displays a Lozenge.
23
+ * @internal
24
24
  * @param {LozengeProps} LozengeProps - The props necessary for the Lozenge element.
25
25
  * @see State
26
26
  */
@@ -29,8 +29,8 @@ var _templateObject;
29
29
  */
30
30
  var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
31
31
  /**
32
- * An element that displays a Media.
33
- * @public
32
+ * A base element that displays a Media.
33
+ * @internal
34
34
  * @param {MediaProps} MediaProps - The props necessary for the Media element.
35
35
  * @see Preview
36
36
  */
@@ -23,8 +23,8 @@ var getStyles = function getStyles(maxLines) {
23
23
  return (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), _token.tokens.text, (0, _utils.getTruncateStyles)(maxLines));
24
24
  };
25
25
  /**
26
- * An element that displays some Text.
27
- * @public
26
+ * A base element that displays some Text.
27
+ * @internal
28
28
  * @param {TextProps} TextProps - The props necessary for the Text element.
29
29
  * @see Title
30
30
  */
@@ -1,214 +1 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- // import setimmediate to temporary fix dataloader 2.0.0 bug
3
- // @see https://github.com/graphql/dataloader/issues/249
4
- import 'setimmediate';
5
- import DataLoader from 'dataloader';
6
- import retry from 'async-retry';
7
- import * as api from './api';
8
- import { APIError } from './errors';
9
- import { getResolverUrl } from './utils/environments';
10
- import pThrottle from 'p-throttle';
11
- import { isSuccessfulResponse, isErrorResponse } from './types/responses';
12
- const MAX_BATCH_SIZE = 50;
13
- const MIN_TIME_BETWEEN_BATCHES = 250;
14
- export default class CardClient {
15
- constructor(envKey) {
16
- _defineProperty(this, "batchResolve", async urls => {
17
- // De-duplicate requested URLs (see `this.createLoader` for more detail).
18
- const deDuplicatedUrls = [...new Set(urls)];
19
- let resolvedUrls = [];
20
-
21
- try {
22
- // Ask the backend to resolve the URLs for us.
23
- resolvedUrls = await api.request('post', `${this.resolverUrl}/resolve/batch`, deDuplicatedUrls.map(resourceUrl => ({
24
- resourceUrl
25
- })));
26
- } catch (error) {
27
- // we make sure we return a valid dataloader response by creating an error
28
- // response for each url
29
- resolvedUrls = urls.map(() => {
30
- const status = isErrorResponse(error) ? error.status : 500;
31
- const errorResponse = {
32
- status,
33
- error
34
- };
35
- return errorResponse;
36
- });
37
- } // Reduce into a map to make accessing faster and easier.
38
-
39
-
40
- const map = {}; // NOTE: the batch endpoint returns the URLs in the same order they were given.
41
-
42
- for (let i = 0; i < deDuplicatedUrls.length; ++i) {
43
- const url = deDuplicatedUrls[i];
44
- const data = resolvedUrls[i];
45
- map[url] = data;
46
- } // Reconvert list back into the original order in which it was given to us.
47
-
48
-
49
- return urls.map(originalUrl => map[originalUrl]);
50
- });
51
-
52
- this.resolverUrl = getResolverUrl(envKey);
53
- this.loadersByDomain = {};
54
- this.retryConfig = {
55
- retries: 2
56
- };
57
- this.resolvedCache = {};
58
- }
59
-
60
- createLoader() {
61
- const batchResolveThrottler = pThrottle({
62
- limit: 1,
63
- interval: MIN_TIME_BETWEEN_BATCHES
64
- });
65
- const throttledBatchResolve = batchResolveThrottler(this.batchResolve);
66
- return new DataLoader( // We place all calls to `batchResolve` in a limiter so we don't send off several simultaneous batch requests.
67
- // This is for two reasons:
68
- // 1: we want to avoid getting rate limited upstream (eg: forge and other APIs)
69
- // 2: we want to avoid sending out heaps of requests from the client at once
70
- urls => throttledBatchResolve(urls), {
71
- maxBatchSize: MAX_BATCH_SIZE,
72
- // NOTE: we turn off DataLoader's cache because it doesn't work for our use-case. Consider the following:
73
- // - a smartlink to a restricted item is resolved to "forbidden" with a "request access button"
74
- // - the user clicks "request access", and then following the auth prompts and gets access
75
- // - the frontend now re-renders the smartlink, but due to DataLoader's caching, the previous "forbidden" state is
76
- // because the smartlink's URL (which is the cache key) is exactly the same
77
- //
78
- // For this reason, we disable DataLoader's cache.
79
- // This means that URLs will not be de-duplicated by DataLoader, so we perform the de-duplication logic
80
- // ourselves in `this.batchResolve`.
81
- cache: false
82
- });
83
- }
84
-
85
- getLoader(hostname) {
86
- if (!this.loadersByDomain[hostname]) {
87
- this.loadersByDomain[hostname] = this.createLoader();
88
- }
89
-
90
- return this.loadersByDomain[hostname];
91
- }
92
-
93
- async prefetchData(url) {
94
- // 1. Queue the URL as part of a dataloader batch.
95
- const hostname = new URL(url).hostname;
96
- const loader = this.getLoader(hostname);
97
- const response = await loader.load(url);
98
-
99
- if (isSuccessfulResponse(response)) {
100
- // 2. If the URL resolves, send it back.
101
- return response.body;
102
- } else {
103
- try {
104
- // 3. If the URL does not resolve, retry it with exponential backoff.
105
- // This is done so that we avoid the scenario where users are unable to
106
- // see a resolved Smart Link, when their expectation is to be able to.
107
- const retriedResponse = await retry(async () => {
108
- // We check if the link has resolved in the cache and stop trying if so.
109
- // We do this by triggering an error that the link has already been resolved.
110
- // This cascades <retryCount> times after which it is handled like a normal
111
- // 'error', returning `undefined`.
112
- if (!this.resolvedCache[url]) {
113
- const response = await loader.load(url);
114
-
115
- if (isSuccessfulResponse(response)) {
116
- return response;
117
- } else {
118
- throw new Error('Retry for URL failed');
119
- }
120
- } else {
121
- // Short-circuit each of the retries, as described above.
122
- throw new Error('Retry unneeded - link has been resolved.');
123
- }
124
- }, this.retryConfig); // Trigger callback after successful backoff.
125
-
126
- return retriedResponse.body;
127
- } catch (err) {
128
- // Do nothing in the case of an error - prefetching
129
- // failures should be silent. Once a link is visible,
130
- // it will be re-fetched anyhow, in which case a
131
- // user-facing error is required.
132
- return undefined;
133
- }
134
- }
135
- }
136
-
137
- async fetchData(url) {
138
- const hostname = new URL(url).hostname;
139
- const loader = this.getLoader(hostname);
140
- const response = await loader.load(url);
141
-
142
- if (!isSuccessfulResponse(response)) {
143
- // Catch non-200 server responses to fallback or return useful information.
144
- if (response.error) {
145
- const errorType = response.error.type;
146
- const errorMessage = response.error.message; // this means there was a network error and we fallback to blue link
147
- // without impacting SLO's
148
-
149
- if (response.error instanceof api.NetworkError) {
150
- throw new APIError('fallback', hostname, errorMessage, errorType);
151
- }
152
-
153
- switch (errorType) {
154
- // BadRequestError - indicative of an API error, render
155
- // a blue link to mitigate customer impact.
156
- case 'ResolveBadRequestError':
157
- throw new APIError('fallback', hostname, errorMessage, errorType);
158
- // AuthError - if the user logs in, we may be able
159
- // to recover. Render an unauthorized card.
160
-
161
- case 'ResolveAuthError':
162
- throw new APIError('auth', hostname, errorMessage, errorType);
163
- // UnsupportedError - we do not know how to render this URL.
164
- // Bail out and ask the Editor to render as a blue link.
165
-
166
- case 'ResolveUnsupportedError':
167
- // URL isn't supported
168
- throw new APIError('fatal', hostname, errorMessage, errorType);
169
- // ResolveFailedError - link resolver may have failed.
170
- // We could recover on re-resolve; render with fallback state.
171
-
172
- case 'ResolveFailedError':
173
- // Timeouts
174
- throw new APIError('error', hostname, errorMessage, errorType);
175
- // TimeoutError - link resolver may be taking a long time.
176
- // We could recover on re-resolve; render with fallback state.
177
-
178
- case 'ResolveTimeoutError':
179
- // Timeouts
180
- throw new APIError('error', hostname, errorMessage, errorType);
181
- // InternalServerError - API call failed.
182
- // We may recover later; render with fallback state.
183
-
184
- case 'InternalServerError':
185
- // ORS failures
186
- throw new APIError('error', hostname, errorMessage, errorType);
187
- }
188
- } // Catch all: we don't know this error, bail out.
189
-
190
-
191
- throw new APIError('fatal', hostname, response.toString(), 'UnexpectedError');
192
- } else {
193
- // Set a flag in the `resolvedCache` for this URL. The intent of this is
194
- // to ensure that the exponential backoff method in `prefetchData` does
195
- // not continue to retry fetching for this URL, especially if it was previously
196
- // in a failed state. Note: this scenario only occurs on initial page load, if the
197
- // user scrolls through the page very fast. Once the URL is visible, prefetching
198
- // no longer takes place.
199
- this.resolvedCache[url] = true; // Return the JSON-LD response back up!
200
-
201
- return response.body;
202
- }
203
- }
204
-
205
- async postData(data) {
206
- const request = {
207
- key: data.key,
208
- action: data.action,
209
- context: data.context
210
- };
211
- return await api.request('post', `${this.resolverUrl}/invoke`, request);
212
- }
213
-
214
- }
1
+ export { CardClient as default } from '@atlaskit/link-provider';
@@ -109,9 +109,6 @@ export let ElementName;
109
109
  ElementName["AuthorGroup"] = "AuthorGroup";
110
110
  ElementName["CollaboratorGroup"] = "CollaboratorGroup";
111
111
  ElementName["CommentCount"] = "CommentCount";
112
- ElementName["ViewCount"] = "ViewCount";
113
- ElementName["ReactCount"] = "ReactCount";
114
- ElementName["VoteCount"] = "VoteCount";
115
112
  ElementName["CreatedBy"] = "CreatedBy";
116
113
  ElementName["CreatedOn"] = "CreatedOn";
117
114
  ElementName["LinkIcon"] = "LinkIcon";
@@ -120,11 +117,14 @@ export let ElementName;
120
117
  ElementName["Preview"] = "Preview";
121
118
  ElementName["Priority"] = "Priority";
122
119
  ElementName["ProgrammingLanguage"] = "ProgrammingLanguage";
120
+ ElementName["Provider"] = "Provider";
121
+ ElementName["ReactCount"] = "ReactCount";
123
122
  ElementName["Snippet"] = "Snippet";
124
123
  ElementName["State"] = "State";
125
124
  ElementName["SubscriberCount"] = "SubscriberCount";
126
125
  ElementName["Title"] = "Title";
127
- ElementName["Provider"] = "Provider";
126
+ ElementName["ViewCount"] = "ViewCount";
127
+ ElementName["VoteCount"] = "VoteCount";
128
128
  })(ElementName || (ElementName = {}));
129
129
 
130
130
  export let ActionName;
@@ -1,6 +1,6 @@
1
- import { extractPreview } from '@atlaskit/linking-common';
2
1
  import { extractLink, extractTitle } from '../common/primitives';
3
2
  import { extractProvider } from '../common/context';
3
+ import { extractPreview } from '@atlaskit/linking-common';
4
4
  import { extractIsTrusted } from '../common/meta/extractIsTrusted';
5
5
 
6
6
  const extractEmbedPreview = (jsonLd, platform) => {
@@ -1,9 +1,9 @@
1
1
  export { SmartCardProvider as Provider, SmartCardContext } from './state';
2
- export { EditorCardProvider, editorCardProvider } from './providers/editor';
3
- export { default as Client } from './client';
4
- export { APIError } from './client/errors';
2
+ export { EditorCardProvider, editorCardProvider } from '@atlaskit/link-provider';
3
+ export { APIError } from '@atlaskit/linking-common';
4
+ export { CardClient as Client } from '@atlaskit/link-provider';
5
5
  export { Card } from './view/Card';
6
- export { default as Context } from './state/context';
6
+ export { SmartCardContext as Context } from '@atlaskit/link-provider';
7
7
  export { EmbedResizeMessageListener } from './view/EmbedCard/EmbedResizeMessageListener';
8
8
  export { embedHeaderHeight } from './view/EmbedCard/components/styled';
9
9
  export { SmartLinkEvents } from './utils/analytics/analytics';
@@ -1,9 +1,3 @@
1
- export const ACTION_PENDING = 'pending';
2
- export const ACTION_RESOLVING = 'resolving';
3
- export const ACTION_RESOLVED = 'resolved';
4
- export const ACTION_ERROR = 'errored';
5
- export const ACTION_ERROR_FALLBACK = 'fallback';
6
- export const ACTION_PRELOAD = 'preload';
7
1
  export const ANALYTICS_RESOLVING = 'resolving';
8
2
  export const ANALYTICS_ERROR = 'errored';
9
3
  export const ANALYTICS_FALLBACK = 'fallback';
@@ -1,11 +1,11 @@
1
1
  import { useMemo, useCallback } from 'react';
2
2
  import { auth } from '@atlaskit/outbound-auth-flow-client';
3
- import { cardAction } from './helpers';
3
+ import { APIError } from '@atlaskit/linking-common';
4
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
5
+ import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ACTION_ERROR_FALLBACK, cardAction } from '@atlaskit/linking-common';
4
6
  import { getDefinitionId, getByDefinitionId, getServices, getStatus, getExtensionKey } from '../helpers';
5
- import { ACTION_PENDING, ACTION_RESOLVED, ACTION_ERROR, ERROR_MESSAGE_OAUTH, ERROR_MESSAGE_FATAL, ACTION_ERROR_FALLBACK } from './constants';
6
- import { useSmartLinkContext } from '../context';
7
+ import { ERROR_MESSAGE_OAUTH, ERROR_MESSAGE_FATAL } from './constants';
7
8
  import * as measure from '../../utils/performance';
8
- import { APIError } from '../../client/errors';
9
9
  import { getUnauthorizedJsonLd } from '../../utils/jsonld';
10
10
  import { addMetadataToExperience } from '../analytics';
11
11
  export const useSmartCardActions = (id, url, analytics) => {
@@ -1,5 +1,5 @@
1
- import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
2
1
  import { useMemo } from 'react';
2
+ import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, uiHoverCardViewedEvent, uiHoverCardDismissedEvent, uiHoverCardOpenLinkClickedEvent, resolvedEvent, unresolvedEvent, invokeSucceededEvent, invokeFailedEvent, connectSucceededEvent, connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
3
3
  import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
4
4
  export const useSmartLinkAnalytics = dispatchAnalytics => {
5
5
  const ui = useMemo(() => ({
@@ -1,4 +1,4 @@
1
- import { useSmartLinkContext } from '../context';
1
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
2
2
  export const useSmartLinkConfig = () => {
3
3
  const context = useSmartLinkContext();
4
4
 
@@ -8,11 +8,6 @@ export const getByDefinitionId = (definitionId, store) => {
8
8
  return details && details.meta.definitionId === definitionId;
9
9
  });
10
10
  };
11
- export const getUrl = (store, url) => {
12
- return store.getState()[url] || {
13
- status: 'pending'
14
- };
15
- };
16
11
  export const getClickUrl = (url, jsonLd) => {
17
12
  if (jsonLd && jsonLd.data) {
18
13
  const visitUrl = extractVisitUrl(jsonLd.data);
@@ -1,5 +1,5 @@
1
1
  import { useCallback } from 'react';
2
- import { useSmartLinkContext } from '../context';
2
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
3
3
  export function usePrefetch(url) {
4
4
  const {
5
5
  store,
@@ -1,2 +1,2 @@
1
- export { SmartCardContext, SmartCardProvider, useSmartLinkContext } from './context';
1
+ export { SmartCardContext, SmartCardProvider, useSmartLinkContext } from '@atlaskit/link-provider';
2
2
  export { useSmartLink, usePrefetch } from './hooks';
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import { useSmartLinkContext } from '../context';
2
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
3
3
  export const useSmartLinkRenderers = () => {
4
4
  const context = useSmartLinkContext();
5
5
  let renderers = context === null || context === void 0 ? void 0 : context.renderers;
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { useSmartLinkContext } from '../context';
3
- import { getUrl } from '../helpers';
2
+ import { useSmartLinkContext } from '@atlaskit/link-provider';
3
+ import { getUrl } from '@atlaskit/linking-common';
4
4
  export function useSmartCardState(url) {
5
5
  const {
6
6
  store
@@ -1,4 +1,4 @@
1
- import CardClient from '../client';
1
+ import { CardClient } from '@atlaskit/link-provider';
2
2
  export const mockContext = {
3
3
  '@vocab': 'https://www.w3.org/ns/activitystreams#',
4
4
  atlassian: 'https://schema.atlassian.com/ns/vocabulary#',
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
- import CardClient from '../client';
3
+ import { CardClient } from '@atlaskit/link-provider';
4
4
  import { SmartCardProvider } from '../state';
5
5
 
6
6
  const Hook = props => {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.22",
3
+ "version": "19.0.2",
4
4
  "sideEffects": false
5
5
  }
@@ -2,7 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useState } from 'react';
3
3
  import { usePrefetch } from '../../../state';
4
4
  import { CardWithUrlContent } from '../component';
5
- import { LoadingCardLink } from './LazyFallback'; // This property enables the intersection observer to be run once the
5
+ import { LoadingCardLink } from './LazyFallback';
6
+ import { startUfoExperience } from '../../../state/analytics/ufoExperiences'; // This property enables the intersection observer to be run once the
6
7
  // HTML element being observed is within `X` px of the target container it is
7
8
  // being compared to. Since the default container is the `document`, we set this
8
9
  // up to check once a Smart Link is within `X` px from the bottom of the viewport.
@@ -13,7 +14,8 @@ export function LazyIntersectionObserverCard(props) {
13
14
  const {
14
15
  showActions,
15
16
  appearance,
16
- url
17
+ url,
18
+ id
17
19
  } = props;
18
20
  const prefetch = usePrefetch(url);
19
21
  const Component = appearance === 'inline' ? 'span' : 'div';
@@ -22,12 +24,13 @@ export function LazyIntersectionObserverCard(props) {
22
24
  const isVisible = entries.some(entry => entry.isIntersecting);
23
25
 
24
26
  if (isVisible) {
27
+ startUfoExperience('smart-link-rendered', id);
25
28
  setIsIntersecting(true);
26
29
  observer.disconnect();
27
30
  } else {
28
31
  prefetch();
29
32
  }
30
- }, [prefetch]);
33
+ }, [prefetch, id]);
31
34
  const onRef = useCallback(element => {
32
35
  if (!element) {
33
36
  return;
@@ -1,15 +1,21 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
2
+ import React, { useState } from 'react';
3
3
  import LazilyRender from 'react-lazily-render';
4
4
  import { CardWithUrlContent } from '../component';
5
5
  import { LoadingCardLink } from './LazyFallback';
6
+ import { startUfoExperience } from '../../../state/analytics/ufoExperiences';
6
7
  export function LazyLazilyRenderCard(props) {
7
8
  const {
8
9
  appearance,
9
10
  container,
10
- showActions
11
+ showActions,
12
+ id
11
13
  } = props;
12
14
  const offset = Math.ceil(window.innerHeight / 4);
15
+ useState(() => {
16
+ // Start of experience when intersectionObserver is not supported.
17
+ startUfoExperience('smart-link-rendered', id);
18
+ });
13
19
  return /*#__PURE__*/React.createElement(LazilyRender, {
14
20
  offset: offset,
15
21
  component: appearance === 'inline' ? 'span' : 'div',
@@ -9,12 +9,7 @@ const LazyCardWithUrlContent = /*#__PURE__*/lazy(() => import(
9
9
  /* webpackChunkName: "@atlaskit-internal_smartcard-urlcardcontent" */
10
10
  './component-lazy/index'));
11
11
  export function CardWithURLRenderer(props) {
12
- const [id] = useState(() => uuid()); // Equivalent to ComponentWillMount
13
-
14
- useState(() => {
15
- // We want to start timing of render event only once and right at the start
16
- startUfoExperience('smart-link-rendered', id);
17
- });
12
+ const [id] = useState(() => uuid());
18
13
  useEffect(() => {
19
14
  // ComponentWillUnmount
20
15
  return () => {
@@ -68,7 +63,10 @@ export function CardWithURLRenderer(props) {
68
63
  else {
69
64
  const errorInfo = {
70
65
  componentStack
71
- };
66
+ }; // Start and fail the smart-link-rendered experience. If it has already
67
+ // been started nothing happens.
68
+
69
+ startUfoExperience('smart-link-rendered', id);
72
70
  failUfoExperience('smart-link-rendered', id);
73
71
  failUfoExperience('smart-link-authenticated', id);
74
72
  dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
@@ -84,8 +84,8 @@ export const sizeToSpacing = {
84
84
  [SmartLinkSize.XLarge]: 'default'
85
85
  };
86
86
  /**
87
- * An action that can be triggered with an on click.
88
- * @public
87
+ * A base action that can be triggered with an on click.
88
+ * @internal
89
89
  * @param {ActionProps} ActionProps - The props necessary for the Action.
90
90
  * @see DeleteAction
91
91
  * @see EditAction
@@ -29,6 +29,7 @@ const styles = css`
29
29
  /**
30
30
  * Creates a group of Action components. Accepts an array of Actions, in addition to some styling
31
31
  * preferences.
32
+ * @internal
32
33
  * @param {ActionGroupProps} ActionGroupProps
33
34
  * @see Action
34
35
  */
@@ -13,8 +13,9 @@ const getBlockStyles = (direction, size) => css`
13
13
  }
14
14
  `;
15
15
  /**
16
- * A block represents a collection of elements and actions that are arranged in a row.
17
- * All elements and actions should be contained within a Block.
16
+ * A block represents a collection of elements and actions that are arranged
17
+ * in a row. All elements and actions should be contained within a Block.
18
+ * @internal
18
19
  * @param {ActionGroupProps} ActionGroupProps
19
20
  * @see Action
20
21
  */
@@ -30,6 +30,7 @@ export const getElementGroupStyles = (direction, size, align, width) => css`
30
30
  /**
31
31
  * Creates a group of Action components. Accepts an array of Actions, in addition to some styling
32
32
  * preferences.
33
+ * @internal
33
34
  * @param {ActionGroupProps} ActionGroupProps
34
35
  * @see Action
35
36
  */
@@ -8,6 +8,7 @@ import ActionGroup from '../action-group';
8
8
  /**
9
9
  * Represents a FooterBlock, designed to contain elements and actions that should appear
10
10
  * at the bottom of a link card.
11
+ * @public
11
12
  * @param {FooterBlockProps} FooterBlockProps
12
13
  * @see Block
13
14
  */
@@ -63,6 +63,7 @@ const getMaxLines = maxLines => {
63
63
  /**
64
64
  * Represents a MetadataBlock, designed to contain groups of metadata in the form of elements.
65
65
  * Accepts an array of elements to be shown either primary (left hand side) or secondary (right hand side).
66
+ * @public
66
67
  * @param {MetadataBlockProps} MetadataBlockProps
67
68
  * @see Block
68
69
  */
@@ -5,6 +5,7 @@ import Block from '../block';
5
5
  import { Preview } from '../../elements';
6
6
  /**
7
7
  * Represents a PreviewBlock, which typically contains media or other large format content.
8
+ * @public
8
9
  * @param {PreviewBlock} PreviewBlock
9
10
  * @see Block
10
11
  */
@@ -9,6 +9,7 @@ const MAXIMUM_MAX_LINES = 3;
9
9
  const MINIMUM_MAX_LINES = 1;
10
10
  /**
11
11
  * Represents a SnippetBlock, which is used to display longer form text content, like descriptions.
12
+ * @public
12
13
  * @param {SnippetBlock} SnippetBlock
13
14
  * @see Block
14
15
  */
@@ -42,10 +42,11 @@ const getTitleBlockViewComponent = status => {
42
42
  }
43
43
  };
44
44
  /**
45
- * Represents a TitleBlock, which is the foundation of all Flexible Smart Links.
45
+ * Represents a TitleBlock, which is the foundation of Flexible UI.
46
46
  * This contains an icon, the link, and any associated metadata and actions in one block.
47
47
  * The TitleBlock will also render differently given the state of the smart link.
48
48
  * This can be found in the corresponding Resolving, Resolved and Errored views.
49
+ * @public
49
50
  * @param {TitleBlockProps} TitleBlockProps
50
51
  * @see Block
51
52
  * @see TitleBlockResolvingView