@readium/navigator 1.2.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/LICENSE +28 -0
- package/README.MD +11 -0
- package/dist/assets/AccessibleDfA.otf +0 -0
- package/dist/assets/iAWriterDuospace-Regular.ttf +0 -0
- package/dist/index.js +6263 -0
- package/dist/index.umd.cjs +107 -0
- package/package.json +65 -0
- package/src/Navigator.ts +66 -0
- package/src/audio/engine/AudioEngine.ts +136 -0
- package/src/audio/engine/WebAudioEngine.ts +286 -0
- package/src/audio/engine/index.ts +2 -0
- package/src/audio/index.ts +1 -0
- package/src/epub/EpubNavigator.ts +507 -0
- package/src/epub/frame/FrameBlobBuilder.ts +211 -0
- package/src/epub/frame/FrameComms.ts +142 -0
- package/src/epub/frame/FrameManager.ts +134 -0
- package/src/epub/frame/FramePoolManager.ts +179 -0
- package/src/epub/frame/index.ts +3 -0
- package/src/epub/fxl/FXLCoordinator.ts +152 -0
- package/src/epub/fxl/FXLFrameManager.ts +286 -0
- package/src/epub/fxl/FXLFramePoolManager.ts +632 -0
- package/src/epub/fxl/FXLPeripherals.ts +587 -0
- package/src/epub/fxl/FXLPeripheralsDebug.ts +46 -0
- package/src/epub/fxl/FXLSpreader.ts +95 -0
- package/src/epub/fxl/index.ts +5 -0
- package/src/epub/index.ts +3 -0
- package/src/helpers/sML.ts +120 -0
- package/src/index.ts +3 -0
- package/types/src/Navigator.d.ts +41 -0
- package/types/src/audio/engine/AudioEngine.d.ts +114 -0
- package/types/src/audio/engine/WebAudioEngine.d.ts +107 -0
- package/types/src/audio/engine/index.d.ts +2 -0
- package/types/src/audio/index.d.ts +1 -0
- package/types/src/epub/EpubNavigator.d.ts +66 -0
- package/types/src/epub/frame/FrameBlobBuilder.d.ts +13 -0
- package/types/src/epub/frame/FrameComms.d.ts +26 -0
- package/types/src/epub/frame/FrameManager.d.ts +21 -0
- package/types/src/epub/frame/FramePoolManager.d.ts +17 -0
- package/types/src/epub/frame/index.d.ts +3 -0
- package/types/src/epub/fxl/FXLCoordinator.d.ts +37 -0
- package/types/src/epub/fxl/FXLFrameManager.d.ts +41 -0
- package/types/src/epub/fxl/FXLFramePoolManager.d.ts +93 -0
- package/types/src/epub/fxl/FXLPeripherals.d.ts +97 -0
- package/types/src/epub/fxl/FXLPeripheralsDebug.d.ts +13 -0
- package/types/src/epub/fxl/FXLSpreader.d.ts +12 -0
- package/types/src/epub/fxl/index.d.ts +5 -0
- package/types/src/epub/index.d.ts +3 -0
- package/types/src/helpers/sML.d.ts +51 -0
- package/types/src/index.d.ts +3 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface Point {
|
|
2
|
+
X: number;
|
|
3
|
+
Y: number;
|
|
4
|
+
}
|
|
5
|
+
export declare enum HorizontalThird {
|
|
6
|
+
Left = 0,
|
|
7
|
+
Center = 1,
|
|
8
|
+
Right = 2
|
|
9
|
+
}
|
|
10
|
+
export declare enum VerticalThird {
|
|
11
|
+
Top = 0,
|
|
12
|
+
Middle = 1,
|
|
13
|
+
Bottom = 2
|
|
14
|
+
}
|
|
15
|
+
export interface NinthPoint {
|
|
16
|
+
X: HorizontalThird | null;
|
|
17
|
+
Y: VerticalThird | null;
|
|
18
|
+
}
|
|
19
|
+
export interface BibiEvent {
|
|
20
|
+
Target: EventTarget | null;
|
|
21
|
+
Coord: Point | null;
|
|
22
|
+
Ratio: Point | null;
|
|
23
|
+
Division: NinthPoint | null;
|
|
24
|
+
}
|
|
25
|
+
export declare class FXLCoordinator {
|
|
26
|
+
HTML: HTMLElement;
|
|
27
|
+
Head: HTMLHeadElement;
|
|
28
|
+
Body: HTMLElement;
|
|
29
|
+
constructor();
|
|
30
|
+
private outerWidth;
|
|
31
|
+
private outerHeight;
|
|
32
|
+
refreshOuterPixels(_: DOMRect): void;
|
|
33
|
+
getBibiEventCoord(Eve: TouchEvent | MouseEvent, touch?: number): Point;
|
|
34
|
+
getTouchDistance(Eve: TouchEvent): number;
|
|
35
|
+
getTouchCenter(Eve: TouchEvent): Point | null;
|
|
36
|
+
getBibiEvent(Eve: Event): BibiEvent;
|
|
37
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Loader, ModuleName } from "@readium/navigator-html-injectables";
|
|
2
|
+
import { Page, ReadingProgression } from "@readium/shared";
|
|
3
|
+
import { FrameComms } from "../frame/FrameComms";
|
|
4
|
+
import { FXLPeripherals } from "./FXLPeripherals";
|
|
5
|
+
export declare class FXLFrameManager {
|
|
6
|
+
private frame;
|
|
7
|
+
private loader;
|
|
8
|
+
source: string;
|
|
9
|
+
private comms;
|
|
10
|
+
private readonly peripherals;
|
|
11
|
+
private currModules;
|
|
12
|
+
wrapper: HTMLDivElement;
|
|
13
|
+
debugHref: string;
|
|
14
|
+
private loadPromise;
|
|
15
|
+
private showPromise;
|
|
16
|
+
constructor(peripherals: FXLPeripherals, direction: ReadingProgression, debugHref: string);
|
|
17
|
+
load(modules: ModuleName[], source: string): Promise<Window>;
|
|
18
|
+
loadPageSize(): {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
update(page?: Page): void;
|
|
23
|
+
destroy(): Promise<void>;
|
|
24
|
+
unload(): Promise<void>;
|
|
25
|
+
deselect(): void;
|
|
26
|
+
unfocus(): Promise<void>;
|
|
27
|
+
private cachedPage;
|
|
28
|
+
show(page: Page): Promise<void>;
|
|
29
|
+
activate(): Promise<void>;
|
|
30
|
+
get element(): HTMLDivElement;
|
|
31
|
+
get iframe(): HTMLIFrameElement;
|
|
32
|
+
get realSize(): DOMRect;
|
|
33
|
+
get loaded(): boolean | null;
|
|
34
|
+
set width(width: number);
|
|
35
|
+
set height(height: number);
|
|
36
|
+
get window(): Window;
|
|
37
|
+
get atLeft(): boolean;
|
|
38
|
+
get atRight(): boolean;
|
|
39
|
+
get msg(): FrameComms | undefined;
|
|
40
|
+
get ldr(): Loader<ModuleName> | undefined;
|
|
41
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ModuleName } from "@readium/navigator-html-injectables";
|
|
2
|
+
import { Locator, Publication, Page, Link } from "@readium/shared";
|
|
3
|
+
import { FrameCommsListener } from "../frame";
|
|
4
|
+
import { FXLFrameManager } from "./FXLFrameManager";
|
|
5
|
+
import { FXLPeripherals } from "./FXLPeripherals";
|
|
6
|
+
export declare class FXLFramePoolManager {
|
|
7
|
+
private readonly container;
|
|
8
|
+
private readonly positions;
|
|
9
|
+
private readonly pool;
|
|
10
|
+
private readonly blobs;
|
|
11
|
+
private readonly inprogress;
|
|
12
|
+
private readonly delayedShow;
|
|
13
|
+
private readonly delayedTimeout;
|
|
14
|
+
private currentBaseURL;
|
|
15
|
+
private previousFrames;
|
|
16
|
+
private readonly bookElement;
|
|
17
|
+
readonly spineElement: HTMLDivElement;
|
|
18
|
+
private readonly pub;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
private transform;
|
|
22
|
+
currentSlide: number;
|
|
23
|
+
private spreader;
|
|
24
|
+
private spread;
|
|
25
|
+
private readonly spreadPresentation;
|
|
26
|
+
private orientationInternal;
|
|
27
|
+
private containerHeightCached;
|
|
28
|
+
private readonly resizeBoundHandler;
|
|
29
|
+
private resizeTimeout;
|
|
30
|
+
readonly peripherals: FXLPeripherals;
|
|
31
|
+
constructor(container: HTMLElement, positions: Locator[], pub: Publication);
|
|
32
|
+
private _listener;
|
|
33
|
+
set listener(listener: FrameCommsListener);
|
|
34
|
+
get listener(): FrameCommsListener;
|
|
35
|
+
get doNotDisturb(): boolean;
|
|
36
|
+
private nativeResizeHandler;
|
|
37
|
+
/**
|
|
38
|
+
* When window resizes, resize slider components as well
|
|
39
|
+
*/
|
|
40
|
+
resizeHandler(slide?: boolean, fast?: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* It is important that these values be cached to avoid spamming them on redraws, they are expensive.
|
|
43
|
+
*/
|
|
44
|
+
private updateDimensions;
|
|
45
|
+
get rtl(): boolean;
|
|
46
|
+
private get single();
|
|
47
|
+
get perPage(): 1 | 2;
|
|
48
|
+
get threshold(): number;
|
|
49
|
+
get portrait(): boolean;
|
|
50
|
+
updateSpineStyle(animate: boolean, fast?: boolean): void;
|
|
51
|
+
updateBookStyle(initial?: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Go to slide with particular index
|
|
54
|
+
* @param {number} index - Item index to slide to.
|
|
55
|
+
*/
|
|
56
|
+
goTo(index: number): void;
|
|
57
|
+
onChange(): void;
|
|
58
|
+
private get offset();
|
|
59
|
+
get length(): number;
|
|
60
|
+
get slength(): number;
|
|
61
|
+
get shift(): boolean;
|
|
62
|
+
private get nLandscape();
|
|
63
|
+
setPerPage(perPage: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Moves sliders frame to position of currently active slide
|
|
66
|
+
*/
|
|
67
|
+
slideToCurrent(enableTransition?: boolean, fast?: boolean): void;
|
|
68
|
+
bounce(rtl?: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Go to next slide.
|
|
71
|
+
* @param {number} [howManySlides=1] - How many items to slide forward.
|
|
72
|
+
* @returns {boolean} Whether or not going to next was possible
|
|
73
|
+
*/
|
|
74
|
+
next(howManySlides?: number): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Go to previous slide.
|
|
77
|
+
* @param {number} [howManySlides=1] - How many items to slide backward.
|
|
78
|
+
* @returns {boolean} Whether or not going to prev was possible
|
|
79
|
+
*/
|
|
80
|
+
prev(howManySlides?: number): boolean;
|
|
81
|
+
get ownerWindow(): Window & typeof globalThis;
|
|
82
|
+
destroy(): Promise<void>;
|
|
83
|
+
makeSpread(itemIndex: number): Link[];
|
|
84
|
+
reAlign(index?: number): number;
|
|
85
|
+
spreadPosition(spread: Link[], target: Link): Page;
|
|
86
|
+
waitForItem(href: string): Promise<void>;
|
|
87
|
+
cancelShowing(href: string): Promise<void>;
|
|
88
|
+
update(pub: Publication, locator: Locator, modules: ModuleName[], _force?: boolean): Promise<void>;
|
|
89
|
+
get currentFrames(): (FXLFrameManager | undefined)[];
|
|
90
|
+
get currentBounds(): DOMRect;
|
|
91
|
+
get currentNumbers(): number[];
|
|
92
|
+
deselect(): void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Point } from "./FXLCoordinator";
|
|
2
|
+
import { FXLFramePoolManager } from "./FXLFramePoolManager";
|
|
3
|
+
export interface PanTracker {
|
|
4
|
+
startX: number;
|
|
5
|
+
endX: number;
|
|
6
|
+
overscrollX: number;
|
|
7
|
+
overscrollY: number;
|
|
8
|
+
startY: number;
|
|
9
|
+
letItGo: boolean;
|
|
10
|
+
preventClick: boolean;
|
|
11
|
+
translateX: number;
|
|
12
|
+
translateY: number;
|
|
13
|
+
touchID: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PinchTracker {
|
|
16
|
+
startDistance: number;
|
|
17
|
+
startScale: number;
|
|
18
|
+
target: Point;
|
|
19
|
+
startTranslate: Point;
|
|
20
|
+
touchN: number;
|
|
21
|
+
}
|
|
22
|
+
export interface Zoomer {
|
|
23
|
+
scale: number;
|
|
24
|
+
translate: {
|
|
25
|
+
X: number;
|
|
26
|
+
Y: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare class FXLPeripherals {
|
|
30
|
+
private readonly manager;
|
|
31
|
+
private readonly coordinator;
|
|
32
|
+
dragState: number;
|
|
33
|
+
private minimumMoved;
|
|
34
|
+
pan: PanTracker;
|
|
35
|
+
private pinch;
|
|
36
|
+
private _scale;
|
|
37
|
+
get scale(): number;
|
|
38
|
+
private scaleDebouncer;
|
|
39
|
+
set scale(value: number);
|
|
40
|
+
private frameBounds;
|
|
41
|
+
private debugger;
|
|
42
|
+
constructor(manager: FXLFramePoolManager, debug?: boolean);
|
|
43
|
+
private readonly btouchstartHandler;
|
|
44
|
+
private readonly btouchendHandler;
|
|
45
|
+
private readonly btouchmoveHandler;
|
|
46
|
+
private readonly bdblclickHandler;
|
|
47
|
+
private readonly bmousedownHandler;
|
|
48
|
+
private readonly bmouseupHandler;
|
|
49
|
+
private readonly bmousemoveHandler;
|
|
50
|
+
/**
|
|
51
|
+
* Attaches listeners to required events.
|
|
52
|
+
*/
|
|
53
|
+
attachEvents(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Clear drag after touchend and mouseup event
|
|
56
|
+
*/
|
|
57
|
+
private clearPan;
|
|
58
|
+
clearPinch(): void;
|
|
59
|
+
observe(item: EventTarget): void;
|
|
60
|
+
clickHandler(_: MouseEvent): void;
|
|
61
|
+
/**
|
|
62
|
+
* touchstart event handler
|
|
63
|
+
*/
|
|
64
|
+
touchstartHandler(e: TouchEvent): void;
|
|
65
|
+
private startTouch;
|
|
66
|
+
/**
|
|
67
|
+
* touchend event handler
|
|
68
|
+
*/
|
|
69
|
+
touchendHandler(e: TouchEvent): void;
|
|
70
|
+
private moveFrame;
|
|
71
|
+
/**
|
|
72
|
+
* touchmove event handler
|
|
73
|
+
*/
|
|
74
|
+
touchmoveHandler(e: TouchEvent): void;
|
|
75
|
+
private dtimer;
|
|
76
|
+
private pdblclick;
|
|
77
|
+
private disableDblClick;
|
|
78
|
+
dblclickHandler(_: MouseEvent): void;
|
|
79
|
+
get isScaled(): boolean;
|
|
80
|
+
private addTouch;
|
|
81
|
+
/**
|
|
82
|
+
* mousedown event handler
|
|
83
|
+
*/
|
|
84
|
+
mousedownHandler(e: MouseEvent): void;
|
|
85
|
+
/**
|
|
86
|
+
* mouseup event handler
|
|
87
|
+
*/
|
|
88
|
+
mouseupHandler(e: MouseEvent): void;
|
|
89
|
+
/**
|
|
90
|
+
* mousemove event handler
|
|
91
|
+
*/
|
|
92
|
+
mousemoveHandler(e: MouseEvent): void;
|
|
93
|
+
/**
|
|
94
|
+
* Recalculate drag/swipe event and reposition the frame of a slider
|
|
95
|
+
*/
|
|
96
|
+
private updateAfterDrag;
|
|
97
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class FXLPeripheralsDebug {
|
|
2
|
+
private readonly _DOM;
|
|
3
|
+
get show(): boolean;
|
|
4
|
+
get DOM(): {
|
|
5
|
+
show: boolean;
|
|
6
|
+
pinchTarget: HTMLDivElement;
|
|
7
|
+
touch1: HTMLDivElement;
|
|
8
|
+
touch2: HTMLDivElement;
|
|
9
|
+
center: HTMLDivElement;
|
|
10
|
+
stats: HTMLDivElement;
|
|
11
|
+
};
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Link, Publication } from "@readium/shared";
|
|
2
|
+
export declare class FXLSpreader {
|
|
3
|
+
shift: boolean;
|
|
4
|
+
private spreads;
|
|
5
|
+
nLandscape: number;
|
|
6
|
+
constructor(publication: Publication);
|
|
7
|
+
private index;
|
|
8
|
+
private testShift;
|
|
9
|
+
private buildSpreads;
|
|
10
|
+
currentSpread(currentSlide: number, perPage: number): Link[];
|
|
11
|
+
findByLink(link: Link): Link[] | undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* (℠)
|
|
3
|
+
* # sML.js | I'm a Simple and Middling Library.
|
|
4
|
+
*
|
|
5
|
+
* * Copyright (c) Satoru MATSUSHIMA - https://github.com/satorumurmur/sML
|
|
6
|
+
* * Licensed under the MIT license. - http://www.opensource.org/licenses/mit-license.php
|
|
7
|
+
*
|
|
8
|
+
* Portions of this code come from the sML library
|
|
9
|
+
* Current version: 1.0.36
|
|
10
|
+
*/
|
|
11
|
+
declare interface OSFlags {
|
|
12
|
+
iOS: number[];
|
|
13
|
+
macOS: number[];
|
|
14
|
+
iPadOS: number[];
|
|
15
|
+
WindowsPhone: number[];
|
|
16
|
+
ChromeOS: number[];
|
|
17
|
+
Windows: number[];
|
|
18
|
+
Android: number[];
|
|
19
|
+
Linux: number[];
|
|
20
|
+
Firefox: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare interface UAFlags {
|
|
23
|
+
Gecko: number[];
|
|
24
|
+
Firefox: number[];
|
|
25
|
+
Waterfox: number[];
|
|
26
|
+
Opera: number[];
|
|
27
|
+
Silk: number[];
|
|
28
|
+
Blink: number[];
|
|
29
|
+
EdgeHTML: number[];
|
|
30
|
+
Chrome: number[];
|
|
31
|
+
Chromium: number[];
|
|
32
|
+
Phoebe: number[];
|
|
33
|
+
UCBrowser: number[];
|
|
34
|
+
Vivaldi: number[];
|
|
35
|
+
Safari: number[];
|
|
36
|
+
Edge: number[];
|
|
37
|
+
WebKit: number[];
|
|
38
|
+
Trident: number[];
|
|
39
|
+
InternetExplorer: number[];
|
|
40
|
+
Flash: number[];
|
|
41
|
+
Facebook: number[];
|
|
42
|
+
LINE: number[];
|
|
43
|
+
}
|
|
44
|
+
declare class sML {
|
|
45
|
+
OS: OSFlags;
|
|
46
|
+
UA: UAFlags;
|
|
47
|
+
Env: string[];
|
|
48
|
+
constructor();
|
|
49
|
+
}
|
|
50
|
+
declare const _default: sML;
|
|
51
|
+
export default _default;
|