@prose-reader/core 1.178.0 → 1.179.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.
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { BehaviorSubject, Subject } from 'rxjs';
|
|
2
1
|
import { Manifest } from '@prose-reader/shared';
|
|
2
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
3
3
|
import { BridgeEvent } from './BridgeEvent';
|
|
4
4
|
export type ContextState = {
|
|
5
5
|
containerElement?: HTMLElement;
|
|
6
6
|
manifest?: Manifest;
|
|
7
7
|
hasVerticalWriting?: boolean;
|
|
8
8
|
isUsingSpreadMode?: boolean;
|
|
9
|
+
assumedRenditionLayout: "reflowable" | "pre-paginated";
|
|
9
10
|
isFullyPrePaginated?: boolean;
|
|
10
11
|
forceSinglePageMode?: boolean;
|
|
11
12
|
calculatedInnerMargin: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Reader } from '../../../reader';
|
|
2
|
-
import { ViewportPosition } from '../../../navigation/viewport/ViewportNavigator';
|
|
3
1
|
import { UserNavigationEntry } from '../../../navigation/UserNavigator';
|
|
2
|
+
import { ViewportPosition } from '../../../navigation/viewport/ViewportNavigator';
|
|
3
|
+
import { Reader } from '../../../reader';
|
|
4
4
|
export declare class ManualNavigator {
|
|
5
5
|
protected reader: Reader;
|
|
6
6
|
movingLastDelta: {
|
package/dist/index.js
CHANGED
|
@@ -2629,7 +2629,8 @@ const mediaEnhancer = (next) => (options) => {
|
|
|
2629
2629
|
destroy
|
|
2630
2630
|
};
|
|
2631
2631
|
};
|
|
2632
|
-
const
|
|
2632
|
+
const report$4 = Report.namespace(`navigation`);
|
|
2633
|
+
const getSpineItemPositionForLeftPage = ({
|
|
2633
2634
|
position,
|
|
2634
2635
|
spineItem,
|
|
2635
2636
|
pageHeight,
|
|
@@ -2637,13 +2638,13 @@ const getSpineItemPositionForRightPage = ({
|
|
|
2637
2638
|
spineItemLocator
|
|
2638
2639
|
}) => {
|
|
2639
2640
|
let nextPotentialPosition = {
|
|
2640
|
-
x: position.x
|
|
2641
|
+
x: position.x - pageWidth,
|
|
2641
2642
|
y: position.y
|
|
2642
2643
|
};
|
|
2643
2644
|
if (spineItem.isUsingVerticalWriting()) {
|
|
2644
2645
|
nextPotentialPosition = {
|
|
2645
2646
|
x: position.x,
|
|
2646
|
-
y: position.y
|
|
2647
|
+
y: position.y + pageHeight
|
|
2647
2648
|
};
|
|
2648
2649
|
}
|
|
2649
2650
|
const navigationPosition = spineItemLocator.getSpineItemClosestPositionFromUnsafePosition(
|
|
@@ -2652,7 +2653,7 @@ const getSpineItemPositionForRightPage = ({
|
|
|
2652
2653
|
);
|
|
2653
2654
|
return navigationPosition;
|
|
2654
2655
|
};
|
|
2655
|
-
const
|
|
2656
|
+
const getNavigationForLeftSinglePage = ({
|
|
2656
2657
|
position,
|
|
2657
2658
|
navigationResolver,
|
|
2658
2659
|
computedPageTurnDirection,
|
|
@@ -2670,7 +2671,7 @@ const getNavigationForRightSinglePage = ({
|
|
|
2670
2671
|
position,
|
|
2671
2672
|
spineItem
|
|
2672
2673
|
);
|
|
2673
|
-
const
|
|
2674
|
+
const spineItemNavigation = getSpineItemPositionForLeftPage({
|
|
2674
2675
|
position: spineItemPosition,
|
|
2675
2676
|
spineItem,
|
|
2676
2677
|
pageHeight: context.getPageSize().height,
|
|
@@ -2678,21 +2679,21 @@ const getNavigationForRightSinglePage = ({
|
|
|
2678
2679
|
spineItemLocator: spineLocator.spineItemLocator
|
|
2679
2680
|
});
|
|
2680
2681
|
const isNewNavigationInCurrentItem = navigationResolver.arePositionsDifferent(
|
|
2681
|
-
|
|
2682
|
+
spineItemNavigation,
|
|
2682
2683
|
spineItemPosition
|
|
2683
2684
|
);
|
|
2684
2685
|
if (!isNewNavigationInCurrentItem) {
|
|
2685
2686
|
return navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
2686
|
-
pageTurnDirection === `horizontal` ? { x: position.x
|
|
2687
|
+
pageTurnDirection === `horizontal` ? { x: position.x - context.getPageSize().width, y: 0 } : { y: position.y - context.getPageSize().height, x: 0 }
|
|
2687
2688
|
);
|
|
2688
2689
|
}
|
|
2689
2690
|
const readingOrderPosition = spineLocator.getSpinePositionFromSpineItemPosition({
|
|
2690
|
-
spineItemPosition:
|
|
2691
|
+
spineItemPosition: spineItemNavigation,
|
|
2691
2692
|
spineItem
|
|
2692
2693
|
});
|
|
2693
2694
|
return readingOrderPosition;
|
|
2694
2695
|
};
|
|
2695
|
-
const
|
|
2696
|
+
const getNavigationForLeftOrTopPage = ({
|
|
2696
2697
|
position,
|
|
2697
2698
|
spineItem,
|
|
2698
2699
|
context,
|
|
@@ -2701,7 +2702,7 @@ const getNavigationForRightOrBottomPage = ({
|
|
|
2701
2702
|
spineLocator,
|
|
2702
2703
|
computedPageTurnDirection
|
|
2703
2704
|
}) => {
|
|
2704
|
-
const navigation =
|
|
2705
|
+
const navigation = getNavigationForLeftSinglePage({
|
|
2705
2706
|
position,
|
|
2706
2707
|
context,
|
|
2707
2708
|
navigationResolver,
|
|
@@ -2716,12 +2717,9 @@ const getNavigationForRightOrBottomPage = ({
|
|
|
2716
2717
|
if ((spineItem == null ? void 0 : spineItem.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
2717
2718
|
return navigationResolver.getAdjustedPositionForSpread(
|
|
2718
2719
|
navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
2719
|
-
context.isRTL() ? {
|
|
2720
|
+
context.isRTL() ? { ...navigation, x: navigation.x + context.getPageSize().width } : {
|
|
2720
2721
|
...navigation,
|
|
2721
2722
|
x: navigation.x - context.getPageSize().width
|
|
2722
|
-
} : {
|
|
2723
|
-
...navigation,
|
|
2724
|
-
x: navigation.x + context.getPageSize().width
|
|
2725
2723
|
}
|
|
2726
2724
|
)
|
|
2727
2725
|
);
|
|
@@ -2729,7 +2727,7 @@ const getNavigationForRightOrBottomPage = ({
|
|
|
2729
2727
|
if (computedPageTurnDirection === `vertical` && position.y !== navigation.y) {
|
|
2730
2728
|
return navigationResolver.getAdjustedPositionForSpread(navigation);
|
|
2731
2729
|
}
|
|
2732
|
-
const doubleNavigation =
|
|
2730
|
+
const doubleNavigation = getNavigationForLeftSinglePage({
|
|
2733
2731
|
position: navigation,
|
|
2734
2732
|
context,
|
|
2735
2733
|
navigationResolver,
|
|
@@ -2741,7 +2739,7 @@ const getNavigationForRightOrBottomPage = ({
|
|
|
2741
2739
|
}
|
|
2742
2740
|
return navigationResolver.getAdjustedPositionForSpread(navigation);
|
|
2743
2741
|
};
|
|
2744
|
-
const
|
|
2742
|
+
const getSpineItemPositionForRightPage = ({
|
|
2745
2743
|
position,
|
|
2746
2744
|
spineItem,
|
|
2747
2745
|
pageHeight,
|
|
@@ -2749,13 +2747,13 @@ const getSpineItemPositionForLeftPage = ({
|
|
|
2749
2747
|
spineItemLocator
|
|
2750
2748
|
}) => {
|
|
2751
2749
|
let nextPotentialPosition = {
|
|
2752
|
-
x: position.x
|
|
2750
|
+
x: position.x + pageWidth,
|
|
2753
2751
|
y: position.y
|
|
2754
2752
|
};
|
|
2755
2753
|
if (spineItem.isUsingVerticalWriting()) {
|
|
2756
2754
|
nextPotentialPosition = {
|
|
2757
2755
|
x: position.x,
|
|
2758
|
-
y: position.y
|
|
2756
|
+
y: position.y - pageHeight
|
|
2759
2757
|
};
|
|
2760
2758
|
}
|
|
2761
2759
|
const navigationPosition = spineItemLocator.getSpineItemClosestPositionFromUnsafePosition(
|
|
@@ -2764,7 +2762,7 @@ const getSpineItemPositionForLeftPage = ({
|
|
|
2764
2762
|
);
|
|
2765
2763
|
return navigationPosition;
|
|
2766
2764
|
};
|
|
2767
|
-
const
|
|
2765
|
+
const getNavigationForRightSinglePage = ({
|
|
2768
2766
|
position,
|
|
2769
2767
|
navigationResolver,
|
|
2770
2768
|
computedPageTurnDirection,
|
|
@@ -2782,7 +2780,7 @@ const getNavigationForLeftSinglePage = ({
|
|
|
2782
2780
|
position,
|
|
2783
2781
|
spineItem
|
|
2784
2782
|
);
|
|
2785
|
-
const
|
|
2783
|
+
const spineItemNavigationForRightPage = getSpineItemPositionForRightPage({
|
|
2786
2784
|
position: spineItemPosition,
|
|
2787
2785
|
spineItem,
|
|
2788
2786
|
pageHeight: context.getPageSize().height,
|
|
@@ -2790,21 +2788,21 @@ const getNavigationForLeftSinglePage = ({
|
|
|
2790
2788
|
spineItemLocator: spineLocator.spineItemLocator
|
|
2791
2789
|
});
|
|
2792
2790
|
const isNewNavigationInCurrentItem = navigationResolver.arePositionsDifferent(
|
|
2793
|
-
|
|
2791
|
+
spineItemNavigationForRightPage,
|
|
2794
2792
|
spineItemPosition
|
|
2795
2793
|
);
|
|
2796
2794
|
if (!isNewNavigationInCurrentItem) {
|
|
2797
2795
|
return navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
2798
|
-
pageTurnDirection === `horizontal` ? { x: position.x
|
|
2796
|
+
pageTurnDirection === `horizontal` ? { x: position.x + context.getPageSize().width, y: 0 } : { y: position.y + context.getPageSize().height, x: 0 }
|
|
2799
2797
|
);
|
|
2800
2798
|
}
|
|
2801
2799
|
const readingOrderPosition = spineLocator.getSpinePositionFromSpineItemPosition({
|
|
2802
|
-
spineItemPosition:
|
|
2800
|
+
spineItemPosition: spineItemNavigationForRightPage,
|
|
2803
2801
|
spineItem
|
|
2804
2802
|
});
|
|
2805
2803
|
return readingOrderPosition;
|
|
2806
2804
|
};
|
|
2807
|
-
const
|
|
2805
|
+
const getNavigationForRightOrBottomPage = ({
|
|
2808
2806
|
position,
|
|
2809
2807
|
spineItem,
|
|
2810
2808
|
context,
|
|
@@ -2813,7 +2811,7 @@ const getNavigationForLeftOrTopPage = ({
|
|
|
2813
2811
|
spineLocator,
|
|
2814
2812
|
computedPageTurnDirection
|
|
2815
2813
|
}) => {
|
|
2816
|
-
const navigation =
|
|
2814
|
+
const navigation = getNavigationForRightSinglePage({
|
|
2817
2815
|
position,
|
|
2818
2816
|
context,
|
|
2819
2817
|
navigationResolver,
|
|
@@ -2828,9 +2826,12 @@ const getNavigationForLeftOrTopPage = ({
|
|
|
2828
2826
|
if ((spineItem == null ? void 0 : spineItem.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
2829
2827
|
return navigationResolver.getAdjustedPositionForSpread(
|
|
2830
2828
|
navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
2831
|
-
context.isRTL() ? {
|
|
2829
|
+
context.isRTL() ? {
|
|
2832
2830
|
...navigation,
|
|
2833
2831
|
x: navigation.x - context.getPageSize().width
|
|
2832
|
+
} : {
|
|
2833
|
+
...navigation,
|
|
2834
|
+
x: navigation.x + context.getPageSize().width
|
|
2834
2835
|
}
|
|
2835
2836
|
)
|
|
2836
2837
|
);
|
|
@@ -2838,7 +2839,7 @@ const getNavigationForLeftOrTopPage = ({
|
|
|
2838
2839
|
if (computedPageTurnDirection === `vertical` && position.y !== navigation.y) {
|
|
2839
2840
|
return navigationResolver.getAdjustedPositionForSpread(navigation);
|
|
2840
2841
|
}
|
|
2841
|
-
const doubleNavigation =
|
|
2842
|
+
const doubleNavigation = getNavigationForRightSinglePage({
|
|
2842
2843
|
position: navigation,
|
|
2843
2844
|
context,
|
|
2844
2845
|
navigationResolver,
|
|
@@ -2850,7 +2851,6 @@ const getNavigationForLeftOrTopPage = ({
|
|
|
2850
2851
|
}
|
|
2851
2852
|
return navigationResolver.getAdjustedPositionForSpread(navigation);
|
|
2852
2853
|
};
|
|
2853
|
-
const report$4 = Report.namespace(`navigation`);
|
|
2854
2854
|
class ManualNavigator {
|
|
2855
2855
|
constructor(reader) {
|
|
2856
2856
|
this.reader = reader;
|
|
@@ -2943,7 +2943,8 @@ class ManualNavigator {
|
|
|
2943
2943
|
}
|
|
2944
2944
|
goToUrl(url) {
|
|
2945
2945
|
this.reader.navigation.navigate({
|
|
2946
|
-
url
|
|
2946
|
+
url,
|
|
2947
|
+
animation: false
|
|
2947
2948
|
});
|
|
2948
2949
|
}
|
|
2949
2950
|
goToRightSpineItem() {
|
|
@@ -5260,20 +5261,6 @@ const resolveCfi = ({
|
|
|
5260
5261
|
spineItem
|
|
5261
5262
|
};
|
|
5262
5263
|
};
|
|
5263
|
-
const isUsingSpreadMode = ({
|
|
5264
|
-
manifest,
|
|
5265
|
-
visibleAreaRect,
|
|
5266
|
-
forceSinglePageMode
|
|
5267
|
-
}) => {
|
|
5268
|
-
const { height, width } = visibleAreaRect;
|
|
5269
|
-
const isLandscape = width > height;
|
|
5270
|
-
if (forceSinglePageMode) return false;
|
|
5271
|
-
if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`) return false;
|
|
5272
|
-
if (!isLandscape && (manifest == null ? void 0 : manifest.renditionSpread) === `portrait`) {
|
|
5273
|
-
return true;
|
|
5274
|
-
}
|
|
5275
|
-
return isLandscape && ((manifest == null ? void 0 : manifest.renditionSpread) === void 0 || (manifest == null ? void 0 : manifest.renditionSpread) === `auto` || (manifest == null ? void 0 : manifest.renditionSpread) === `landscape` || (manifest == null ? void 0 : manifest.renditionSpread) === `both`);
|
|
5276
|
-
};
|
|
5277
5264
|
const isFullyPrePaginated = (manifest) => (manifest == null ? void 0 : manifest.renditionLayout) === "pre-paginated" || (manifest == null ? void 0 : manifest.spineItems.every((item) => item.renditionLayout === "pre-paginated"));
|
|
5278
5265
|
class BridgeEvent {
|
|
5279
5266
|
constructor() {
|
|
@@ -5296,12 +5283,27 @@ class BridgeEvent {
|
|
|
5296
5283
|
this.navigation$ = this.navigationSubject.asObservable();
|
|
5297
5284
|
}
|
|
5298
5285
|
}
|
|
5286
|
+
const isUsingSpreadMode = ({
|
|
5287
|
+
manifest,
|
|
5288
|
+
visibleAreaRect,
|
|
5289
|
+
forceSinglePageMode
|
|
5290
|
+
}) => {
|
|
5291
|
+
const { height, width } = visibleAreaRect;
|
|
5292
|
+
const isLandscape = width > height;
|
|
5293
|
+
if (forceSinglePageMode) return false;
|
|
5294
|
+
if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`) return false;
|
|
5295
|
+
if (!isLandscape && (manifest == null ? void 0 : manifest.renditionSpread) === `portrait`) {
|
|
5296
|
+
return true;
|
|
5297
|
+
}
|
|
5298
|
+
return isLandscape && ((manifest == null ? void 0 : manifest.renditionSpread) === void 0 || (manifest == null ? void 0 : manifest.renditionSpread) === `auto` || (manifest == null ? void 0 : manifest.renditionSpread) === `landscape` || (manifest == null ? void 0 : manifest.renditionSpread) === `both`);
|
|
5299
|
+
};
|
|
5299
5300
|
class Context {
|
|
5300
5301
|
constructor() {
|
|
5301
5302
|
this._stateSubject = new BehaviorSubject({
|
|
5302
5303
|
marginBottom: 0,
|
|
5303
5304
|
marginTop: 0,
|
|
5304
5305
|
calculatedInnerMargin: 0,
|
|
5306
|
+
assumedRenditionLayout: "reflowable",
|
|
5305
5307
|
visibleAreaRect: {
|
|
5306
5308
|
width: 0,
|
|
5307
5309
|
height: 0,
|
|
@@ -5359,7 +5361,8 @@ class Context {
|
|
|
5359
5361
|
height: newState.visibleAreaRect.height - marginTop - marginBottom
|
|
5360
5362
|
},
|
|
5361
5363
|
...newState.manifest && {
|
|
5362
|
-
isFullyPrePaginated: isFullyPrePaginated(manifest)
|
|
5364
|
+
isFullyPrePaginated: isFullyPrePaginated(manifest),
|
|
5365
|
+
assumedRenditionLayout: (manifest == null ? void 0 : manifest.renditionLayout) ?? "reflowable"
|
|
5363
5366
|
},
|
|
5364
5367
|
isUsingSpreadMode: isUsingSpreadMode({
|
|
5365
5368
|
manifest,
|