@prose-reader/core 1.41.0 → 1.43.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/index.d.ts +4366 -8
- package/dist/{prose.js → index.js} +632 -443
- package/dist/index.js.map +1 -0
- package/dist/{prose.umd.cjs → index.umd.cjs} +630 -441
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +7 -7
- package/dist/cfi.d.ts +0 -74
- package/dist/constants.d.ts +0 -6
- package/dist/context.d.ts +0 -44
- package/dist/createReaderWithEnhancer.d.ts +0 -5381
- package/dist/enhancers/accessibility.d.ts +0 -4890
- package/dist/enhancers/chrome.d.ts +0 -4890
- package/dist/enhancers/fonts.d.ts +0 -4904
- package/dist/enhancers/hotkeys.d.ts +0 -4890
- package/dist/enhancers/layoutEnhancer/createMovingSafePan$.d.ts +0 -3
- package/dist/enhancers/layoutEnhancer/fixReflowable.d.ts +0 -2
- package/dist/enhancers/layoutEnhancer/layoutEnhancer.d.ts +0 -4897
- package/dist/enhancers/layoutEnhancer/types.d.ts +0 -8
- package/dist/enhancers/links.d.ts +0 -4900
- package/dist/enhancers/loadingEnhancer.d.ts +0 -4919
- package/dist/enhancers/media.d.ts +0 -4890
- package/dist/enhancers/navigation.d.ts +0 -4893
- package/dist/enhancers/pagination.d.ts +0 -5279
- package/dist/enhancers/progression.d.ts +0 -4903
- package/dist/enhancers/resources/index.d.ts +0 -4890
- package/dist/enhancers/resources/indexedDB.d.ts +0 -6
- package/dist/enhancers/resources/resourcesManager.d.ts +0 -6
- package/dist/enhancers/theme.d.ts +0 -4916
- package/dist/enhancers/types/enhancer.d.ts +0 -4894
- package/dist/enhancers/utils.d.ts +0 -4894
- package/dist/enhancers/webkit.d.ts +0 -4890
- package/dist/enhancers/zoom/elementZoomer.d.ts +0 -18
- package/dist/enhancers/zoom/index.d.ts +0 -4891
- package/dist/enhancers/zoom/types.d.ts +0 -22
- package/dist/enhancers/zoom/viewportZoomer.d.ts +0 -18
- package/dist/frames.d.ts +0 -5
- package/dist/pagination.d.ts +0 -65
- package/dist/prose.js.map +0 -1
- package/dist/prose.umd.cjs.map +0 -1
- package/dist/reader.d.ts +0 -4907
- package/dist/report.d.ts +0 -26
- package/dist/selection.d.ts +0 -6
- package/dist/settings.d.ts +0 -39
- package/dist/spine/cfiLocator.d.ts +0 -371
- package/dist/spine/createSpine.d.ts +0 -29
- package/dist/spine/eventsHelper.d.ts +0 -11
- package/dist/spine/locationResolver.d.ts +0 -697
- package/dist/spine/navigationResolver.d.ts +0 -45
- package/dist/spine/types.d.ts +0 -10
- package/dist/spineItem/commonSpineItem.d.ts +0 -171
- package/dist/spineItem/createSpineItem.d.ts +0 -181
- package/dist/spineItem/frameItem/createFrame$.d.ts +0 -1
- package/dist/spineItem/frameItem/createFrameManipulator.d.ts +0 -5
- package/dist/spineItem/frameItem/createHtmlPageFromResource.d.ts +0 -2
- package/dist/spineItem/frameItem/frameItem.d.ts +0 -46
- package/dist/spineItem/frameItem/loader.d.ts +0 -27
- package/dist/spineItem/locationResolver.d.ts +0 -23
- package/dist/spineItem/navigationResolver.d.ts +0 -13
- package/dist/spineItem/prePaginatedSpineItem.d.ts +0 -180
- package/dist/spineItem/reflowableSpineItem.d.ts +0 -179
- package/dist/spineItem/styles/getStyleForViewportDocument.d.ts +0 -1
- package/dist/spineItem/trackers.d.ts +0 -34
- package/dist/spineItem/types.d.ts +0 -19
- package/dist/spineItemManager.d.ts +0 -550
- package/dist/types/Hook.d.ts +0 -73
- package/dist/types/Spine.d.ts +0 -39
- package/dist/types/index.d.ts +0 -11
- package/dist/utils/dom.d.ts +0 -19
- package/dist/utils/layout.d.ts +0 -7
- package/dist/utils/objects.d.ts +0 -6
- package/dist/utils/rxjs.d.ts +0 -4
- package/dist/viewportNavigator/manualViewportNavigator.d.ts +0 -1440
- package/dist/viewportNavigator/panViewportNavigator.d.ts +0 -215
- package/dist/viewportNavigator/scrollViewportNavigator.d.ts +0 -35
- package/dist/viewportNavigator/types.d.ts +0 -33
- package/dist/viewportNavigator/viewportNavigator.d.ts +0 -71
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("rxjs"), require("rxjs/operators"), require("@prose-reader/shared")) : typeof define === "function" && define.amd ? define(["exports", "rxjs", "rxjs/operators", "@prose-reader/shared"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.prose = {}, global.rxjs, global.operators, global.shared));
|
|
3
3
|
})(this, function(exports2, rxjs, operators, shared) {
|
|
4
4
|
"use strict";
|
|
5
|
-
const SHOULD_NOT_LAYOUT$3 = false;
|
|
6
5
|
const chromeEnhancer = (next) => (options) => {
|
|
7
6
|
const reader = next(options);
|
|
8
|
-
reader.
|
|
7
|
+
reader.context$.pipe(rxjs.takeUntil(reader.$.destroy$)).subscribe(({ containerElement }) => {
|
|
8
|
+
if (!containerElement)
|
|
9
|
+
return;
|
|
9
10
|
const onScroll = () => {
|
|
10
|
-
if (reader.
|
|
11
|
-
|
|
11
|
+
if (reader.settings.getSettings().computedPageTurnMode === `controlled`) {
|
|
12
|
+
containerElement.scrollTo(0, 0);
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
return SHOULD_NOT_LAYOUT$3;
|
|
15
|
+
containerElement.addEventListener(`scroll`, onScroll);
|
|
16
16
|
});
|
|
17
17
|
reader.registerHook(`item.onLoad`, ({ frame }) => {
|
|
18
18
|
var _a;
|
|
@@ -140,30 +140,35 @@
|
|
|
140
140
|
);
|
|
141
141
|
newSettings$.subscribe(settings$);
|
|
142
142
|
settings$.pipe(shouldRequireLayout, operators.tap(applyChangeToSpineItem), rxjs.takeUntil(reader.$.destroy$)).subscribe();
|
|
143
|
-
const settingsMerge$ = rxjs.combineLatest([reader.settings$, settings$]).pipe(
|
|
143
|
+
const settingsMerge$ = rxjs.combineLatest([reader.settings.settings$, settings$]).pipe(
|
|
144
144
|
rxjs.map(([innerSettings, settings]) => ({
|
|
145
145
|
...innerSettings,
|
|
146
146
|
...settings
|
|
147
147
|
}))
|
|
148
148
|
);
|
|
149
|
+
const setSettings = (settings) => {
|
|
150
|
+
const { fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2, ...passthroughSettings } = settings;
|
|
151
|
+
changes$.next({ fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2 });
|
|
152
|
+
reader.settings.setSettings(passthroughSettings);
|
|
153
|
+
};
|
|
149
154
|
return {
|
|
150
155
|
...reader,
|
|
151
156
|
destroy: () => {
|
|
152
157
|
changes$.complete();
|
|
153
158
|
settings$.complete();
|
|
159
|
+
reader.destroy();
|
|
154
160
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
settings$: settingsMerge$
|
|
161
|
+
settings: {
|
|
162
|
+
...reader.settings,
|
|
163
|
+
setSettings,
|
|
164
|
+
settings$: settingsMerge$
|
|
165
|
+
}
|
|
161
166
|
};
|
|
162
167
|
};
|
|
163
168
|
const hotkeysEnhancer = (next) => (options) => {
|
|
164
169
|
const reader = next(options);
|
|
165
170
|
const navigateOnKey = (document2) => rxjs.fromEvent(document2, "keyup").pipe(
|
|
166
|
-
rxjs.withLatestFrom(reader.settings$),
|
|
171
|
+
rxjs.withLatestFrom(reader.settings.settings$),
|
|
167
172
|
rxjs.map(([e, { pageTurnDirection }]) => {
|
|
168
173
|
if (pageTurnDirection === "horizontal") {
|
|
169
174
|
if (e.key === `ArrowRight`) {
|
|
@@ -199,22 +204,30 @@
|
|
|
199
204
|
).subscribe();
|
|
200
205
|
return reader;
|
|
201
206
|
};
|
|
202
|
-
const SHOULD_NOT_LAYOUT$2 = false;
|
|
203
207
|
const createMovingSafePan$ = (reader) => {
|
|
204
208
|
let iframeOverlayForAnimationsElement;
|
|
205
|
-
reader.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
209
|
+
const updateOverlayElement$ = reader.context$.pipe(
|
|
210
|
+
operators.switchMap(({ containerElement }) => {
|
|
211
|
+
if (!containerElement)
|
|
212
|
+
return rxjs.NEVER;
|
|
213
|
+
return new rxjs.Observable(() => {
|
|
214
|
+
iframeOverlayForAnimationsElement = containerElement.ownerDocument.createElement(`div`);
|
|
215
|
+
iframeOverlayForAnimationsElement.style.cssText = `
|
|
216
|
+
position: absolute;
|
|
217
|
+
left: 0;
|
|
218
|
+
top: 0;
|
|
219
|
+
width: 100%;
|
|
220
|
+
height: 100%;
|
|
221
|
+
visibility: hidden;
|
|
222
|
+
`;
|
|
223
|
+
containerElement.appendChild(iframeOverlayForAnimationsElement);
|
|
224
|
+
return () => {
|
|
225
|
+
iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.remove();
|
|
226
|
+
iframeOverlayForAnimationsElement = void 0;
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
})
|
|
230
|
+
);
|
|
218
231
|
const createResetLock$ = (source) => rxjs.scheduled(source, rxjs.animationFrameScheduler).pipe(
|
|
219
232
|
operators.tap(() => {
|
|
220
233
|
iframeOverlayForAnimationsElement == null ? void 0 : iframeOverlayForAnimationsElement.style.setProperty(`visibility`, `hidden`);
|
|
@@ -228,8 +241,8 @@
|
|
|
228
241
|
})
|
|
229
242
|
);
|
|
230
243
|
const resetLockViewportFree$ = createResetLock$(viewportFree$).pipe(operators.take(1));
|
|
231
|
-
const pageTurnMode$ = reader.
|
|
232
|
-
operators.map(() => reader.
|
|
244
|
+
const pageTurnMode$ = reader.settings.settings$.pipe(
|
|
245
|
+
operators.map(() => reader.settings.getSettings().computedPageTurnMode),
|
|
233
246
|
operators.distinctUntilChanged()
|
|
234
247
|
);
|
|
235
248
|
const handleViewportLock$ = pageTurnMode$.pipe(
|
|
@@ -238,7 +251,7 @@
|
|
|
238
251
|
),
|
|
239
252
|
operators.takeUntil(reader.$.destroy$)
|
|
240
253
|
);
|
|
241
|
-
return handleViewportLock
|
|
254
|
+
return rxjs.merge(updateOverlayElement$, handleViewportLock$);
|
|
242
255
|
};
|
|
243
256
|
const mapKeysTo = (keys) => {
|
|
244
257
|
return operators.map((obj) => {
|
|
@@ -274,7 +287,10 @@
|
|
|
274
287
|
}
|
|
275
288
|
});
|
|
276
289
|
};
|
|
277
|
-
|
|
290
|
+
function isDefined(arg) {
|
|
291
|
+
return arg !== null && arg !== void 0;
|
|
292
|
+
}
|
|
293
|
+
const SHOULD_NOT_LAYOUT = false;
|
|
278
294
|
const layoutEnhancer = (next) => (options) => {
|
|
279
295
|
const { pageHorizontalMargin = 24, pageVerticalMargin = 24 } = options;
|
|
280
296
|
const reader = next(options);
|
|
@@ -289,7 +305,7 @@
|
|
|
289
305
|
void frame.getBoundingClientRect().left;
|
|
290
306
|
hasRedrawn = true;
|
|
291
307
|
}
|
|
292
|
-
return SHOULD_NOT_LAYOUT
|
|
308
|
+
return SHOULD_NOT_LAYOUT;
|
|
293
309
|
});
|
|
294
310
|
});
|
|
295
311
|
reader.registerHook(`item.onLayoutBeforeMeasurement`, ({ frame, minimumWidth, item, isImageType }) => {
|
|
@@ -334,10 +350,17 @@
|
|
|
334
350
|
fixReflowable(reader);
|
|
335
351
|
let observer;
|
|
336
352
|
if (options.layoutAutoResize === `container`) {
|
|
337
|
-
|
|
338
|
-
|
|
353
|
+
reader.context$.pipe(
|
|
354
|
+
operators.map((state) => state.containerElement),
|
|
355
|
+
operators.filter(isDefined),
|
|
356
|
+
operators.distinctUntilChanged(),
|
|
357
|
+
operators.takeUntil(reader.$.destroy$)
|
|
358
|
+
).subscribe((container) => {
|
|
359
|
+
observer = new ResizeObserver(() => {
|
|
360
|
+
reader == null ? void 0 : reader.layout();
|
|
361
|
+
});
|
|
362
|
+
observer.observe(container);
|
|
339
363
|
});
|
|
340
|
-
observer.observe(options.containerElement);
|
|
341
364
|
}
|
|
342
365
|
const movingSafePan$ = createMovingSafePan$(reader);
|
|
343
366
|
movingSafePan$.subscribe();
|
|
@@ -350,27 +373,32 @@
|
|
|
350
373
|
}),
|
|
351
374
|
operators.takeUntil(reader.$.destroy$)
|
|
352
375
|
).subscribe();
|
|
376
|
+
const settings$ = rxjs.combineLatest([reader.settings.settings$, settingsSubject$.asObservable()]).pipe(
|
|
377
|
+
operators.map(([innerSettings, settings]) => ({
|
|
378
|
+
...innerSettings,
|
|
379
|
+
...settings
|
|
380
|
+
}))
|
|
381
|
+
);
|
|
382
|
+
const setSettings = ({ pageVerticalMargin: pageVerticalMargin2, pageHorizontalMargin: pageHorizontalMargin2, ...rest }) => {
|
|
383
|
+
if (pageHorizontalMargin2 !== void 0 || pageVerticalMargin2 !== void 0) {
|
|
384
|
+
settingsSubject$.next({
|
|
385
|
+
pageHorizontalMargin: pageHorizontalMargin2 ?? settingsSubject$.value.pageHorizontalMargin,
|
|
386
|
+
pageVerticalMargin: pageVerticalMargin2 ?? settingsSubject$.value.pageVerticalMargin
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
reader.settings.setSettings(rest);
|
|
390
|
+
};
|
|
353
391
|
return {
|
|
354
392
|
...reader,
|
|
355
393
|
destroy: () => {
|
|
356
394
|
reader.destroy();
|
|
357
395
|
observer == null ? void 0 : observer.disconnect();
|
|
358
396
|
},
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
reader.setSettings(rest);
|
|
367
|
-
},
|
|
368
|
-
settings$: rxjs.combineLatest([reader.settings$, settingsSubject$.asObservable()]).pipe(
|
|
369
|
-
operators.map(([innerSettings, settings]) => ({
|
|
370
|
-
...innerSettings,
|
|
371
|
-
...settings
|
|
372
|
-
}))
|
|
373
|
-
)
|
|
397
|
+
settings: {
|
|
398
|
+
...reader.settings,
|
|
399
|
+
setSettings,
|
|
400
|
+
settings$
|
|
401
|
+
}
|
|
374
402
|
};
|
|
375
403
|
};
|
|
376
404
|
const ROOT_NAMESPACE = `@prose-reader/core`;
|
|
@@ -462,13 +490,15 @@
|
|
|
462
490
|
const handleNavigationForClick = (element) => {
|
|
463
491
|
var _a;
|
|
464
492
|
if (!element.href)
|
|
465
|
-
return;
|
|
493
|
+
return false;
|
|
466
494
|
const hrefUrl = new URL(element.href);
|
|
467
495
|
const hrefWithoutAnchor = `${hrefUrl.origin}${hrefUrl.pathname}`;
|
|
468
496
|
const hasExistingSpineItem = (_a = reader.context.getManifest()) == null ? void 0 : _a.spineItems.some((item) => item.href === hrefWithoutAnchor);
|
|
469
497
|
if (hasExistingSpineItem) {
|
|
470
498
|
reader.goToUrl(hrefUrl);
|
|
499
|
+
return true;
|
|
471
500
|
}
|
|
501
|
+
return false;
|
|
472
502
|
};
|
|
473
503
|
reader.registerHook(`item.onLoad`, ({ frame }) => {
|
|
474
504
|
if (frame.contentDocument) {
|
|
@@ -477,8 +507,8 @@
|
|
|
477
507
|
if (e.target && `style` in e.target && `ELEMENT_NODE` in e.target) {
|
|
478
508
|
Report.warn(`prevented click on`, element, e);
|
|
479
509
|
e.preventDefault();
|
|
480
|
-
handleNavigationForClick(element);
|
|
481
|
-
subject.next({ event: `linkClicked`, data: element });
|
|
510
|
+
const isNavigable = handleNavigationForClick(element);
|
|
511
|
+
subject.next({ event: `linkClicked`, data: element, isNavigable });
|
|
482
512
|
}
|
|
483
513
|
})
|
|
484
514
|
);
|
|
@@ -492,8 +522,7 @@
|
|
|
492
522
|
}
|
|
493
523
|
};
|
|
494
524
|
};
|
|
495
|
-
const
|
|
496
|
-
const reader = next(options);
|
|
525
|
+
const createNavigator = (reader) => {
|
|
497
526
|
const goToNextSpineItem = () => {
|
|
498
527
|
var _a;
|
|
499
528
|
const focusedSpineItemIndex = reader.getFocusedSpineItemIndex() || 0;
|
|
@@ -513,14 +542,19 @@
|
|
|
513
542
|
}
|
|
514
543
|
};
|
|
515
544
|
return {
|
|
516
|
-
|
|
545
|
+
goToNextSpineItem,
|
|
546
|
+
goToPreviousSpineItem,
|
|
517
547
|
goToLeftSpineItem: () => {
|
|
548
|
+
if (reader.settings.getSettings().computedPageTurnDirection === "vertical")
|
|
549
|
+
return;
|
|
518
550
|
if (reader.context.isRTL()) {
|
|
519
551
|
return goToNextSpineItem();
|
|
520
552
|
}
|
|
521
553
|
return goToPreviousSpineItem();
|
|
522
554
|
},
|
|
523
555
|
goToRightSpineItem: () => {
|
|
556
|
+
if (reader.settings.getSettings().computedPageTurnDirection === "vertical")
|
|
557
|
+
return;
|
|
524
558
|
if (reader.context.isRTL()) {
|
|
525
559
|
return goToPreviousSpineItem();
|
|
526
560
|
}
|
|
@@ -528,15 +562,44 @@
|
|
|
528
562
|
}
|
|
529
563
|
};
|
|
530
564
|
};
|
|
565
|
+
const createState = (reader) => {
|
|
566
|
+
return reader.pagination.paginationInfo$.pipe(
|
|
567
|
+
rxjs.withLatestFrom(reader.context.$.manifest$, reader.settings.settings$),
|
|
568
|
+
rxjs.map(([paginationInfo, manifest, { computedPageTurnDirection }]) => {
|
|
569
|
+
const numberOfSpineItems = (manifest == null ? void 0 : manifest.spineItems.length) ?? 0;
|
|
570
|
+
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0 && paginationInfo.beginPageIndexInSpineItem === 0;
|
|
571
|
+
const isAtAbsoluteEnd = paginationInfo.endPageIndexInSpineItem === paginationInfo.endNumberOfPagesInSpineItem - 1 && paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
572
|
+
return {
|
|
573
|
+
canGoTopSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteBeginning,
|
|
574
|
+
canGoBottomSpineItem: computedPageTurnDirection === "vertical" && !isAtAbsoluteEnd,
|
|
575
|
+
canGoLeftSpineItem: computedPageTurnDirection !== "vertical" && ((manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteBeginning || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteEnd),
|
|
576
|
+
canGoRightSpineItem: computedPageTurnDirection !== "vertical" && ((manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteEnd || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteBeginning)
|
|
577
|
+
};
|
|
578
|
+
}),
|
|
579
|
+
rxjs.distinctUntilChanged(isShallowEqual)
|
|
580
|
+
);
|
|
581
|
+
};
|
|
582
|
+
const navigationEnhancer = (next) => (options) => {
|
|
583
|
+
const reader = next(options);
|
|
584
|
+
const state$ = createState(reader);
|
|
585
|
+
const navigator2 = createNavigator(reader);
|
|
586
|
+
return {
|
|
587
|
+
...reader,
|
|
588
|
+
navigation: {
|
|
589
|
+
...navigator2,
|
|
590
|
+
state$
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
};
|
|
531
594
|
const NAMESPACE$6 = `pagination`;
|
|
532
595
|
const createPagination = ({ context }) => {
|
|
533
596
|
const paginationSubject$ = new rxjs.BehaviorSubject({
|
|
534
|
-
|
|
535
|
-
|
|
597
|
+
beginPageIndexInSpineItem: void 0,
|
|
598
|
+
beginNumberOfPagesInSpineItem: 0,
|
|
536
599
|
beginCfi: void 0,
|
|
537
600
|
beginSpineItemIndex: void 0,
|
|
538
|
-
|
|
539
|
-
|
|
601
|
+
endPageIndexInSpineItem: void 0,
|
|
602
|
+
endNumberOfPagesInSpineItem: 0,
|
|
540
603
|
endCfi: void 0,
|
|
541
604
|
endSpineItemIndex: void 0
|
|
542
605
|
});
|
|
@@ -563,12 +626,12 @@
|
|
|
563
626
|
const beginInfo = getInfoForUpdate(begin);
|
|
564
627
|
const endInfo = getInfoForUpdate(end);
|
|
565
628
|
const newValues = {
|
|
566
|
-
|
|
567
|
-
|
|
629
|
+
beginPageIndexInSpineItem: beginInfo.pageIndex,
|
|
630
|
+
beginNumberOfPagesInSpineItem: beginInfo.numberOfPages,
|
|
568
631
|
beginCfi: beginInfo.cfi,
|
|
569
632
|
beginSpineItemIndex: begin.spineItemIndex,
|
|
570
|
-
|
|
571
|
-
|
|
633
|
+
endPageIndexInSpineItem: endInfo.pageIndex,
|
|
634
|
+
endNumberOfPagesInSpineItem: endInfo.numberOfPages,
|
|
572
635
|
endCfi: endInfo.cfi,
|
|
573
636
|
endSpineItemIndex: end.spineItemIndex
|
|
574
637
|
};
|
|
@@ -579,18 +642,19 @@
|
|
|
579
642
|
},
|
|
580
643
|
{ disable: true }
|
|
581
644
|
);
|
|
582
|
-
const
|
|
583
|
-
const
|
|
645
|
+
const getPaginationInfo = () => paginationSubject$.value;
|
|
646
|
+
const paginationInfo$ = paginationSubject$.pipe(
|
|
647
|
+
rxjs.distinctUntilChanged(isShallowEqual),
|
|
648
|
+
rxjs.filter(({ beginPageIndexInSpineItem }) => beginPageIndexInSpineItem !== void 0)
|
|
649
|
+
);
|
|
584
650
|
const destroy = () => {
|
|
585
651
|
paginationSubject$.complete();
|
|
586
652
|
};
|
|
587
653
|
return {
|
|
588
654
|
destroy,
|
|
589
655
|
updateBeginAndEnd,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
info$
|
|
593
|
-
}
|
|
656
|
+
getPaginationInfo,
|
|
657
|
+
paginationInfo$
|
|
594
658
|
};
|
|
595
659
|
};
|
|
596
660
|
const getItemOffsetFromPageIndex = (pageWidth, pageIndex, itemWidth) => {
|
|
@@ -621,15 +685,10 @@
|
|
|
621
685
|
};
|
|
622
686
|
const mapPaginationInfoToExtendedInfo = (paginationInfo) => {
|
|
623
687
|
const context = reader.context;
|
|
624
|
-
const manifest = context.getManifest();
|
|
625
|
-
const numberOfSpineItems = (manifest == null ? void 0 : manifest.spineItems.length) ?? 0;
|
|
626
688
|
const beginItem = paginationInfo.beginSpineItemIndex !== void 0 ? reader.getSpineItem(paginationInfo.beginSpineItemIndex) : void 0;
|
|
627
689
|
const endItem = paginationInfo.endSpineItemIndex !== void 0 ? reader.getSpineItem(paginationInfo.endSpineItemIndex) : void 0;
|
|
628
|
-
const isAtAbsoluteBeginning = paginationInfo.beginSpineItemIndex === 0 && paginationInfo.beginPageIndex === 0;
|
|
629
|
-
const isAtAbsoluteEnd = paginationInfo.endPageIndex === paginationInfo.endNumberOfPages - 1 && paginationInfo.endSpineItemIndex === Math.max(numberOfSpineItems - 1, 0);
|
|
630
690
|
return {
|
|
631
|
-
|
|
632
|
-
beginNumberOfPagesInChapter: paginationInfo.beginNumberOfPages,
|
|
691
|
+
...paginationInfo,
|
|
633
692
|
beginChapterInfo: beginItem ? chaptersInfo[beginItem.item.id] : void 0,
|
|
634
693
|
// chapterIndex: number;
|
|
635
694
|
// pages: number;
|
|
@@ -641,15 +700,9 @@
|
|
|
641
700
|
// domIndex: number;
|
|
642
701
|
// charOffset: number;
|
|
643
702
|
// serializeString?: string;
|
|
644
|
-
beginSpineItemIndex: paginationInfo.beginSpineItemIndex,
|
|
645
|
-
beginCfi: paginationInfo.beginCfi,
|
|
646
703
|
beginSpineItemReadingDirection: beginItem == null ? void 0 : beginItem.getReadingDirection(),
|
|
647
704
|
endChapterInfo: endItem ? chaptersInfo[endItem.item.id] : void 0,
|
|
648
|
-
endPageIndexInChapter: paginationInfo.endPageIndex,
|
|
649
|
-
endNumberOfPagesInChapter: paginationInfo.endNumberOfPages,
|
|
650
|
-
endSpineItemIndex: paginationInfo.endSpineItemIndex,
|
|
651
705
|
endSpineItemReadingDirection: endItem == null ? void 0 : endItem.getReadingDirection(),
|
|
652
|
-
endCfi: paginationInfo.endCfi,
|
|
653
706
|
// spineItemReadingDirection: focusedSpineItem?.getReadingDirection(),
|
|
654
707
|
/**
|
|
655
708
|
* This percentage is based of the weight (kb) of every items and the number of pages.
|
|
@@ -660,23 +713,21 @@
|
|
|
660
713
|
percentageEstimateOfBook: endItem ? reader.progression.getPercentageEstimate(
|
|
661
714
|
context,
|
|
662
715
|
paginationInfo.endSpineItemIndex ?? 0,
|
|
663
|
-
paginationInfo.
|
|
664
|
-
paginationInfo.
|
|
716
|
+
paginationInfo.endNumberOfPagesInSpineItem,
|
|
717
|
+
paginationInfo.endPageIndexInSpineItem || 0,
|
|
665
718
|
reader.getCurrentViewportPosition(),
|
|
666
719
|
endItem
|
|
667
720
|
) : 0,
|
|
668
|
-
isUsingSpread: context.
|
|
721
|
+
isUsingSpread: context.isUsingSpreadMode() ?? false
|
|
669
722
|
// hasNextChapter: (reader.spine.spineItemIndex || 0) < (manifest.readingOrder.length - 1),
|
|
670
723
|
// hasPreviousChapter: (reader.spine.spineItemIndex || 0) < (manifest.readingOrder.length - 1),
|
|
671
724
|
// numberOfSpineItems: context.getManifest()?.readingOrder.length,
|
|
672
|
-
canGoLeft: (manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteBeginning || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteEnd,
|
|
673
|
-
canGoRight: (manifest == null ? void 0 : manifest.readingDirection) === "ltr" && !isAtAbsoluteEnd || (manifest == null ? void 0 : manifest.readingDirection) === "rtl" && !isAtAbsoluteBeginning
|
|
674
725
|
};
|
|
675
726
|
};
|
|
676
727
|
const getSpineItemNumberOfPages = (spineItem) => {
|
|
677
728
|
const writingMode = spineItem.spineItemFrame.getWritingMode();
|
|
678
729
|
const { width, height } = spineItem.getElementDimensions();
|
|
679
|
-
const settings = reader.
|
|
730
|
+
const settings = reader.settings.getSettings();
|
|
680
731
|
if (settings.pageTurnDirection === `vertical` && settings.pageTurnMode === `scrollable`) {
|
|
681
732
|
return 1;
|
|
682
733
|
}
|
|
@@ -696,7 +747,7 @@
|
|
|
696
747
|
),
|
|
697
748
|
operators.takeUntil(reader.$.destroy$)
|
|
698
749
|
).subscribe();
|
|
699
|
-
const innerPaginationExtendedInfo$ = reader.pagination$.pipe(
|
|
750
|
+
const innerPaginationExtendedInfo$ = reader.pagination.paginationInfo$.pipe(
|
|
700
751
|
operators.map((info) => ({
|
|
701
752
|
...info,
|
|
702
753
|
...mapPaginationInfoToExtendedInfo(info)
|
|
@@ -705,7 +756,7 @@
|
|
|
705
756
|
);
|
|
706
757
|
const totalPages$ = reader.$.layout$.pipe(
|
|
707
758
|
operators.debounceTime(10, rxjs.animationFrameScheduler),
|
|
708
|
-
operators.withLatestFrom(reader.pagination$),
|
|
759
|
+
operators.withLatestFrom(reader.pagination.paginationInfo$),
|
|
709
760
|
operators.map(() => {
|
|
710
761
|
const numberOfPagesPerItems = getNumberOfPagesPerItems();
|
|
711
762
|
return {
|
|
@@ -722,19 +773,25 @@
|
|
|
722
773
|
numberOfTotalPages: 0
|
|
723
774
|
})
|
|
724
775
|
);
|
|
725
|
-
const
|
|
776
|
+
const paginationInfo$ = rxjs.combineLatest([
|
|
777
|
+
innerPaginationExtendedInfo$,
|
|
778
|
+
totalPages$
|
|
779
|
+
]).pipe(
|
|
726
780
|
operators.map(([pageInfo, totalPageInfo]) => ({
|
|
727
781
|
...pageInfo,
|
|
728
782
|
...totalPageInfo,
|
|
729
|
-
beginAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.beginSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.
|
|
730
|
-
endAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.endSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.
|
|
783
|
+
beginAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.beginSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.beginPageIndexInSpineItem ?? 0),
|
|
784
|
+
endAbsolutePageIndex: totalPageInfo.numberOfPagesPerItems.slice(0, pageInfo.endSpineItemIndex).reduce((acc, numberOfPagesForItem) => acc + numberOfPagesForItem, pageInfo.endPageIndexInSpineItem ?? 0)
|
|
731
785
|
})),
|
|
732
786
|
operators.shareReplay(1),
|
|
733
787
|
operators.takeUntil(reader.$.destroy$)
|
|
734
788
|
);
|
|
735
789
|
return {
|
|
736
790
|
...reader,
|
|
737
|
-
pagination
|
|
791
|
+
pagination: {
|
|
792
|
+
...reader.pagination,
|
|
793
|
+
paginationInfo$
|
|
794
|
+
}
|
|
738
795
|
};
|
|
739
796
|
};
|
|
740
797
|
const buildChapterInfoFromSpineItem = (manifest, item) => {
|
|
@@ -855,7 +912,6 @@
|
|
|
855
912
|
}
|
|
856
913
|
};
|
|
857
914
|
};
|
|
858
|
-
const SHOULD_NOT_LAYOUT = false;
|
|
859
915
|
const createElementZoomer = (reader) => {
|
|
860
916
|
const isZooming$ = new rxjs.BehaviorSubject(false);
|
|
861
917
|
let imageMagnifierContainer;
|
|
@@ -868,7 +924,8 @@
|
|
|
868
924
|
imgLastPosition = { x: 0, y: 0 };
|
|
869
925
|
baseScale = 1;
|
|
870
926
|
lastUserScale = 1;
|
|
871
|
-
reader.
|
|
927
|
+
const container = reader.context.getState().containerElement;
|
|
928
|
+
if (container) {
|
|
872
929
|
imageMagnifierContainer = container.ownerDocument.createElement(`div`);
|
|
873
930
|
imageMagnifierContainer.style.cssText = `
|
|
874
931
|
top: 0;
|
|
@@ -879,6 +936,7 @@
|
|
|
879
936
|
background: black;
|
|
880
937
|
width: 100%;
|
|
881
938
|
height: 100%;
|
|
939
|
+
user-select: none;
|
|
882
940
|
`;
|
|
883
941
|
const clonedImgElement = imgElement.cloneNode();
|
|
884
942
|
clonedImgElement.src = imgElement.src;
|
|
@@ -888,8 +946,7 @@
|
|
|
888
946
|
clonedImgElement.style.setProperty(`pointer-events`, `none`);
|
|
889
947
|
imageMagnifierContainer.appendChild(clonedImgElement);
|
|
890
948
|
container.appendChild(imageMagnifierContainer);
|
|
891
|
-
|
|
892
|
-
});
|
|
949
|
+
}
|
|
893
950
|
scale(1.2);
|
|
894
951
|
setCurrentScaleAsBase();
|
|
895
952
|
};
|
|
@@ -912,14 +969,14 @@
|
|
|
912
969
|
const move = (delta, { isFirst, isLast }) => {
|
|
913
970
|
const imgElement = imageMagnifierContainer == null ? void 0 : imageMagnifierContainer.querySelector(`img`);
|
|
914
971
|
if (isFirst) {
|
|
915
|
-
movingLastDelta =
|
|
972
|
+
movingLastDelta = delta;
|
|
916
973
|
}
|
|
917
974
|
if (delta) {
|
|
918
|
-
const
|
|
919
|
-
const
|
|
975
|
+
const newOffsetX = delta.x - ((movingLastDelta == null ? void 0 : movingLastDelta.x) || 0);
|
|
976
|
+
const newOffsetY = delta.y - ((movingLastDelta == null ? void 0 : movingLastDelta.y) || 0);
|
|
920
977
|
imgLastPosition = {
|
|
921
|
-
x: imgLastPosition.x +
|
|
922
|
-
y: imgLastPosition.y +
|
|
978
|
+
x: imgLastPosition.x + newOffsetX,
|
|
979
|
+
y: imgLastPosition.y + newOffsetY
|
|
923
980
|
};
|
|
924
981
|
imgElement == null ? void 0 : imgElement.style.setProperty(
|
|
925
982
|
`transform`,
|
|
@@ -933,11 +990,8 @@
|
|
|
933
990
|
};
|
|
934
991
|
const exit = () => {
|
|
935
992
|
lastUserScale = 1;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
imageMagnifierContainer = void 0;
|
|
939
|
-
return SHOULD_NOT_LAYOUT;
|
|
940
|
-
});
|
|
993
|
+
imageMagnifierContainer == null ? void 0 : imageMagnifierContainer.remove();
|
|
994
|
+
imageMagnifierContainer = void 0;
|
|
941
995
|
isZooming$.next(false);
|
|
942
996
|
};
|
|
943
997
|
const _isZooming = () => isZooming$.value;
|
|
@@ -981,7 +1035,10 @@
|
|
|
981
1035
|
};
|
|
982
1036
|
const enter = () => {
|
|
983
1037
|
reset();
|
|
984
|
-
reader.spine.
|
|
1038
|
+
const spineElement = reader.spine.getElement();
|
|
1039
|
+
if (spineElement) {
|
|
1040
|
+
spineElement.style.transformOrigin = `0 0`;
|
|
1041
|
+
}
|
|
985
1042
|
isZooming$.next(true);
|
|
986
1043
|
scale(1);
|
|
987
1044
|
setCurrentScaleAsBase();
|
|
@@ -990,23 +1047,27 @@
|
|
|
990
1047
|
baseScale = lastUserScale;
|
|
991
1048
|
};
|
|
992
1049
|
const scale = (userScale) => {
|
|
1050
|
+
const spineElement = reader.spine.getElement();
|
|
1051
|
+
const viewportElement = reader.viewportNavigator.getElement();
|
|
1052
|
+
if (!spineElement || !viewportElement)
|
|
1053
|
+
return;
|
|
993
1054
|
const roundedScale = Math.ceil((userScale < 1 ? baseScale - (1 - userScale) : baseScale + (userScale - 1)) * 100) / 100;
|
|
994
1055
|
const newScale = Math.max(roundedScale, 1);
|
|
995
|
-
const currentScale =
|
|
996
|
-
const currentScrollTop =
|
|
997
|
-
|
|
998
|
-
|
|
1056
|
+
const currentScale = spineElement.getBoundingClientRect().width / spineElement.offsetWidth;
|
|
1057
|
+
const currentScrollTop = viewportElement.scrollTop;
|
|
1058
|
+
spineElement.style.transform = `scale(${newScale})`;
|
|
1059
|
+
viewportElement.scrollLeft = getNewScaledOffset({
|
|
999
1060
|
newScale,
|
|
1000
1061
|
oldScale: currentScale,
|
|
1001
|
-
pageSize:
|
|
1002
|
-
screenSize:
|
|
1003
|
-
scrollOffset:
|
|
1062
|
+
pageSize: viewportElement.clientWidth,
|
|
1063
|
+
screenSize: spineElement.offsetWidth,
|
|
1064
|
+
scrollOffset: viewportElement.scrollLeft
|
|
1004
1065
|
});
|
|
1005
|
-
|
|
1066
|
+
viewportElement.scrollTop = getNewScaledOffset({
|
|
1006
1067
|
newScale,
|
|
1007
1068
|
oldScale: currentScale,
|
|
1008
|
-
pageSize:
|
|
1009
|
-
screenSize:
|
|
1069
|
+
pageSize: viewportElement.clientHeight,
|
|
1070
|
+
screenSize: spineElement.offsetHeight,
|
|
1010
1071
|
scrollOffset: currentScrollTop
|
|
1011
1072
|
});
|
|
1012
1073
|
lastUserScale = newScale;
|
|
@@ -1038,7 +1099,7 @@
|
|
|
1038
1099
|
const elementZoomer = createElementZoomer(reader);
|
|
1039
1100
|
const viewportZoomer = createViewportZoomer(reader);
|
|
1040
1101
|
const currentZoomerSubject$ = new rxjs.BehaviorSubject(void 0);
|
|
1041
|
-
const isUsingScrollableViewport = () => reader.
|
|
1102
|
+
const isUsingScrollableViewport = () => reader.settings.getSettings().computedPageTurnMode === `scrollable`;
|
|
1042
1103
|
const enter = (imgElement) => {
|
|
1043
1104
|
var _a;
|
|
1044
1105
|
(_a = currentZoomerSubject$ == null ? void 0 : currentZoomerSubject$.value) == null ? void 0 : _a.exit();
|
|
@@ -1104,83 +1165,44 @@
|
|
|
1104
1165
|
}
|
|
1105
1166
|
};
|
|
1106
1167
|
};
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
numberOfAdjacentSpineItemToPreLoad: 0,
|
|
1121
|
-
...initialSettings
|
|
1122
|
-
};
|
|
1123
|
-
updateComputedSettings(void 0, mergedSettings, false);
|
|
1124
|
-
const settingsSubject$ = new rxjs.BehaviorSubject(mergedSettings);
|
|
1125
|
-
const setSettings = (newSettings, options) => {
|
|
1126
|
-
if (Object.keys(newSettings).length === 0)
|
|
1127
|
-
return;
|
|
1128
|
-
const newMergedSettings = { ...settingsSubject$.value, ...newSettings };
|
|
1129
|
-
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWritingSubject);
|
|
1130
|
-
settingsSubject$.next(newMergedSettings);
|
|
1131
|
-
};
|
|
1132
|
-
const recompute = (options) => {
|
|
1133
|
-
const newMergedSettings = { ...settingsSubject$.value };
|
|
1134
|
-
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWritingSubject);
|
|
1135
|
-
settingsSubject$.next(newMergedSettings);
|
|
1136
|
-
};
|
|
1137
|
-
const destroy = () => {
|
|
1138
|
-
settingsSubject$.complete();
|
|
1139
|
-
};
|
|
1140
|
-
return {
|
|
1141
|
-
getSettings: () => settingsSubject$.value,
|
|
1142
|
-
setSettings,
|
|
1143
|
-
recompute,
|
|
1144
|
-
destroy,
|
|
1145
|
-
$: {
|
|
1146
|
-
settings$: settingsSubject$.asObservable().pipe(operators.distinctUntilChanged(isShallowEqual))
|
|
1147
|
-
}
|
|
1148
|
-
};
|
|
1149
|
-
};
|
|
1150
|
-
const areAllItemsPrePaginated$1 = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
1151
|
-
const updateComputedSettings = (newManifest, settings, hasVerticalWriting) => {
|
|
1152
|
-
settings.computedPageTurnDirection = settings.pageTurnDirection;
|
|
1153
|
-
settings.computedPageTurnAnimation = settings.pageTurnAnimation;
|
|
1154
|
-
settings.computedPageTurnMode = `controlled`;
|
|
1155
|
-
if ((newManifest == null ? void 0 : newManifest.renditionFlow) === `scrolled-continuous`) {
|
|
1156
|
-
settings.computedPageTurnMode = `scrollable`;
|
|
1157
|
-
settings.computedPageTurnDirection = `vertical`;
|
|
1158
|
-
} else if (newManifest && settings.pageTurnMode === `scrollable` && (newManifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated$1(newManifest))) {
|
|
1159
|
-
Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
|
|
1160
|
-
settings.computedPageTurnAnimation = `none`;
|
|
1161
|
-
settings.computedPageTurnMode = `controlled`;
|
|
1162
|
-
} else if (settings.pageTurnMode === `scrollable`) {
|
|
1163
|
-
settings.computedPageTurnMode = `scrollable`;
|
|
1164
|
-
settings.computedPageTurnDirection = `vertical`;
|
|
1165
|
-
}
|
|
1166
|
-
if (hasVerticalWriting && settings.computedPageTurnAnimation === `slide`) {
|
|
1167
|
-
Report.warn(
|
|
1168
|
-
`pageTurnAnimation ${settings.computedPageTurnAnimation} incompatible with current book, switching back to default`
|
|
1169
|
-
);
|
|
1170
|
-
settings.computedPageTurnAnimation = `none`;
|
|
1171
|
-
}
|
|
1172
|
-
if (settings.computedPageTurnMode === `scrollable`) {
|
|
1173
|
-
settings.computedPageTurnAnimationDuration = 0;
|
|
1174
|
-
settings.computedPageTurnAnimation = `none`;
|
|
1175
|
-
} else {
|
|
1176
|
-
settings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
|
|
1168
|
+
const isUsingSpreadMode = ({
|
|
1169
|
+
manifest,
|
|
1170
|
+
visibleAreaRect,
|
|
1171
|
+
forceSinglePageMode
|
|
1172
|
+
}) => {
|
|
1173
|
+
const { height, width } = visibleAreaRect;
|
|
1174
|
+
const isLandscape = width > height;
|
|
1175
|
+
if (forceSinglePageMode)
|
|
1176
|
+
return false;
|
|
1177
|
+
if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`)
|
|
1178
|
+
return false;
|
|
1179
|
+
if (!isLandscape && (manifest == null ? void 0 : manifest.renditionSpread) === `portrait`) {
|
|
1180
|
+
return true;
|
|
1177
1181
|
}
|
|
1182
|
+
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`);
|
|
1178
1183
|
};
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
+
const isFullyPrePaginated = (manifest) => (manifest == null ? void 0 : manifest.renditionLayout) === "pre-paginated" || (manifest == null ? void 0 : manifest.spineItems.every((item) => item.renditionLayout === "pre-paginated"));
|
|
1185
|
+
const createContext = (settings) => {
|
|
1186
|
+
const stateSubject = new rxjs.BehaviorSubject({});
|
|
1187
|
+
const manifest$ = stateSubject.pipe(
|
|
1188
|
+
operators.map((state) => state.manifest),
|
|
1189
|
+
operators.filter(isDefined),
|
|
1190
|
+
operators.distinctUntilChanged()
|
|
1191
|
+
);
|
|
1192
|
+
const containerElement$ = stateSubject.pipe(
|
|
1193
|
+
operators.map((state) => state.containerElement),
|
|
1194
|
+
operators.filter(isDefined),
|
|
1195
|
+
operators.distinctUntilChanged()
|
|
1196
|
+
);
|
|
1197
|
+
const hasVerticalWriting$ = stateSubject.pipe(
|
|
1198
|
+
operators.map((state) => state.hasVerticalWriting),
|
|
1199
|
+
operators.filter(isDefined),
|
|
1200
|
+
operators.distinctUntilChanged()
|
|
1201
|
+
);
|
|
1202
|
+
const isUsingSpreadMode$ = stateSubject.pipe(
|
|
1203
|
+
operators.map((state) => state.isUsingSpreadMode),
|
|
1204
|
+
operators.distinctUntilChanged()
|
|
1205
|
+
);
|
|
1184
1206
|
const visibleAreaRect = {
|
|
1185
1207
|
width: 0,
|
|
1186
1208
|
height: 0,
|
|
@@ -1190,82 +1212,113 @@
|
|
|
1190
1212
|
const marginTop = 0;
|
|
1191
1213
|
const marginBottom = 0;
|
|
1192
1214
|
const destroy$ = new rxjs.Subject();
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
if (settings.getSettings().forceSinglePageMode)
|
|
1198
|
-
return false;
|
|
1199
|
-
if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`)
|
|
1200
|
-
return false;
|
|
1201
|
-
if (!isLandscape && (manifest == null ? void 0 : manifest.renditionSpread) === `portrait`) {
|
|
1202
|
-
return true;
|
|
1215
|
+
const setState = (newState) => {
|
|
1216
|
+
const newCompleteState = { ...stateSubject.getValue(), ...newState };
|
|
1217
|
+
if (!isShallowEqual(newCompleteState, stateSubject.getValue())) {
|
|
1218
|
+
stateSubject.next(newCompleteState);
|
|
1203
1219
|
}
|
|
1204
|
-
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`);
|
|
1205
1220
|
};
|
|
1206
1221
|
const load = (newManifest, newLoadOptions) => {
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1222
|
+
setState({
|
|
1223
|
+
manifest: newManifest,
|
|
1224
|
+
...newLoadOptions,
|
|
1225
|
+
isFullyPrePaginated: isFullyPrePaginated(newManifest),
|
|
1226
|
+
isUsingSpreadMode: isUsingSpreadMode({
|
|
1227
|
+
manifest: newManifest,
|
|
1228
|
+
visibleAreaRect,
|
|
1229
|
+
forceSinglePageMode: settings.getSettings().forceSinglePageMode
|
|
1230
|
+
})
|
|
1231
|
+
});
|
|
1211
1232
|
};
|
|
1212
1233
|
const isRTL = () => {
|
|
1213
|
-
|
|
1234
|
+
var _a;
|
|
1235
|
+
return ((_a = stateSubject.getValue().manifest) == null ? void 0 : _a.readingDirection) === `rtl`;
|
|
1214
1236
|
};
|
|
1215
|
-
const setHasVerticalWriting = () =>
|
|
1216
|
-
|
|
1217
|
-
|
|
1237
|
+
const setHasVerticalWriting = (value) => setState({
|
|
1238
|
+
hasVerticalWriting: value
|
|
1239
|
+
});
|
|
1240
|
+
const recomputeSettings$ = rxjs.merge(hasVerticalWriting$, manifest$);
|
|
1241
|
+
recomputeSettings$.pipe(
|
|
1242
|
+
operators.withLatestFrom(hasVerticalWriting$, manifest$),
|
|
1243
|
+
operators.tap(([, hasVerticalWriting, manifest]) => {
|
|
1244
|
+
settings.recompute({ hasVerticalWriting, manifest });
|
|
1245
|
+
}),
|
|
1246
|
+
operators.takeUntil(destroy$)
|
|
1247
|
+
).subscribe();
|
|
1248
|
+
settings.$.settings$.pipe(
|
|
1249
|
+
operators.map(({ forceSinglePageMode }) => forceSinglePageMode),
|
|
1218
1250
|
operators.distinctUntilChanged(),
|
|
1219
|
-
operators.
|
|
1220
|
-
|
|
1251
|
+
operators.withLatestFrom(manifest$),
|
|
1252
|
+
operators.tap(([forceSinglePageMode, manifest]) => {
|
|
1253
|
+
setState({
|
|
1254
|
+
isUsingSpreadMode: isUsingSpreadMode({
|
|
1255
|
+
manifest,
|
|
1256
|
+
visibleAreaRect,
|
|
1257
|
+
forceSinglePageMode
|
|
1258
|
+
})
|
|
1259
|
+
});
|
|
1221
1260
|
}),
|
|
1222
1261
|
operators.takeUntil(destroy$)
|
|
1223
1262
|
).subscribe();
|
|
1224
1263
|
const destroy = () => {
|
|
1225
|
-
|
|
1226
|
-
loadSubject$.complete();
|
|
1264
|
+
stateSubject.complete();
|
|
1227
1265
|
destroy$.next();
|
|
1228
1266
|
destroy$.complete();
|
|
1229
|
-
hasVerticalWritingSubject$.complete();
|
|
1230
1267
|
};
|
|
1231
1268
|
return {
|
|
1232
1269
|
load,
|
|
1233
1270
|
isRTL,
|
|
1234
|
-
areAllItemsPrePaginated: () =>
|
|
1271
|
+
areAllItemsPrePaginated: () => {
|
|
1272
|
+
var _a;
|
|
1273
|
+
return areAllItemsPrePaginated$1((_a = stateSubject.getValue()) == null ? void 0 : _a.manifest);
|
|
1274
|
+
},
|
|
1235
1275
|
destroy,
|
|
1236
|
-
getLoadOptions: () => loadOptions,
|
|
1237
1276
|
getCalculatedInnerMargin: () => 0,
|
|
1238
1277
|
getVisibleAreaRect: () => visibleAreaRect,
|
|
1239
|
-
|
|
1278
|
+
isUsingSpreadMode: () => stateSubject.getValue().isUsingSpreadMode,
|
|
1240
1279
|
setHasVerticalWriting,
|
|
1241
1280
|
setVisibleAreaRect: ({ height, width, x, y }) => {
|
|
1242
1281
|
visibleAreaRect.width = width;
|
|
1243
1282
|
visibleAreaRect.height = height - marginTop - marginBottom;
|
|
1244
1283
|
visibleAreaRect.x = x;
|
|
1245
1284
|
visibleAreaRect.y = y;
|
|
1285
|
+
const manifest = stateSubject.getValue().manifest;
|
|
1286
|
+
if (manifest) {
|
|
1287
|
+
setState({
|
|
1288
|
+
isUsingSpreadMode: isUsingSpreadMode({
|
|
1289
|
+
manifest,
|
|
1290
|
+
visibleAreaRect,
|
|
1291
|
+
forceSinglePageMode: settings.getSettings().forceSinglePageMode
|
|
1292
|
+
})
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
getState: () => stateSubject.getValue(),
|
|
1297
|
+
getManifest: () => {
|
|
1298
|
+
var _a;
|
|
1299
|
+
return (_a = stateSubject.getValue()) == null ? void 0 : _a.manifest;
|
|
1300
|
+
},
|
|
1301
|
+
getReadingDirection: () => {
|
|
1302
|
+
var _a, _b;
|
|
1303
|
+
return (_b = (_a = stateSubject.getValue()) == null ? void 0 : _a.manifest) == null ? void 0 : _b.readingDirection;
|
|
1246
1304
|
},
|
|
1247
|
-
getManifest: () => manifest,
|
|
1248
|
-
getReadingDirection: () => manifest == null ? void 0 : manifest.readingDirection,
|
|
1249
1305
|
getPageSize: () => {
|
|
1250
1306
|
return {
|
|
1251
|
-
width:
|
|
1307
|
+
width: stateSubject.getValue().isUsingSpreadMode ? visibleAreaRect.width / 2 : visibleAreaRect.width,
|
|
1252
1308
|
height: visibleAreaRect.height
|
|
1253
1309
|
};
|
|
1254
1310
|
},
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
manifest
|
|
1259
|
-
}),
|
|
1311
|
+
containerElement$,
|
|
1312
|
+
isUsingSpreadMode$,
|
|
1313
|
+
hasVerticalWriting$,
|
|
1260
1314
|
$: {
|
|
1261
|
-
|
|
1315
|
+
manifest$,
|
|
1262
1316
|
destroy$: destroy$.asObservable(),
|
|
1263
|
-
|
|
1264
|
-
load$: loadSubject$.asObservable()
|
|
1317
|
+
state$: stateSubject.asObservable()
|
|
1265
1318
|
}
|
|
1266
1319
|
};
|
|
1267
1320
|
};
|
|
1268
|
-
const areAllItemsPrePaginated = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
1321
|
+
const areAllItemsPrePaginated$1 = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
1269
1322
|
const __UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT_KEY = `__UNSAFE_REFERENCE_ORIGINAL_IFRAME_EVENT`;
|
|
1270
1323
|
const ITEM_EXTENSION_VALID_FOR_FRAME_SRC = [`.xhtml`, `.html`, `.htm`];
|
|
1271
1324
|
const HTML_PREFIX$1 = `prose-reader`;
|
|
@@ -1382,7 +1435,8 @@
|
|
|
1382
1435
|
fetchResource,
|
|
1383
1436
|
hooks$,
|
|
1384
1437
|
context,
|
|
1385
|
-
viewportState
|
|
1438
|
+
viewportState$,
|
|
1439
|
+
settings
|
|
1386
1440
|
}) => {
|
|
1387
1441
|
const destroySubject$ = new rxjs.Subject();
|
|
1388
1442
|
const loadSubject$ = new rxjs.Subject();
|
|
@@ -1471,7 +1525,7 @@
|
|
|
1471
1525
|
if ((frame == null ? void 0 : frame.contentDocument) && body) {
|
|
1472
1526
|
computedStyleAfterLoad = (_b = frame == null ? void 0 : frame.contentWindow) == null ? void 0 : _b.getComputedStyle(body);
|
|
1473
1527
|
}
|
|
1474
|
-
if (
|
|
1528
|
+
if (settings.getSettings().computedPageTurnMode !== `scrollable`) {
|
|
1475
1529
|
frame.setAttribute(`tab-index`, `0`);
|
|
1476
1530
|
}
|
|
1477
1531
|
const manipulableFrame = createFrameManipulator(frame);
|
|
@@ -1540,7 +1594,8 @@
|
|
|
1540
1594
|
fetchResource,
|
|
1541
1595
|
context,
|
|
1542
1596
|
hooks$,
|
|
1543
|
-
viewportState
|
|
1597
|
+
viewportState$,
|
|
1598
|
+
settings
|
|
1544
1599
|
}) => {
|
|
1545
1600
|
const destroySubject$ = new rxjs.Subject();
|
|
1546
1601
|
const {
|
|
@@ -1549,7 +1604,7 @@
|
|
|
1549
1604
|
unload,
|
|
1550
1605
|
destroy: loaderDestroy,
|
|
1551
1606
|
getComputedStyleAfterLoad
|
|
1552
|
-
} = createLoader({ context, hooks$, item, parent, fetchResource, viewportState
|
|
1607
|
+
} = createLoader({ context, hooks$, item, parent, fetchResource, viewportState$, settings });
|
|
1553
1608
|
let isLoadedSync = false;
|
|
1554
1609
|
let isReadySync = false;
|
|
1555
1610
|
isLoaded$.subscribe({
|
|
@@ -1637,7 +1692,7 @@
|
|
|
1637
1692
|
if (frame) {
|
|
1638
1693
|
frame.style.width = `${size.width}px`;
|
|
1639
1694
|
frame.style.height = `${size.height}px`;
|
|
1640
|
-
if (
|
|
1695
|
+
if (settings.getSettings().computedPageTurnMode !== `scrollable`) {
|
|
1641
1696
|
frame.setAttribute(`tab-index`, `0`);
|
|
1642
1697
|
}
|
|
1643
1698
|
}
|
|
@@ -1902,9 +1957,12 @@
|
|
|
1902
1957
|
`pointermove`,
|
|
1903
1958
|
`pointerout`,
|
|
1904
1959
|
`pointerover`,
|
|
1905
|
-
`pointerup
|
|
1960
|
+
`pointerup`,
|
|
1961
|
+
`touchstart`,
|
|
1962
|
+
`touchend`
|
|
1906
1963
|
];
|
|
1907
1964
|
const mouseEvents = [
|
|
1965
|
+
`click`,
|
|
1908
1966
|
`mousedown`,
|
|
1909
1967
|
`mouseup`,
|
|
1910
1968
|
`mouseenter`,
|
|
@@ -1918,9 +1976,10 @@
|
|
|
1918
1976
|
item,
|
|
1919
1977
|
context,
|
|
1920
1978
|
parentElement,
|
|
1921
|
-
iframeEventBridgeElement
|
|
1979
|
+
iframeEventBridgeElement$,
|
|
1922
1980
|
hooks$,
|
|
1923
|
-
viewportState
|
|
1981
|
+
viewportState$,
|
|
1982
|
+
settings
|
|
1924
1983
|
}) => {
|
|
1925
1984
|
var _a;
|
|
1926
1985
|
const destroySubject$ = new rxjs.Subject();
|
|
@@ -1928,14 +1987,15 @@
|
|
|
1928
1987
|
const overlayElement = createOverlayElement(parentElement, item);
|
|
1929
1988
|
const fingerTracker = createFingerTracker();
|
|
1930
1989
|
const selectionTracker = createSelectionTracker();
|
|
1931
|
-
const frameHooks = createFrameHooks(iframeEventBridgeElement
|
|
1990
|
+
const frameHooks = createFrameHooks(iframeEventBridgeElement$, fingerTracker, selectionTracker);
|
|
1932
1991
|
const spineItemFrame = createFrameItem({
|
|
1933
1992
|
parent: containerElement,
|
|
1934
1993
|
item,
|
|
1935
1994
|
context,
|
|
1936
|
-
fetchResource: (_a = context.
|
|
1995
|
+
fetchResource: (_a = context.getState()) == null ? void 0 : _a.fetchResource,
|
|
1937
1996
|
hooks$: hooks$.asObservable().pipe(operators.map((hooks) => [...hooks, ...frameHooks])),
|
|
1938
|
-
viewportState
|
|
1997
|
+
viewportState$,
|
|
1998
|
+
settings
|
|
1939
1999
|
});
|
|
1940
2000
|
containerElement.appendChild(overlayElement);
|
|
1941
2001
|
parentElement.appendChild(containerElement);
|
|
@@ -2060,10 +2120,10 @@
|
|
|
2060
2120
|
};
|
|
2061
2121
|
};
|
|
2062
2122
|
const getResource = async () => {
|
|
2063
|
-
const
|
|
2123
|
+
const fetchResource = context.getState().fetchResource;
|
|
2064
2124
|
const lastFetch = (_) => {
|
|
2065
|
-
if (
|
|
2066
|
-
return
|
|
2125
|
+
if (fetchResource) {
|
|
2126
|
+
return fetchResource(item);
|
|
2067
2127
|
}
|
|
2068
2128
|
return fetch(item.href);
|
|
2069
2129
|
};
|
|
@@ -2199,7 +2259,7 @@
|
|
|
2199
2259
|
`;
|
|
2200
2260
|
return element;
|
|
2201
2261
|
};
|
|
2202
|
-
const createFrameHooks = (iframeEventBridgeElement
|
|
2262
|
+
const createFrameHooks = (iframeEventBridgeElement$, fingerTracker, selectionTracker) => {
|
|
2203
2263
|
return [
|
|
2204
2264
|
{
|
|
2205
2265
|
name: `item.onLoad`,
|
|
@@ -2207,6 +2267,7 @@
|
|
|
2207
2267
|
const unregister = passthroughEvents.map((event) => {
|
|
2208
2268
|
var _a;
|
|
2209
2269
|
const listener = (e) => {
|
|
2270
|
+
var _a2;
|
|
2210
2271
|
let convertedEvent = e;
|
|
2211
2272
|
if (isPointerEvent(e)) {
|
|
2212
2273
|
convertedEvent = new PointerEvent(e.type, e);
|
|
@@ -2216,7 +2277,7 @@
|
|
|
2216
2277
|
}
|
|
2217
2278
|
if (convertedEvent !== e) {
|
|
2218
2279
|
attachOriginalFrameEventToDocumentEvent(convertedEvent, e);
|
|
2219
|
-
iframeEventBridgeElement.dispatchEvent(convertedEvent);
|
|
2280
|
+
(_a2 = iframeEventBridgeElement$.getValue()) == null ? void 0 : _a2.dispatchEvent(convertedEvent);
|
|
2220
2281
|
}
|
|
2221
2282
|
};
|
|
2222
2283
|
(_a = frame.contentDocument) == null ? void 0 : _a.addEventListener(event, listener);
|
|
@@ -2246,17 +2307,19 @@
|
|
|
2246
2307
|
item,
|
|
2247
2308
|
context,
|
|
2248
2309
|
containerElement,
|
|
2249
|
-
iframeEventBridgeElement
|
|
2310
|
+
iframeEventBridgeElement$,
|
|
2250
2311
|
hooks$,
|
|
2251
|
-
viewportState
|
|
2312
|
+
viewportState$,
|
|
2313
|
+
settings
|
|
2252
2314
|
}) => {
|
|
2253
2315
|
const commonSpineItem = createCommonSpineItem({
|
|
2254
2316
|
context,
|
|
2255
2317
|
item,
|
|
2256
2318
|
parentElement: containerElement,
|
|
2257
|
-
iframeEventBridgeElement
|
|
2319
|
+
iframeEventBridgeElement$,
|
|
2258
2320
|
hooks$,
|
|
2259
|
-
viewportState
|
|
2321
|
+
viewportState$,
|
|
2322
|
+
settings
|
|
2260
2323
|
});
|
|
2261
2324
|
const spineItemFrame = commonSpineItem.spineItemFrame;
|
|
2262
2325
|
const layout = ({
|
|
@@ -2275,7 +2338,7 @@
|
|
|
2275
2338
|
const cssLink = buildDocumentStyle(
|
|
2276
2339
|
{
|
|
2277
2340
|
...commonSpineItem.getDimensionsForPaginatedContent(),
|
|
2278
|
-
enableTouch:
|
|
2341
|
+
enableTouch: settings.getSettings().computedPageTurnMode !== `scrollable`,
|
|
2279
2342
|
spreadPosition
|
|
2280
2343
|
},
|
|
2281
2344
|
viewportDimensions
|
|
@@ -2418,17 +2481,19 @@
|
|
|
2418
2481
|
item,
|
|
2419
2482
|
context,
|
|
2420
2483
|
containerElement,
|
|
2421
|
-
iframeEventBridgeElement
|
|
2484
|
+
iframeEventBridgeElement$,
|
|
2422
2485
|
hooks$,
|
|
2423
|
-
viewportState
|
|
2486
|
+
viewportState$,
|
|
2487
|
+
settings
|
|
2424
2488
|
}) => {
|
|
2425
2489
|
const commonSpineItem = createCommonSpineItem({
|
|
2426
2490
|
context,
|
|
2427
2491
|
item,
|
|
2428
2492
|
parentElement: containerElement,
|
|
2429
|
-
iframeEventBridgeElement
|
|
2493
|
+
iframeEventBridgeElement$,
|
|
2430
2494
|
hooks$,
|
|
2431
|
-
viewportState
|
|
2495
|
+
viewportState$,
|
|
2496
|
+
settings
|
|
2432
2497
|
});
|
|
2433
2498
|
const spineItemFrame = commonSpineItem.spineItemFrame;
|
|
2434
2499
|
let latestContentHeightWhenLoaded;
|
|
@@ -2467,7 +2532,7 @@
|
|
|
2467
2532
|
} else {
|
|
2468
2533
|
const frameStyle = commonSpineItem.isImageType() ? buildStyleForReflowableImageOnly({
|
|
2469
2534
|
isScrollable: ((_g = context.getManifest()) == null ? void 0 : _g.renditionFlow) === `scrolled-continuous`,
|
|
2470
|
-
enableTouch:
|
|
2535
|
+
enableTouch: settings.getSettings().computedPageTurnMode !== `scrollable`
|
|
2471
2536
|
}) : buildStyleWithMultiColumn(
|
|
2472
2537
|
commonSpineItem.getDimensionsForReflowableContent(spineItemFrame.isUsingVerticalWriting(), minimumWidth)
|
|
2473
2538
|
);
|
|
@@ -2692,36 +2757,39 @@
|
|
|
2692
2757
|
item,
|
|
2693
2758
|
context,
|
|
2694
2759
|
containerElement,
|
|
2695
|
-
iframeEventBridgeElement
|
|
2760
|
+
iframeEventBridgeElement$,
|
|
2696
2761
|
hooks$,
|
|
2697
|
-
viewportState
|
|
2762
|
+
viewportState$,
|
|
2763
|
+
settings
|
|
2698
2764
|
}) => {
|
|
2699
2765
|
if (item.renditionLayout === `pre-paginated`) {
|
|
2700
2766
|
return createPrePaginatedSpineItem({
|
|
2701
2767
|
item,
|
|
2702
2768
|
context,
|
|
2703
2769
|
containerElement,
|
|
2704
|
-
iframeEventBridgeElement
|
|
2770
|
+
iframeEventBridgeElement$,
|
|
2705
2771
|
hooks$,
|
|
2706
|
-
viewportState
|
|
2772
|
+
viewportState$,
|
|
2773
|
+
settings
|
|
2707
2774
|
});
|
|
2708
2775
|
}
|
|
2709
2776
|
return createReflowableSpineItem({
|
|
2710
2777
|
item,
|
|
2711
2778
|
context,
|
|
2712
2779
|
containerElement,
|
|
2713
|
-
iframeEventBridgeElement
|
|
2780
|
+
iframeEventBridgeElement$,
|
|
2714
2781
|
hooks$,
|
|
2715
|
-
viewportState
|
|
2782
|
+
viewportState$,
|
|
2783
|
+
settings
|
|
2716
2784
|
});
|
|
2717
2785
|
};
|
|
2718
2786
|
const createEventsHelper = ({
|
|
2719
|
-
iframeEventBridgeElement
|
|
2787
|
+
iframeEventBridgeElement$,
|
|
2720
2788
|
locator
|
|
2721
2789
|
}) => {
|
|
2722
2790
|
const normalizeEventForViewport = (event) => {
|
|
2723
2791
|
var _a;
|
|
2724
|
-
const eventIsComingFromBridge = event.target === iframeEventBridgeElement;
|
|
2792
|
+
const eventIsComingFromBridge = event.target === iframeEventBridgeElement$.getValue();
|
|
2725
2793
|
const iframeOriginalEvent = getOriginalFrameEventFromDocumentEvent(event);
|
|
2726
2794
|
const originalFrame = (_a = iframeOriginalEvent == null ? void 0 : iframeOriginalEvent.view) == null ? void 0 : _a.frameElement;
|
|
2727
2795
|
if (!eventIsComingFromBridge || !iframeOriginalEvent || !originalFrame)
|
|
@@ -3669,11 +3737,12 @@
|
|
|
3669
3737
|
};
|
|
3670
3738
|
};
|
|
3671
3739
|
const report = Report.namespace(`spine`);
|
|
3740
|
+
const noopElement$1 = document.createElement("div");
|
|
3672
3741
|
const createSpine = ({
|
|
3673
|
-
|
|
3742
|
+
element$,
|
|
3674
3743
|
context,
|
|
3675
3744
|
pagination,
|
|
3676
|
-
iframeEventBridgeElement
|
|
3745
|
+
iframeEventBridgeElement$,
|
|
3677
3746
|
spineItemManager,
|
|
3678
3747
|
hooks$,
|
|
3679
3748
|
spineItemLocator,
|
|
@@ -3682,31 +3751,32 @@
|
|
|
3682
3751
|
navigation$,
|
|
3683
3752
|
navigationAdjusted$,
|
|
3684
3753
|
currentNavigationPosition$,
|
|
3685
|
-
viewportState
|
|
3754
|
+
viewportState$,
|
|
3755
|
+
settings
|
|
3686
3756
|
}) => {
|
|
3687
3757
|
const spineItems$ = new rxjs.Subject();
|
|
3688
3758
|
const itemsBeforeDestroySubject$ = new rxjs.Subject();
|
|
3689
3759
|
const subject = new rxjs.Subject();
|
|
3690
|
-
const containerElement =
|
|
3760
|
+
const containerElement$ = new rxjs.BehaviorSubject(noopElement$1);
|
|
3691
3761
|
const eventsHelper = createEventsHelper({
|
|
3692
3762
|
context,
|
|
3693
3763
|
spineItemManager,
|
|
3694
|
-
iframeEventBridgeElement
|
|
3764
|
+
iframeEventBridgeElement$,
|
|
3695
3765
|
locator: spineLocator
|
|
3696
3766
|
});
|
|
3697
3767
|
let selectionSubscription;
|
|
3698
|
-
const reload = () => {
|
|
3699
|
-
var _a;
|
|
3768
|
+
const reload = (manifest) => {
|
|
3700
3769
|
itemsBeforeDestroySubject$.next();
|
|
3701
3770
|
spineItemManager.destroyItems();
|
|
3702
|
-
|
|
3771
|
+
manifest.spineItems.map((resource) => {
|
|
3703
3772
|
const spineItem = createSpineItem({
|
|
3704
3773
|
item: resource,
|
|
3705
|
-
containerElement,
|
|
3706
|
-
iframeEventBridgeElement
|
|
3774
|
+
containerElement: containerElement$.getValue(),
|
|
3775
|
+
iframeEventBridgeElement$,
|
|
3707
3776
|
context,
|
|
3708
3777
|
hooks$,
|
|
3709
|
-
viewportState
|
|
3778
|
+
viewportState$,
|
|
3779
|
+
settings
|
|
3710
3780
|
});
|
|
3711
3781
|
spineItemManager.add(spineItem);
|
|
3712
3782
|
});
|
|
@@ -3725,7 +3795,7 @@
|
|
|
3725
3795
|
var _a;
|
|
3726
3796
|
(_a = spineItemManager.get(id)) == null ? void 0 : _a.manipulateSpineItem(cb);
|
|
3727
3797
|
};
|
|
3728
|
-
context.$.
|
|
3798
|
+
context.$.manifest$.pipe(operators.tap(reload), operators.takeUntil(context.$.destroy$)).subscribe();
|
|
3729
3799
|
const waitForViewportFree$ = viewportState$.pipe(
|
|
3730
3800
|
operators.filter((v) => v === `free`),
|
|
3731
3801
|
operators.take(1)
|
|
@@ -3740,10 +3810,10 @@
|
|
|
3740
3810
|
const spineItemsFromPosition = spineLocator.getSpineItemsFromReadingOrderPosition(position);
|
|
3741
3811
|
const beginSpineItem = spineItemsFromPosition ? spineItemManager.get(spineItemsFromPosition.begin) : void 0;
|
|
3742
3812
|
const endSpineItem = spineItemsFromPosition ? spineItemManager.get(spineItemsFromPosition.end) : void 0;
|
|
3743
|
-
const beginLastCfi = pagination.
|
|
3744
|
-
const endLastCfi = pagination.
|
|
3745
|
-
const shouldUpdateBeginCfi = pagination.
|
|
3746
|
-
const shouldUpdateEndCfi = pagination.
|
|
3813
|
+
const beginLastCfi = pagination.getPaginationInfo().beginCfi;
|
|
3814
|
+
const endLastCfi = pagination.getPaginationInfo().endCfi;
|
|
3815
|
+
const shouldUpdateBeginCfi = pagination.getPaginationInfo().beginSpineItemIndex !== (spineItemsFromPosition == null ? void 0 : spineItemsFromPosition.begin) || beginLastCfi === void 0 || (beginLastCfi == null ? void 0 : beginLastCfi.startsWith(`epubcfi(/0`));
|
|
3816
|
+
const shouldUpdateEndCfi = pagination.getPaginationInfo().endSpineItemIndex !== (spineItemsFromPosition == null ? void 0 : spineItemsFromPosition.end) || endLastCfi === void 0 || (endLastCfi == null ? void 0 : endLastCfi.startsWith(`epubcfi(/0`));
|
|
3747
3817
|
if (beginSpineItem && endSpineItem && spineItemsFromPosition) {
|
|
3748
3818
|
const beginPosition = spineLocator.getSpineItemPositionFromSpinePosition(
|
|
3749
3819
|
spineItemsFromPosition.beginPosition,
|
|
@@ -3863,7 +3933,7 @@
|
|
|
3863
3933
|
*
|
|
3864
3934
|
* The cfi is later adjusted with heavy dom lookup once the viewport is free.
|
|
3865
3935
|
*/
|
|
3866
|
-
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === beginSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` &&
|
|
3936
|
+
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === beginSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` && settings.getSettings().computedPageTurnMode === `controlled` ? pagination.getPaginationInfo().beginCfi : beginItemIndex !== pagination.getPaginationInfo().beginSpineItemIndex ? cfiLocator.getRootCfi(beginSpineItem) : (
|
|
3867
3937
|
/* @todo check ? */
|
|
3868
3938
|
cfiLocator.getRootCfi(beginSpineItem)
|
|
3869
3939
|
),
|
|
@@ -3875,7 +3945,7 @@
|
|
|
3875
3945
|
spineItem: endSpineItem,
|
|
3876
3946
|
spineItemIndex: endItemIndex,
|
|
3877
3947
|
pageIndex: endPageIndex,
|
|
3878
|
-
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === endSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` &&
|
|
3948
|
+
cfi: (lastExpectedNavigation == null ? void 0 : lastExpectedNavigation.type) === `navigate-from-cfi` && spineItemToFocus === endSpineItem ? lastExpectedNavigation.data : data.triggeredBy === `adjust` && settings.getSettings().computedPageTurnMode === `controlled` ? pagination.getPaginationInfo().endCfi : endItemIndex !== pagination.getPaginationInfo().endSpineItemIndex ? cfiLocator.getRootCfi(endSpineItem) : (
|
|
3879
3949
|
/* @todo check ? */
|
|
3880
3950
|
cfiLocator.getRootCfi(endSpineItem)
|
|
3881
3951
|
),
|
|
@@ -3941,8 +4011,13 @@
|
|
|
3941
4011
|
}),
|
|
3942
4012
|
operators.takeUntil(context.$.destroy$)
|
|
3943
4013
|
).subscribe();
|
|
4014
|
+
const elementSub = element$.pipe().subscribe((element) => {
|
|
4015
|
+
const containerElement = createContainerElement(element.ownerDocument);
|
|
4016
|
+
containerElement$.next(containerElement);
|
|
4017
|
+
});
|
|
3944
4018
|
return {
|
|
3945
|
-
element
|
|
4019
|
+
element$: containerElement$,
|
|
4020
|
+
getElement: () => containerElement$.getValue(),
|
|
3946
4021
|
locator: spineLocator,
|
|
3947
4022
|
spineItemLocator,
|
|
3948
4023
|
cfiLocator,
|
|
@@ -3950,13 +4025,14 @@
|
|
|
3950
4025
|
manipulateSpineItems,
|
|
3951
4026
|
manipulateSpineItem,
|
|
3952
4027
|
destroy: () => {
|
|
4028
|
+
elementSub.unsubscribe();
|
|
3953
4029
|
spineItems$.complete();
|
|
3954
4030
|
itemsBeforeDestroySubject$.next();
|
|
3955
4031
|
itemsBeforeDestroySubject$.complete();
|
|
3956
4032
|
subject.complete();
|
|
3957
4033
|
spineItemManager.destroy();
|
|
3958
4034
|
selectionSubscription == null ? void 0 : selectionSubscription.unsubscribe();
|
|
3959
|
-
containerElement.remove();
|
|
4035
|
+
containerElement$.getValue().remove();
|
|
3960
4036
|
},
|
|
3961
4037
|
adjustPagination,
|
|
3962
4038
|
isSelecting: () => {
|
|
@@ -3975,22 +4051,17 @@
|
|
|
3975
4051
|
}
|
|
3976
4052
|
};
|
|
3977
4053
|
};
|
|
3978
|
-
const createContainerElement = (doc
|
|
4054
|
+
const createContainerElement = (doc) => {
|
|
3979
4055
|
const element = doc.createElement(`div`);
|
|
3980
4056
|
element.style.cssText = `
|
|
3981
4057
|
height: 100%;
|
|
3982
4058
|
position: relative;
|
|
3983
4059
|
`;
|
|
3984
4060
|
element.className = `${HTML_PREFIX$1}-spine`;
|
|
3985
|
-
return
|
|
3986
|
-
if (hook.name === `spine.onBeforeContainerCreated`) {
|
|
3987
|
-
return hook.fn(element2);
|
|
3988
|
-
}
|
|
3989
|
-
return element2;
|
|
3990
|
-
}, element);
|
|
4061
|
+
return element;
|
|
3991
4062
|
};
|
|
3992
4063
|
const NAMESPACE$4 = `spineItemManager`;
|
|
3993
|
-
const createSpineItemManager = ({ context }) => {
|
|
4064
|
+
const createSpineItemManager = ({ context, settings }) => {
|
|
3994
4065
|
const focus$ = new rxjs.Subject();
|
|
3995
4066
|
const layout$ = new rxjs.Subject();
|
|
3996
4067
|
let itemLayoutInformation = [];
|
|
@@ -4006,7 +4077,7 @@
|
|
|
4006
4077
|
let blankPagePosition = `none`;
|
|
4007
4078
|
const itemStartOnNewScreen = horizontalOffset % context.getVisibleAreaRect().width === 0;
|
|
4008
4079
|
const isLastItem = index === orderedSpineItemsSubject$.value.length - 1;
|
|
4009
|
-
if (context.
|
|
4080
|
+
if (context.isUsingSpreadMode()) {
|
|
4010
4081
|
if (!isGloballyPrePaginated && item.item.renditionLayout === `reflowable` && !isLastItem) {
|
|
4011
4082
|
minimumWidth = context.getPageSize().width * 2;
|
|
4012
4083
|
}
|
|
@@ -4032,9 +4103,9 @@
|
|
|
4032
4103
|
const { width, height } = item.layout({
|
|
4033
4104
|
minimumWidth,
|
|
4034
4105
|
blankPagePosition,
|
|
4035
|
-
spreadPosition: context.
|
|
4106
|
+
spreadPosition: context.isUsingSpreadMode() ? itemStartOnNewScreen ? context.isRTL() ? `right` : `left` : context.isRTL() ? `left` : `right` : `none`
|
|
4036
4107
|
});
|
|
4037
|
-
if (
|
|
4108
|
+
if (settings.getSettings().computedPageTurnDirection === `vertical`) {
|
|
4038
4109
|
const currentValidEdgeYForVerticalPositioning = itemStartOnNewScreen ? verticalOffset : verticalOffset - context.getVisibleAreaRect().height;
|
|
4039
4110
|
const currentValidEdgeXForVerticalPositioning = itemStartOnNewScreen ? 0 : horizontalOffset;
|
|
4040
4111
|
if (context.isRTL()) {
|
|
@@ -4102,9 +4173,9 @@
|
|
|
4102
4173
|
const loadContents = Report.measurePerformance(`loadContents`, 10, (rangeOfIndex) => {
|
|
4103
4174
|
var _a;
|
|
4104
4175
|
const [leftIndex, rightIndex] = rangeOfIndex;
|
|
4105
|
-
const numberOfAdjacentSpineItemToPreLoad =
|
|
4176
|
+
const numberOfAdjacentSpineItemToPreLoad = settings.getSettings().numberOfAdjacentSpineItemToPreLoad;
|
|
4106
4177
|
const isPrePaginated = ((_a = context.getManifest()) == null ? void 0 : _a.renditionLayout) === `pre-paginated`;
|
|
4107
|
-
const isUsingFreeScroll =
|
|
4178
|
+
const isUsingFreeScroll = settings.getSettings().computedPageTurnMode === `scrollable`;
|
|
4108
4179
|
orderedSpineItemsSubject$.value.forEach((orderedSpineItem, index) => {
|
|
4109
4180
|
const isBeforeFocusedWithPreload = (
|
|
4110
4181
|
// we never want to preload anything before on free scroll on flow because it could offset the cursor
|
|
@@ -4158,7 +4229,9 @@
|
|
|
4158
4229
|
spineItem.$.loaded$.pipe(
|
|
4159
4230
|
operators.tap(() => {
|
|
4160
4231
|
if (spineItem.isUsingVerticalWriting()) {
|
|
4161
|
-
context.setHasVerticalWriting();
|
|
4232
|
+
context.setHasVerticalWriting(true);
|
|
4233
|
+
} else {
|
|
4234
|
+
context.setHasVerticalWriting(false);
|
|
4162
4235
|
}
|
|
4163
4236
|
}),
|
|
4164
4237
|
operators.takeUntil(context.$.destroy$)
|
|
@@ -4399,9 +4472,10 @@
|
|
|
4399
4472
|
context,
|
|
4400
4473
|
spineItemManager,
|
|
4401
4474
|
cfiLocator,
|
|
4402
|
-
locator
|
|
4475
|
+
locator,
|
|
4476
|
+
settings
|
|
4403
4477
|
}) => {
|
|
4404
|
-
const spineItemNavigator = createNavigationResolver$1({ context });
|
|
4478
|
+
const spineItemNavigator = createNavigationResolver$1({ context, settings });
|
|
4405
4479
|
const arePositionsDifferent = (a, b) => a.x !== b.x || a.y !== b.y;
|
|
4406
4480
|
const areNavigationDifferent = (a, b) => arePositionsDifferent(a, b) || !!a.spineItem && !!b.spineItem && a.spineItem !== b.spineItem;
|
|
4407
4481
|
const wrapPositionWithSafeEdge = Report.measurePerformance(
|
|
@@ -4466,7 +4540,7 @@
|
|
|
4466
4540
|
return { x: 0, y: 0 };
|
|
4467
4541
|
};
|
|
4468
4542
|
const getNavigationForRightSinglePage = (position) => {
|
|
4469
|
-
const pageTurnDirection =
|
|
4543
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4470
4544
|
const spineItem = locator.getSpineItemFromPosition(position) || spineItemManager.getFocusedSpineItem();
|
|
4471
4545
|
const defaultNavigation = position;
|
|
4472
4546
|
if (!spineItem) {
|
|
@@ -4485,7 +4559,7 @@
|
|
|
4485
4559
|
}
|
|
4486
4560
|
};
|
|
4487
4561
|
const getNavigationForLeftSinglePage = (position) => {
|
|
4488
|
-
const pageTurnDirection =
|
|
4562
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4489
4563
|
const spineItem = locator.getSpineItemFromPosition(position) || spineItemManager.getFocusedSpineItem();
|
|
4490
4564
|
const defaultNavigation = { ...position, spineItem };
|
|
4491
4565
|
if (!spineItem) {
|
|
@@ -4509,7 +4583,7 @@
|
|
|
4509
4583
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x === navigation.x) {
|
|
4510
4584
|
return getAdjustedPositionForSpread(navigation);
|
|
4511
4585
|
}
|
|
4512
|
-
if (context.
|
|
4586
|
+
if (context.isUsingSpreadMode()) {
|
|
4513
4587
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
4514
4588
|
return getAdjustedPositionForSpread(
|
|
4515
4589
|
wrapPositionWithSafeEdge(
|
|
@@ -4523,7 +4597,7 @@
|
|
|
4523
4597
|
)
|
|
4524
4598
|
);
|
|
4525
4599
|
}
|
|
4526
|
-
if (
|
|
4600
|
+
if (settings.getSettings().computedPageTurnDirection === `vertical` && position.y !== navigation.y) {
|
|
4527
4601
|
return getAdjustedPositionForSpread(navigation);
|
|
4528
4602
|
}
|
|
4529
4603
|
const doubleNavigation = getNavigationForRightSinglePage(navigation);
|
|
@@ -4537,7 +4611,7 @@
|
|
|
4537
4611
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x === navigation.x) {
|
|
4538
4612
|
return getAdjustedPositionForSpread(navigation);
|
|
4539
4613
|
}
|
|
4540
|
-
if (context.
|
|
4614
|
+
if (context.isUsingSpreadMode()) {
|
|
4541
4615
|
if ((spineItemOnPosition == null ? void 0 : spineItemOnPosition.isUsingVerticalWriting()) && position.x !== navigation.x) {
|
|
4542
4616
|
return getAdjustedPositionForSpread(
|
|
4543
4617
|
wrapPositionWithSafeEdge(
|
|
@@ -4545,7 +4619,7 @@
|
|
|
4545
4619
|
)
|
|
4546
4620
|
);
|
|
4547
4621
|
}
|
|
4548
|
-
if (
|
|
4622
|
+
if (settings.getSettings().computedPageTurnDirection === `vertical` && position.y !== navigation.y) {
|
|
4549
4623
|
return getAdjustedPositionForSpread(navigation);
|
|
4550
4624
|
}
|
|
4551
4625
|
const doubleNavigation = getNavigationForLeftSinglePage(navigation);
|
|
@@ -4587,7 +4661,7 @@
|
|
|
4587
4661
|
return { x: 0, y: 0 };
|
|
4588
4662
|
};
|
|
4589
4663
|
const getMostPredominantNavigationForPosition = (viewportPosition) => {
|
|
4590
|
-
const pageTurnDirection =
|
|
4664
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4591
4665
|
const triggerPercentage = 0.5;
|
|
4592
4666
|
const triggerXPosition = pageTurnDirection === `horizontal` ? viewportPosition.x + context.getVisibleAreaRect().width * triggerPercentage : 0;
|
|
4593
4667
|
const triggerYPosition = pageTurnDirection === `horizontal` ? 0 : viewportPosition.y + context.getVisibleAreaRect().height * triggerPercentage;
|
|
@@ -4595,7 +4669,7 @@
|
|
|
4595
4669
|
return getNavigationForPosition(midScreenPositionSafePosition);
|
|
4596
4670
|
};
|
|
4597
4671
|
const isNavigationGoingForwardFrom = (to, from) => {
|
|
4598
|
-
const pageTurnDirection =
|
|
4672
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4599
4673
|
if (pageTurnDirection === `vertical`) {
|
|
4600
4674
|
return to.y > from.y;
|
|
4601
4675
|
}
|
|
@@ -4621,9 +4695,10 @@
|
|
|
4621
4695
|
const SCROLL_FINISHED_DEBOUNCE_TIMEOUT = 200;
|
|
4622
4696
|
const createScrollViewportNavigator = ({
|
|
4623
4697
|
context,
|
|
4624
|
-
element
|
|
4698
|
+
element$,
|
|
4625
4699
|
navigator: navigator2,
|
|
4626
4700
|
currentNavigationSubject$,
|
|
4701
|
+
settings,
|
|
4627
4702
|
spine
|
|
4628
4703
|
}) => {
|
|
4629
4704
|
let lastScrollWasProgrammaticallyTriggered = false;
|
|
@@ -4637,38 +4712,44 @@
|
|
|
4637
4712
|
})
|
|
4638
4713
|
);
|
|
4639
4714
|
const adjustReadingOffset = ({ x, y }) => {
|
|
4640
|
-
|
|
4715
|
+
var _a;
|
|
4716
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
4641
4717
|
lastScrollWasProgrammaticallyTriggered = true;
|
|
4642
|
-
element.scrollTo({ left: x, top: y });
|
|
4718
|
+
(_a = element$.getValue()) == null ? void 0 : _a.scrollTo({ left: x, top: y });
|
|
4643
4719
|
return true;
|
|
4644
4720
|
}
|
|
4645
4721
|
return false;
|
|
4646
4722
|
};
|
|
4647
|
-
const runOnFreePageTurnModeOnly$ = (source) =>
|
|
4648
|
-
operators.map(() =>
|
|
4723
|
+
const runOnFreePageTurnModeOnly$ = (source) => settings.$.settings$.pipe(
|
|
4724
|
+
operators.map(({ computedPageTurnMode }) => computedPageTurnMode),
|
|
4649
4725
|
operators.distinctUntilChanged(),
|
|
4650
4726
|
operators.switchMap((mode) => rxjs.iif(() => mode === `controlled`, rxjs.EMPTY, source))
|
|
4651
4727
|
);
|
|
4652
|
-
const userScroll$ = runOnFreePageTurnModeOnly$(
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4728
|
+
const userScroll$ = runOnFreePageTurnModeOnly$(
|
|
4729
|
+
element$.pipe(
|
|
4730
|
+
operators.filter(isDefined),
|
|
4731
|
+
operators.switchMap((element) => rxjs.fromEvent(element, `scroll`))
|
|
4732
|
+
)
|
|
4733
|
+
).pipe(onlyUserScrollFilter, operators.share(), operators.takeUntil(context.$.destroy$));
|
|
4657
4734
|
const getScaledDownPosition = ({ x, y }) => {
|
|
4658
|
-
|
|
4735
|
+
var _a, _b;
|
|
4736
|
+
const spineElement = spine.getElement();
|
|
4737
|
+
if (!spineElement)
|
|
4738
|
+
throw new Error("Invalid spine element");
|
|
4739
|
+
const spineScaleX = spineElement.getBoundingClientRect().width / spineElement.offsetWidth;
|
|
4659
4740
|
const scaledDownPosition = {
|
|
4660
4741
|
x: getNewScaledOffset({
|
|
4661
4742
|
newScale: 1,
|
|
4662
4743
|
oldScale: spineScaleX,
|
|
4663
|
-
screenSize: element.clientWidth,
|
|
4664
|
-
pageSize:
|
|
4744
|
+
screenSize: ((_a = element$.getValue()) == null ? void 0 : _a.clientWidth) ?? 0,
|
|
4745
|
+
pageSize: spineElement.scrollWidth,
|
|
4665
4746
|
scrollOffset: x
|
|
4666
4747
|
}),
|
|
4667
4748
|
y: getNewScaledOffset({
|
|
4668
4749
|
newScale: 1,
|
|
4669
4750
|
oldScale: spineScaleX,
|
|
4670
|
-
screenSize: element.clientHeight,
|
|
4671
|
-
pageSize:
|
|
4751
|
+
screenSize: ((_b = element$.getValue()) == null ? void 0 : _b.clientHeight) ?? 0,
|
|
4752
|
+
pageSize: spineElement.scrollHeight,
|
|
4672
4753
|
scrollOffset: y
|
|
4673
4754
|
})
|
|
4674
4755
|
};
|
|
@@ -4679,13 +4760,17 @@
|
|
|
4679
4760
|
return navigation;
|
|
4680
4761
|
};
|
|
4681
4762
|
const getCurrentViewportPosition = () => {
|
|
4682
|
-
|
|
4763
|
+
var _a, _b;
|
|
4764
|
+
return getScaledDownPosition({ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0, y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0 });
|
|
4683
4765
|
};
|
|
4684
4766
|
const navigationOnScroll$ = userScroll$.pipe(
|
|
4685
4767
|
operators.debounceTime(SCROLL_FINISHED_DEBOUNCE_TIMEOUT, rxjs.animationFrameScheduler),
|
|
4686
4768
|
operators.withLatestFrom(currentNavigationSubject$),
|
|
4687
4769
|
operators.switchMap(() => {
|
|
4688
|
-
|
|
4770
|
+
var _a, _b;
|
|
4771
|
+
const navigation = getNavigationForPosition(
|
|
4772
|
+
getScaledDownPosition({ x: ((_a = element$.getValue()) == null ? void 0 : _a.scrollLeft) ?? 0, y: ((_b = element$.getValue()) == null ? void 0 : _b.scrollTop) ?? 0 })
|
|
4773
|
+
);
|
|
4689
4774
|
return rxjs.of({ position: navigation, animate: false, lastUserExpectedNavigation: void 0 });
|
|
4690
4775
|
}),
|
|
4691
4776
|
operators.share()
|
|
@@ -4908,7 +4993,8 @@
|
|
|
4908
4993
|
spineItemManager,
|
|
4909
4994
|
locator,
|
|
4910
4995
|
context,
|
|
4911
|
-
currentNavigationSubject
|
|
4996
|
+
currentNavigationSubject$,
|
|
4997
|
+
settings
|
|
4912
4998
|
}) => {
|
|
4913
4999
|
const navigationTriggerSubject$ = new rxjs.Subject();
|
|
4914
5000
|
const stateSubject$ = new rxjs.BehaviorSubject(`end`);
|
|
@@ -4919,11 +5005,11 @@
|
|
|
4919
5005
|
`${NAMESPACE$1} moveTo`,
|
|
4920
5006
|
5,
|
|
4921
5007
|
(delta, { final, start } = {}) => {
|
|
4922
|
-
if (
|
|
5008
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
4923
5009
|
Report.warn(`pan control is not available on free page turn mode`);
|
|
4924
5010
|
return;
|
|
4925
5011
|
}
|
|
4926
|
-
const pageTurnDirection =
|
|
5012
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4927
5013
|
if (start) {
|
|
4928
5014
|
stateSubject$.next(`start`);
|
|
4929
5015
|
movingLastDelta = { x: 0, y: 0 };
|
|
@@ -4983,7 +5069,7 @@
|
|
|
4983
5069
|
);
|
|
4984
5070
|
const snapNavigation$ = navigationTriggerSubject$.pipe(
|
|
4985
5071
|
operators.filter((e) => e.type === `snap`),
|
|
4986
|
-
rxjs.withLatestFrom(
|
|
5072
|
+
rxjs.withLatestFrom(settings.$.settings$),
|
|
4987
5073
|
operators.switchMap(
|
|
4988
5074
|
([
|
|
4989
5075
|
{
|
|
@@ -4991,7 +5077,7 @@
|
|
|
4991
5077
|
},
|
|
4992
5078
|
{ navigationSnapThreshold }
|
|
4993
5079
|
]) => {
|
|
4994
|
-
const pageTurnDirection =
|
|
5080
|
+
const pageTurnDirection = settings.getSettings().computedPageTurnDirection;
|
|
4995
5081
|
const movingForward = navigator2.isNavigationGoingForwardFrom(to, from);
|
|
4996
5082
|
const triggerPercentage = movingForward ? 1 - navigationSnapThreshold : navigationSnapThreshold;
|
|
4997
5083
|
const triggerXPosition = pageTurnDirection === `horizontal` ? to.x + context.getVisibleAreaRect().width * triggerPercentage : 0;
|
|
@@ -5024,18 +5110,19 @@
|
|
|
5024
5110
|
};
|
|
5025
5111
|
};
|
|
5026
5112
|
const NAMESPACE = `viewportNavigator`;
|
|
5113
|
+
const noopElement = document.createElement("div");
|
|
5027
5114
|
const createViewportNavigator = ({
|
|
5028
5115
|
spineItemManager,
|
|
5029
5116
|
context,
|
|
5030
5117
|
pagination,
|
|
5031
|
-
parentElement
|
|
5118
|
+
parentElement$,
|
|
5032
5119
|
cfiLocator,
|
|
5033
5120
|
spineLocator,
|
|
5034
5121
|
hooks$,
|
|
5035
|
-
spine
|
|
5122
|
+
spine,
|
|
5123
|
+
settings
|
|
5036
5124
|
}) => {
|
|
5037
|
-
const element =
|
|
5038
|
-
element.appendChild(spine.element);
|
|
5125
|
+
const element$ = new rxjs.BehaviorSubject(noopElement);
|
|
5039
5126
|
const layoutSubject$ = new rxjs.Subject();
|
|
5040
5127
|
let currentViewportPositionMemoUnused;
|
|
5041
5128
|
const currentNavigationPositionSubject$ = new rxjs.BehaviorSubject({
|
|
@@ -5045,17 +5132,18 @@
|
|
|
5045
5132
|
});
|
|
5046
5133
|
const navigator2 = createNavigationResolver({
|
|
5047
5134
|
context,
|
|
5135
|
+
settings,
|
|
5048
5136
|
spineItemManager,
|
|
5049
5137
|
cfiLocator,
|
|
5050
5138
|
locator: spineLocator
|
|
5051
5139
|
});
|
|
5052
5140
|
const adjustNavigationSubject$ = new rxjs.Subject();
|
|
5053
|
-
parentElement.appendChild(element);
|
|
5054
5141
|
const getCurrentViewportPosition = Report.measurePerformance(`${NAMESPACE} getCurrentViewportPosition`, 1, () => {
|
|
5055
|
-
|
|
5142
|
+
var _a;
|
|
5143
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
5056
5144
|
return scrollViewportNavigator.getCurrentViewportPosition();
|
|
5057
5145
|
}
|
|
5058
|
-
const { x, y } = element.getBoundingClientRect();
|
|
5146
|
+
const { x, y } = ((_a = element$.getValue()) == null ? void 0 : _a.getBoundingClientRect()) ?? { x: 0, y: 0 };
|
|
5059
5147
|
const newValue = {
|
|
5060
5148
|
// we want to round to first decimal because it's possible to have half pixel
|
|
5061
5149
|
// however browser engine can also gives back x.yyyy based on their precision
|
|
@@ -5069,7 +5157,7 @@
|
|
|
5069
5157
|
});
|
|
5070
5158
|
const panViewportNavigator = createPanViewportNavigator({
|
|
5071
5159
|
context,
|
|
5072
|
-
|
|
5160
|
+
settings,
|
|
5073
5161
|
navigator: navigator2,
|
|
5074
5162
|
spineItemManager,
|
|
5075
5163
|
locator: spineLocator,
|
|
@@ -5078,15 +5166,15 @@
|
|
|
5078
5166
|
});
|
|
5079
5167
|
const scrollViewportNavigator = createScrollViewportNavigator({
|
|
5080
5168
|
context,
|
|
5081
|
-
element
|
|
5169
|
+
element$,
|
|
5082
5170
|
navigator: navigator2,
|
|
5083
5171
|
currentNavigationSubject$: currentNavigationPositionSubject$,
|
|
5084
5172
|
spine,
|
|
5085
|
-
spineItemManager
|
|
5173
|
+
spineItemManager,
|
|
5174
|
+
settings
|
|
5086
5175
|
});
|
|
5087
5176
|
const manualViewportNavigator = createManualViewportNavigator({
|
|
5088
5177
|
context,
|
|
5089
|
-
element,
|
|
5090
5178
|
navigator: navigator2,
|
|
5091
5179
|
currentNavigationSubject$: currentNavigationPositionSubject$,
|
|
5092
5180
|
spineItemManager,
|
|
@@ -5103,6 +5191,9 @@
|
|
|
5103
5191
|
`adjustReadingOffset`,
|
|
5104
5192
|
2,
|
|
5105
5193
|
({ x, y }, hooks) => {
|
|
5194
|
+
const element = element$.getValue();
|
|
5195
|
+
if (!element)
|
|
5196
|
+
throw new Error("Invalid element");
|
|
5106
5197
|
currentViewportPositionMemoUnused = void 0;
|
|
5107
5198
|
const isAdjusted = viewportNavigators.reduce((isAdjusted2, navigator22) => {
|
|
5108
5199
|
return navigator22.adjustReadingOffset({ x, y }) || isAdjusted2;
|
|
@@ -5119,10 +5210,10 @@
|
|
|
5119
5210
|
{ disable: true }
|
|
5120
5211
|
);
|
|
5121
5212
|
const adjustNavigation = (spineItem) => {
|
|
5122
|
-
const lastCfi = pagination.
|
|
5213
|
+
const lastCfi = pagination.getPaginationInfo().beginCfi;
|
|
5123
5214
|
let adjustedSpinePosition = currentNavigationPositionSubject$.value;
|
|
5124
5215
|
const offsetInSpineItem = 0;
|
|
5125
|
-
if (
|
|
5216
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
5126
5217
|
adjustedSpinePosition = scrollViewportNavigator.getNavigationForPosition(getCurrentViewportPosition());
|
|
5127
5218
|
} else if ((lastUserExpectedNavigation == null ? void 0 : lastUserExpectedNavigation.type) === `navigate-from-cfi`) {
|
|
5128
5219
|
adjustedSpinePosition = navigator2.getNavigationForCfi(lastUserExpectedNavigation.data);
|
|
@@ -5140,7 +5231,7 @@
|
|
|
5140
5231
|
adjustedSpinePosition = navigator2.getNavigationForCfi(lastCfi);
|
|
5141
5232
|
Report.log(NAMESPACE, `adjustNavigation`, `use last cfi`);
|
|
5142
5233
|
} else {
|
|
5143
|
-
const currentPageIndex = pagination.
|
|
5234
|
+
const currentPageIndex = pagination.getPaginationInfo().beginPageIndexInSpineItem || 0;
|
|
5144
5235
|
adjustedSpinePosition = navigator2.getNavigationForPage(currentPageIndex, spineItem);
|
|
5145
5236
|
Report.log(NAMESPACE, `adjustNavigation`, `use guess strategy`, {});
|
|
5146
5237
|
}
|
|
@@ -5167,14 +5258,15 @@
|
|
|
5167
5258
|
layoutSubject$.subscribe(() => {
|
|
5168
5259
|
currentViewportPositionMemoUnused = void 0;
|
|
5169
5260
|
});
|
|
5170
|
-
const layoutChangeSettings$ =
|
|
5261
|
+
const layoutChangeSettings$ = settings.$.settings$.pipe(
|
|
5171
5262
|
mapKeysTo([`computedPageTurnDirection`, `computedPageTurnMode`, `numberOfAdjacentSpineItemToPreLoad`]),
|
|
5172
5263
|
operators.distinctUntilChanged(isShallowEqual),
|
|
5173
5264
|
operators.skip(1)
|
|
5174
5265
|
);
|
|
5175
5266
|
const layout$ = rxjs.merge(layoutSubject$, layoutChangeSettings$).pipe(
|
|
5176
|
-
operators.
|
|
5177
|
-
|
|
5267
|
+
operators.withLatestFrom(element$),
|
|
5268
|
+
operators.tap(([, element]) => {
|
|
5269
|
+
if (settings.getSettings().computedPageTurnMode === `scrollable`) {
|
|
5178
5270
|
element.style.removeProperty(`transform`);
|
|
5179
5271
|
element.style.removeProperty(`transition`);
|
|
5180
5272
|
element.style.overflow = `scroll`;
|
|
@@ -5230,7 +5322,7 @@
|
|
|
5230
5322
|
);
|
|
5231
5323
|
const navigationWhichRequireManualAdjust$ = navigation$.pipe(
|
|
5232
5324
|
operators.filter(({ triggeredBy }) => {
|
|
5233
|
-
if (triggeredBy === `scroll` ||
|
|
5325
|
+
if (triggeredBy === `scroll` || settings.getSettings().computedPageTurnMode === `scrollable` && triggeredBy === `adjust`) {
|
|
5234
5326
|
return false;
|
|
5235
5327
|
} else {
|
|
5236
5328
|
return true;
|
|
@@ -5242,7 +5334,7 @@
|
|
|
5242
5334
|
navigationWhichRequireManualAdjust$
|
|
5243
5335
|
).pipe(
|
|
5244
5336
|
operators.map(({ animation, position }) => {
|
|
5245
|
-
const shouldAnimate = !(!animation || animation === `turn` &&
|
|
5337
|
+
const shouldAnimate = !(!animation || animation === `turn` && settings.getSettings().computedPageTurnAnimation === `none`);
|
|
5246
5338
|
return {
|
|
5247
5339
|
type: `manualAdjust`,
|
|
5248
5340
|
shouldAnimate,
|
|
@@ -5257,15 +5349,15 @@
|
|
|
5257
5349
|
operators.pairwise(),
|
|
5258
5350
|
operators.tap(([prevEvent, currentEvent]) => {
|
|
5259
5351
|
if ((prevEvent == null ? void 0 : prevEvent.type) === `manualAdjust` && (currentEvent == null ? void 0 : currentEvent.type) !== `manualAdjust`) {
|
|
5260
|
-
element.style.setProperty(`transition`, `none`);
|
|
5261
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5352
|
+
element$.getValue().style.setProperty(`transition`, `none`);
|
|
5353
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5262
5354
|
}
|
|
5263
5355
|
}),
|
|
5264
5356
|
operators.switchMap(([, currentEvent]) => {
|
|
5265
5357
|
if ((currentEvent == null ? void 0 : currentEvent.type) !== `manualAdjust`)
|
|
5266
5358
|
return rxjs.EMPTY;
|
|
5267
|
-
const animationDuration = currentEvent.animation === `snap` ?
|
|
5268
|
-
const pageTurnAnimation = currentEvent.animation === `snap` ? `slide` :
|
|
5359
|
+
const animationDuration = currentEvent.animation === `snap` ? settings.getSettings().computedSnapAnimationDuration : settings.getSettings().computedPageTurnAnimationDuration;
|
|
5360
|
+
const pageTurnAnimation = currentEvent.animation === `snap` ? `slide` : settings.getSettings().computedPageTurnAnimation;
|
|
5269
5361
|
return rxjs.of(currentEvent).pipe(
|
|
5270
5362
|
/**
|
|
5271
5363
|
* @important
|
|
@@ -5280,15 +5372,15 @@
|
|
|
5280
5372
|
const noAdjustmentNeeded = false;
|
|
5281
5373
|
if (data.shouldAnimate && !noAdjustmentNeeded) {
|
|
5282
5374
|
if (pageTurnAnimation === `fade`) {
|
|
5283
|
-
element.style.setProperty(`transition`, `opacity ${animationDuration / 2}ms`);
|
|
5284
|
-
element.style.setProperty(`opacity`, `0`);
|
|
5375
|
+
element$.getValue().style.setProperty(`transition`, `opacity ${animationDuration / 2}ms`);
|
|
5376
|
+
element$.getValue().style.setProperty(`opacity`, `0`);
|
|
5285
5377
|
} else if (currentEvent.animation === `snap` || pageTurnAnimation === `slide`) {
|
|
5286
|
-
element.style.setProperty(`transition`, `transform ${animationDuration}ms`);
|
|
5287
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5378
|
+
element$.getValue().style.setProperty(`transition`, `transform ${animationDuration}ms`);
|
|
5379
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5288
5380
|
}
|
|
5289
5381
|
} else {
|
|
5290
|
-
element.style.setProperty(`transition`, `none`);
|
|
5291
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5382
|
+
element$.getValue().style.setProperty(`transition`, `none`);
|
|
5383
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5292
5384
|
}
|
|
5293
5385
|
}),
|
|
5294
5386
|
/**
|
|
@@ -5309,7 +5401,7 @@
|
|
|
5309
5401
|
operators.tap(([data, hooks]) => {
|
|
5310
5402
|
if (pageTurnAnimation === `fade`) {
|
|
5311
5403
|
adjustReadingOffset(data.position, hooks);
|
|
5312
|
-
element.style.setProperty(`opacity`, `1`);
|
|
5404
|
+
element$.getValue().style.setProperty(`opacity`, `1`);
|
|
5313
5405
|
}
|
|
5314
5406
|
}),
|
|
5315
5407
|
currentEvent.shouldAnimate ? operators.delay(animationDuration / 2, rxjs.animationFrameScheduler) : rxjs.identity,
|
|
@@ -5381,10 +5473,17 @@
|
|
|
5381
5473
|
),
|
|
5382
5474
|
operators.share()
|
|
5383
5475
|
);
|
|
5476
|
+
const parentElementSub = parentElement$.pipe(operators.filter(isDefined), operators.withLatestFrom(spine.element$)).subscribe(([parentElement, spineElement]) => {
|
|
5477
|
+
const element = createElement(parentElement.ownerDocument, hooks$);
|
|
5478
|
+
element.appendChild(spineElement);
|
|
5479
|
+
parentElement.appendChild(element);
|
|
5480
|
+
element$.next(element);
|
|
5481
|
+
});
|
|
5384
5482
|
const destroy = () => {
|
|
5385
5483
|
layoutSubject$.complete();
|
|
5386
5484
|
adjustNavigationSubject$.complete();
|
|
5387
5485
|
currentNavigationPositionSubject$.complete();
|
|
5486
|
+
parentElementSub.unsubscribe();
|
|
5388
5487
|
viewportNavigators.forEach((navigator22) => navigator22.destroy());
|
|
5389
5488
|
};
|
|
5390
5489
|
return {
|
|
@@ -5401,7 +5500,8 @@
|
|
|
5401
5500
|
goToPageOfCurrentChapter: manualViewportNavigator.goToPageOfCurrentChapter,
|
|
5402
5501
|
moveTo: panViewportNavigator.moveTo,
|
|
5403
5502
|
getLastUserExpectedNavigation: () => lastUserExpectedNavigation,
|
|
5404
|
-
element
|
|
5503
|
+
element$,
|
|
5504
|
+
getElement: () => element$.getValue(),
|
|
5405
5505
|
$: {
|
|
5406
5506
|
state$,
|
|
5407
5507
|
navigation$,
|
|
@@ -5427,7 +5527,8 @@
|
|
|
5427
5527
|
const createLocationResolver = ({
|
|
5428
5528
|
spineItemManager,
|
|
5429
5529
|
context,
|
|
5430
|
-
spineItemLocator
|
|
5530
|
+
spineItemLocator,
|
|
5531
|
+
settings
|
|
5431
5532
|
}) => {
|
|
5432
5533
|
const getSpineItemPositionFromSpinePosition = Report.measurePerformance(
|
|
5433
5534
|
`getSpineItemPositionFromSpinePosition`,
|
|
@@ -5462,7 +5563,7 @@
|
|
|
5462
5563
|
const spineItem = spineItemManager.getAll().find((item) => {
|
|
5463
5564
|
const { left, right, bottom, top } = spineItemManager.getAbsolutePositionOf(item);
|
|
5464
5565
|
const isWithinXAxis = position.x >= left && position.x < right;
|
|
5465
|
-
if (
|
|
5566
|
+
if (settings.getSettings().computedPageTurnDirection === `horizontal`) {
|
|
5466
5567
|
return isWithinXAxis;
|
|
5467
5568
|
} else {
|
|
5468
5569
|
return isWithinXAxis && position.y >= top && position.y < bottom;
|
|
@@ -5489,7 +5590,7 @@
|
|
|
5489
5590
|
if (itemAtPositionIndex === void 0)
|
|
5490
5591
|
return void 0;
|
|
5491
5592
|
let endPosition = position;
|
|
5492
|
-
if (context.
|
|
5593
|
+
if (context.isUsingSpreadMode()) {
|
|
5493
5594
|
endPosition = { x: position.x + context.getPageSize().width, y: position.y };
|
|
5494
5595
|
}
|
|
5495
5596
|
const endItemIndex = spineItemManager.getSpineItemIndex(getSpineItemFromPosition(endPosition) || spineItemManager.getFocusedSpineItem()) ?? itemAtPositionIndex;
|
|
@@ -5610,15 +5711,86 @@
|
|
|
5610
5711
|
generateFromRange
|
|
5611
5712
|
};
|
|
5612
5713
|
};
|
|
5714
|
+
const areAllItemsPrePaginated = (manifest) => !(manifest == null ? void 0 : manifest.spineItems.some((item) => item.renditionLayout === `reflowable`));
|
|
5715
|
+
const createSettings = (initialSettings) => {
|
|
5716
|
+
const mergedSettings = {
|
|
5717
|
+
forceSinglePageMode: false,
|
|
5718
|
+
pageTurnAnimation: `none`,
|
|
5719
|
+
computedPageTurnAnimation: `none`,
|
|
5720
|
+
pageTurnDirection: `horizontal`,
|
|
5721
|
+
computedPageTurnDirection: `horizontal`,
|
|
5722
|
+
pageTurnAnimationDuration: void 0,
|
|
5723
|
+
computedPageTurnAnimationDuration: 0,
|
|
5724
|
+
pageTurnMode: `controlled`,
|
|
5725
|
+
computedPageTurnMode: `controlled`,
|
|
5726
|
+
computedSnapAnimationDuration: 300,
|
|
5727
|
+
navigationSnapThreshold: 0.3,
|
|
5728
|
+
numberOfAdjacentSpineItemToPreLoad: 0,
|
|
5729
|
+
...initialSettings
|
|
5730
|
+
};
|
|
5731
|
+
updateComputedSettings(void 0, mergedSettings, false);
|
|
5732
|
+
const settingsSubject$ = new rxjs.BehaviorSubject(mergedSettings);
|
|
5733
|
+
const setSettings = (newSettings, options) => {
|
|
5734
|
+
if (Object.keys(newSettings).length === 0)
|
|
5735
|
+
return;
|
|
5736
|
+
const newMergedSettings = { ...settingsSubject$.value, ...newSettings };
|
|
5737
|
+
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWriting ?? false);
|
|
5738
|
+
settingsSubject$.next(newMergedSettings);
|
|
5739
|
+
};
|
|
5740
|
+
const recompute = (options) => {
|
|
5741
|
+
const newMergedSettings = { ...settingsSubject$.value };
|
|
5742
|
+
updateComputedSettings(options.manifest, newMergedSettings, options.hasVerticalWriting ?? false);
|
|
5743
|
+
settingsSubject$.next(newMergedSettings);
|
|
5744
|
+
};
|
|
5745
|
+
const destroy = () => {
|
|
5746
|
+
settingsSubject$.complete();
|
|
5747
|
+
};
|
|
5748
|
+
return {
|
|
5749
|
+
getSettings: () => settingsSubject$.value,
|
|
5750
|
+
setSettings,
|
|
5751
|
+
recompute,
|
|
5752
|
+
destroy,
|
|
5753
|
+
$: {
|
|
5754
|
+
settings$: settingsSubject$.asObservable().pipe(operators.distinctUntilChanged(isShallowEqual))
|
|
5755
|
+
}
|
|
5756
|
+
};
|
|
5757
|
+
};
|
|
5758
|
+
const updateComputedSettings = (newManifest, settings, hasVerticalWriting) => {
|
|
5759
|
+
settings.computedPageTurnDirection = settings.pageTurnDirection;
|
|
5760
|
+
settings.computedPageTurnAnimation = settings.pageTurnAnimation;
|
|
5761
|
+
settings.computedPageTurnMode = `controlled`;
|
|
5762
|
+
if ((newManifest == null ? void 0 : newManifest.renditionFlow) === `scrolled-continuous`) {
|
|
5763
|
+
settings.computedPageTurnMode = `scrollable`;
|
|
5764
|
+
settings.computedPageTurnDirection = `vertical`;
|
|
5765
|
+
} else if (newManifest && settings.pageTurnMode === `scrollable` && (newManifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated(newManifest))) {
|
|
5766
|
+
Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
|
|
5767
|
+
settings.computedPageTurnAnimation = `none`;
|
|
5768
|
+
settings.computedPageTurnMode = `controlled`;
|
|
5769
|
+
} else if (settings.pageTurnMode === `scrollable`) {
|
|
5770
|
+
settings.computedPageTurnMode = `scrollable`;
|
|
5771
|
+
settings.computedPageTurnDirection = `vertical`;
|
|
5772
|
+
}
|
|
5773
|
+
if (hasVerticalWriting && settings.computedPageTurnAnimation === `slide`) {
|
|
5774
|
+
Report.warn(
|
|
5775
|
+
`pageTurnAnimation ${settings.computedPageTurnAnimation} incompatible with current book, switching back to default`
|
|
5776
|
+
);
|
|
5777
|
+
settings.computedPageTurnAnimation = `none`;
|
|
5778
|
+
}
|
|
5779
|
+
if (settings.computedPageTurnMode === `scrollable`) {
|
|
5780
|
+
settings.computedPageTurnAnimationDuration = 0;
|
|
5781
|
+
settings.computedPageTurnAnimation = `none`;
|
|
5782
|
+
} else {
|
|
5783
|
+
settings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
|
|
5784
|
+
}
|
|
5785
|
+
};
|
|
5613
5786
|
const IFRAME_EVENT_BRIDGE_ELEMENT_ID = `proseReaderIframeEventBridgeElement`;
|
|
5614
|
-
const createReader = ({
|
|
5787
|
+
const createReader = ({ hooks: initialHooks, ...inputSettings }) => {
|
|
5615
5788
|
const stateSubject$ = new rxjs.BehaviorSubject({
|
|
5616
5789
|
supportedPageTurnAnimation: [`fade`, `none`, `slide`],
|
|
5617
5790
|
supportedPageTurnMode: [`controlled`, `scrollable`],
|
|
5618
5791
|
supportedPageTurnDirection: [`horizontal`, `vertical`],
|
|
5619
5792
|
supportedComputedPageTurnDirection: [`horizontal`, `vertical`]
|
|
5620
5793
|
});
|
|
5621
|
-
const readySubject$ = new rxjs.Subject();
|
|
5622
5794
|
const destroy$ = new rxjs.Subject();
|
|
5623
5795
|
const selectionSubject$ = new rxjs.Subject();
|
|
5624
5796
|
const hooksSubject$ = new rxjs.BehaviorSubject(initialHooks || []);
|
|
@@ -5626,16 +5798,19 @@
|
|
|
5626
5798
|
const navigationAdjustedSubject = new rxjs.Subject();
|
|
5627
5799
|
const currentNavigationPositionSubject$ = new rxjs.BehaviorSubject({ x: 0, y: 0 });
|
|
5628
5800
|
const viewportStateSubject = new rxjs.BehaviorSubject(`free`);
|
|
5801
|
+
const settings = createSettings(inputSettings);
|
|
5629
5802
|
const context = createContext(settings);
|
|
5630
|
-
const spineItemManager = createSpineItemManager({ context });
|
|
5803
|
+
const spineItemManager = createSpineItemManager({ context, settings });
|
|
5631
5804
|
const pagination = createPagination({ context, spineItemManager });
|
|
5632
|
-
const
|
|
5633
|
-
const
|
|
5805
|
+
const elementSubject$ = new rxjs.BehaviorSubject(void 0);
|
|
5806
|
+
const element$ = elementSubject$.pipe(operators.filter(isDefined));
|
|
5807
|
+
const iframeEventBridgeElement$ = new rxjs.BehaviorSubject(void 0);
|
|
5634
5808
|
const spineItemLocator = createLocationResolver$1({ context });
|
|
5635
5809
|
const spineLocator = createLocationResolver({
|
|
5636
5810
|
context,
|
|
5637
5811
|
spineItemManager,
|
|
5638
|
-
spineItemLocator
|
|
5812
|
+
spineItemLocator,
|
|
5813
|
+
settings
|
|
5639
5814
|
});
|
|
5640
5815
|
const cfiLocator = createCfiLocator({
|
|
5641
5816
|
spineItemManager,
|
|
@@ -5644,9 +5819,10 @@
|
|
|
5644
5819
|
});
|
|
5645
5820
|
const navigation$ = navigationSubject.asObservable();
|
|
5646
5821
|
const spine = createSpine({
|
|
5647
|
-
|
|
5648
|
-
iframeEventBridgeElement
|
|
5822
|
+
element$,
|
|
5823
|
+
iframeEventBridgeElement$,
|
|
5649
5824
|
context,
|
|
5825
|
+
settings,
|
|
5650
5826
|
pagination,
|
|
5651
5827
|
spineItemManager,
|
|
5652
5828
|
hooks$: hooksSubject$,
|
|
@@ -5662,22 +5838,26 @@
|
|
|
5662
5838
|
context,
|
|
5663
5839
|
pagination,
|
|
5664
5840
|
spineItemManager,
|
|
5665
|
-
parentElement
|
|
5841
|
+
parentElement$: elementSubject$,
|
|
5666
5842
|
cfiLocator,
|
|
5667
5843
|
spineLocator,
|
|
5668
5844
|
hooks$: hooksSubject$,
|
|
5669
|
-
spine
|
|
5845
|
+
spine,
|
|
5846
|
+
settings
|
|
5670
5847
|
});
|
|
5671
|
-
containerElement.appendChild(element);
|
|
5672
|
-
element.appendChild(iframeEventBridgeElement);
|
|
5673
5848
|
viewportNavigator.$.state$.subscribe(viewportStateSubject);
|
|
5674
5849
|
viewportNavigator.$.navigation$.subscribe(navigationSubject);
|
|
5675
5850
|
viewportNavigator.$.navigationAdjustedAfterLayout$.subscribe(navigationAdjustedSubject);
|
|
5676
5851
|
viewportNavigator.$.currentNavigationPosition$.subscribe(currentNavigationPositionSubject$);
|
|
5677
5852
|
const layout = () => {
|
|
5853
|
+
var _a;
|
|
5854
|
+
const containerElement = (_a = elementSubject$.getValue()) == null ? void 0 : _a.parentElement;
|
|
5855
|
+
const element = elementSubject$.getValue();
|
|
5856
|
+
if (!element || !containerElement)
|
|
5857
|
+
throw new Error("Invalid element");
|
|
5678
5858
|
const dimensions = {
|
|
5679
|
-
width: containerElement.offsetWidth,
|
|
5680
|
-
height: containerElement.offsetHeight
|
|
5859
|
+
width: containerElement == null ? void 0 : containerElement.offsetWidth,
|
|
5860
|
+
height: containerElement == null ? void 0 : containerElement.offsetHeight
|
|
5681
5861
|
};
|
|
5682
5862
|
const margin = 0;
|
|
5683
5863
|
const marginTop = 0;
|
|
@@ -5697,12 +5877,21 @@
|
|
|
5697
5877
|
});
|
|
5698
5878
|
viewportNavigator.layout();
|
|
5699
5879
|
};
|
|
5700
|
-
const load = (manifest, loadOptions
|
|
5880
|
+
const load = (manifest, loadOptions) => {
|
|
5881
|
+
var _a;
|
|
5701
5882
|
if (context.getManifest()) {
|
|
5702
5883
|
Report.warn(`loading a new book is not supported yet`);
|
|
5703
5884
|
return;
|
|
5704
5885
|
}
|
|
5705
5886
|
Report.log(`load`, { manifest, loadOptions });
|
|
5887
|
+
const element = createWrapperElement(loadOptions.containerElement);
|
|
5888
|
+
const iframeEventBridgeElement = createIframeEventBridgeElement(loadOptions.containerElement);
|
|
5889
|
+
if (loadOptions.containerElement !== ((_a = elementSubject$.getValue()) == null ? void 0 : _a.parentElement)) {
|
|
5890
|
+
elementSubject$.next(element);
|
|
5891
|
+
iframeEventBridgeElement$.next(iframeEventBridgeElement);
|
|
5892
|
+
loadOptions.containerElement.appendChild(element);
|
|
5893
|
+
element.appendChild(iframeEventBridgeElement);
|
|
5894
|
+
}
|
|
5706
5895
|
context.load(manifest, loadOptions);
|
|
5707
5896
|
layout();
|
|
5708
5897
|
if (!loadOptions.cfi) {
|
|
@@ -5710,14 +5899,10 @@
|
|
|
5710
5899
|
} else {
|
|
5711
5900
|
viewportNavigator.goToCfi(loadOptions.cfi, { animate: false });
|
|
5712
5901
|
}
|
|
5713
|
-
readySubject$.next();
|
|
5714
5902
|
};
|
|
5715
5903
|
const registerHook = (name, fn) => {
|
|
5716
5904
|
hooksSubject$.next([...hooksSubject$.getValue(), { name, fn }]);
|
|
5717
5905
|
};
|
|
5718
|
-
const manipulateContainer = (cb) => {
|
|
5719
|
-
cb(element);
|
|
5720
|
-
};
|
|
5721
5906
|
spine.$.$.pipe(
|
|
5722
5907
|
operators.tap((event) => {
|
|
5723
5908
|
if (event.type === `onSelectionChange`) {
|
|
@@ -5732,45 +5917,42 @@
|
|
|
5732
5917
|
}),
|
|
5733
5918
|
operators.takeUntil(context.$.destroy$)
|
|
5734
5919
|
).subscribe();
|
|
5735
|
-
rxjs.merge(context.$.
|
|
5736
|
-
operators.
|
|
5737
|
-
operators.withLatestFrom(context.$.
|
|
5738
|
-
operators.map(([, hasVerticalWriting]) => {
|
|
5739
|
-
const settings2 = context.getSettings();
|
|
5920
|
+
rxjs.merge(context.$.state$, settings.$.settings$).pipe(
|
|
5921
|
+
operators.map(() => void 0),
|
|
5922
|
+
operators.withLatestFrom(context.$.state$),
|
|
5923
|
+
operators.map(([, { hasVerticalWriting }]) => {
|
|
5740
5924
|
const manifest = context.getManifest();
|
|
5741
5925
|
return {
|
|
5742
5926
|
hasVerticalWriting,
|
|
5743
5927
|
renditionFlow: manifest == null ? void 0 : manifest.renditionFlow,
|
|
5744
5928
|
renditionLayout: manifest == null ? void 0 : manifest.renditionLayout,
|
|
5745
|
-
computedPageTurnMode:
|
|
5929
|
+
computedPageTurnMode: settings.getSettings().computedPageTurnMode
|
|
5746
5930
|
};
|
|
5747
5931
|
}),
|
|
5748
5932
|
operators.distinctUntilChanged(isShallowEqual),
|
|
5749
5933
|
operators.map(
|
|
5750
|
-
({
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
supportedPageTurnAnimation: renditionFlow === `scrolled-continuous` || computedPageTurnMode === `scrollable` ? [`none`] : hasVerticalWriting ? [`fade`, `none`] : [`fade`, `none`, `slide`],
|
|
5759
|
-
supportedPageTurnDirection: computedPageTurnMode === `scrollable` ? [`vertical`] : renditionLayout === `reflowable` ? [`horizontal`] : [`horizontal`, `vertical`]
|
|
5760
|
-
})
|
|
5934
|
+
({ hasVerticalWriting, renditionFlow, renditionLayout, computedPageTurnMode }) => {
|
|
5935
|
+
return {
|
|
5936
|
+
...stateSubject$.value,
|
|
5937
|
+
supportedPageTurnMode: renditionFlow === `scrolled-continuous` ? [`scrollable`] : !context.areAllItemsPrePaginated() ? [`controlled`] : [`controlled`, `scrollable`],
|
|
5938
|
+
supportedPageTurnAnimation: renditionFlow === `scrolled-continuous` || computedPageTurnMode === `scrollable` ? [`none`] : hasVerticalWriting ? [`fade`, `none`] : [`fade`, `none`, `slide`],
|
|
5939
|
+
supportedPageTurnDirection: computedPageTurnMode === `scrollable` ? [`vertical`] : renditionLayout === `reflowable` ? [`horizontal`] : [`horizontal`, `vertical`]
|
|
5940
|
+
};
|
|
5941
|
+
}
|
|
5761
5942
|
),
|
|
5762
5943
|
operators.takeUntil(destroy$)
|
|
5763
5944
|
).subscribe(stateSubject$);
|
|
5764
5945
|
const destroy = () => {
|
|
5946
|
+
var _a, _b;
|
|
5947
|
+
settings.destroy();
|
|
5765
5948
|
hooksSubject$.next([]);
|
|
5766
5949
|
hooksSubject$.complete();
|
|
5767
5950
|
pagination.destroy();
|
|
5768
5951
|
context.destroy();
|
|
5769
5952
|
viewportNavigator.destroy();
|
|
5770
5953
|
spine.destroy();
|
|
5771
|
-
|
|
5772
|
-
iframeEventBridgeElement.remove();
|
|
5773
|
-
readySubject$.complete();
|
|
5954
|
+
(_a = elementSubject$.getValue()) == null ? void 0 : _a.remove();
|
|
5955
|
+
(_b = iframeEventBridgeElement$.getValue()) == null ? void 0 : _b.remove();
|
|
5774
5956
|
stateSubject$.complete();
|
|
5775
5957
|
selectionSubject$.complete();
|
|
5776
5958
|
destroy$.next();
|
|
@@ -5783,7 +5965,6 @@
|
|
|
5783
5965
|
viewportNavigator,
|
|
5784
5966
|
manipulateSpineItems: spine.manipulateSpineItems,
|
|
5785
5967
|
manipulateSpineItem: spine.manipulateSpineItem,
|
|
5786
|
-
manipulateContainer,
|
|
5787
5968
|
moveTo: viewportNavigator.moveTo,
|
|
5788
5969
|
turnLeft: viewportNavigator.turnLeft,
|
|
5789
5970
|
turnRight: viewportNavigator.turnRight,
|
|
@@ -5808,23 +5989,23 @@
|
|
|
5808
5989
|
layout,
|
|
5809
5990
|
load,
|
|
5810
5991
|
destroy,
|
|
5811
|
-
setSettings: context.setSettings,
|
|
5812
|
-
settings$: context.$.settings$,
|
|
5813
|
-
/**
|
|
5814
|
-
* @important
|
|
5815
|
-
* BehaviorSubject
|
|
5816
|
-
*/
|
|
5817
|
-
pagination$: pagination.$.info$,
|
|
5818
5992
|
spineItems$: spine.$.spineItems$,
|
|
5993
|
+
context$: context.$.state$,
|
|
5994
|
+
pagination,
|
|
5995
|
+
settings: {
|
|
5996
|
+
settings$: settings.$.settings$,
|
|
5997
|
+
getSettings: settings.getSettings,
|
|
5998
|
+
setSettings: (data) => settings.setSettings(data, context.getState())
|
|
5999
|
+
},
|
|
5819
6000
|
$: {
|
|
5820
6001
|
state$: stateSubject$.asObservable(),
|
|
5821
6002
|
/**
|
|
5822
|
-
* Dispatched when the reader has loaded a book and is
|
|
6003
|
+
* Dispatched when the reader has loaded a book and is rendering a book.
|
|
5823
6004
|
* Using navigation API and getting information about current content will
|
|
5824
6005
|
* have an effect.
|
|
5825
6006
|
* It can typically be used to hide a loading indicator.
|
|
5826
6007
|
*/
|
|
5827
|
-
|
|
6008
|
+
loadStatus$: context.$.manifest$.pipe(operators.map((manifest) => manifest ? "ready" : "idle")),
|
|
5828
6009
|
/**
|
|
5829
6010
|
* Dispatched when a change in selection happens
|
|
5830
6011
|
*/
|
|
@@ -6027,7 +6208,7 @@
|
|
|
6027
6208
|
}),
|
|
6028
6209
|
operators.takeUntil(context.$.destroy$)
|
|
6029
6210
|
).subscribe();
|
|
6030
|
-
const onLoad$ = context.$.
|
|
6211
|
+
const onLoad$ = context.$.manifest$.pipe(
|
|
6031
6212
|
operators.tap(() => {
|
|
6032
6213
|
uniqueID = Date.now().toString();
|
|
6033
6214
|
})
|
|
@@ -6179,9 +6360,9 @@
|
|
|
6179
6360
|
totalProgress = getTotalProgressFromPercentages(estimateBeforeThisItem, currentItemWeight, progressWithinThisItem);
|
|
6180
6361
|
}
|
|
6181
6362
|
if (currentSpineIndex === readingOrderLength - 1 && pageIndex === numberOfPages - 1 && totalProgress > 0.99) {
|
|
6182
|
-
return
|
|
6363
|
+
return 100;
|
|
6183
6364
|
}
|
|
6184
|
-
return totalProgress;
|
|
6365
|
+
return totalProgress * 100;
|
|
6185
6366
|
};
|
|
6186
6367
|
const getTotalProgressFromPercentages = (estimateBeforeThisItem, currentItemWeight, progressWithinThisItem) => {
|
|
6187
6368
|
return estimateBeforeThisItem + currentItemWeight * progressWithinThisItem;
|
|
@@ -6189,7 +6370,7 @@
|
|
|
6189
6370
|
const getScrollPercentageWithinItem = (context, currentPosition, currentItem) => {
|
|
6190
6371
|
const { height, width } = currentItem.getElementDimensions();
|
|
6191
6372
|
const { top, left } = reader.getAbsolutePositionOf(currentItem);
|
|
6192
|
-
if (
|
|
6373
|
+
if (reader.settings.getSettings().computedPageTurnDirection === `vertical`) {
|
|
6193
6374
|
return Math.max(0, Math.min(1, (currentPosition.y - top + context.getVisibleAreaRect().height) / height));
|
|
6194
6375
|
} else {
|
|
6195
6376
|
return Math.max(0, Math.min(1, (currentPosition.x - left + context.getVisibleAreaRect().width) / width));
|
|
@@ -6379,26 +6560,34 @@
|
|
|
6379
6560
|
container.appendChild(detailsElement);
|
|
6380
6561
|
return container;
|
|
6381
6562
|
};
|
|
6563
|
+
const publicApiEnhancer = (next) => {
|
|
6564
|
+
return (options) => {
|
|
6565
|
+
const reader = next(options);
|
|
6566
|
+
return reader;
|
|
6567
|
+
};
|
|
6568
|
+
};
|
|
6382
6569
|
const createReaderWithEnhancers = (
|
|
6383
6570
|
//__
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6571
|
+
publicApiEnhancer(
|
|
6572
|
+
loadingEnhancer(
|
|
6573
|
+
webkitEnhancer(
|
|
6574
|
+
fontsEnhancer(
|
|
6575
|
+
linksEnhancer(
|
|
6576
|
+
accessibilityEnhancer(
|
|
6577
|
+
resourcesEnhancer(
|
|
6578
|
+
utilsEnhancer(
|
|
6579
|
+
layoutEnhancer(
|
|
6580
|
+
zoomEnhancer(
|
|
6581
|
+
mediaEnhancer(
|
|
6582
|
+
chromeEnhancer(
|
|
6583
|
+
navigationEnhancer(
|
|
6584
|
+
themeEnhancer(
|
|
6585
|
+
hotkeysEnhancer(
|
|
6586
|
+
paginationEnhancer(
|
|
6587
|
+
progressionEnhancer(
|
|
6588
|
+
// __
|
|
6589
|
+
createReader
|
|
6590
|
+
)
|
|
6402
6591
|
)
|
|
6403
6592
|
)
|
|
6404
6593
|
)
|
|
@@ -6422,4 +6611,4 @@
|
|
|
6422
6611
|
exports2.isShallowEqual = isShallowEqual;
|
|
6423
6612
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
6424
6613
|
});
|
|
6425
|
-
//# sourceMappingURL=
|
|
6614
|
+
//# sourceMappingURL=index.umd.cjs.map
|