@atlaskit/anonymous-assets 1.1.1 → 2.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 +26 -0
- package/dist/cjs/common/utils/get-anonymous-asset.js +20 -20
- package/dist/cjs/common/utils/intl.js +23 -23
- package/dist/cjs/common/utils/retry.js +20 -20
- package/dist/esm/common/utils/get-anonymous-asset.js +20 -20
- package/dist/esm/common/utils/intl.js +23 -23
- package/dist/esm/common/utils/retry.js +20 -20
- package/get-anonymous-asset/package.json +1 -8
- package/package.json +6 -13
- package/types/package.json +1 -8
- package/dist/types-ts4.5/common/assets/index.d.ts +0 -106
- package/dist/types-ts4.5/common/utils/anonymous-assets.d.ts +0 -678
- package/dist/types-ts4.5/common/utils/get-anonymous-asset.d.ts +0 -26
- package/dist/types-ts4.5/common/utils/intl.d.ts +0 -2
- package/dist/types-ts4.5/common/utils/retry.d.ts +0 -22
- package/dist/types-ts4.5/i18n/cs.d.ts +0 -144
- package/dist/types-ts4.5/i18n/da.d.ts +0 -144
- package/dist/types-ts4.5/i18n/de.d.ts +0 -144
- package/dist/types-ts4.5/i18n/en.d.ts +0 -144
- package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -144
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -144
- package/dist/types-ts4.5/i18n/es.d.ts +0 -144
- package/dist/types-ts4.5/i18n/fi.d.ts +0 -144
- package/dist/types-ts4.5/i18n/fr.d.ts +0 -144
- package/dist/types-ts4.5/i18n/hr.d.ts +0 -144
- package/dist/types-ts4.5/i18n/hu.d.ts +0 -144
- package/dist/types-ts4.5/i18n/index.d.ts +0 -1
- package/dist/types-ts4.5/i18n/it.d.ts +0 -144
- package/dist/types-ts4.5/i18n/ja.d.ts +0 -144
- package/dist/types-ts4.5/i18n/ko.d.ts +0 -144
- package/dist/types-ts4.5/i18n/nb.d.ts +0 -144
- package/dist/types-ts4.5/i18n/nl.d.ts +0 -144
- package/dist/types-ts4.5/i18n/pl.d.ts +0 -144
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -144
- package/dist/types-ts4.5/i18n/ru.d.ts +0 -144
- package/dist/types-ts4.5/i18n/sr_RS.d.ts +0 -144
- package/dist/types-ts4.5/i18n/sr_YR.d.ts +0 -144
- package/dist/types-ts4.5/i18n/sv.d.ts +0 -144
- package/dist/types-ts4.5/i18n/th.d.ts +0 -144
- package/dist/types-ts4.5/i18n/tr.d.ts +0 -144
- package/dist/types-ts4.5/i18n/uk.d.ts +0 -144
- package/dist/types-ts4.5/i18n/vi.d.ts +0 -144
- package/dist/types-ts4.5/i18n/zh.d.ts +0 -144
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -144
- package/dist/types-ts4.5/index.d.ts +0 -2
- package/dist/types-ts4.5/messages.d.ts +0 -3
- package/dist/types-ts4.5/types.d.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlassian/anonymous-assets
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
|
|
8
|
+
Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
|
|
9
|
+
|
|
10
|
+
Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
|
|
11
|
+
|
|
12
|
+
Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
|
|
13
|
+
|
|
14
|
+
```diff
|
|
15
|
+
- "typesVersions": {
|
|
16
|
+
- ">=4.5 <4.9": {
|
|
17
|
+
- "*": [
|
|
18
|
+
- "dist/types-ts4.5/*",
|
|
19
|
+
- "dist/types-ts4.5/index.d.ts"
|
|
20
|
+
- ]
|
|
21
|
+
- }
|
|
22
|
+
- },
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
|
|
3
29
|
## 1.1.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -55,16 +55,16 @@ var getAnonymousAvatarWithStyling = exports.getAnonymousAvatarWithStyling = /*#_
|
|
|
55
55
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(props) {
|
|
56
56
|
var _response$result;
|
|
57
57
|
var index, _ANONYMOUS_ASSETS$ind, id, messageDescriptor, src, intl, response, svgString, doc, svg;
|
|
58
|
-
return _regenerator.default.wrap(function
|
|
58
|
+
return _regenerator.default.wrap(function (_context) {
|
|
59
59
|
while (1) switch (_context.prev = _context.next) {
|
|
60
60
|
case 0:
|
|
61
61
|
index = getAssetIndex(props === null || props === void 0 ? void 0 : props.index);
|
|
62
62
|
_ANONYMOUS_ASSETS$ind = _anonymousAssets.ANONYMOUS_ASSETS[index], id = _ANONYMOUS_ASSETS$ind.id, messageDescriptor = _ANONYMOUS_ASSETS$ind.messageDescriptor, src = _ANONYMOUS_ASSETS$ind.src;
|
|
63
|
-
_context.next =
|
|
63
|
+
_context.next = 1;
|
|
64
64
|
return (0, _intl.getIntl)();
|
|
65
|
-
case
|
|
65
|
+
case 1:
|
|
66
66
|
intl = _context.sent;
|
|
67
|
-
_context.next =
|
|
67
|
+
_context.next = 2;
|
|
68
68
|
return (0, _retry.fetchWithRetry)({
|
|
69
69
|
url: src,
|
|
70
70
|
shouldRetryOnApiError: true,
|
|
@@ -74,24 +74,24 @@ var getAnonymousAvatarWithStyling = exports.getAnonymousAvatarWithStyling = /*#_
|
|
|
74
74
|
baseDelay: props.baseDelay,
|
|
75
75
|
maxDelay: props.maxDelay
|
|
76
76
|
});
|
|
77
|
-
case
|
|
77
|
+
case 2:
|
|
78
78
|
response = _context.sent;
|
|
79
|
-
_context.next =
|
|
79
|
+
_context.next = 3;
|
|
80
80
|
return (_response$result = response.result) === null || _response$result === void 0 ? void 0 : _response$result.text();
|
|
81
|
-
case
|
|
81
|
+
case 3:
|
|
82
82
|
svgString = _context.sent;
|
|
83
83
|
if (response.success) {
|
|
84
|
-
_context.next =
|
|
84
|
+
_context.next = 4;
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
87
87
|
throw new Error("Error while fetching svg ".concat(id, " with src ").concat(src));
|
|
88
|
-
case
|
|
88
|
+
case 4:
|
|
89
89
|
if (svgString) {
|
|
90
|
-
_context.next =
|
|
90
|
+
_context.next = 5;
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
93
|
throw new Error("svg returned null with svg ".concat(id, " with src ").concat(src));
|
|
94
|
-
case
|
|
94
|
+
case 5:
|
|
95
95
|
doc = svgStringToDomDocument(svgString);
|
|
96
96
|
svg = doc.documentElement;
|
|
97
97
|
addStyling(svg, props.styleProperties);
|
|
@@ -100,7 +100,7 @@ var getAnonymousAvatarWithStyling = exports.getAnonymousAvatarWithStyling = /*#_
|
|
|
100
100
|
name: intl.formatMessage(messageDescriptor),
|
|
101
101
|
src: encodeSvgToDataUri(svg)
|
|
102
102
|
});
|
|
103
|
-
case
|
|
103
|
+
case 6:
|
|
104
104
|
case "end":
|
|
105
105
|
return _context.stop();
|
|
106
106
|
}
|
|
@@ -118,19 +118,19 @@ var getAnonymousAvatarWithStyling = exports.getAnonymousAvatarWithStyling = /*#_
|
|
|
118
118
|
var getAnonymousAsset = exports.getAnonymousAsset = /*#__PURE__*/function () {
|
|
119
119
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(props) {
|
|
120
120
|
var index, asset, intl;
|
|
121
|
-
return _regenerator.default.wrap(function
|
|
121
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
122
122
|
while (1) switch (_context2.prev = _context2.next) {
|
|
123
123
|
case 0:
|
|
124
124
|
index = getAssetIndex(props === null || props === void 0 ? void 0 : props.index);
|
|
125
125
|
asset = _anonymousAssets.ANONYMOUS_ASSETS[index];
|
|
126
|
-
_context2.next =
|
|
126
|
+
_context2.next = 1;
|
|
127
127
|
return (0, _intl.getIntl)();
|
|
128
|
-
case
|
|
128
|
+
case 1:
|
|
129
129
|
intl = _context2.sent;
|
|
130
130
|
return _context2.abrupt("return", _objectSpread(_objectSpread({}, asset), {}, {
|
|
131
131
|
name: intl.formatMessage(asset.messageDescriptor)
|
|
132
132
|
}));
|
|
133
|
-
case
|
|
133
|
+
case 2:
|
|
134
134
|
case "end":
|
|
135
135
|
return _context2.stop();
|
|
136
136
|
}
|
|
@@ -147,12 +147,12 @@ var getAnonymousAsset = exports.getAnonymousAsset = /*#__PURE__*/function () {
|
|
|
147
147
|
var getAllAnonymousAssets = exports.getAllAnonymousAssets = /*#__PURE__*/function () {
|
|
148
148
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
149
149
|
var intl;
|
|
150
|
-
return _regenerator.default.wrap(function
|
|
150
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
151
151
|
while (1) switch (_context3.prev = _context3.next) {
|
|
152
152
|
case 0:
|
|
153
|
-
_context3.next =
|
|
153
|
+
_context3.next = 1;
|
|
154
154
|
return (0, _intl.getIntl)();
|
|
155
|
-
case
|
|
155
|
+
case 1:
|
|
156
156
|
intl = _context3.sent;
|
|
157
157
|
return _context3.abrupt("return", _anonymousAssets.ANONYMOUS_ASSETS.map(function (asset) {
|
|
158
158
|
return {
|
|
@@ -161,7 +161,7 @@ var getAllAnonymousAssets = exports.getAllAnonymousAssets = /*#__PURE__*/functio
|
|
|
161
161
|
src: asset.src
|
|
162
162
|
};
|
|
163
163
|
}));
|
|
164
|
-
case
|
|
164
|
+
case 2:
|
|
165
165
|
case "end":
|
|
166
166
|
return _context3.stop();
|
|
167
167
|
}
|
|
@@ -21,17 +21,17 @@ var getIntl = exports.getIntl = /*#__PURE__*/function () {
|
|
|
21
21
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
22
22
|
var _getDocument;
|
|
23
23
|
var key, messages, cache, intl;
|
|
24
|
-
return _regenerator.default.wrap(function
|
|
24
|
+
return _regenerator.default.wrap(function (_context) {
|
|
25
25
|
while (1) switch (_context.prev = _context.next) {
|
|
26
26
|
case 0:
|
|
27
27
|
key = ((_getDocument = (0, _browserApis.getDocument)()) === null || _getDocument === void 0 || (_getDocument = _getDocument.documentElement) === null || _getDocument === void 0 ? void 0 : _getDocument.lang) || 'en-US';
|
|
28
28
|
if (intlCacheMap.has(key)) {
|
|
29
|
-
_context.next =
|
|
29
|
+
_context.next = 2;
|
|
30
30
|
break;
|
|
31
31
|
}
|
|
32
|
-
_context.next =
|
|
32
|
+
_context.next = 1;
|
|
33
33
|
return fetchMessages(key);
|
|
34
|
-
case
|
|
34
|
+
case 1:
|
|
35
35
|
messages = _context.sent;
|
|
36
36
|
cache = (0, _reactIntl.createIntlCache)();
|
|
37
37
|
intl = (0, _reactIntl.createIntl)({
|
|
@@ -39,9 +39,9 @@ var getIntl = exports.getIntl = /*#__PURE__*/function () {
|
|
|
39
39
|
messages: messages
|
|
40
40
|
}, cache);
|
|
41
41
|
intlCacheMap.set(key, intl);
|
|
42
|
-
case
|
|
42
|
+
case 2:
|
|
43
43
|
return _context.abrupt("return", intlCacheMap.get(key));
|
|
44
|
-
case
|
|
44
|
+
case 3:
|
|
45
45
|
case "end":
|
|
46
46
|
return _context.stop();
|
|
47
47
|
}
|
|
@@ -53,45 +53,45 @@ var getIntl = exports.getIntl = /*#__PURE__*/function () {
|
|
|
53
53
|
}();
|
|
54
54
|
var fetchMessages = /*#__PURE__*/function () {
|
|
55
55
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(locale) {
|
|
56
|
-
var _ref3, _localeMap$locale, targetLocale, messages, parentLocale, _messages;
|
|
57
|
-
return _regenerator.default.wrap(function
|
|
56
|
+
var _ref3, _localeMap$locale, targetLocale, messages, parentLocale, _messages, _t;
|
|
57
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
58
58
|
while (1) switch (_context2.prev = _context2.next) {
|
|
59
59
|
case 0:
|
|
60
60
|
_context2.prev = 0;
|
|
61
61
|
targetLocale = ((_ref3 = (_localeMap$locale = localeMap[locale]) !== null && _localeMap$locale !== void 0 ? _localeMap$locale : locale) !== null && _ref3 !== void 0 ? _ref3 : '').replace('-', '_');
|
|
62
62
|
if (!(targetLocale in _i18n.locales)) {
|
|
63
|
-
_context2.next =
|
|
63
|
+
_context2.next = 2;
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
|
-
_context2.next =
|
|
66
|
+
_context2.next = 1;
|
|
67
67
|
return _i18n.locales[targetLocale]();
|
|
68
|
-
case
|
|
68
|
+
case 1:
|
|
69
69
|
messages = _context2.sent;
|
|
70
70
|
return _context2.abrupt("return", messages.default);
|
|
71
|
-
case
|
|
71
|
+
case 2:
|
|
72
72
|
parentLocale = locale.split(/[-_]/)[0];
|
|
73
73
|
if (!(parentLocale in _i18n.locales)) {
|
|
74
|
-
_context2.next =
|
|
74
|
+
_context2.next = 4;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
_context2.next =
|
|
77
|
+
_context2.next = 3;
|
|
78
78
|
return _i18n.locales[parentLocale]();
|
|
79
|
-
case
|
|
79
|
+
case 3:
|
|
80
80
|
_messages = _context2.sent;
|
|
81
81
|
return _context2.abrupt("return", _messages.default);
|
|
82
|
-
case
|
|
83
|
-
_context2.next =
|
|
82
|
+
case 4:
|
|
83
|
+
_context2.next = 6;
|
|
84
84
|
break;
|
|
85
|
-
case
|
|
86
|
-
_context2.prev =
|
|
87
|
-
|
|
88
|
-
case
|
|
85
|
+
case 5:
|
|
86
|
+
_context2.prev = 5;
|
|
87
|
+
_t = _context2["catch"](0);
|
|
88
|
+
case 6:
|
|
89
89
|
return _context2.abrupt("return", _en.default);
|
|
90
|
-
case
|
|
90
|
+
case 7:
|
|
91
91
|
case "end":
|
|
92
92
|
return _context2.stop();
|
|
93
93
|
}
|
|
94
|
-
}, _callee2, null, [[0,
|
|
94
|
+
}, _callee2, null, [[0, 5]]);
|
|
95
95
|
}));
|
|
96
96
|
return function fetchMessages(_x) {
|
|
97
97
|
return _ref2.apply(this, arguments);
|
|
@@ -27,52 +27,52 @@ var maxExpBackoffWithJitter = exports.maxExpBackoffWithJitter = function maxExpB
|
|
|
27
27
|
};
|
|
28
28
|
var _fetchWithRetry = exports.fetchWithRetry = /*#__PURE__*/function () {
|
|
29
29
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
30
|
-
var url, options, shouldRetryOnApiError, _ref$retries, retries, _ref$baseDelay, baseDelay, _ref$maxDelay, maxDelay, response, errorBody, retryDelay, newError;
|
|
31
|
-
return _regenerator.default.wrap(function
|
|
30
|
+
var url, options, shouldRetryOnApiError, _ref$retries, retries, _ref$baseDelay, baseDelay, _ref$maxDelay, maxDelay, response, errorBody, retryDelay, newError, _t;
|
|
31
|
+
return _regenerator.default.wrap(function (_context) {
|
|
32
32
|
while (1) switch (_context.prev = _context.next) {
|
|
33
33
|
case 0:
|
|
34
34
|
url = _ref.url, options = _ref.options, shouldRetryOnApiError = _ref.shouldRetryOnApiError, _ref$retries = _ref.retries, retries = _ref$retries === void 0 ? 3 : _ref$retries, _ref$baseDelay = _ref.baseDelay, baseDelay = _ref$baseDelay === void 0 ? 300 : _ref$baseDelay, _ref$maxDelay = _ref.maxDelay, maxDelay = _ref$maxDelay === void 0 ? 10000 : _ref$maxDelay;
|
|
35
35
|
_context.prev = 1;
|
|
36
|
-
_context.next =
|
|
36
|
+
_context.next = 2;
|
|
37
37
|
return fetch(url, options);
|
|
38
|
-
case
|
|
38
|
+
case 2:
|
|
39
39
|
response = _context.sent;
|
|
40
40
|
if (!response.ok) {
|
|
41
|
-
_context.next =
|
|
41
|
+
_context.next = 3;
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
return _context.abrupt("return", {
|
|
45
45
|
success: true,
|
|
46
46
|
result: response
|
|
47
47
|
});
|
|
48
|
-
case
|
|
48
|
+
case 3:
|
|
49
49
|
if (!shouldRetryOnApiError) {
|
|
50
|
-
_context.next =
|
|
50
|
+
_context.next = 4;
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
throw new Error('Failed request with an error');
|
|
54
|
-
case
|
|
55
|
-
_context.next =
|
|
54
|
+
case 4:
|
|
55
|
+
_context.next = 5;
|
|
56
56
|
return response.json();
|
|
57
|
-
case
|
|
57
|
+
case 5:
|
|
58
58
|
errorBody = _context.sent;
|
|
59
59
|
return _context.abrupt("return", {
|
|
60
60
|
success: false,
|
|
61
61
|
error: new Error(errorBody)
|
|
62
62
|
});
|
|
63
|
-
case
|
|
64
|
-
_context.prev =
|
|
65
|
-
|
|
63
|
+
case 6:
|
|
64
|
+
_context.prev = 6;
|
|
65
|
+
_t = _context["catch"](1);
|
|
66
66
|
if (!(retries > 0)) {
|
|
67
|
-
_context.next =
|
|
67
|
+
_context.next = 8;
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
retryDelay = maxExpBackoffWithJitter(retries, baseDelay, maxDelay);
|
|
71
|
-
_context.next =
|
|
71
|
+
_context.next = 7;
|
|
72
72
|
return new Promise(function (resolve) {
|
|
73
73
|
return setTimeout(resolve, retryDelay);
|
|
74
74
|
});
|
|
75
|
-
case
|
|
75
|
+
case 7:
|
|
76
76
|
return _context.abrupt("return", _fetchWithRetry({
|
|
77
77
|
url: url,
|
|
78
78
|
options: options,
|
|
@@ -81,17 +81,17 @@ var _fetchWithRetry = exports.fetchWithRetry = /*#__PURE__*/function () {
|
|
|
81
81
|
baseDelay: baseDelay,
|
|
82
82
|
maxDelay: maxDelay
|
|
83
83
|
}));
|
|
84
|
-
case
|
|
85
|
-
newError =
|
|
84
|
+
case 8:
|
|
85
|
+
newError = _t instanceof Error ? _t : new Error('An unknown error occurred');
|
|
86
86
|
return _context.abrupt("return", {
|
|
87
87
|
success: false,
|
|
88
88
|
error: newError
|
|
89
89
|
});
|
|
90
|
-
case
|
|
90
|
+
case 9:
|
|
91
91
|
case "end":
|
|
92
92
|
return _context.stop();
|
|
93
93
|
}
|
|
94
|
-
}, _callee, null, [[1,
|
|
94
|
+
}, _callee, null, [[1, 6]]);
|
|
95
95
|
}));
|
|
96
96
|
return function fetchWithRetry(_x) {
|
|
97
97
|
return _ref2.apply(this, arguments);
|
|
@@ -48,16 +48,16 @@ export var getAnonymousAvatarWithStyling = /*#__PURE__*/function () {
|
|
|
48
48
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(props) {
|
|
49
49
|
var _response$result;
|
|
50
50
|
var index, _ANONYMOUS_ASSETS$ind, id, messageDescriptor, src, intl, response, svgString, doc, svg;
|
|
51
|
-
return _regeneratorRuntime.wrap(function
|
|
51
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
52
52
|
while (1) switch (_context.prev = _context.next) {
|
|
53
53
|
case 0:
|
|
54
54
|
index = getAssetIndex(props === null || props === void 0 ? void 0 : props.index);
|
|
55
55
|
_ANONYMOUS_ASSETS$ind = ANONYMOUS_ASSETS[index], id = _ANONYMOUS_ASSETS$ind.id, messageDescriptor = _ANONYMOUS_ASSETS$ind.messageDescriptor, src = _ANONYMOUS_ASSETS$ind.src;
|
|
56
|
-
_context.next =
|
|
56
|
+
_context.next = 1;
|
|
57
57
|
return getIntl();
|
|
58
|
-
case
|
|
58
|
+
case 1:
|
|
59
59
|
intl = _context.sent;
|
|
60
|
-
_context.next =
|
|
60
|
+
_context.next = 2;
|
|
61
61
|
return fetchWithRetry({
|
|
62
62
|
url: src,
|
|
63
63
|
shouldRetryOnApiError: true,
|
|
@@ -67,24 +67,24 @@ export var getAnonymousAvatarWithStyling = /*#__PURE__*/function () {
|
|
|
67
67
|
baseDelay: props.baseDelay,
|
|
68
68
|
maxDelay: props.maxDelay
|
|
69
69
|
});
|
|
70
|
-
case
|
|
70
|
+
case 2:
|
|
71
71
|
response = _context.sent;
|
|
72
|
-
_context.next =
|
|
72
|
+
_context.next = 3;
|
|
73
73
|
return (_response$result = response.result) === null || _response$result === void 0 ? void 0 : _response$result.text();
|
|
74
|
-
case
|
|
74
|
+
case 3:
|
|
75
75
|
svgString = _context.sent;
|
|
76
76
|
if (response.success) {
|
|
77
|
-
_context.next =
|
|
77
|
+
_context.next = 4;
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
80
80
|
throw new Error("Error while fetching svg ".concat(id, " with src ").concat(src));
|
|
81
|
-
case
|
|
81
|
+
case 4:
|
|
82
82
|
if (svgString) {
|
|
83
|
-
_context.next =
|
|
83
|
+
_context.next = 5;
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
86
|
throw new Error("svg returned null with svg ".concat(id, " with src ").concat(src));
|
|
87
|
-
case
|
|
87
|
+
case 5:
|
|
88
88
|
doc = svgStringToDomDocument(svgString);
|
|
89
89
|
svg = doc.documentElement;
|
|
90
90
|
addStyling(svg, props.styleProperties);
|
|
@@ -93,7 +93,7 @@ export var getAnonymousAvatarWithStyling = /*#__PURE__*/function () {
|
|
|
93
93
|
name: intl.formatMessage(messageDescriptor),
|
|
94
94
|
src: encodeSvgToDataUri(svg)
|
|
95
95
|
});
|
|
96
|
-
case
|
|
96
|
+
case 6:
|
|
97
97
|
case "end":
|
|
98
98
|
return _context.stop();
|
|
99
99
|
}
|
|
@@ -111,19 +111,19 @@ export var getAnonymousAvatarWithStyling = /*#__PURE__*/function () {
|
|
|
111
111
|
export var getAnonymousAsset = /*#__PURE__*/function () {
|
|
112
112
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(props) {
|
|
113
113
|
var index, asset, intl;
|
|
114
|
-
return _regeneratorRuntime.wrap(function
|
|
114
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
115
115
|
while (1) switch (_context2.prev = _context2.next) {
|
|
116
116
|
case 0:
|
|
117
117
|
index = getAssetIndex(props === null || props === void 0 ? void 0 : props.index);
|
|
118
118
|
asset = ANONYMOUS_ASSETS[index];
|
|
119
|
-
_context2.next =
|
|
119
|
+
_context2.next = 1;
|
|
120
120
|
return getIntl();
|
|
121
|
-
case
|
|
121
|
+
case 1:
|
|
122
122
|
intl = _context2.sent;
|
|
123
123
|
return _context2.abrupt("return", _objectSpread(_objectSpread({}, asset), {}, {
|
|
124
124
|
name: intl.formatMessage(asset.messageDescriptor)
|
|
125
125
|
}));
|
|
126
|
-
case
|
|
126
|
+
case 2:
|
|
127
127
|
case "end":
|
|
128
128
|
return _context2.stop();
|
|
129
129
|
}
|
|
@@ -140,12 +140,12 @@ export var getAnonymousAsset = /*#__PURE__*/function () {
|
|
|
140
140
|
export var getAllAnonymousAssets = /*#__PURE__*/function () {
|
|
141
141
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
142
142
|
var intl;
|
|
143
|
-
return _regeneratorRuntime.wrap(function
|
|
143
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
144
144
|
while (1) switch (_context3.prev = _context3.next) {
|
|
145
145
|
case 0:
|
|
146
|
-
_context3.next =
|
|
146
|
+
_context3.next = 1;
|
|
147
147
|
return getIntl();
|
|
148
|
-
case
|
|
148
|
+
case 1:
|
|
149
149
|
intl = _context3.sent;
|
|
150
150
|
return _context3.abrupt("return", ANONYMOUS_ASSETS.map(function (asset) {
|
|
151
151
|
return {
|
|
@@ -154,7 +154,7 @@ export var getAllAnonymousAssets = /*#__PURE__*/function () {
|
|
|
154
154
|
src: asset.src
|
|
155
155
|
};
|
|
156
156
|
}));
|
|
157
|
-
case
|
|
157
|
+
case 2:
|
|
158
158
|
case "end":
|
|
159
159
|
return _context3.stop();
|
|
160
160
|
}
|
|
@@ -14,17 +14,17 @@ export var getIntl = /*#__PURE__*/function () {
|
|
|
14
14
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
15
15
|
var _getDocument;
|
|
16
16
|
var key, messages, cache, intl;
|
|
17
|
-
return _regeneratorRuntime.wrap(function
|
|
17
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
20
|
key = ((_getDocument = getDocument()) === null || _getDocument === void 0 || (_getDocument = _getDocument.documentElement) === null || _getDocument === void 0 ? void 0 : _getDocument.lang) || 'en-US';
|
|
21
21
|
if (intlCacheMap.has(key)) {
|
|
22
|
-
_context.next =
|
|
22
|
+
_context.next = 2;
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
|
-
_context.next =
|
|
25
|
+
_context.next = 1;
|
|
26
26
|
return fetchMessages(key);
|
|
27
|
-
case
|
|
27
|
+
case 1:
|
|
28
28
|
messages = _context.sent;
|
|
29
29
|
cache = createIntlCache();
|
|
30
30
|
intl = createIntl({
|
|
@@ -32,9 +32,9 @@ export var getIntl = /*#__PURE__*/function () {
|
|
|
32
32
|
messages: messages
|
|
33
33
|
}, cache);
|
|
34
34
|
intlCacheMap.set(key, intl);
|
|
35
|
-
case
|
|
35
|
+
case 2:
|
|
36
36
|
return _context.abrupt("return", intlCacheMap.get(key));
|
|
37
|
-
case
|
|
37
|
+
case 3:
|
|
38
38
|
case "end":
|
|
39
39
|
return _context.stop();
|
|
40
40
|
}
|
|
@@ -46,45 +46,45 @@ export var getIntl = /*#__PURE__*/function () {
|
|
|
46
46
|
}();
|
|
47
47
|
var fetchMessages = /*#__PURE__*/function () {
|
|
48
48
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(locale) {
|
|
49
|
-
var _ref3, _localeMap$locale, targetLocale, messages, parentLocale, _messages;
|
|
50
|
-
return _regeneratorRuntime.wrap(function
|
|
49
|
+
var _ref3, _localeMap$locale, targetLocale, messages, parentLocale, _messages, _t;
|
|
50
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
51
51
|
while (1) switch (_context2.prev = _context2.next) {
|
|
52
52
|
case 0:
|
|
53
53
|
_context2.prev = 0;
|
|
54
54
|
targetLocale = ((_ref3 = (_localeMap$locale = localeMap[locale]) !== null && _localeMap$locale !== void 0 ? _localeMap$locale : locale) !== null && _ref3 !== void 0 ? _ref3 : '').replace('-', '_');
|
|
55
55
|
if (!(targetLocale in locales)) {
|
|
56
|
-
_context2.next =
|
|
56
|
+
_context2.next = 2;
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
_context2.next =
|
|
59
|
+
_context2.next = 1;
|
|
60
60
|
return locales[targetLocale]();
|
|
61
|
-
case
|
|
61
|
+
case 1:
|
|
62
62
|
messages = _context2.sent;
|
|
63
63
|
return _context2.abrupt("return", messages.default);
|
|
64
|
-
case
|
|
64
|
+
case 2:
|
|
65
65
|
parentLocale = locale.split(/[-_]/)[0];
|
|
66
66
|
if (!(parentLocale in locales)) {
|
|
67
|
-
_context2.next =
|
|
67
|
+
_context2.next = 4;
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
|
-
_context2.next =
|
|
70
|
+
_context2.next = 3;
|
|
71
71
|
return locales[parentLocale]();
|
|
72
|
-
case
|
|
72
|
+
case 3:
|
|
73
73
|
_messages = _context2.sent;
|
|
74
74
|
return _context2.abrupt("return", _messages.default);
|
|
75
|
-
case
|
|
76
|
-
_context2.next =
|
|
75
|
+
case 4:
|
|
76
|
+
_context2.next = 6;
|
|
77
77
|
break;
|
|
78
|
-
case
|
|
79
|
-
_context2.prev =
|
|
80
|
-
|
|
81
|
-
case
|
|
78
|
+
case 5:
|
|
79
|
+
_context2.prev = 5;
|
|
80
|
+
_t = _context2["catch"](0);
|
|
81
|
+
case 6:
|
|
82
82
|
return _context2.abrupt("return", enMessages);
|
|
83
|
-
case
|
|
83
|
+
case 7:
|
|
84
84
|
case "end":
|
|
85
85
|
return _context2.stop();
|
|
86
86
|
}
|
|
87
|
-
}, _callee2, null, [[0,
|
|
87
|
+
}, _callee2, null, [[0, 5]]);
|
|
88
88
|
}));
|
|
89
89
|
return function fetchMessages(_x) {
|
|
90
90
|
return _ref2.apply(this, arguments);
|
|
@@ -20,52 +20,52 @@ export var maxExpBackoffWithJitter = function maxExpBackoffWithJitter(retryCount
|
|
|
20
20
|
};
|
|
21
21
|
var _fetchWithRetry = /*#__PURE__*/function () {
|
|
22
22
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
23
|
-
var url, options, shouldRetryOnApiError, _ref$retries, retries, _ref$baseDelay, baseDelay, _ref$maxDelay, maxDelay, response, errorBody, retryDelay, newError;
|
|
24
|
-
return _regeneratorRuntime.wrap(function
|
|
23
|
+
var url, options, shouldRetryOnApiError, _ref$retries, retries, _ref$baseDelay, baseDelay, _ref$maxDelay, maxDelay, response, errorBody, retryDelay, newError, _t;
|
|
24
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
25
25
|
while (1) switch (_context.prev = _context.next) {
|
|
26
26
|
case 0:
|
|
27
27
|
url = _ref.url, options = _ref.options, shouldRetryOnApiError = _ref.shouldRetryOnApiError, _ref$retries = _ref.retries, retries = _ref$retries === void 0 ? 3 : _ref$retries, _ref$baseDelay = _ref.baseDelay, baseDelay = _ref$baseDelay === void 0 ? 300 : _ref$baseDelay, _ref$maxDelay = _ref.maxDelay, maxDelay = _ref$maxDelay === void 0 ? 10000 : _ref$maxDelay;
|
|
28
28
|
_context.prev = 1;
|
|
29
|
-
_context.next =
|
|
29
|
+
_context.next = 2;
|
|
30
30
|
return fetch(url, options);
|
|
31
|
-
case
|
|
31
|
+
case 2:
|
|
32
32
|
response = _context.sent;
|
|
33
33
|
if (!response.ok) {
|
|
34
|
-
_context.next =
|
|
34
|
+
_context.next = 3;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
37
|
return _context.abrupt("return", {
|
|
38
38
|
success: true,
|
|
39
39
|
result: response
|
|
40
40
|
});
|
|
41
|
-
case
|
|
41
|
+
case 3:
|
|
42
42
|
if (!shouldRetryOnApiError) {
|
|
43
|
-
_context.next =
|
|
43
|
+
_context.next = 4;
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
throw new Error('Failed request with an error');
|
|
47
|
-
case
|
|
48
|
-
_context.next =
|
|
47
|
+
case 4:
|
|
48
|
+
_context.next = 5;
|
|
49
49
|
return response.json();
|
|
50
|
-
case
|
|
50
|
+
case 5:
|
|
51
51
|
errorBody = _context.sent;
|
|
52
52
|
return _context.abrupt("return", {
|
|
53
53
|
success: false,
|
|
54
54
|
error: new Error(errorBody)
|
|
55
55
|
});
|
|
56
|
-
case
|
|
57
|
-
_context.prev =
|
|
58
|
-
|
|
56
|
+
case 6:
|
|
57
|
+
_context.prev = 6;
|
|
58
|
+
_t = _context["catch"](1);
|
|
59
59
|
if (!(retries > 0)) {
|
|
60
|
-
_context.next =
|
|
60
|
+
_context.next = 8;
|
|
61
61
|
break;
|
|
62
62
|
}
|
|
63
63
|
retryDelay = maxExpBackoffWithJitter(retries, baseDelay, maxDelay);
|
|
64
|
-
_context.next =
|
|
64
|
+
_context.next = 7;
|
|
65
65
|
return new Promise(function (resolve) {
|
|
66
66
|
return setTimeout(resolve, retryDelay);
|
|
67
67
|
});
|
|
68
|
-
case
|
|
68
|
+
case 7:
|
|
69
69
|
return _context.abrupt("return", _fetchWithRetry({
|
|
70
70
|
url: url,
|
|
71
71
|
options: options,
|
|
@@ -74,17 +74,17 @@ var _fetchWithRetry = /*#__PURE__*/function () {
|
|
|
74
74
|
baseDelay: baseDelay,
|
|
75
75
|
maxDelay: maxDelay
|
|
76
76
|
}));
|
|
77
|
-
case
|
|
78
|
-
newError =
|
|
77
|
+
case 8:
|
|
78
|
+
newError = _t instanceof Error ? _t : new Error('An unknown error occurred');
|
|
79
79
|
return _context.abrupt("return", {
|
|
80
80
|
success: false,
|
|
81
81
|
error: newError
|
|
82
82
|
});
|
|
83
|
-
case
|
|
83
|
+
case 9:
|
|
84
84
|
case "end":
|
|
85
85
|
return _context.stop();
|
|
86
86
|
}
|
|
87
|
-
}, _callee, null, [[1,
|
|
87
|
+
}, _callee, null, [[1, 6]]);
|
|
88
88
|
}));
|
|
89
89
|
return function fetchWithRetry(_x) {
|
|
90
90
|
return _ref2.apply(this, arguments);
|
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/common/utils/get-anonymous-asset.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/common/utils/get-anonymous-asset.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/common/utils/get-anonymous-asset.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/common/utils/get-anonymous-asset.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/common/utils/get-anonymous-asset.d.ts"
|
|
15
8
|
}
|