@prose-reader/core 1.70.0 → 1.72.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/dist/createReaderWithEnhancer.d.ts +7 -7
- package/dist/enhancers/navigation/state.d.ts +2 -0
- package/dist/enhancers/pagination/enhancer.d.ts +3 -3
- package/dist/index.js +51 -30
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +51 -30
- package/dist/index.umd.cjs.map +1 -1
- package/dist/pagination/Pagination.d.ts +2 -2
- package/dist/reader.d.ts +2 -2
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -1061,21 +1061,31 @@
|
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
1063
|
const observeState = (reader) => {
|
|
1064
|
-
return reader.pagination.
|
|
1064
|
+
return reader.pagination.state$.pipe(
|
|
1065
1065
|
rxjs.withLatestFrom(reader.context.manifest$, reader.settings.settings$),
|
|
1066
|
-
rxjs.map(
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1066
|
+
rxjs.map(
|
|
1067
|
+
([
|
|
1068
|
+
paginationInfo,
|
|
1069
|
+
{ spineItems, readingDirection },
|
|
1070
|
+
{ computedPageTurnDirection }
|
|
1071
|
+
]) => {
|
|
1072
|
+
const numberOfSpineItems = spineItems.length ?? 0;
|
|
1073
|
+
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0;
|
|
1074
|
+
const isAtAbsoluteEnd = paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
1075
|
+
const isAtEndSpineItem = paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
1076
|
+
const isAtBeginSpineItem = paginationInfo.beginSpineItemIndex === 0;
|
|
1077
|
+
const isAtBeginFirstPage = paginationInfo.beginPageIndexInSpineItem === 0;
|
|
1078
|
+
const isAtEndLastPage = paginationInfo.endPageIndexInSpineItem === paginationInfo.endNumberOfPagesInSpineItem - 1;
|
|
1079
|
+
return {
|
|
1080
|
+
canTurnLeft: computedPageTurnDirection === "vertical" ? false : !isAtBeginFirstPage,
|
|
1081
|
+
canTurnRight: computedPageTurnDirection === "vertical" ? false : !isAtEndLastPage,
|
|
1082
|
+
canGoTopSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteBeginning,
|
|
1083
|
+
canGoBottomSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteEnd,
|
|
1084
|
+
canGoLeftSpineItem: computedPageTurnDirection !== "vertical" && (readingDirection === "ltr" && !isAtAbsoluteBeginning || readingDirection === "rtl" && !isAtEndSpineItem),
|
|
1085
|
+
canGoRightSpineItem: computedPageTurnDirection !== "vertical" && (readingDirection === "ltr" && !isAtAbsoluteEnd || readingDirection === "rtl" && !isAtBeginSpineItem)
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
),
|
|
1079
1089
|
rxjs.distinctUntilChanged(isShallowEqual)
|
|
1080
1090
|
);
|
|
1081
1091
|
};
|
|
@@ -1183,7 +1193,7 @@
|
|
|
1183
1193
|
const trackTotalPages = (reader) => {
|
|
1184
1194
|
const totalPages$ = reader.spine.layout$.pipe(
|
|
1185
1195
|
rxjs.debounceTime(10, rxjs.animationFrameScheduler),
|
|
1186
|
-
rxjs.withLatestFrom(reader.pagination.
|
|
1196
|
+
rxjs.withLatestFrom(reader.pagination.state$),
|
|
1187
1197
|
rxjs.map(() => {
|
|
1188
1198
|
const numberOfPagesPerItems = getNumberOfPagesForAllSpineItems(reader);
|
|
1189
1199
|
return {
|
|
@@ -1250,16 +1260,16 @@
|
|
|
1250
1260
|
const chaptersInfo$ = trackChapterInfo(reader);
|
|
1251
1261
|
const totalPages$ = trackTotalPages(reader);
|
|
1252
1262
|
const currentValue = new rxjs.BehaviorSubject({
|
|
1253
|
-
...reader.pagination.
|
|
1263
|
+
...reader.pagination.state,
|
|
1254
1264
|
...mapPaginationInfoToExtendedInfo(reader)(
|
|
1255
|
-
reader.pagination.
|
|
1265
|
+
reader.pagination.state,
|
|
1256
1266
|
getChaptersInfo(reader)
|
|
1257
1267
|
),
|
|
1258
1268
|
beginAbsolutePageIndex: 0,
|
|
1259
1269
|
endAbsolutePageIndex: 0,
|
|
1260
1270
|
numberOfTotalPages: 0
|
|
1261
1271
|
});
|
|
1262
|
-
const extandedBasePagination$ = reader.pagination.
|
|
1272
|
+
const extandedBasePagination$ = reader.pagination.state$.pipe(
|
|
1263
1273
|
rxjs.combineLatestWith(chaptersInfo$),
|
|
1264
1274
|
rxjs.map(([info, chaptersInfo]) => ({
|
|
1265
1275
|
...info,
|
|
@@ -1300,10 +1310,10 @@
|
|
|
1300
1310
|
...reader,
|
|
1301
1311
|
pagination: {
|
|
1302
1312
|
...reader.pagination,
|
|
1303
|
-
get
|
|
1313
|
+
get state() {
|
|
1304
1314
|
return getPaginationInfo();
|
|
1305
1315
|
},
|
|
1306
|
-
|
|
1316
|
+
state$: paginationInfo$
|
|
1307
1317
|
}
|
|
1308
1318
|
};
|
|
1309
1319
|
};
|
|
@@ -1822,7 +1832,7 @@
|
|
|
1822
1832
|
endSpineItemIndex: void 0,
|
|
1823
1833
|
navigationId: void 0
|
|
1824
1834
|
});
|
|
1825
|
-
this.
|
|
1835
|
+
this.state$ = this.paginationSubject.pipe(
|
|
1826
1836
|
rxjs.distinctUntilChanged(isShallowEqual),
|
|
1827
1837
|
rxjs.tap((value) => {
|
|
1828
1838
|
report$3.info(`update`, value);
|
|
@@ -1836,7 +1846,7 @@
|
|
|
1836
1846
|
...pagination
|
|
1837
1847
|
});
|
|
1838
1848
|
}
|
|
1839
|
-
get
|
|
1849
|
+
get state() {
|
|
1840
1850
|
return this.paginationSubject.value;
|
|
1841
1851
|
}
|
|
1842
1852
|
destroy() {
|
|
@@ -4439,7 +4449,7 @@
|
|
|
4439
4449
|
rxjs.map(
|
|
4440
4450
|
() => ({
|
|
4441
4451
|
...navigation,
|
|
4442
|
-
animation: "
|
|
4452
|
+
animation: "snap"
|
|
4443
4453
|
})
|
|
4444
4454
|
),
|
|
4445
4455
|
rxjs.finalize(() => {
|
|
@@ -4806,7 +4816,7 @@
|
|
|
4806
4816
|
pageTurnMode: `controlled`,
|
|
4807
4817
|
snapAnimationDuration: 300,
|
|
4808
4818
|
navigationSnapThreshold: 0.3,
|
|
4809
|
-
numberOfAdjacentSpineItemToPreLoad:
|
|
4819
|
+
numberOfAdjacentSpineItemToPreLoad: 2
|
|
4810
4820
|
};
|
|
4811
4821
|
}
|
|
4812
4822
|
}
|
|
@@ -4943,7 +4953,7 @@
|
|
|
4943
4953
|
rxjs.withLatestFrom(this.context.bridgeEvent.navigation$),
|
|
4944
4954
|
rxjs.tap(([, navigation]) => {
|
|
4945
4955
|
const { position } = navigation;
|
|
4946
|
-
const previousPagination = this.pagination.
|
|
4956
|
+
const previousPagination = this.pagination.state;
|
|
4947
4957
|
const {
|
|
4948
4958
|
beginIndex: beginSpineItemIndex,
|
|
4949
4959
|
endIndex: endSpineItemIndex
|
|
@@ -5005,7 +5015,7 @@
|
|
|
5005
5015
|
endSpineItemIndex,
|
|
5006
5016
|
beginPageIndexInSpineItem,
|
|
5007
5017
|
endPageIndexInSpineItem
|
|
5008
|
-
} = this.pagination.
|
|
5018
|
+
} = this.pagination.state;
|
|
5009
5019
|
if (beginPageIndexInSpineItem === void 0 || endPageIndexInSpineItem === void 0 || beginSpineItemIndex === void 0 || endSpineItemIndex === void 0)
|
|
5010
5020
|
return;
|
|
5011
5021
|
const beginSpineItem = this.spineItemsManager.get(beginSpineItemIndex);
|
|
@@ -6915,7 +6925,18 @@
|
|
|
6915
6925
|
const layoutHasChanged$ = spineItemsManager.layout$.pipe(
|
|
6916
6926
|
rxjs.filter((hasChanged) => hasChanged)
|
|
6917
6927
|
);
|
|
6918
|
-
const
|
|
6928
|
+
const numberOfAdjacentSpineItemToPreLoad$ = settings.settings$.pipe(
|
|
6929
|
+
rxjs.map(
|
|
6930
|
+
({ numberOfAdjacentSpineItemToPreLoad }) => numberOfAdjacentSpineItemToPreLoad
|
|
6931
|
+
),
|
|
6932
|
+
rxjs.skip(1),
|
|
6933
|
+
rxjs.distinctUntilChanged()
|
|
6934
|
+
);
|
|
6935
|
+
const loadSpineItems$ = rxjs.merge(
|
|
6936
|
+
navigationUpdate$,
|
|
6937
|
+
layoutHasChanged$,
|
|
6938
|
+
numberOfAdjacentSpineItemToPreLoad$
|
|
6939
|
+
).pipe(
|
|
6919
6940
|
// this can be changed by whatever we want and SHOULD not break navigation.
|
|
6920
6941
|
// Ideally loading faster is better but loading too close to user navigating can
|
|
6921
6942
|
// be dangerous.
|
|
@@ -7061,7 +7082,7 @@
|
|
|
7061
7082
|
navigator2.viewportState$.subscribe(context.bridgeEvent.viewportStateSubject);
|
|
7062
7083
|
navigator2.navigation$.subscribe(context.bridgeEvent.navigationSubject);
|
|
7063
7084
|
navigator2.isLocked$.subscribe(context.bridgeEvent.navigationIsLockedSubject);
|
|
7064
|
-
pagination.
|
|
7085
|
+
pagination.state$.subscribe(context.bridgeEvent.paginationSubject);
|
|
7065
7086
|
const layout = () => {
|
|
7066
7087
|
var _a;
|
|
7067
7088
|
const containerElement = (_a = elementSubject$.getValue()) == null ? void 0 : _a.parentElement;
|
|
@@ -7181,8 +7202,8 @@
|
|
|
7181
7202
|
load,
|
|
7182
7203
|
destroy,
|
|
7183
7204
|
pagination: {
|
|
7184
|
-
|
|
7185
|
-
|
|
7205
|
+
state: pagination.state,
|
|
7206
|
+
state$: pagination.state$
|
|
7186
7207
|
},
|
|
7187
7208
|
settings: settingsManager,
|
|
7188
7209
|
element$,
|