@atlaskit/smart-card 18.0.22 → 19.0.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 +36 -0
- package/dist/cjs/client/index.js +6 -379
- package/dist/cjs/extractors/embed/index.js +2 -2
- package/dist/cjs/index.js +7 -13
- package/dist/cjs/state/actions/constants.js +1 -13
- package/dist/cjs/state/actions/index.js +20 -22
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +2 -2
- package/dist/cjs/state/config/index.js +2 -2
- package/dist/cjs/state/helpers.js +1 -9
- package/dist/cjs/state/hooks/usePrefetch.js +2 -2
- package/dist/cjs/state/index.js +4 -4
- package/dist/cjs/state/renderers/index.js +2 -2
- package/dist/cjs/state/store/index.js +5 -5
- package/dist/cjs/utils/mocks.js +2 -2
- package/dist/cjs/utils/test-utils.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/index.js +1 -214
- package/dist/es2019/extractors/embed/index.js +1 -1
- package/dist/es2019/index.js +4 -4
- package/dist/es2019/state/actions/constants.js +0 -6
- package/dist/es2019/state/actions/index.js +4 -4
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +1 -1
- package/dist/es2019/state/config/index.js +1 -1
- package/dist/es2019/state/helpers.js +0 -5
- package/dist/es2019/state/hooks/usePrefetch.js +1 -1
- package/dist/es2019/state/index.js +1 -1
- package/dist/es2019/state/renderers/index.js +1 -1
- package/dist/es2019/state/store/index.js +2 -2
- package/dist/es2019/utils/mocks.js +1 -1
- package/dist/es2019/utils/test-utils.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/index.js +1 -360
- package/dist/esm/extractors/embed/index.js +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/state/actions/constants.js +0 -6
- package/dist/esm/state/actions/index.js +4 -4
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +1 -1
- package/dist/esm/state/config/index.js +1 -1
- package/dist/esm/state/helpers.js +0 -5
- package/dist/esm/state/hooks/usePrefetch.js +1 -1
- package/dist/esm/state/index.js +1 -1
- package/dist/esm/state/renderers/index.js +1 -1
- package/dist/esm/state/store/index.js +2 -2
- package/dist/esm/utils/mocks.js +1 -1
- package/dist/esm/utils/test-utils.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/__tests_external__/page-objects/BaseCard.d.ts +1 -2
- package/dist/types/client/index.d.ts +1 -18
- package/dist/types/extractors/block/index.d.ts +1 -1
- package/dist/types/extractors/common/title-prefix/extractTitlePrefix.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/extract-icon-renderer.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/index.d.ts +1 -1
- package/dist/types/extractors/flexible/index.d.ts +1 -1
- package/dist/types/extractors/inline/index.d.ts +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/model/invoke-opts.d.ts +1 -14
- package/dist/types/state/actions/constants.d.ts +0 -6
- package/dist/types/state/actions/types.d.ts +2 -13
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +1 -2
- package/dist/types/state/config/index.d.ts +1 -1
- package/dist/types/state/helpers.d.ts +1 -3
- package/dist/types/state/hooks/useSmartLink.d.ts +6 -6
- package/dist/types/state/index.d.ts +3 -3
- package/dist/types/state/reducers/types.d.ts +1 -1
- package/dist/types/state/renderers/index.d.ts +1 -1
- package/dist/types/state/store/index.d.ts +2 -2
- package/dist/types/state/types.d.ts +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/utils/analytics/analytics.d.ts +1 -1
- package/dist/types/utils/analytics/index.d.ts +1 -2
- package/dist/types/utils/performance.d.ts +1 -1
- package/dist/types/view/BlockCard/types.d.ts +1 -1
- package/dist/types/view/Card/types.d.ts +2 -3
- package/dist/types/view/FlexibleCard/types.d.ts +2 -2
- package/dist/types/view/FlexibleCard/utils.d.ts +1 -1
- package/dist/types/view/InlineCard/types.d.ts +1 -1
- package/package.json +3 -9
- package/dist/cjs/client/api.js +0 -119
- package/dist/cjs/client/errors.js +0 -55
- package/dist/cjs/client/types/index.js +0 -5
- package/dist/cjs/client/types/requests.js +0 -5
- package/dist/cjs/client/types/responses.js +0 -31
- package/dist/cjs/client/utils/environments.js +0 -47
- package/dist/cjs/providers/editor/index.js +0 -283
- package/dist/cjs/providers/editor/transformer.js +0 -84
- package/dist/cjs/providers/editor/types.js +0 -5
- package/dist/cjs/state/actions/helpers.js +0 -18
- package/dist/cjs/state/context/index.js +0 -34
- package/dist/cjs/state/context/provider.js +0 -74
- package/dist/cjs/state/context/types.js +0 -5
- package/dist/cjs/state/reducers/index.js +0 -89
- package/dist/cjs/state/store/types.js +0 -5
- package/dist/es2019/client/api.js +0 -38
- package/dist/es2019/client/errors.js +0 -19
- package/dist/es2019/client/types/index.js +0 -1
- package/dist/es2019/client/types/requests.js +0 -1
- package/dist/es2019/client/types/responses.js +0 -19
- package/dist/es2019/client/utils/environments.js +0 -33
- package/dist/es2019/providers/editor/index.js +0 -82
- package/dist/es2019/providers/editor/transformer.js +0 -53
- package/dist/es2019/providers/editor/types.js +0 -1
- package/dist/es2019/state/actions/helpers.js +0 -8
- package/dist/es2019/state/context/index.js +0 -14
- package/dist/es2019/state/context/provider.js +0 -51
- package/dist/es2019/state/context/types.js +0 -1
- package/dist/es2019/state/reducers/index.js +0 -74
- package/dist/es2019/state/store/types.js +0 -1
- package/dist/esm/client/api.js +0 -98
- package/dist/esm/client/errors.js +0 -40
- package/dist/esm/client/types/index.js +0 -1
- package/dist/esm/client/types/requests.js +0 -1
- package/dist/esm/client/types/responses.js +0 -19
- package/dist/esm/client/utils/environments.js +0 -33
- package/dist/esm/providers/editor/index.js +0 -257
- package/dist/esm/providers/editor/transformer.js +0 -73
- package/dist/esm/providers/editor/types.js +0 -1
- package/dist/esm/state/actions/helpers.js +0 -9
- package/dist/esm/state/context/index.js +0 -14
- package/dist/esm/state/context/provider.js +0 -50
- package/dist/esm/state/context/types.js +0 -1
- package/dist/esm/state/reducers/index.js +0 -69
- package/dist/esm/state/store/types.js +0 -1
- package/dist/types/client/api.d.ts +0 -5
- package/dist/types/client/errors.d.ts +0 -9
- package/dist/types/client/types/index.d.ts +0 -13
- package/dist/types/client/types/requests.d.ts +0 -9
- package/dist/types/client/types/responses.d.ts +0 -19
- package/dist/types/client/utils/environments.d.ts +0 -12
- package/dist/types/providers/editor/index.d.ts +0 -22
- package/dist/types/providers/editor/transformer.d.ts +0 -8
- package/dist/types/providers/editor/types.d.ts +0 -19
- package/dist/types/state/actions/helpers.d.ts +0 -2
- package/dist/types/state/context/index.d.ts +0 -8
- package/dist/types/state/context/provider.d.ts +0 -5
- package/dist/types/state/context/types.d.ts +0 -39
- package/dist/types/state/reducers/index.d.ts +0 -4
- package/dist/types/state/store/types.d.ts +0 -18
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
// import setimmediate to temporary fix dataloader 2.0.0 bug
|
|
6
|
-
// @see https://github.com/graphql/dataloader/issues/249
|
|
7
|
-
import 'setimmediate';
|
|
8
|
-
import DataLoader from 'dataloader';
|
|
9
|
-
import { Transformer } from './transformer';
|
|
10
|
-
import { getResolverUrl, getBaseUrl } from '../../client/utils/environments';
|
|
11
|
-
import * as api from '../../client/api';
|
|
12
|
-
var BATCH_WAIT_TIME = 50;
|
|
13
|
-
export var EditorCardProvider = /*#__PURE__*/function () {
|
|
14
|
-
function EditorCardProvider(envKey) {
|
|
15
|
-
var _this = this;
|
|
16
|
-
|
|
17
|
-
_classCallCheck(this, EditorCardProvider);
|
|
18
|
-
|
|
19
|
-
this.baseUrl = getBaseUrl(envKey);
|
|
20
|
-
this.resolverUrl = getResolverUrl(envKey);
|
|
21
|
-
this.transformer = new Transformer();
|
|
22
|
-
this.requestHeaders = {
|
|
23
|
-
Origin: this.baseUrl
|
|
24
|
-
};
|
|
25
|
-
this.patternLoader = new DataLoader(function (keys) {
|
|
26
|
-
return _this.batchPatterns(keys);
|
|
27
|
-
}, {
|
|
28
|
-
batchScheduleFn: function batchScheduleFn(callback) {
|
|
29
|
-
return setTimeout(callback, BATCH_WAIT_TIME);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_createClass(EditorCardProvider, [{
|
|
35
|
-
key: "batchPatterns",
|
|
36
|
-
value: function () {
|
|
37
|
-
var _batchPatterns = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keys) {
|
|
38
|
-
var patterns;
|
|
39
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
40
|
-
while (1) {
|
|
41
|
-
switch (_context.prev = _context.next) {
|
|
42
|
-
case 0:
|
|
43
|
-
_context.next = 2;
|
|
44
|
-
return this.fetchPatterns();
|
|
45
|
-
|
|
46
|
-
case 2:
|
|
47
|
-
patterns = _context.sent;
|
|
48
|
-
return _context.abrupt("return", keys.map(function () {
|
|
49
|
-
return patterns;
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
case 4:
|
|
53
|
-
case "end":
|
|
54
|
-
return _context.stop();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}, _callee, this);
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
function batchPatterns(_x) {
|
|
61
|
-
return _batchPatterns.apply(this, arguments);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return batchPatterns;
|
|
65
|
-
}()
|
|
66
|
-
}, {
|
|
67
|
-
key: "check",
|
|
68
|
-
value: function () {
|
|
69
|
-
var _check = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resourceUrl) {
|
|
70
|
-
var endpoint, response;
|
|
71
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
72
|
-
while (1) {
|
|
73
|
-
switch (_context2.prev = _context2.next) {
|
|
74
|
-
case 0:
|
|
75
|
-
_context2.prev = 0;
|
|
76
|
-
endpoint = "".concat(this.resolverUrl, "/check");
|
|
77
|
-
_context2.next = 4;
|
|
78
|
-
return api.request('post', endpoint, {
|
|
79
|
-
resourceUrl: resourceUrl
|
|
80
|
-
}, this.requestHeaders);
|
|
81
|
-
|
|
82
|
-
case 4:
|
|
83
|
-
response = _context2.sent;
|
|
84
|
-
return _context2.abrupt("return", response.isSupported);
|
|
85
|
-
|
|
86
|
-
case 8:
|
|
87
|
-
_context2.prev = 8;
|
|
88
|
-
_context2.t0 = _context2["catch"](0);
|
|
89
|
-
// eslint-disable-next-line
|
|
90
|
-
console.error('failed to fetch /check', _context2.t0);
|
|
91
|
-
return _context2.abrupt("return", undefined);
|
|
92
|
-
|
|
93
|
-
case 12:
|
|
94
|
-
case "end":
|
|
95
|
-
return _context2.stop();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, _callee2, this, [[0, 8]]);
|
|
99
|
-
}));
|
|
100
|
-
|
|
101
|
-
function check(_x2) {
|
|
102
|
-
return _check.apply(this, arguments);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return check;
|
|
106
|
-
}()
|
|
107
|
-
}, {
|
|
108
|
-
key: "fetchPatterns",
|
|
109
|
-
value: function () {
|
|
110
|
-
var _fetchPatterns = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
111
|
-
var endpoint, response;
|
|
112
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
113
|
-
while (1) {
|
|
114
|
-
switch (_context3.prev = _context3.next) {
|
|
115
|
-
case 0:
|
|
116
|
-
_context3.prev = 0;
|
|
117
|
-
endpoint = "".concat(this.resolverUrl, "/providers");
|
|
118
|
-
_context3.next = 4;
|
|
119
|
-
return api.request('post', endpoint, undefined, this.requestHeaders);
|
|
120
|
-
|
|
121
|
-
case 4:
|
|
122
|
-
response = _context3.sent;
|
|
123
|
-
return _context3.abrupt("return", response.providers.reduce(function (allSources, provider) {
|
|
124
|
-
var providerSources = provider.patterns.map(function (pattern) {
|
|
125
|
-
return pattern.source;
|
|
126
|
-
});
|
|
127
|
-
return allSources.concat(providerSources);
|
|
128
|
-
}, []));
|
|
129
|
-
|
|
130
|
-
case 8:
|
|
131
|
-
_context3.prev = 8;
|
|
132
|
-
_context3.t0 = _context3["catch"](0);
|
|
133
|
-
// eslint-disable-next-line
|
|
134
|
-
console.error('failed to fetch /providers', _context3.t0);
|
|
135
|
-
return _context3.abrupt("return", undefined);
|
|
136
|
-
|
|
137
|
-
case 12:
|
|
138
|
-
case "end":
|
|
139
|
-
return _context3.stop();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}, _callee3, this, [[0, 8]]);
|
|
143
|
-
}));
|
|
144
|
-
|
|
145
|
-
function fetchPatterns() {
|
|
146
|
-
return _fetchPatterns.apply(this, arguments);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return fetchPatterns;
|
|
150
|
-
}()
|
|
151
|
-
}, {
|
|
152
|
-
key: "findPattern",
|
|
153
|
-
value: function () {
|
|
154
|
-
var _findPattern = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url) {
|
|
155
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
156
|
-
while (1) {
|
|
157
|
-
switch (_context4.prev = _context4.next) {
|
|
158
|
-
case 0:
|
|
159
|
-
if (this.patterns) {
|
|
160
|
-
_context4.next = 4;
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
_context4.next = 3;
|
|
165
|
-
return this.patternLoader.load('providers');
|
|
166
|
-
|
|
167
|
-
case 3:
|
|
168
|
-
this.patterns = _context4.sent;
|
|
169
|
-
|
|
170
|
-
case 4:
|
|
171
|
-
return _context4.abrupt("return", this.patterns ? this.patterns.some(function (pattern) {
|
|
172
|
-
return url.match(pattern);
|
|
173
|
-
}) : false);
|
|
174
|
-
|
|
175
|
-
case 5:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context4.stop();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}, _callee4, this);
|
|
181
|
-
}));
|
|
182
|
-
|
|
183
|
-
function findPattern(_x3) {
|
|
184
|
-
return _findPattern.apply(this, arguments);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return findPattern;
|
|
188
|
-
}()
|
|
189
|
-
}, {
|
|
190
|
-
key: "resolve",
|
|
191
|
-
value: function () {
|
|
192
|
-
var _resolve = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url, appearance) {
|
|
193
|
-
var isSupported;
|
|
194
|
-
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
195
|
-
while (1) {
|
|
196
|
-
switch (_context5.prev = _context5.next) {
|
|
197
|
-
case 0:
|
|
198
|
-
_context5.prev = 0;
|
|
199
|
-
_context5.next = 3;
|
|
200
|
-
return this.findPattern(url);
|
|
201
|
-
|
|
202
|
-
case 3:
|
|
203
|
-
_context5.t0 = _context5.sent;
|
|
204
|
-
|
|
205
|
-
if (_context5.t0) {
|
|
206
|
-
_context5.next = 8;
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
_context5.next = 7;
|
|
211
|
-
return this.check(url);
|
|
212
|
-
|
|
213
|
-
case 7:
|
|
214
|
-
_context5.t0 = _context5.sent;
|
|
215
|
-
|
|
216
|
-
case 8:
|
|
217
|
-
isSupported = _context5.t0;
|
|
218
|
-
|
|
219
|
-
if (!isSupported) {
|
|
220
|
-
_context5.next = 11;
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return _context5.abrupt("return", this.transformer.toAdf(url, appearance));
|
|
225
|
-
|
|
226
|
-
case 11:
|
|
227
|
-
_context5.next = 16;
|
|
228
|
-
break;
|
|
229
|
-
|
|
230
|
-
case 13:
|
|
231
|
-
_context5.prev = 13;
|
|
232
|
-
_context5.t1 = _context5["catch"](0);
|
|
233
|
-
// eslint-disable-next-line
|
|
234
|
-
console.warn("Error when trying to check Smart Card url \"".concat(url, " - ").concat(_context5.t1.prototype.name, " ").concat(_context5.t1.message), _context5.t1);
|
|
235
|
-
|
|
236
|
-
case 16:
|
|
237
|
-
return _context5.abrupt("return", Promise.reject(undefined));
|
|
238
|
-
|
|
239
|
-
case 17:
|
|
240
|
-
case "end":
|
|
241
|
-
return _context5.stop();
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}, _callee5, this, [[0, 13]]);
|
|
245
|
-
}));
|
|
246
|
-
|
|
247
|
-
function resolve(_x4, _x5) {
|
|
248
|
-
return _resolve.apply(this, arguments);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return resolve;
|
|
252
|
-
}()
|
|
253
|
-
}]);
|
|
254
|
-
|
|
255
|
-
return EditorCardProvider;
|
|
256
|
-
}();
|
|
257
|
-
export var editorCardProvider = new EditorCardProvider();
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
|
|
4
|
-
var isJiraRoadMap = function isJiraRoadMap(url) {
|
|
5
|
-
return url.match(/^https:\/\/.*?\/jira\/software\/(c\/)?projects\/[^\/]+?\/boards\/.*?\/roadmap\/?/);
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
var isPolarisView = function isPolarisView(url) {
|
|
9
|
-
return url.match(/^https:\/\/.*?\/jira\/polaris\/projects\/[^\/]+?\/ideas\/view\/\d+$|^https:\/\/.*?\/secure\/JiraProductDiscoveryAnonymous\.jspa\?hash=\w+|^https:\/\/.*?\/jira\/polaris\/share\/\w+/);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
var isJwmView = function isJwmView(url) {
|
|
13
|
-
return url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar|list|board)\/?/);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export var Transformer = /*#__PURE__*/function () {
|
|
17
|
-
function Transformer() {
|
|
18
|
-
_classCallCheck(this, Transformer);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_createClass(Transformer, [{
|
|
22
|
-
key: "buildInlineAdf",
|
|
23
|
-
value: function buildInlineAdf(url) {
|
|
24
|
-
return {
|
|
25
|
-
type: 'inlineCard',
|
|
26
|
-
attrs: {
|
|
27
|
-
url: url
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
key: "buildBlockAdf",
|
|
33
|
-
value: function buildBlockAdf(url) {
|
|
34
|
-
return {
|
|
35
|
-
type: 'blockCard',
|
|
36
|
-
attrs: {
|
|
37
|
-
url: url
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "buildEmbedAdf",
|
|
43
|
-
value: function buildEmbedAdf(url) {
|
|
44
|
-
return {
|
|
45
|
-
type: 'embedCard',
|
|
46
|
-
attrs: {
|
|
47
|
-
url: url,
|
|
48
|
-
layout: 'wide'
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "toAdf",
|
|
54
|
-
value: function toAdf(url, appearance) {
|
|
55
|
-
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
56
|
-
return this.buildEmbedAdf(url);
|
|
57
|
-
} else {
|
|
58
|
-
switch (appearance) {
|
|
59
|
-
case 'inline':
|
|
60
|
-
return this.buildInlineAdf(url);
|
|
61
|
-
|
|
62
|
-
case 'block':
|
|
63
|
-
return this.buildBlockAdf(url);
|
|
64
|
-
|
|
65
|
-
case 'embed':
|
|
66
|
-
return this.buildEmbedAdf(url);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}]);
|
|
71
|
-
|
|
72
|
-
return Transformer;
|
|
73
|
-
}();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useContext, createContext } from 'react';
|
|
2
|
-
import { SmartCardProvider } from './provider';
|
|
3
|
-
export var SmartCardContext = /*#__PURE__*/createContext(undefined);
|
|
4
|
-
export function useSmartLinkContext() {
|
|
5
|
-
var context = useContext(SmartCardContext);
|
|
6
|
-
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw Error('useSmartCard() must be wrapped in <SmartCardProvider>');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
13
|
-
export { SmartCardProvider };
|
|
14
|
-
export default SmartCardContext;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useContext, useMemo } from 'react';
|
|
3
|
-
import { createStore } from 'redux';
|
|
4
|
-
import { cardReducer } from '../reducers';
|
|
5
|
-
import { SmartCardContext } from '.';
|
|
6
|
-
import CardClient from '../../client';
|
|
7
|
-
import { extractPreview } from '../../extractors/common/preview';
|
|
8
|
-
import { getUrl } from '../helpers';
|
|
9
|
-
export function SmartCardProvider(_ref) {
|
|
10
|
-
var storeOptions = _ref.storeOptions,
|
|
11
|
-
customClient = _ref.client,
|
|
12
|
-
customAuthFlow = _ref.authFlow,
|
|
13
|
-
children = _ref.children,
|
|
14
|
-
renderers = _ref.renderers;
|
|
15
|
-
var parentContext = useContext(SmartCardContext);
|
|
16
|
-
var providerValue = useMemo(function () {
|
|
17
|
-
var _ref2 = storeOptions || {
|
|
18
|
-
initialState: {}
|
|
19
|
-
},
|
|
20
|
-
initialState = _ref2.initialState;
|
|
21
|
-
|
|
22
|
-
var client = customClient || new CardClient();
|
|
23
|
-
var store = createStore(cardReducer, initialState);
|
|
24
|
-
var authFlow = customAuthFlow || 'oauth2';
|
|
25
|
-
|
|
26
|
-
var getPreview = function getPreview(url, platform) {
|
|
27
|
-
var cardState = getUrl(store, url);
|
|
28
|
-
return cardState.details ? extractPreview(cardState.details.data, platform) : undefined;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
renderers: renderers,
|
|
33
|
-
store: store,
|
|
34
|
-
prefetchStore: {},
|
|
35
|
-
connections: {
|
|
36
|
-
client: client
|
|
37
|
-
},
|
|
38
|
-
config: {
|
|
39
|
-
authFlow: authFlow
|
|
40
|
-
},
|
|
41
|
-
extractors: {
|
|
42
|
-
getPreview: getPreview
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}, [customClient, customAuthFlow, storeOptions, renderers]);
|
|
46
|
-
return /*#__PURE__*/React.createElement(SmartCardContext.Provider, {
|
|
47
|
-
value: parentContext || providerValue
|
|
48
|
-
}, children);
|
|
49
|
-
}
|
|
50
|
-
export default SmartCardProvider;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
var _cardReducerMap;
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
|
-
import * as actions from '../actions/constants';
|
|
10
|
-
import { getStatus } from '../helpers';
|
|
11
|
-
var cardReducerMap = (_cardReducerMap = {}, _defineProperty(_cardReducerMap, actions.ACTION_PENDING, function (_state, _ref) {
|
|
12
|
-
var type = _ref.type;
|
|
13
|
-
return {
|
|
14
|
-
status: type
|
|
15
|
-
};
|
|
16
|
-
}), _defineProperty(_cardReducerMap, actions.ACTION_RESOLVING, function (state, _ref2) {
|
|
17
|
-
var type = _ref2.type;
|
|
18
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
19
|
-
status: type
|
|
20
|
-
});
|
|
21
|
-
}), _defineProperty(_cardReducerMap, actions.ACTION_RESOLVED, function (state, _ref3) {
|
|
22
|
-
var type = _ref3.type,
|
|
23
|
-
payload = _ref3.payload;
|
|
24
|
-
var nextDetails = payload;
|
|
25
|
-
|
|
26
|
-
var nextState = _objectSpread({}, state);
|
|
27
|
-
|
|
28
|
-
if (nextDetails) {
|
|
29
|
-
nextState.status = getStatus(nextDetails);
|
|
30
|
-
nextState.details = nextDetails;
|
|
31
|
-
} else {
|
|
32
|
-
// Keep the pre-existing data in the store. If there
|
|
33
|
-
// is no data, the UI should handle this gracefully.
|
|
34
|
-
nextState.status = type;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return nextState;
|
|
38
|
-
}), _defineProperty(_cardReducerMap, actions.ACTION_ERROR, function (state, _ref4) {
|
|
39
|
-
var type = _ref4.type,
|
|
40
|
-
error = _ref4.error;
|
|
41
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
42
|
-
status: type,
|
|
43
|
-
error: error
|
|
44
|
-
});
|
|
45
|
-
}), _defineProperty(_cardReducerMap, actions.ACTION_ERROR_FALLBACK, function (state, _ref5) {
|
|
46
|
-
var type = _ref5.type,
|
|
47
|
-
error = _ref5.error;
|
|
48
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
49
|
-
status: type,
|
|
50
|
-
error: error
|
|
51
|
-
});
|
|
52
|
-
}), _cardReducerMap);
|
|
53
|
-
export var cardReducer = function cardReducer(state, action) {
|
|
54
|
-
if (cardReducerMap[action.type]) {
|
|
55
|
-
var cardState = state[action.url]; // Card may have reached the same state on account of multiple of the same
|
|
56
|
-
// URL being present in an editor session. E.g. page with N links to one resource.
|
|
57
|
-
|
|
58
|
-
var hasSameStatus = cardState && cardState.status === action.type;
|
|
59
|
-
|
|
60
|
-
if (hasSameStatus) {
|
|
61
|
-
return state;
|
|
62
|
-
} else {
|
|
63
|
-
var nextState = cardReducerMap[action.type](cardState, action);
|
|
64
|
-
return _objectSpread(_objectSpread({}, state), {}, _defineProperty({}, action.url, nextState));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return state;
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ErrorType } from './types/responses';
|
|
2
|
-
export declare type APIErrorKind = 'fatal' | 'auth' | 'error' | 'fallback';
|
|
3
|
-
export declare class APIError extends Error {
|
|
4
|
-
readonly kind: APIErrorKind;
|
|
5
|
-
readonly hostname: string;
|
|
6
|
-
readonly message: string;
|
|
7
|
-
readonly type?: ErrorType | undefined;
|
|
8
|
-
constructor(kind: APIErrorKind, hostname: string, message: string, type?: ErrorType | undefined);
|
|
9
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { JsonLd } from 'json-ld-types';
|
|
2
|
-
import Environments from '../utils/environments';
|
|
3
|
-
import { InvokePayload, ServerActionOpts } from '../../model/invoke-opts';
|
|
4
|
-
export interface CardClient {
|
|
5
|
-
fetchData(url: string): Promise<JsonLd.Response>;
|
|
6
|
-
prefetchData(url: string): Promise<JsonLd.Response | undefined>;
|
|
7
|
-
postData(data: InvokePayload<ServerActionOpts>): Promise<JsonLd.Response>;
|
|
8
|
-
}
|
|
9
|
-
export declare type ClientEnvironment = {
|
|
10
|
-
baseUrl: string;
|
|
11
|
-
resolverUrl: string;
|
|
12
|
-
};
|
|
13
|
-
export declare type EnvironmentsKeys = keyof typeof Environments;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ServerActionOpts } from '../../model/invoke-opts';
|
|
2
|
-
export interface ResolveRequest {
|
|
3
|
-
resourceUrl: string;
|
|
4
|
-
context?: string;
|
|
5
|
-
}
|
|
6
|
-
export interface BatchResolveRequest {
|
|
7
|
-
resourceUrls: ResolveRequest[];
|
|
8
|
-
}
|
|
9
|
-
export declare type InvokeRequest = ServerActionOpts;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { JsonLd } from 'json-ld-types';
|
|
2
|
-
export declare type BatchResponse = Array<SuccessResponse | ErrorResponse>;
|
|
3
|
-
export declare type SuccessResponse = {
|
|
4
|
-
status: number;
|
|
5
|
-
body: JsonLd.Response;
|
|
6
|
-
};
|
|
7
|
-
export interface ErrorResponse {
|
|
8
|
-
status: number;
|
|
9
|
-
error: ErrorResponseBody;
|
|
10
|
-
}
|
|
11
|
-
export interface ErrorResponseBody {
|
|
12
|
-
type: ServerErrorType;
|
|
13
|
-
message: string;
|
|
14
|
-
status: number;
|
|
15
|
-
}
|
|
16
|
-
export declare type ServerErrorType = 'ResolveBadRequestError' | 'ResolveAuthError' | 'ResolveUnsupportedError' | 'ResolveFailedError' | 'ResolveTimeoutError' | 'InternalServerError';
|
|
17
|
-
export declare type ErrorType = ServerErrorType | 'UnexpectedError';
|
|
18
|
-
export declare const isSuccessfulResponse: (response?: SuccessResponse | ErrorResponse | undefined) => response is SuccessResponse;
|
|
19
|
-
export declare const isErrorResponse: (response: SuccessResponse | ErrorResponse) => response is ErrorResponse;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const BaseUrls: {
|
|
2
|
-
dev: string;
|
|
3
|
-
development: string;
|
|
4
|
-
stg: string;
|
|
5
|
-
staging: string;
|
|
6
|
-
prd: string;
|
|
7
|
-
prod: string;
|
|
8
|
-
production: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const getBaseUrl: (envKey?: "dev" | "development" | "stg" | "staging" | "prd" | "prod" | "production" | undefined) => string;
|
|
11
|
-
export declare const getResolverUrl: (envKey?: "dev" | "development" | "stg" | "staging" | "prd" | "prod" | "production" | undefined) => string;
|
|
12
|
-
export default BaseUrls;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import 'setimmediate';
|
|
2
|
-
import { CardAdf } from '@atlaskit/linking-common';
|
|
3
|
-
import { CardProvider } from './types';
|
|
4
|
-
import { CardAppearance } from '../../view/Card';
|
|
5
|
-
import { EnvironmentsKeys } from '../../client/types';
|
|
6
|
-
export declare class EditorCardProvider implements CardProvider {
|
|
7
|
-
private baseUrl;
|
|
8
|
-
private resolverUrl;
|
|
9
|
-
private patterns?;
|
|
10
|
-
private requestHeaders;
|
|
11
|
-
private transformer;
|
|
12
|
-
private patternLoader;
|
|
13
|
-
constructor(envKey?: EnvironmentsKeys);
|
|
14
|
-
private batchPatterns;
|
|
15
|
-
private check;
|
|
16
|
-
private fetchPatterns;
|
|
17
|
-
findPattern(url: string): Promise<boolean>;
|
|
18
|
-
resolve(url: string, appearance: CardAppearance): Promise<CardAdf>;
|
|
19
|
-
}
|
|
20
|
-
export declare const editorCardProvider: EditorCardProvider;
|
|
21
|
-
export type { CardProvider, ORSCheckResponse } from './types';
|
|
22
|
-
export type { CardAdf, InlineCardAdf, BlockCardAdf, EmbedCardAdf, } from '@atlaskit/linking-common';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { CardAdf } from '@atlaskit/linking-common';
|
|
2
|
-
import { CardAppearance } from '../../view/Card';
|
|
3
|
-
export declare class Transformer {
|
|
4
|
-
private buildInlineAdf;
|
|
5
|
-
private buildBlockAdf;
|
|
6
|
-
private buildEmbedAdf;
|
|
7
|
-
toAdf(url: string, appearance: CardAppearance): CardAdf;
|
|
8
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CardAppearance } from '../../view/Card';
|
|
2
|
-
export interface CardProvider {
|
|
3
|
-
resolve(url: string, appearance: CardAppearance): Promise<any>;
|
|
4
|
-
}
|
|
5
|
-
export declare type ORSCheckResponse = {
|
|
6
|
-
isSupported: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare type ProviderPattern = {
|
|
9
|
-
source: string;
|
|
10
|
-
flags: string;
|
|
11
|
-
};
|
|
12
|
-
declare type Provider = {
|
|
13
|
-
key: string;
|
|
14
|
-
patterns: ProviderPattern[];
|
|
15
|
-
};
|
|
16
|
-
export declare type ORSProvidersResponse = {
|
|
17
|
-
providers: Provider[];
|
|
18
|
-
};
|
|
19
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CardContext } from './types';
|
|
3
|
-
import { SmartCardProvider, ProviderProps } from './provider';
|
|
4
|
-
export declare const SmartCardContext: import("react").Context<CardContext | undefined>;
|
|
5
|
-
export declare function useSmartLinkContext(): CardContext;
|
|
6
|
-
export { SmartCardProvider };
|
|
7
|
-
export type { ProviderProps, CardContext };
|
|
8
|
-
export default SmartCardContext;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { CardProviderProps } from './types';
|
|
3
|
-
export declare function SmartCardProvider({ storeOptions, client: customClient, authFlow: customAuthFlow, children, renderers, }: CardProviderProps): JSX.Element;
|
|
4
|
-
export type { CardProviderProps as ProviderProps };
|
|
5
|
-
export default SmartCardProvider;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Store } from 'redux';
|
|
3
|
-
import { LinkPreview } from '@atlaskit/linking-common';
|
|
4
|
-
import { CardStore, CardConnections } from '../store/types';
|
|
5
|
-
import { CardPlatform, CardAppearance } from '../../view/Card';
|
|
6
|
-
import CardClient from '../../client';
|
|
7
|
-
export interface CardAuthFlowOpts {
|
|
8
|
-
authFlow?: 'oauth2' | 'disabled';
|
|
9
|
-
}
|
|
10
|
-
export interface CardContext {
|
|
11
|
-
store: Store<CardStore>;
|
|
12
|
-
prefetchStore: Record<string, boolean>;
|
|
13
|
-
connections: CardConnections;
|
|
14
|
-
config: CardProviderCacheOpts & CardAuthFlowOpts;
|
|
15
|
-
extractors: {
|
|
16
|
-
getPreview: (url: string, platform?: CardPlatform) => LinkPreview | undefined;
|
|
17
|
-
};
|
|
18
|
-
renderers?: CardProviderRenderers;
|
|
19
|
-
}
|
|
20
|
-
/** @deprecated Feature removed (EDM-2205) */
|
|
21
|
-
export interface CardProviderCacheOpts {
|
|
22
|
-
maxAge?: number;
|
|
23
|
-
maxLoadingDelay?: number;
|
|
24
|
-
}
|
|
25
|
-
export interface CardProviderStoreOpts {
|
|
26
|
-
initialState: CardStore;
|
|
27
|
-
}
|
|
28
|
-
export interface CardProviderRenderers {
|
|
29
|
-
adf?: (adf: string) => React.ReactNode;
|
|
30
|
-
emoji?: (emoji?: string, parentComponent?: CardAppearance) => React.ReactNode;
|
|
31
|
-
}
|
|
32
|
-
export declare type CardProviderProps = {
|
|
33
|
-
client?: CardClient;
|
|
34
|
-
/** @deprecated Feature removed (EDM-2205) */
|
|
35
|
-
cacheOptions?: CardProviderCacheOpts;
|
|
36
|
-
storeOptions?: CardProviderStoreOpts;
|
|
37
|
-
children: React.ReactNode;
|
|
38
|
-
renderers?: CardProviderRenderers;
|
|
39
|
-
} & CardAuthFlowOpts;
|