@atlaskit/smart-card 44.5.1 → 44.5.3
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 +15 -0
- package/dist/cjs/state/hooks/use-current-site-cloud-id/index.js +71 -0
- package/dist/cjs/state/hooks/use-social-proof/index.js +60 -0
- package/dist/cjs/state/services/current-site-cloud-id/index.js +182 -0
- package/dist/cjs/state/services/personalization/index.js +267 -0
- package/dist/cjs/state/services/personalization/types.js +1 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/es2019/state/hooks/use-current-site-cloud-id/index.js +28 -0
- package/dist/es2019/state/hooks/use-social-proof/index.js +45 -0
- package/dist/es2019/state/services/current-site-cloud-id/index.js +118 -0
- package/dist/es2019/state/services/personalization/index.js +164 -0
- package/dist/es2019/state/services/personalization/types.js +0 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/esm/state/hooks/use-current-site-cloud-id/index.js +35 -0
- package/dist/esm/state/hooks/use-social-proof/index.js +53 -0
- package/dist/esm/state/services/current-site-cloud-id/index.js +174 -0
- package/dist/esm/state/services/personalization/index.js +258 -0
- package/dist/esm/state/services/personalization/types.js +0 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/types/common/ui/icons/blog-icon.d.ts +1 -1
- package/dist/types/common/ui/icons/live-document-icon.d.ts +1 -1
- package/dist/types/state/hooks/use-current-site-cloud-id/index.d.ts +6 -0
- package/dist/types/state/hooks/use-social-proof/index.d.ts +13 -0
- package/dist/types/state/services/current-site-cloud-id/index.d.ts +46 -0
- package/dist/types/state/services/personalization/index.d.ts +41 -0
- package/dist/types/state/services/personalization/types.d.ts +10 -0
- package/dist/types/view/FlexibleCard/assets/ai-chapter-icon.d.ts +3 -2
- package/dist/types/view/FlexibleCard/assets/ai-edit-icon.d.ts +3 -2
- package/dist/types/view/FlexibleCard/assets/ai-search-icon.d.ts +3 -2
- package/dist/types/view/FlexibleCard/assets/rovo-hex-logo.d.ts +4 -3
- package/dist/types-ts4.5/common/ui/icons/blog-icon.d.ts +1 -1
- package/dist/types-ts4.5/common/ui/icons/live-document-icon.d.ts +1 -1
- package/dist/types-ts4.5/state/hooks/use-current-site-cloud-id/index.d.ts +6 -0
- package/dist/types-ts4.5/state/hooks/use-social-proof/index.d.ts +13 -0
- package/dist/types-ts4.5/state/services/current-site-cloud-id/index.d.ts +46 -0
- package/dist/types-ts4.5/state/services/personalization/index.d.ts +41 -0
- package/dist/types-ts4.5/state/services/personalization/types.d.ts +10 -0
- package/dist/types-ts4.5/view/FlexibleCard/assets/ai-chapter-icon.d.ts +3 -2
- package/dist/types-ts4.5/view/FlexibleCard/assets/ai-edit-icon.d.ts +3 -2
- package/dist/types-ts4.5/view/FlexibleCard/assets/ai-search-icon.d.ts +3 -2
- package/dist/types-ts4.5/view/FlexibleCard/assets/rovo-hex-logo.d.ts +4 -3
- package/package.json +4 -4
- package/smart-card.docs.tsx +35 -15
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
import { StorageClient } from '@atlaskit/frontend-utilities/storage-client';
|
|
9
|
+
import { getCurrentSiteCloudId, getCachedCurrentSiteCloudIdAndRefresh } from '../current-site-cloud-id';
|
|
10
|
+
var BASE_URL = '/gateway/api/tap-delivery/api/v3/personalization';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Logical key shape: `@atlaskit/smart-card:<feature>:<schema-version>:<scope>` (see smart-card
|
|
14
|
+
* storage conventions). {@link StorageClient} narrows the localStorage key to
|
|
15
|
+
* `<clientKey>_<itemKey>` with `clientKey === '@atlaskit/smart-card'` and
|
|
16
|
+
* `itemKey === 'pct-map:v1:<cloudId>:<traitName>'` (scope segments URI-encoded).
|
|
17
|
+
*/
|
|
18
|
+
export var PERSONALIZATION_STORAGE_SCOPE = '@atlaskit/smart-card';
|
|
19
|
+
export var PERSONALIZATION_STORAGE_ITEM_KEY_PREFIX = 'pct-map:v1:';
|
|
20
|
+
var smartCardStorage = new StorageClient(PERSONALIZATION_STORAGE_SCOPE);
|
|
21
|
+
|
|
22
|
+
/** Keys written by this service in localStorage when using {@link smartCardStorage}. */
|
|
23
|
+
var LOCAL_STORAGE_ROW_KEY_PREFIX = "".concat(PERSONALIZATION_STORAGE_SCOPE, "_").concat(PERSONALIZATION_STORAGE_ITEM_KEY_PREFIX);
|
|
24
|
+
function pctMapStorageItemKey(cloudId, traitName) {
|
|
25
|
+
return "".concat(PERSONALIZATION_STORAGE_ITEM_KEY_PREFIX).concat(encodeURIComponent(cloudId), ":").concat(encodeURIComponent(traitName));
|
|
26
|
+
}
|
|
27
|
+
function fetchSiteTraits(_x) {
|
|
28
|
+
return _fetchSiteTraits.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Service for fetching site-level traits from the TAP Delivery personalization API.
|
|
32
|
+
*/
|
|
33
|
+
function _fetchSiteTraits() {
|
|
34
|
+
_fetchSiteTraits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(cloudId) {
|
|
35
|
+
var _data$attributes;
|
|
36
|
+
var response, data;
|
|
37
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
38
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
39
|
+
case 0:
|
|
40
|
+
_context3.next = 2;
|
|
41
|
+
return fetch("".concat(BASE_URL, "/site/").concat(cloudId), {
|
|
42
|
+
method: 'GET',
|
|
43
|
+
credentials: 'include',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
case 2:
|
|
49
|
+
response = _context3.sent;
|
|
50
|
+
if (response.ok) {
|
|
51
|
+
_context3.next = 5;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return _context3.abrupt("return", []);
|
|
55
|
+
case 5:
|
|
56
|
+
_context3.next = 7;
|
|
57
|
+
return response.json();
|
|
58
|
+
case 7:
|
|
59
|
+
data = _context3.sent;
|
|
60
|
+
return _context3.abrupt("return", (_data$attributes = data === null || data === void 0 ? void 0 : data.attributes) !== null && _data$attributes !== void 0 ? _data$attributes : []);
|
|
61
|
+
case 9:
|
|
62
|
+
case "end":
|
|
63
|
+
return _context3.stop();
|
|
64
|
+
}
|
|
65
|
+
}, _callee3);
|
|
66
|
+
}));
|
|
67
|
+
return _fetchSiteTraits.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
export var PersonalizationService = /*#__PURE__*/function () {
|
|
70
|
+
function PersonalizationService() {
|
|
71
|
+
_classCallCheck(this, PersonalizationService);
|
|
72
|
+
_defineProperty(this, "cache", new Map());
|
|
73
|
+
}
|
|
74
|
+
return _createClass(PersonalizationService, [{
|
|
75
|
+
key: "getCachedProviderPctMapAndRefresh",
|
|
76
|
+
value:
|
|
77
|
+
/**
|
|
78
|
+
* Returns the currently cached provider percentage map synchronously and starts a background refresh.
|
|
79
|
+
* The refresh result is persisted for future calls but is not awaited by this call.
|
|
80
|
+
*/
|
|
81
|
+
function getCachedProviderPctMapAndRefresh(traitName) {
|
|
82
|
+
var cloudId = getCachedCurrentSiteCloudIdAndRefresh();
|
|
83
|
+
var fromStorage = cloudId && this.readStoredProviderPctMap(cloudId, traitName) || null;
|
|
84
|
+
void this.getProviderPctMap(traitName);
|
|
85
|
+
return fromStorage;
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
key: "getProviderPctMap",
|
|
89
|
+
value: function () {
|
|
90
|
+
var _getProviderPctMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(traitName) {
|
|
91
|
+
var _this = this;
|
|
92
|
+
var cachedPromise, promise;
|
|
93
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
94
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
cachedPromise = this.cache.get(traitName);
|
|
97
|
+
if (!cachedPromise) {
|
|
98
|
+
_context2.next = 3;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
return _context2.abrupt("return", cachedPromise);
|
|
102
|
+
case 3:
|
|
103
|
+
promise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
104
|
+
var cloudId, traits, trait, mapped;
|
|
105
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
106
|
+
while (1) switch (_context.prev = _context.next) {
|
|
107
|
+
case 0:
|
|
108
|
+
_context.prev = 0;
|
|
109
|
+
_context.next = 3;
|
|
110
|
+
return getCurrentSiteCloudId();
|
|
111
|
+
case 3:
|
|
112
|
+
cloudId = _context.sent;
|
|
113
|
+
if (cloudId) {
|
|
114
|
+
_context.next = 6;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
return _context.abrupt("return", undefined);
|
|
118
|
+
case 6:
|
|
119
|
+
_context.next = 8;
|
|
120
|
+
return fetchSiteTraits(cloudId);
|
|
121
|
+
case 8:
|
|
122
|
+
traits = _context.sent;
|
|
123
|
+
trait = traits.find(function (t) {
|
|
124
|
+
return t.name === traitName;
|
|
125
|
+
});
|
|
126
|
+
mapped = _this.parseTraitValue(trait === null || trait === void 0 ? void 0 : trait.value);
|
|
127
|
+
if (mapped !== undefined) {
|
|
128
|
+
_this.writeStoredProviderPctMap(cloudId, traitName, mapped);
|
|
129
|
+
}
|
|
130
|
+
return _context.abrupt("return", mapped);
|
|
131
|
+
case 15:
|
|
132
|
+
_context.prev = 15;
|
|
133
|
+
_context.t0 = _context["catch"](0);
|
|
134
|
+
return _context.abrupt("return", undefined);
|
|
135
|
+
case 18:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context.stop();
|
|
138
|
+
}
|
|
139
|
+
}, _callee, null, [[0, 15]]);
|
|
140
|
+
}))();
|
|
141
|
+
this.cache.set(traitName, promise);
|
|
142
|
+
return _context2.abrupt("return", promise);
|
|
143
|
+
case 6:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context2.stop();
|
|
146
|
+
}
|
|
147
|
+
}, _callee2, this);
|
|
148
|
+
}));
|
|
149
|
+
function getProviderPctMap(_x2) {
|
|
150
|
+
return _getProviderPctMap.apply(this, arguments);
|
|
151
|
+
}
|
|
152
|
+
return getProviderPctMap;
|
|
153
|
+
}()
|
|
154
|
+
}, {
|
|
155
|
+
key: "readStoredProviderPctMap",
|
|
156
|
+
value: function readStoredProviderPctMap(cloudId, traitName) {
|
|
157
|
+
try {
|
|
158
|
+
var stored = smartCardStorage.getItem(pctMapStorageItemKey(cloudId, traitName));
|
|
159
|
+
if (stored === undefined || stored === null) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
return this.normalizeProviderPctMap(stored);
|
|
163
|
+
} catch (_unused2) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "writeStoredProviderPctMap",
|
|
169
|
+
value: function writeStoredProviderPctMap(cloudId, traitName, map) {
|
|
170
|
+
try {
|
|
171
|
+
smartCardStorage.setItemWithExpiry(pctMapStorageItemKey(cloudId, traitName), map);
|
|
172
|
+
} catch (_unused3) {
|
|
173
|
+
// Quota, private-mode, etc.
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "normalizeProviderPctMap",
|
|
178
|
+
value: function normalizeProviderPctMap(value) {
|
|
179
|
+
if (_typeof(value) !== 'object' || value === null || Array.isArray(value)) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
var map = {};
|
|
183
|
+
var entries = Object.entries(value);
|
|
184
|
+
for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
|
|
185
|
+
var _entries$_i = _slicedToArray(_entries[_i], 2),
|
|
186
|
+
providerKey = _entries$_i[0],
|
|
187
|
+
percentageRaw = _entries$_i[1];
|
|
188
|
+
if (typeof percentageRaw !== 'number' || !Number.isFinite(percentageRaw)) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
map[providerKey] = percentageRaw;
|
|
192
|
+
}
|
|
193
|
+
return map;
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
key: "parseTraitValue",
|
|
197
|
+
value: function parseTraitValue(raw) {
|
|
198
|
+
if (typeof raw !== 'string') {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
var parsed = JSON.parse(raw);
|
|
203
|
+
var normalized = this.normalizeProviderPctMap(parsed);
|
|
204
|
+
return normalized === null ? undefined : normalized;
|
|
205
|
+
} catch (_unused4) {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "clearCache",
|
|
211
|
+
value: function clearCache() {
|
|
212
|
+
this.cache.clear();
|
|
213
|
+
this.clearStoredProviderPctMaps();
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
key: "clearStoredProviderPctMaps",
|
|
217
|
+
value: function clearStoredProviderPctMaps() {
|
|
218
|
+
if (typeof globalThis.localStorage === 'undefined' || globalThis.localStorage === null) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
var keysToRemove = [];
|
|
222
|
+
for (var index = 0; index < globalThis.localStorage.length; index += 1) {
|
|
223
|
+
var key = globalThis.localStorage.key(index);
|
|
224
|
+
if (key !== null && key.startsWith(LOCAL_STORAGE_ROW_KEY_PREFIX)) {
|
|
225
|
+
keysToRemove.push(key);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (var _i2 = 0, _keysToRemove = keysToRemove; _i2 < _keysToRemove.length; _i2++) {
|
|
229
|
+
var _key = _keysToRemove[_i2];
|
|
230
|
+
try {
|
|
231
|
+
globalThis.localStorage.removeItem(_key);
|
|
232
|
+
} catch (_unused5) {
|
|
233
|
+
/* ignore */
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}]);
|
|
238
|
+
}();
|
|
239
|
+
export var personalizationService = new PersonalizationService();
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Resolves the provider percentage map for a TAP Delivery trait through the module-level
|
|
243
|
+
* {@link personalizationService}. Work is deduped per trait name for the page lifetime, and a
|
|
244
|
+
* successful response is persisted by cloud id and trait name for later cached reads.
|
|
245
|
+
*/
|
|
246
|
+
export var getProviderPctMap = function getProviderPctMap(traitName) {
|
|
247
|
+
return personalizationService.getProviderPctMap(traitName);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Reads the provider percentage map for a trait from browser storage via the module-level
|
|
252
|
+
* {@link personalizationService} singleton, without awaiting network work.
|
|
253
|
+
* Calling this also starts the trait-scoped shared refresh in the background, so a later call can
|
|
254
|
+
* use a refreshed value when it becomes available.
|
|
255
|
+
*/
|
|
256
|
+
export function getCachedProviderPctMapAndRefresh(traitName) {
|
|
257
|
+
return personalizationService.getCachedProviderPctMapAndRefresh(traitName);
|
|
258
|
+
}
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export var context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card" || '',
|
|
7
|
-
packageVersion: "44.5.
|
|
7
|
+
packageVersion: "44.5.2" || ''
|
|
8
8
|
};
|
|
9
9
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -15,7 +15,7 @@ import LinkWarningModal from './LinkWarningModal';
|
|
|
15
15
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
16
16
|
var PACKAGE_DATA = {
|
|
17
17
|
packageName: "@atlaskit/smart-card",
|
|
18
|
-
packageVersion: "44.5.
|
|
18
|
+
packageVersion: "44.5.2",
|
|
19
19
|
componentName: 'linkUrl'
|
|
20
20
|
};
|
|
21
21
|
var Anchor = withLinkClickedEvent('a');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { ObjectProps } from '@atlaskit/object/types';
|
|
3
3
|
import type { SmartLinkSize } from '../../../constants';
|
|
4
|
-
declare const BlogIconWithColor: FC<Omit<ObjectProps,
|
|
4
|
+
declare const BlogIconWithColor: FC<Omit<ObjectProps, 'size'> & {
|
|
5
5
|
size?: SmartLinkSize;
|
|
6
6
|
}>;
|
|
7
7
|
export default BlogIconWithColor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { ObjectProps } from '@atlaskit/object/types';
|
|
3
3
|
import type { SmartLinkSize } from '../../../constants';
|
|
4
|
-
declare const LiveDocumentIconWithColor: FC<Omit<ObjectProps,
|
|
4
|
+
declare const LiveDocumentIconWithColor: FC<Omit<ObjectProps, 'size'> & {
|
|
5
5
|
size?: SmartLinkSize;
|
|
6
6
|
}>;
|
|
7
7
|
export default LiveDocumentIconWithColor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CURRENT_SITE_CLOUD_ID_LOCAL_STORAGE_KEY, CURRENT_SITE_CLOUD_ID_STORAGE_ITEM_KEY, currentSiteCloudIdService, getCurrentSiteCloudId, getCachedCurrentSiteCloudIdAndRefresh, } from '../../services/current-site-cloud-id';
|
|
2
|
+
declare const useCurrentSiteCloudId: () => {
|
|
3
|
+
cloudId: string | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
};
|
|
6
|
+
export default useCurrentSiteCloudId;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SocialProof {
|
|
2
|
+
connectedPct: number | undefined;
|
|
3
|
+
isEnabled: boolean;
|
|
4
|
+
/** True while fetching personalization (only when `isEnabled`). */
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fetches provider usage percentage from the TAP Delivery personalization service when the
|
|
9
|
+
* killswitch allows it. Callers decide separately (e.g. via Statsig experiment) whether to
|
|
10
|
+
* surface that data in the UI.
|
|
11
|
+
*/
|
|
12
|
+
declare const useSocialProof: (traitName: string, extensionKey?: string, isKillswitchOn?: boolean) => SocialProof;
|
|
13
|
+
export default useSocialProof;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const CURRENT_SITE_CLOUD_ID_STORAGE_ITEM_KEY: string;
|
|
2
|
+
/** Keys written by this service in localStorage when using {@link smartCardStorage}. */
|
|
3
|
+
export declare const CURRENT_SITE_CLOUD_ID_LOCAL_STORAGE_KEY: string;
|
|
4
|
+
export declare class CurrentSiteCloudIdService {
|
|
5
|
+
/**
|
|
6
|
+
* Holds the shared tenant_info work: one in-flight fetch, then (on success) a settled promise for the session cloud
|
|
7
|
+
* id so later callers never trigger another `tenant_info` in the same page lifetime (until {@link clearCache}).
|
|
8
|
+
*/
|
|
9
|
+
private tenantInfoInflightPromise;
|
|
10
|
+
private readStoredCloudId;
|
|
11
|
+
private writeStoredCloudId;
|
|
12
|
+
private ensureTenantInfoInflightStarted;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the currently cached cloud id synchronously and starts a background refresh.
|
|
15
|
+
* The refresh result is persisted for future calls but is not awaited by this call.
|
|
16
|
+
*/
|
|
17
|
+
getCachedCloudIdAndRefresh(): string | undefined;
|
|
18
|
+
/** Writes tenant cloud id for tests or callers that intentionally warm storage before edge resolves. */
|
|
19
|
+
persistStoredCloudId(cloudId: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* When local storage already has a tenant cloud id, it is returned immediately; a background tenant_info refresh
|
|
22
|
+
* is still kicked off unless one is already in flight.
|
|
23
|
+
*
|
|
24
|
+
* Without storage, this awaits the deduped in-flight tenant_info (first concurrent caller chooses the URL;
|
|
25
|
+
* all share one promise regardless of subsequent `baseUriWithNoTrailingSlash`).
|
|
26
|
+
*
|
|
27
|
+
* On network success with no cloud id, or on failure: falls back via {@link readStoredCloudId}.
|
|
28
|
+
*/
|
|
29
|
+
get(baseUriWithNoTrailingSlash?: string): Promise<string | undefined>;
|
|
30
|
+
/** Clears the session pin so the next {@link get} may run `tenant_info` again (e.g. tests). */
|
|
31
|
+
clearCache(): void;
|
|
32
|
+
}
|
|
33
|
+
export declare const currentSiteCloudIdService: CurrentSiteCloudIdService;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the current site cloud id through the module-level {@link currentSiteCloudIdService}.
|
|
36
|
+
* Returns a stored cloud id immediately when one exists; otherwise waits for the shared
|
|
37
|
+
* `tenant_info` request and persists the result for subsequent cached reads.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getCurrentSiteCloudId: (baseUriWithNoTrailingSlash?: string) => Promise<string | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Reads the current site cloud id from browser storage (the `site-cloud-id:v1` row) via the
|
|
42
|
+
* module-level {@link currentSiteCloudIdService} singleton, without awaiting network work.
|
|
43
|
+
* Calling this also starts the shared `tenant_info` refresh in the background when one is not
|
|
44
|
+
* already running, so a later call can observe a refreshed value when available.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getCachedCurrentSiteCloudIdAndRefresh(): string | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ProviderPctMap } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Logical key shape: `@atlaskit/smart-card:<feature>:<schema-version>:<scope>` (see smart-card
|
|
4
|
+
* storage conventions). {@link StorageClient} narrows the localStorage key to
|
|
5
|
+
* `<clientKey>_<itemKey>` with `clientKey === '@atlaskit/smart-card'` and
|
|
6
|
+
* `itemKey === 'pct-map:v1:<cloudId>:<traitName>'` (scope segments URI-encoded).
|
|
7
|
+
*/
|
|
8
|
+
export declare const PERSONALIZATION_STORAGE_SCOPE: string;
|
|
9
|
+
export declare const PERSONALIZATION_STORAGE_ITEM_KEY_PREFIX: string;
|
|
10
|
+
/**
|
|
11
|
+
* Service for fetching site-level traits from the TAP Delivery personalization API.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PersonalizationService {
|
|
14
|
+
private cache;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the currently cached provider percentage map synchronously and starts a background refresh.
|
|
17
|
+
* The refresh result is persisted for future calls but is not awaited by this call.
|
|
18
|
+
*/
|
|
19
|
+
getCachedProviderPctMapAndRefresh(traitName: string): ProviderPctMap | null;
|
|
20
|
+
getProviderPctMap(traitName: string): Promise<ProviderPctMap | undefined>;
|
|
21
|
+
private readStoredProviderPctMap;
|
|
22
|
+
private writeStoredProviderPctMap;
|
|
23
|
+
private normalizeProviderPctMap;
|
|
24
|
+
private parseTraitValue;
|
|
25
|
+
clearCache(): void;
|
|
26
|
+
private clearStoredProviderPctMaps;
|
|
27
|
+
}
|
|
28
|
+
export declare const personalizationService: PersonalizationService;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the provider percentage map for a TAP Delivery trait through the module-level
|
|
31
|
+
* {@link personalizationService}. Work is deduped per trait name for the page lifetime, and a
|
|
32
|
+
* successful response is persisted by cloud id and trait name for later cached reads.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getProviderPctMap: (traitName: string) => Promise<ProviderPctMap | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Reads the provider percentage map for a trait from browser storage via the module-level
|
|
37
|
+
* {@link personalizationService} singleton, without awaiting network work.
|
|
38
|
+
* Calling this also starts the trait-scoped shared refresh in the background, so a later call can
|
|
39
|
+
* use a refreshed value when it becomes available.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCachedProviderPctMapAndRefresh(traitName: string): ProviderPctMap | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type PersonalizationTrait = {
|
|
2
|
+
name: string;
|
|
3
|
+
value: string | boolean | number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Map of extensionKey to connected users percentage.
|
|
7
|
+
* Keys are extensionKeys directly (e.g. 'google-object-provider').
|
|
8
|
+
* Values are integers 0-100.
|
|
9
|
+
*/
|
|
10
|
+
export type ProviderPctMap = Record<string, number>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
(
|
|
2
|
+
interface RovoHexLogoFunction {
|
|
3
|
+
(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
declare const RovoHexLogo: RovoHexLogoFunction;
|
|
6
7
|
export default RovoHexLogo;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { ObjectProps } from '@atlaskit/object/types';
|
|
3
3
|
import type { SmartLinkSize } from '../../../constants';
|
|
4
|
-
declare const BlogIconWithColor: FC<Omit<ObjectProps,
|
|
4
|
+
declare const BlogIconWithColor: FC<Omit<ObjectProps, 'size'> & {
|
|
5
5
|
size?: SmartLinkSize;
|
|
6
6
|
}>;
|
|
7
7
|
export default BlogIconWithColor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
2
|
import type { ObjectProps } from '@atlaskit/object/types';
|
|
3
3
|
import type { SmartLinkSize } from '../../../constants';
|
|
4
|
-
declare const LiveDocumentIconWithColor: FC<Omit<ObjectProps,
|
|
4
|
+
declare const LiveDocumentIconWithColor: FC<Omit<ObjectProps, 'size'> & {
|
|
5
5
|
size?: SmartLinkSize;
|
|
6
6
|
}>;
|
|
7
7
|
export default LiveDocumentIconWithColor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { CURRENT_SITE_CLOUD_ID_LOCAL_STORAGE_KEY, CURRENT_SITE_CLOUD_ID_STORAGE_ITEM_KEY, currentSiteCloudIdService, getCurrentSiteCloudId, getCachedCurrentSiteCloudIdAndRefresh, } from '../../services/current-site-cloud-id';
|
|
2
|
+
declare const useCurrentSiteCloudId: () => {
|
|
3
|
+
cloudId: string | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
};
|
|
6
|
+
export default useCurrentSiteCloudId;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SocialProof {
|
|
2
|
+
connectedPct: number | undefined;
|
|
3
|
+
isEnabled: boolean;
|
|
4
|
+
/** True while fetching personalization (only when `isEnabled`). */
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Fetches provider usage percentage from the TAP Delivery personalization service when the
|
|
9
|
+
* killswitch allows it. Callers decide separately (e.g. via Statsig experiment) whether to
|
|
10
|
+
* surface that data in the UI.
|
|
11
|
+
*/
|
|
12
|
+
declare const useSocialProof: (traitName: string, extensionKey?: string, isKillswitchOn?: boolean) => SocialProof;
|
|
13
|
+
export default useSocialProof;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const CURRENT_SITE_CLOUD_ID_STORAGE_ITEM_KEY: string;
|
|
2
|
+
/** Keys written by this service in localStorage when using {@link smartCardStorage}. */
|
|
3
|
+
export declare const CURRENT_SITE_CLOUD_ID_LOCAL_STORAGE_KEY: string;
|
|
4
|
+
export declare class CurrentSiteCloudIdService {
|
|
5
|
+
/**
|
|
6
|
+
* Holds the shared tenant_info work: one in-flight fetch, then (on success) a settled promise for the session cloud
|
|
7
|
+
* id so later callers never trigger another `tenant_info` in the same page lifetime (until {@link clearCache}).
|
|
8
|
+
*/
|
|
9
|
+
private tenantInfoInflightPromise;
|
|
10
|
+
private readStoredCloudId;
|
|
11
|
+
private writeStoredCloudId;
|
|
12
|
+
private ensureTenantInfoInflightStarted;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the currently cached cloud id synchronously and starts a background refresh.
|
|
15
|
+
* The refresh result is persisted for future calls but is not awaited by this call.
|
|
16
|
+
*/
|
|
17
|
+
getCachedCloudIdAndRefresh(): string | undefined;
|
|
18
|
+
/** Writes tenant cloud id for tests or callers that intentionally warm storage before edge resolves. */
|
|
19
|
+
persistStoredCloudId(cloudId: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* When local storage already has a tenant cloud id, it is returned immediately; a background tenant_info refresh
|
|
22
|
+
* is still kicked off unless one is already in flight.
|
|
23
|
+
*
|
|
24
|
+
* Without storage, this awaits the deduped in-flight tenant_info (first concurrent caller chooses the URL;
|
|
25
|
+
* all share one promise regardless of subsequent `baseUriWithNoTrailingSlash`).
|
|
26
|
+
*
|
|
27
|
+
* On network success with no cloud id, or on failure: falls back via {@link readStoredCloudId}.
|
|
28
|
+
*/
|
|
29
|
+
get(baseUriWithNoTrailingSlash?: string): Promise<string | undefined>;
|
|
30
|
+
/** Clears the session pin so the next {@link get} may run `tenant_info` again (e.g. tests). */
|
|
31
|
+
clearCache(): void;
|
|
32
|
+
}
|
|
33
|
+
export declare const currentSiteCloudIdService: CurrentSiteCloudIdService;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the current site cloud id through the module-level {@link currentSiteCloudIdService}.
|
|
36
|
+
* Returns a stored cloud id immediately when one exists; otherwise waits for the shared
|
|
37
|
+
* `tenant_info` request and persists the result for subsequent cached reads.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getCurrentSiteCloudId: (baseUriWithNoTrailingSlash?: string) => Promise<string | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Reads the current site cloud id from browser storage (the `site-cloud-id:v1` row) via the
|
|
42
|
+
* module-level {@link currentSiteCloudIdService} singleton, without awaiting network work.
|
|
43
|
+
* Calling this also starts the shared `tenant_info` refresh in the background when one is not
|
|
44
|
+
* already running, so a later call can observe a refreshed value when available.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getCachedCurrentSiteCloudIdAndRefresh(): string | undefined;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ProviderPctMap } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Logical key shape: `@atlaskit/smart-card:<feature>:<schema-version>:<scope>` (see smart-card
|
|
4
|
+
* storage conventions). {@link StorageClient} narrows the localStorage key to
|
|
5
|
+
* `<clientKey>_<itemKey>` with `clientKey === '@atlaskit/smart-card'` and
|
|
6
|
+
* `itemKey === 'pct-map:v1:<cloudId>:<traitName>'` (scope segments URI-encoded).
|
|
7
|
+
*/
|
|
8
|
+
export declare const PERSONALIZATION_STORAGE_SCOPE: string;
|
|
9
|
+
export declare const PERSONALIZATION_STORAGE_ITEM_KEY_PREFIX: string;
|
|
10
|
+
/**
|
|
11
|
+
* Service for fetching site-level traits from the TAP Delivery personalization API.
|
|
12
|
+
*/
|
|
13
|
+
export declare class PersonalizationService {
|
|
14
|
+
private cache;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the currently cached provider percentage map synchronously and starts a background refresh.
|
|
17
|
+
* The refresh result is persisted for future calls but is not awaited by this call.
|
|
18
|
+
*/
|
|
19
|
+
getCachedProviderPctMapAndRefresh(traitName: string): ProviderPctMap | null;
|
|
20
|
+
getProviderPctMap(traitName: string): Promise<ProviderPctMap | undefined>;
|
|
21
|
+
private readStoredProviderPctMap;
|
|
22
|
+
private writeStoredProviderPctMap;
|
|
23
|
+
private normalizeProviderPctMap;
|
|
24
|
+
private parseTraitValue;
|
|
25
|
+
clearCache(): void;
|
|
26
|
+
private clearStoredProviderPctMaps;
|
|
27
|
+
}
|
|
28
|
+
export declare const personalizationService: PersonalizationService;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the provider percentage map for a TAP Delivery trait through the module-level
|
|
31
|
+
* {@link personalizationService}. Work is deduped per trait name for the page lifetime, and a
|
|
32
|
+
* successful response is persisted by cloud id and trait name for later cached reads.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getProviderPctMap: (traitName: string) => Promise<ProviderPctMap | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* Reads the provider percentage map for a trait from browser storage via the module-level
|
|
37
|
+
* {@link personalizationService} singleton, without awaiting network work.
|
|
38
|
+
* Calling this also starts the trait-scoped shared refresh in the background, so a later call can
|
|
39
|
+
* use a refreshed value when it becomes available.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCachedProviderPctMapAndRefresh(traitName: string): ProviderPctMap | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type PersonalizationTrait = {
|
|
2
|
+
name: string;
|
|
3
|
+
value: string | boolean | number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Map of extensionKey to connected users percentage.
|
|
7
|
+
* Keys are extensionKeys directly (e.g. 'google-object-provider').
|
|
8
|
+
* Values are integers 0-100.
|
|
9
|
+
*/
|
|
10
|
+
export type ProviderPctMap = Record<string, number>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
(
|
|
2
|
+
interface RovoHexLogoFunction {
|
|
3
|
+
(props: React.SVGProps<SVGSVGElement>): React.JSX.Element;
|
|
4
4
|
displayName: string;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
declare const RovoHexLogo: RovoHexLogoFunction;
|
|
6
7
|
export default RovoHexLogo;
|