@atlaskit/smart-card 22.1.2 → 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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/state/hooks/usePrefetch.js +26 -14
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/loader.js +10 -10
- package/dist/es2019/state/hooks/usePrefetch.js +9 -4
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/loader.js +10 -10
- package/dist/esm/state/hooks/usePrefetch.js +26 -14
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/loader.js +10 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 22.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`9a0c1c39d27`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9a0c1c39d27) - Rethrow errors from child component of smart-card so all non API errors will be handed to parent of smart-card
|
|
8
|
+
|
|
3
9
|
## 22.1.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -23,15 +23,27 @@ function usePrefetch(url) {
|
|
|
23
23
|
prefetchStore = _useSmartLinkContext.prefetchStore,
|
|
24
24
|
connections = _useSmartLinkContext.connections;
|
|
25
25
|
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
var _ref = store || {},
|
|
27
|
+
dispatch = _ref.dispatch,
|
|
28
|
+
getState = _ref.getState;
|
|
29
|
+
|
|
30
|
+
var _ref2 = connections || {},
|
|
31
|
+
client = _ref2.client;
|
|
32
|
+
|
|
29
33
|
return (0, _react.useCallback)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
30
34
|
var isPrefetching, isFetching, needsPrefetch, response;
|
|
31
35
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
32
36
|
while (1) {
|
|
33
37
|
switch (_context.prev = _context.next) {
|
|
34
38
|
case 0:
|
|
39
|
+
if (!(!store || !prefetchStore || !connections)) {
|
|
40
|
+
_context.next = 2;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return _context.abrupt("return");
|
|
45
|
+
|
|
46
|
+
case 2:
|
|
35
47
|
// If the link is already being prefetched, the prefetch store
|
|
36
48
|
// should have a flag set against the URL. The prefetch store is purposefully
|
|
37
49
|
// separate from the UI in order to ensure no rendering takes place;
|
|
@@ -45,7 +57,7 @@ function usePrefetch(url) {
|
|
|
45
57
|
needsPrefetch = !isPrefetching && !isFetching;
|
|
46
58
|
|
|
47
59
|
if (!needsPrefetch) {
|
|
48
|
-
_context.next =
|
|
60
|
+
_context.next = 16;
|
|
49
61
|
break;
|
|
50
62
|
}
|
|
51
63
|
|
|
@@ -57,11 +69,11 @@ function usePrefetch(url) {
|
|
|
57
69
|
// requests by domain (as usual) to ensure we minimize the amount of connections
|
|
58
70
|
// we create between browser -> ORS when making network requests.
|
|
59
71
|
|
|
60
|
-
_context.prev =
|
|
61
|
-
_context.next =
|
|
72
|
+
_context.prev = 7;
|
|
73
|
+
_context.next = 10;
|
|
62
74
|
return client.prefetchData(url);
|
|
63
75
|
|
|
64
|
-
case
|
|
76
|
+
case 10:
|
|
65
77
|
response = _context.sent;
|
|
66
78
|
|
|
67
79
|
// Once the data comes back, we put the link in the `resolved` status. This ensures
|
|
@@ -80,18 +92,18 @@ function usePrefetch(url) {
|
|
|
80
92
|
}, undefined, undefined, 'resolved'));
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
_context.next =
|
|
95
|
+
_context.next = 16;
|
|
84
96
|
break;
|
|
85
97
|
|
|
86
|
-
case 12:
|
|
87
|
-
_context.prev = 12;
|
|
88
|
-
_context.t0 = _context["catch"](5);
|
|
89
|
-
|
|
90
98
|
case 14:
|
|
99
|
+
_context.prev = 14;
|
|
100
|
+
_context.t0 = _context["catch"](7);
|
|
101
|
+
|
|
102
|
+
case 16:
|
|
91
103
|
case "end":
|
|
92
104
|
return _context.stop();
|
|
93
105
|
}
|
|
94
106
|
}
|
|
95
|
-
}, _callee, null, [[
|
|
96
|
-
})), [prefetchStore, url, getState, client, dispatch]);
|
|
107
|
+
}, _callee, null, [[7, 14]]);
|
|
108
|
+
})), [store, prefetchStore, connections, url, getState, client, dispatch]);
|
|
97
109
|
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -83,16 +83,12 @@ function CardWithURLRenderer(props) {
|
|
|
83
83
|
}, [appearance, createAnalyticsEvent]);
|
|
84
84
|
var analytics = (0, _analytics2.useSmartLinkAnalytics)(url !== null && url !== void 0 ? url : '', dispatchAnalytics, id);
|
|
85
85
|
var logError = (0, _react.useCallback)(function (error, info) {
|
|
86
|
-
var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service.
|
|
87
|
-
// In these cases, control is handed back to the Editor. We do not
|
|
86
|
+
var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service. We do not
|
|
88
87
|
// fire an event for these, as they do not cover failed UI render events.
|
|
88
|
+
// The rest of the errors caught here are unexpected, and correlate
|
|
89
|
+
// to the reliability of the smart-card front-end components.
|
|
89
90
|
|
|
90
|
-
if (error.name
|
|
91
|
-
throw error;
|
|
92
|
-
} // NB: the rest of the errors caught here are unexpected, and correlate
|
|
93
|
-
// to the reliability of the smart-card front-end components. We instrument
|
|
94
|
-
// these in order to measure our front-end reliability.
|
|
95
|
-
else {
|
|
91
|
+
if (error.name !== 'APIError') {
|
|
96
92
|
var errorInfo = {
|
|
97
93
|
componentStack: componentStack
|
|
98
94
|
};
|
|
@@ -102,7 +98,11 @@ function CardWithURLRenderer(props) {
|
|
|
102
98
|
error: error,
|
|
103
99
|
errorInfo: errorInfo
|
|
104
100
|
});
|
|
105
|
-
}
|
|
101
|
+
} // Rethrow to hand control to the consumer of Smart-card.
|
|
102
|
+
// In the case of editor this allows the Smart Link to fallback to a blue link.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
throw error;
|
|
106
106
|
}, [analytics.ui, appearance, id]);
|
|
107
107
|
|
|
108
108
|
if (!url) {
|
|
@@ -140,5 +140,5 @@ function CardWithURLRenderer(props) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
var ErrorFallback = function ErrorFallback() {
|
|
143
|
-
return
|
|
143
|
+
return null;
|
|
144
144
|
};
|
|
@@ -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
|
|
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
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -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
|
|
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
|
|
115
|
+
return null;
|
|
116
116
|
};
|
|
@@ -9,15 +9,27 @@ export function usePrefetch(url) {
|
|
|
9
9
|
prefetchStore = _useSmartLinkContext.prefetchStore,
|
|
10
10
|
connections = _useSmartLinkContext.connections;
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
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 =
|
|
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 =
|
|
47
|
-
_context.next =
|
|
58
|
+
_context.prev = 7;
|
|
59
|
+
_context.next = 10;
|
|
48
60
|
return client.prefetchData(url);
|
|
49
61
|
|
|
50
|
-
case
|
|
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 =
|
|
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, [[
|
|
82
|
-
})), [prefetchStore, url, getState, client, dispatch]);
|
|
93
|
+
}, _callee, null, [[7, 14]]);
|
|
94
|
+
})), [store, prefetchStore, connections, url, getState, client, dispatch]);
|
|
83
95
|
}
|
package/dist/esm/version.json
CHANGED
|
@@ -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
|
|
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
|
|
119
|
+
return null;
|
|
120
120
|
};
|