@prose-reader/core 1.68.0 → 1.70.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 +1 -1
- package/dist/index.js +78 -62
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +77 -61
- package/dist/index.umd.cjs.map +1 -1
- package/dist/navigation/Navigator.d.ts +1 -1
- package/dist/navigation/resolvers/NavigationResolver.d.ts +1 -1
- package/dist/navigation/resolvers/{wrapPositionWithSafeEdge.d.ts → getAdjustedPositionWithSafeEdge.d.ts} +2 -2
- package/dist/reader.d.ts +1 -1
- package/dist/spineItem/frame/FrameItem.d.ts +1 -1
- package/dist/spineItem/frame/loader/loader.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -705,7 +705,7 @@
|
|
|
705
705
|
spineItemPosition
|
|
706
706
|
);
|
|
707
707
|
if (!isNewNavigationInCurrentItem) {
|
|
708
|
-
return navigationResolver.
|
|
708
|
+
return navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
709
709
|
pageTurnDirection === `horizontal` ? { x: position.x + context.getPageSize().width, y: 0 } : { y: position.y + context.getPageSize().height, x: 0 }
|
|
710
710
|
);
|
|
711
711
|
} else {
|
|
@@ -739,7 +739,7 @@
|
|
|
739
739
|
if (context.state.isUsingSpreadMode) {
|
|
740
740
|
if ((spineItem == null ? void 0 : spineItem.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
741
741
|
return navigationResolver.getAdjustedPositionForSpread(
|
|
742
|
-
navigationResolver.
|
|
742
|
+
navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
743
743
|
context.isRTL() ? {
|
|
744
744
|
...navigation,
|
|
745
745
|
x: navigation.x - context.getPageSize().width
|
|
@@ -818,7 +818,7 @@
|
|
|
818
818
|
spineItemPosition
|
|
819
819
|
);
|
|
820
820
|
if (!isNewNavigationInCurrentItem) {
|
|
821
|
-
return navigationResolver.
|
|
821
|
+
return navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
822
822
|
pageTurnDirection === `horizontal` ? { x: position.x - context.getPageSize().width, y: 0 } : { y: position.y - context.getPageSize().height, x: 0 }
|
|
823
823
|
);
|
|
824
824
|
} else {
|
|
@@ -852,7 +852,7 @@
|
|
|
852
852
|
if (context.state.isUsingSpreadMode) {
|
|
853
853
|
if ((spineItem == null ? void 0 : spineItem.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
854
854
|
return navigationResolver.getAdjustedPositionForSpread(
|
|
855
|
-
navigationResolver.
|
|
855
|
+
navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
856
856
|
context.isRTL() ? { ...navigation, x: navigation.x + context.getPageSize().width } : {
|
|
857
857
|
...navigation,
|
|
858
858
|
x: navigation.x - context.getPageSize().width
|
|
@@ -2250,12 +2250,12 @@
|
|
|
2250
2250
|
const correctedX = isOffsetNotAtEdge ? x - pageSizeWidth : x;
|
|
2251
2251
|
return { x: correctedX, y };
|
|
2252
2252
|
};
|
|
2253
|
-
const
|
|
2253
|
+
const getAdjustedPositionWithSafeEdge = ({
|
|
2254
2254
|
position,
|
|
2255
2255
|
isRTL,
|
|
2256
|
-
pageSizeWidth,
|
|
2257
2256
|
pageSizeHeight,
|
|
2258
|
-
spineItemsManager
|
|
2257
|
+
spineItemsManager,
|
|
2258
|
+
visibleAreaRectWidth
|
|
2259
2259
|
}) => {
|
|
2260
2260
|
const lastSpineItem = spineItemsManager.get(spineItemsManager.getLength() - 1);
|
|
2261
2261
|
const distanceOfLastSpineItem = spineItemsManager.getAbsolutePositionOf(
|
|
@@ -2269,7 +2269,7 @@
|
|
|
2269
2269
|
y
|
|
2270
2270
|
};
|
|
2271
2271
|
}
|
|
2272
|
-
const maximumXOffset = distanceOfLastSpineItem.right -
|
|
2272
|
+
const maximumXOffset = distanceOfLastSpineItem.right - visibleAreaRectWidth;
|
|
2273
2273
|
return {
|
|
2274
2274
|
x: Math.min(Math.max(0, position.x), maximumXOffset),
|
|
2275
2275
|
y
|
|
@@ -3400,14 +3400,14 @@
|
|
|
3400
3400
|
const triggerPercentage = 0.5;
|
|
3401
3401
|
const triggerXPosition = pageTurnDirection === `horizontal` ? viewportPosition.x + context.state.visibleAreaRect.width * triggerPercentage : 0;
|
|
3402
3402
|
const triggerYPosition = pageTurnDirection === `horizontal` ? 0 : viewportPosition.y + context.state.visibleAreaRect.height * triggerPercentage;
|
|
3403
|
-
const midScreenPositionSafePosition =
|
|
3403
|
+
const midScreenPositionSafePosition = getAdjustedPositionWithSafeEdge({
|
|
3404
3404
|
position: {
|
|
3405
3405
|
x: triggerXPosition,
|
|
3406
3406
|
y: triggerYPosition
|
|
3407
3407
|
},
|
|
3408
3408
|
isRTL: context.isRTL(),
|
|
3409
3409
|
pageSizeHeight: context.getPageSize().height,
|
|
3410
|
-
|
|
3410
|
+
visibleAreaRectWidth: context.state.visibleAreaRect.width,
|
|
3411
3411
|
spineItemsManager
|
|
3412
3412
|
});
|
|
3413
3413
|
return getNavigationForPosition({
|
|
@@ -3456,11 +3456,11 @@
|
|
|
3456
3456
|
spineLocator: locator
|
|
3457
3457
|
}),
|
|
3458
3458
|
getMostPredominantNavigationForPosition,
|
|
3459
|
-
|
|
3459
|
+
getAdjustedPositionWithSafeEdge: (position) => getAdjustedPositionWithSafeEdge({
|
|
3460
3460
|
position,
|
|
3461
3461
|
isRTL: context.isRTL(),
|
|
3462
3462
|
pageSizeHeight: context.getPageSize().height,
|
|
3463
|
-
|
|
3463
|
+
visibleAreaRectWidth: context.state.visibleAreaRect.width,
|
|
3464
3464
|
spineItemsManager
|
|
3465
3465
|
}),
|
|
3466
3466
|
isNavigationGoingForwardFrom,
|
|
@@ -4149,7 +4149,7 @@
|
|
|
4149
4149
|
return {
|
|
4150
4150
|
navigation: {
|
|
4151
4151
|
...navigation,
|
|
4152
|
-
position: navigationResolver.
|
|
4152
|
+
position: navigationResolver.getAdjustedPositionWithSafeEdge(
|
|
4153
4153
|
navigation.position
|
|
4154
4154
|
)
|
|
4155
4155
|
},
|
|
@@ -5537,73 +5537,88 @@
|
|
|
5537
5537
|
const loadSubject = new rxjs.Subject();
|
|
5538
5538
|
const unloadSubject = new rxjs.Subject();
|
|
5539
5539
|
const frameElementSubject = new rxjs.BehaviorSubject(void 0);
|
|
5540
|
-
const
|
|
5541
|
-
const unload$ = unloadSubject.asObservable();
|
|
5542
|
-
const stateIdle$ = stateSubject.pipe(operators.filter((state) => state === "idle"));
|
|
5543
|
-
const stateIsReady$ = stateSubject.pipe(
|
|
5544
|
-
operators.map((state) => state === "ready"),
|
|
5545
|
-
operators.distinctUntilChanged()
|
|
5546
|
-
);
|
|
5547
|
-
const unloaded$ = unload$.pipe(
|
|
5540
|
+
const unloadFrame$ = unloadSubject.pipe(
|
|
5548
5541
|
operators.withLatestFrom(stateSubject),
|
|
5549
5542
|
operators.filter(([, state]) => state !== "unloading" && state !== "idle"),
|
|
5550
|
-
operators.exhaustMap(() => {
|
|
5551
|
-
stateSubject.next("unloading");
|
|
5552
|
-
return unloadFrame({
|
|
5553
|
-
hookManager,
|
|
5554
|
-
item,
|
|
5555
|
-
frameElement: frameElementSubject.getValue(),
|
|
5556
|
-
context
|
|
5557
|
-
}).pipe(
|
|
5558
|
-
operators.tap(() => {
|
|
5559
|
-
frameElementSubject.next(void 0);
|
|
5560
|
-
stateSubject.next("idle");
|
|
5561
|
-
})
|
|
5562
|
-
);
|
|
5563
|
-
}),
|
|
5564
|
-
operators.share()
|
|
5565
|
-
);
|
|
5566
|
-
const loaded$ = load$.pipe(
|
|
5567
5543
|
operators.exhaustMap(
|
|
5568
|
-
() =>
|
|
5544
|
+
() => context.bridgeEvent.viewportFree$.pipe(
|
|
5569
5545
|
operators.first(),
|
|
5570
|
-
operators.tap(() => {
|
|
5571
|
-
stateSubject.next("loading");
|
|
5572
|
-
}),
|
|
5573
|
-
waitForSwitch(context.bridgeEvent.viewportFree$),
|
|
5574
5546
|
operators.switchMap(
|
|
5575
|
-
() =>
|
|
5576
|
-
element: parent,
|
|
5547
|
+
() => unloadFrame({
|
|
5577
5548
|
hookManager,
|
|
5578
5549
|
item,
|
|
5579
|
-
|
|
5580
|
-
frameElementSubject.next(element);
|
|
5581
|
-
},
|
|
5582
|
-
settings,
|
|
5550
|
+
frameElement: frameElementSubject.getValue(),
|
|
5583
5551
|
context
|
|
5584
5552
|
})
|
|
5585
5553
|
),
|
|
5586
5554
|
operators.tap(() => {
|
|
5587
|
-
|
|
5555
|
+
frameElementSubject.next(void 0);
|
|
5588
5556
|
}),
|
|
5589
|
-
operators.
|
|
5557
|
+
operators.ignoreElements(),
|
|
5558
|
+
operators.startWith("loading"),
|
|
5559
|
+
operators.endWith("success"),
|
|
5560
|
+
operators.defaultIfEmpty("idle")
|
|
5590
5561
|
)
|
|
5591
5562
|
),
|
|
5563
|
+
operators.startWith("idle"),
|
|
5564
|
+
operators.distinctUntilChanged(),
|
|
5565
|
+
operators.share()
|
|
5566
|
+
);
|
|
5567
|
+
const unloaded$ = unloadFrame$.pipe(operators.filter((state) => state === "success"));
|
|
5568
|
+
const unloading$ = unloadFrame$.pipe(operators.filter((state) => state === "loading"));
|
|
5569
|
+
const loadFrame$ = loadSubject.pipe(
|
|
5570
|
+
operators.exhaustMap(() => {
|
|
5571
|
+
const preventFurtherLoad$ = rxjs.NEVER;
|
|
5572
|
+
return rxjs.merge(
|
|
5573
|
+
preventFurtherLoad$,
|
|
5574
|
+
context.bridgeEvent.viewportFree$.pipe(
|
|
5575
|
+
operators.first(),
|
|
5576
|
+
operators.switchMap(
|
|
5577
|
+
() => loadFrame({
|
|
5578
|
+
element: parent,
|
|
5579
|
+
hookManager,
|
|
5580
|
+
item,
|
|
5581
|
+
onFrameElement: (element) => {
|
|
5582
|
+
frameElementSubject.next(element);
|
|
5583
|
+
},
|
|
5584
|
+
settings,
|
|
5585
|
+
context
|
|
5586
|
+
})
|
|
5587
|
+
),
|
|
5588
|
+
operators.map((frame) => ({ state: "success", frame })),
|
|
5589
|
+
operators.startWith({ state: "loading" }),
|
|
5590
|
+
operators.defaultIfEmpty({ state: "idle" })
|
|
5591
|
+
)
|
|
5592
|
+
).pipe(operators.takeUntil(unloaded$));
|
|
5593
|
+
}),
|
|
5594
|
+
operators.startWith({ state: "idle" }),
|
|
5592
5595
|
operators.share()
|
|
5593
5596
|
);
|
|
5594
|
-
const
|
|
5597
|
+
const loading$ = loadFrame$.pipe(operators.filter(({ state }) => state === "loading"));
|
|
5598
|
+
const loaded$ = loadFrame$.pipe(
|
|
5599
|
+
operators.filter((state) => state.state === "success"),
|
|
5600
|
+
operators.map(({ frame }) => frame)
|
|
5601
|
+
);
|
|
5602
|
+
const frameIsReady$ = loaded$.pipe(
|
|
5595
5603
|
operators.switchMap(
|
|
5596
|
-
(frame) => rxjs.of(frame).pipe(
|
|
5597
|
-
waitForFrameReady,
|
|
5598
|
-
operators.tap(() => {
|
|
5599
|
-
stateSubject.next("ready");
|
|
5600
|
-
}),
|
|
5601
|
-
operators.takeUntil(unload$)
|
|
5602
|
-
)
|
|
5604
|
+
(frame) => rxjs.of(frame).pipe(waitForFrameReady, operators.takeUntil(unloadSubject))
|
|
5603
5605
|
),
|
|
5604
5606
|
operators.share()
|
|
5605
5607
|
);
|
|
5606
|
-
|
|
5608
|
+
const ready$ = frameIsReady$;
|
|
5609
|
+
const state$ = rxjs.merge(
|
|
5610
|
+
unloaded$.pipe(operators.map(() => "idle")),
|
|
5611
|
+
unloading$.pipe(operators.map(() => "unloading")),
|
|
5612
|
+
loaded$.pipe(operators.map(() => "loaded")),
|
|
5613
|
+
loading$.pipe(operators.map(() => "loading")),
|
|
5614
|
+
ready$.pipe(operators.map(() => "ready"))
|
|
5615
|
+
).pipe(
|
|
5616
|
+
operators.startWith("idle"),
|
|
5617
|
+
operators.tap((state) => stateSubject.next(state)),
|
|
5618
|
+
operators.shareReplay(1)
|
|
5619
|
+
);
|
|
5620
|
+
const isReady$ = state$.pipe(operators.map((state) => state === "ready"));
|
|
5621
|
+
state$.pipe(operators.takeUntil(destroySubject$)).subscribe();
|
|
5607
5622
|
return {
|
|
5608
5623
|
load: () => loadSubject.next(),
|
|
5609
5624
|
unload: () => unloadSubject.next(),
|
|
@@ -5614,6 +5629,7 @@
|
|
|
5614
5629
|
frameElementSubject.complete();
|
|
5615
5630
|
destroySubject$.next();
|
|
5616
5631
|
destroySubject$.complete();
|
|
5632
|
+
stateSubject.complete();
|
|
5617
5633
|
},
|
|
5618
5634
|
get state() {
|
|
5619
5635
|
return stateSubject.getValue();
|
|
@@ -5621,7 +5637,7 @@
|
|
|
5621
5637
|
get element() {
|
|
5622
5638
|
return frameElementSubject.getValue();
|
|
5623
5639
|
},
|
|
5624
|
-
isReady
|
|
5640
|
+
isReady$,
|
|
5625
5641
|
ready$,
|
|
5626
5642
|
loaded$,
|
|
5627
5643
|
unloaded$,
|