@fluid-topics/ft-reader-context 2.2.18 → 2.2.20
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/build/ft-reader-context.js +2 -1
- package/build/ft-reader-context.light.js +3 -3
- package/build/ft-reader-context.min.js +5 -5
- package/build/store/FtReaderStateManager.js +17 -16
- package/build/store/utils/FtReaderConverter.js +10 -8
- package/build/store/utils/FtReaderService.js +6 -8
- package/package.json +4 -4
|
@@ -70,7 +70,8 @@ export class FtReaderStateManager {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
async resolvePage(tocId, pageNumber) {
|
|
73
|
-
var _a
|
|
73
|
+
var _a;
|
|
74
|
+
var _b;
|
|
74
75
|
const service = await this.awaitService();
|
|
75
76
|
if (pageNumber) {
|
|
76
77
|
return service.getPage(pageNumber, this.getTranslationSettings());
|
|
@@ -86,8 +87,9 @@ export class FtReaderStateManager {
|
|
|
86
87
|
return service.getPageByTocId(tocId, this.getTranslationSettings());
|
|
87
88
|
}
|
|
88
89
|
resolveValidNonRootTocId(tocId, page) {
|
|
89
|
-
var _a
|
|
90
|
-
|
|
90
|
+
var _a;
|
|
91
|
+
var _b, _c, _d, _e;
|
|
92
|
+
const nonRootTocId = (_b = (tocId === "root" ? undefined : tocId)) !== null && _b !== void 0 ? _b : page.rootTocId;
|
|
91
93
|
if (!page.topics.includes(nonRootTocId)) {
|
|
92
94
|
if (tocId != "root" && !page.hiddenTopics.includes(nonRootTocId)) {
|
|
93
95
|
// The redirection is expected when tocId = root or when landing from an "only in toc" topic, don't send the event.
|
|
@@ -95,7 +97,7 @@ export class FtReaderStateManager {
|
|
|
95
97
|
const maybeFilteredTopic = this.store.getState().filteredTocNodes[nonRootTocId];
|
|
96
98
|
if (maybeFilteredTopic) {
|
|
97
99
|
this.store.dispatchEvent(new FtRequestedTopicFilteredEvent(maybeFilteredTopic));
|
|
98
|
-
const nodeIsInToc = ((
|
|
100
|
+
const nodeIsInToc = ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getTocNodeNow(maybeFilteredTopic.tocId)) != null;
|
|
99
101
|
if (maybeFilteredTopic.reason === "ACCESS_RIGHTS_FILTER" || nodeIsInToc) {
|
|
100
102
|
return maybeFilteredTopic.tocId;
|
|
101
103
|
}
|
|
@@ -245,7 +247,8 @@ export class FtReaderStateManager {
|
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
249
|
createClusteringHelper() {
|
|
248
|
-
var _a
|
|
250
|
+
var _a;
|
|
251
|
+
var _b;
|
|
249
252
|
if (this.clusteringHelperProvider) {
|
|
250
253
|
return this.clusteringHelperProvider();
|
|
251
254
|
}
|
|
@@ -369,17 +372,18 @@ export class FtReaderStateManager {
|
|
|
369
372
|
this.store.dispatchEvent(new Event(FtReaderStoreEvents.mapAttachmentsUpdate));
|
|
370
373
|
}
|
|
371
374
|
async getRelativeDocumentUrlForLocale(uiLocale) {
|
|
372
|
-
var _a, _b
|
|
375
|
+
var _a, _b;
|
|
376
|
+
var _c;
|
|
373
377
|
if (this.store.getState().relatives == undefined) {
|
|
374
378
|
await this.fetchRelatives();
|
|
375
379
|
}
|
|
376
|
-
const maybeRelativeResultMap = ClusteringHelper.findResultWithMetadataValue((
|
|
380
|
+
const maybeRelativeResultMap = ClusteringHelper.findResultWithMetadataValue((_c = this.store.getState().relatives) !== null && _c !== void 0 ? _c : [], "ft:locale", uiLocale);
|
|
377
381
|
let targetUrl = accessResultUrl(maybeRelativeResultMap);
|
|
378
382
|
if (targetUrl) {
|
|
379
383
|
const currentTocId = this.store.getState().visibleTopics[0];
|
|
380
|
-
const metadataKey = (
|
|
384
|
+
const metadataKey = (_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.relativeTopicPivotMetadata;
|
|
381
385
|
if (metadataKey && currentTocId) {
|
|
382
|
-
const maybePivot = await ((
|
|
386
|
+
const maybePivot = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getTopicMetadataValue(currentTocId, metadataKey));
|
|
383
387
|
targetUrl = addPivotQueryParam(targetUrl, maybePivot);
|
|
384
388
|
}
|
|
385
389
|
}
|
|
@@ -445,13 +449,10 @@ export class FtReaderStateManager {
|
|
|
445
449
|
appVersion: apiIntegrationAppVersion,
|
|
446
450
|
sourceLanguage: this.parseLanguageToAnalyticsFormat(map.lang),
|
|
447
451
|
destinationLanguage: this.parseLanguageToAnalyticsFormat(destinationLanguage),
|
|
448
|
-
breadcrumb: breadcrumb.map((item) => {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
title: (_a = item.untranslatedTitle) !== null && _a !== void 0 ? _a : item.title,
|
|
453
|
-
});
|
|
454
|
-
}),
|
|
452
|
+
breadcrumb: breadcrumb.map((item) => { var _a; return ({
|
|
453
|
+
tocId: item.tocId,
|
|
454
|
+
title: (_a = item.untranslatedTitle) !== null && _a !== void 0 ? _a : item.title,
|
|
455
|
+
}); }),
|
|
455
456
|
document: documentWithOriginalTitle,
|
|
456
457
|
profileId,
|
|
457
458
|
});
|
|
@@ -46,14 +46,15 @@ class EnrichedTocBuilder {
|
|
|
46
46
|
}
|
|
47
47
|
convertNodes(nodes, depth, parentTocId) {
|
|
48
48
|
return nodes.flatMap((node) => {
|
|
49
|
-
var _a
|
|
49
|
+
var _a;
|
|
50
|
+
var _b, _c;
|
|
50
51
|
if (node.tocId == null) {
|
|
51
52
|
return [
|
|
52
|
-
...this.convertSectionNodes((
|
|
53
|
+
...this.convertSectionNodes((_b = node.pageToc) !== null && _b !== void 0 ? _b : [], depth, node.tocId),
|
|
53
54
|
...this.convertNodes(node.children, depth, node.tocId),
|
|
54
55
|
];
|
|
55
56
|
}
|
|
56
|
-
const prettyUrl = (
|
|
57
|
+
const prettyUrl = (_a = node.prettyUrl) === null || _a === void 0 ? void 0 : _a.replace(/^\//, "");
|
|
57
58
|
const enrichedNode = {
|
|
58
59
|
tocId: node.tocId,
|
|
59
60
|
contentId: node.contentId,
|
|
@@ -95,21 +96,22 @@ class EnrichedTocBuilder {
|
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
buildPage(node, parentTocId) {
|
|
98
|
-
var _a, _b, _c
|
|
99
|
-
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
var _d, _e, _f, _g, _h;
|
|
101
|
+
const rootTocId = (_d = node.tocId) !== null && _d !== void 0 ? _d : (_b = (_a = node.pageToc) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.tocId;
|
|
100
102
|
const page = {
|
|
101
103
|
number: this.pages.length + 1,
|
|
102
|
-
title: (
|
|
104
|
+
title: (_e = node.title) !== null && _e !== void 0 ? _e : "",
|
|
103
105
|
untranslatedTitle: node.untranslatedTitle,
|
|
104
106
|
rootTocId: rootTocId !== null && rootTocId !== void 0 ? rootTocId : "root",
|
|
105
|
-
toc: ((
|
|
107
|
+
toc: ((_f = node.pageToc) !== null && _f !== void 0 ? _f : []).map((n) => this.nodeByTocId[n.tocId]),
|
|
106
108
|
topics: [],
|
|
107
109
|
hiddenTopics: [],
|
|
108
110
|
rootDepth: rootTocId ? this.nodeByTocId[rootTocId].depth : 1,
|
|
109
111
|
breadcrumb: parentTocId ? this.buildBreadcrumb(this.nodeByTocId[parentTocId]) : [],
|
|
110
112
|
};
|
|
111
113
|
const add = (tocId, visible) => (visible ? page.topics : page.hiddenTopics).push(tocId);
|
|
112
|
-
const parentsVisibility = (_g = (
|
|
114
|
+
const parentsVisibility = (_g = (_c = node.pageConfiguration) === null || _c === void 0 ? void 0 : _c.parentsVisibility) !== null && _g !== void 0 ? _g : [];
|
|
113
115
|
page.breadcrumb.forEach((tocId, index) => {
|
|
114
116
|
add(tocId, parentsVisibility[index]);
|
|
115
117
|
});
|
|
@@ -33,7 +33,8 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
33
33
|
this.cache.register("map", () => this.withMapId((mapId) => this.fetchMap(mapId)));
|
|
34
34
|
this.cache.register(this.makeCacheKey("enrichedToc", undefined, this.metadataFilters), () => this.withMapId((mapId) => this.fetchPages(mapId, this._metadataFilters).then((toc) => this.converter.convertPaginatedToc(mapId, toc))));
|
|
35
35
|
this.cache.register("ratingSummary", () => {
|
|
36
|
-
var _a
|
|
36
|
+
var _a;
|
|
37
|
+
var _b;
|
|
37
38
|
const userHaveRatingRole = userHasRole((_b = (_a = ftAppInfoStore.getState().session) === null || _a === void 0 ? void 0 : _a.profile.roles) !== null && _b !== void 0 ? _b : [], "RATING_USER");
|
|
38
39
|
return userHaveRatingRole ? this.withMapId((mapId) => this.fetchMapRating(mapId)) : Promise.resolve();
|
|
39
40
|
});
|
|
@@ -198,13 +199,10 @@ export class FtReaderService extends FtServiceWithCache {
|
|
|
198
199
|
return this.getRatingSummary().then((rm) => rm === null || rm === void 0 ? void 0 : rm.publication);
|
|
199
200
|
}
|
|
200
201
|
getTopicRating(tocId) {
|
|
201
|
-
return this.getRatingSummary().then((rm) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find((t) => t.tocId === tocId),
|
|
206
|
-
} : undefined;
|
|
207
|
-
});
|
|
202
|
+
return this.getRatingSummary().then((rm) => { var _a; return rm ? {
|
|
203
|
+
type: rm.topics.type,
|
|
204
|
+
rating: (_a = rm.topics) === null || _a === void 0 ? void 0 : _a.ratings.find((t) => t.tocId === tocId),
|
|
205
|
+
} : undefined; });
|
|
208
206
|
}
|
|
209
207
|
rateMap(type, value) {
|
|
210
208
|
return this.makeRateMapRequest(type, value).then(() => this.clearRatingIfNecessary());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-context",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
4
4
|
"description": "Context block for integrated reader components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "2.2.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "2.2.
|
|
22
|
+
"@fluid-topics/ft-app-context": "2.2.20",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "2.2.20",
|
|
24
24
|
"lit": "3.3.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@fluid-topics/public-api": "1.0.143"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1edf5039fd9e6f390f81d9f7f3bbb8b1e3e6d2db"
|
|
30
30
|
}
|