@readium/navigator 2.6.1 → 2.7.0-alpha.1

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.
Files changed (51) hide show
  1. package/LICENSE +28 -0
  2. package/dist/index.js +4795 -3156
  3. package/dist/index.umd.cjs +42 -40
  4. package/package.json +10 -10
  5. package/src/divina/DivinaNavigator.ts +662 -0
  6. package/src/divina/DivinaPageManager.ts +322 -0
  7. package/src/divina/DivinaPagedPresenter.ts +508 -0
  8. package/src/divina/DivinaPeripherals.ts +630 -0
  9. package/src/divina/DivinaScrolledPresenter.ts +516 -0
  10. package/src/divina/DivinaSpreader.ts +202 -0
  11. package/src/divina/DivinaVariantSelector.ts +77 -0
  12. package/src/divina/index.ts +8 -0
  13. package/src/divina/preferences/DivinaDefaults.ts +37 -0
  14. package/src/divina/preferences/DivinaPreferences.ts +77 -0
  15. package/src/divina/preferences/DivinaPreferencesEditor.ts +89 -0
  16. package/src/divina/preferences/DivinaSettings.ts +38 -0
  17. package/src/divina/preferences/index.ts +4 -0
  18. package/src/divina/protection/DivinaNavigatorProtector.ts +44 -0
  19. package/src/epub/EpubNavigator.ts +59 -3
  20. package/src/epub/frame/FrameBlobBuilder.ts +85 -32
  21. package/src/epub/frame/FrameManager.ts +3 -3
  22. package/src/epub/frame/FramePoolManager.ts +78 -34
  23. package/src/epub/fxl/FXLFrameManager.ts +69 -26
  24. package/src/epub/fxl/FXLFramePoolManager.ts +88 -50
  25. package/src/epub/fxl/FXLPeripherals.ts +22 -1
  26. package/src/index.ts +1 -0
  27. package/src/peripherals/KeyboardConditionBridge.ts +15 -5
  28. package/src/peripherals/KeyboardPeripherals.ts +13 -7
  29. package/src/webpub/WebPubFrameManager.ts +3 -3
  30. package/types/src/divina/DivinaNavigator.d.ts +113 -0
  31. package/types/src/divina/DivinaPageManager.d.ts +66 -0
  32. package/types/src/divina/DivinaPagedPresenter.d.ts +122 -0
  33. package/types/src/divina/DivinaPeripherals.d.ts +121 -0
  34. package/types/src/divina/DivinaScrolledPresenter.d.ts +125 -0
  35. package/types/src/divina/DivinaSpreader.d.ts +65 -0
  36. package/types/src/divina/DivinaVariantSelector.d.ts +30 -0
  37. package/types/src/divina/index.d.ts +8 -0
  38. package/types/src/divina/preferences/DivinaDefaults.d.ts +18 -0
  39. package/types/src/divina/preferences/DivinaPreferences.d.ts +33 -0
  40. package/types/src/divina/preferences/DivinaPreferencesEditor.d.ts +20 -0
  41. package/types/src/divina/preferences/DivinaSettings.d.ts +26 -0
  42. package/types/src/divina/preferences/index.d.ts +4 -0
  43. package/types/src/divina/protection/DivinaNavigatorProtector.d.ts +14 -0
  44. package/types/src/epub/EpubNavigator.d.ts +3 -1
  45. package/types/src/epub/frame/FrameBlobBuilder.d.ts +6 -3
  46. package/types/src/epub/frame/FramePoolManager.d.ts +1 -0
  47. package/types/src/epub/fxl/FXLFrameManager.d.ts +2 -0
  48. package/types/src/epub/fxl/FXLFramePoolManager.d.ts +6 -2
  49. package/types/src/epub/fxl/FXLPeripherals.d.ts +3 -0
  50. package/types/src/index.d.ts +1 -0
  51. package/types/src/peripherals/KeyboardPeripherals.d.ts +1 -0
@@ -0,0 +1,33 @@
1
+ import { ConfigurablePreferences } from "../../preferences/Configurable.ts";
2
+ import { RangeConfig } from "../../preferences/Types.ts";
3
+ import { DivinaQuality } from "../DivinaVariantSelector.ts";
4
+ /**
5
+ * Maximum width in pixels of the vertical strip in scrolled mode.
6
+ */
7
+ export declare const stripWidthRangeConfig: RangeConfig;
8
+ export interface IDivinaPreferences {
9
+ /** Background color behind the pages (equivalent of the EPUB page background theme) */
10
+ backgroundColor?: string | null;
11
+ /** Number of pixels to constrain the container width by (e.g. for docked panels) */
12
+ constraint?: number | null;
13
+ /** Image quality when the publication offers alternate resolutions */
14
+ quality?: DivinaQuality | null;
15
+ /** Display the publication as a vertical scroll instead of horizontal pages */
16
+ scrolled?: boolean | null;
17
+ /** Display two pages side-by-side on landscape viewports (paged mode only) */
18
+ spreads?: boolean | null;
19
+ /** Maximum width in pixels of the vertical strip in scrolled mode */
20
+ stripWidth?: number | null;
21
+ }
22
+ export declare class DivinaPreferences implements ConfigurablePreferences<DivinaPreferences> {
23
+ backgroundColor?: string | null;
24
+ constraint?: number | null;
25
+ quality?: DivinaQuality | null;
26
+ scrolled?: boolean | null;
27
+ spreads?: boolean | null;
28
+ stripWidth?: number | null;
29
+ constructor(preferences?: IDivinaPreferences);
30
+ static serialize(preferences: DivinaPreferences): string;
31
+ static deserialize(preferences: string): DivinaPreferences | null;
32
+ merging(other: DivinaPreferences): DivinaPreferences;
33
+ }
@@ -0,0 +1,20 @@
1
+ import { Metadata } from "@readium/shared";
2
+ import { IPreferencesEditor } from "../../preferences/PreferencesEditor.ts";
3
+ import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference.ts";
4
+ import { DivinaQuality } from "../DivinaVariantSelector.ts";
5
+ import { DivinaPreferences } from "./DivinaPreferences.ts";
6
+ import { DivinaSettings } from "./DivinaSettings.ts";
7
+ export declare class DivinaPreferencesEditor implements IPreferencesEditor {
8
+ preferences: DivinaPreferences;
9
+ private settings;
10
+ private metadata;
11
+ constructor(initialPreferences: DivinaPreferences, settings: DivinaSettings, metadata: Metadata);
12
+ clear(): void;
13
+ private updatePreference;
14
+ private get manifestScrolled();
15
+ get backgroundColor(): Preference<string>;
16
+ get quality(): EnumPreference<DivinaQuality>;
17
+ get scrolled(): BooleanPreference;
18
+ get spreads(): BooleanPreference;
19
+ get stripWidth(): RangePreference<number>;
20
+ }
@@ -0,0 +1,26 @@
1
+ import { ConfigurableSettings } from "../../preferences/Configurable.ts";
2
+ import { DivinaQuality } from "../DivinaVariantSelector.ts";
3
+ import { DivinaDefaults } from "./DivinaDefaults.ts";
4
+ import { DivinaPreferences } from "./DivinaPreferences.ts";
5
+ export interface IDivinaSettings {
6
+ backgroundColor?: string | null;
7
+ constraint?: number | null;
8
+ quality?: DivinaQuality | null;
9
+ scrolled?: boolean | null;
10
+ spreads?: boolean | null;
11
+ stripWidth?: number | null;
12
+ }
13
+ export declare class DivinaSettings implements ConfigurableSettings {
14
+ backgroundColor: string | null;
15
+ constraint: number;
16
+ quality: DivinaQuality;
17
+ scrolled: boolean;
18
+ spreads: boolean;
19
+ stripWidth: number;
20
+ /**
21
+ * @param manifestScrolled Whether the publication itself declares `layout: scrolled`.
22
+ * A natively scrolled publication (e.g. webtoon) cannot be switched to paged mode,
23
+ * while a fixed publication can be switched to scrolled by the user.
24
+ */
25
+ constructor(preferences: DivinaPreferences, defaults: DivinaDefaults, manifestScrolled: boolean);
26
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./DivinaDefaults.ts";
2
+ export * from "./DivinaPreferences.ts";
3
+ export * from "./DivinaPreferencesEditor.ts";
4
+ export * from "./DivinaSettings.ts";
@@ -0,0 +1,14 @@
1
+ import { NavigatorProtector } from "../../protection/NavigatorProtector.ts";
2
+ import { IContentProtectionConfig } from "../../Navigator.ts";
3
+ /**
4
+ * Content protection for the Divina navigator. Because Divina renders images
5
+ * directly in the host DOM (no iframes), the in-frame halves of the EPUB
6
+ * protection (copy and drag-and-drop blocking) must run host-side instead,
7
+ * like the audio navigator does.
8
+ */
9
+ export declare class DivinaNavigatorProtector extends NavigatorProtector {
10
+ private dragAndDropProtector?;
11
+ private copyProtector?;
12
+ constructor(config?: IContentProtectionConfig);
13
+ destroy(): void;
14
+ }
@@ -41,6 +41,7 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
41
41
  private readonly container;
42
42
  private readonly listeners;
43
43
  private framePool;
44
+ private _destroyed;
44
45
  private positions;
45
46
  private currentLocation;
46
47
  private lastLocationInView;
@@ -70,7 +71,7 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
70
71
  private reflowViewport;
71
72
  constructor(container: HTMLElement, pub: Publication, listeners: EpubNavigatorListeners, positions?: Locator[], initialPosition?: Locator | undefined, configuration?: EpubNavigatorConfiguration);
72
73
  static determineLayout(pub: Publication, scroll?: boolean): Layout;
73
- load(): Promise<void>;
74
+ load(): Promise<unknown>;
74
75
  get settings(): Readonly<EpubSettings>;
75
76
  get preferencesEditor(): EpubPreferencesEditor;
76
77
  submitPreferences(preferences: EpubPreferences): Promise<void>;
@@ -128,6 +129,7 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
128
129
  private setLayout;
129
130
  get publication(): Publication;
130
131
  private loadLocator;
132
+ private completeLocator;
131
133
  go(locator: Locator, _: boolean, cb: (ok: boolean) => void): void;
132
134
  goLink(link: Link, animated: boolean, cb: (ok: boolean) => void): void;
133
135
  }
@@ -1,17 +1,20 @@
1
1
  import { Link, Publication } from "@readium/shared";
2
2
  import { Injector } from "../../injection/Injector.ts";
3
- export default class FrameBlobBuider {
4
- private readonly item;
5
- private readonly burl;
3
+ export default class FrameBlobBuilder {
6
4
  private readonly pub;
5
+ private readonly baseURL;
6
+ private readonly item;
7
7
  private readonly cssProperties?;
8
8
  private readonly injector;
9
+ private currentUrl?;
10
+ private currentResource?;
9
11
  constructor(pub: Publication, baseURL: string, item: Link, options: {
10
12
  cssProperties?: {
11
13
  [key: string]: string;
12
14
  };
13
15
  injector?: Injector | null;
14
16
  });
17
+ reset(): void;
15
18
  build(fxl?: boolean): Promise<string>;
16
19
  private buildHtmlFrame;
17
20
  private buildImageFrame;
@@ -16,6 +16,7 @@ export declare class FramePoolManager {
16
16
  private readonly injector;
17
17
  private readonly contentProtectionConfig;
18
18
  private readonly keyboardPeripheralsConfig;
19
+ private updateSequence;
19
20
  constructor(container: HTMLElement, positions: Locator[], cssProperties?: {
20
21
  [key: string]: string;
21
22
  }, injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
@@ -5,6 +5,7 @@ import { FXLPeripherals } from "./FXLPeripherals.ts";
5
5
  import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../../Navigator.ts";
6
6
  export declare class FXLFrameManager {
7
7
  private frame;
8
+ private frameIsAppended;
8
9
  private loader;
9
10
  source: string;
10
11
  private comms;
@@ -17,6 +18,7 @@ export declare class FXLFrameManager {
17
18
  debugHref: string;
18
19
  private loadPromise;
19
20
  private showPromise;
21
+ private viewportSize;
20
22
  constructor(peripherals: FXLPeripherals, direction: ReadingProgression, debugHref: string, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
21
23
  load(modules: ModuleName[], source: string): Promise<Window>;
22
24
  loadPageSize(): {
@@ -1,5 +1,5 @@
1
1
  import { ModuleName } from "@readium/navigator-html-injectables";
2
- import { Locator, Publication, Page, Link } from "@readium/shared";
2
+ import { Locator, Publication, Page, Link, Layout } from "@readium/shared";
3
3
  import { FrameCommsListener } from "../frame/index.ts";
4
4
  import { FXLFrameManager } from "./FXLFrameManager.ts";
5
5
  import { FXLPeripherals } from "./FXLPeripherals.ts";
@@ -32,7 +32,8 @@ export declare class FXLFramePoolManager {
32
32
  private containerHeightCached;
33
33
  private resizeTimeout;
34
34
  readonly peripherals: FXLPeripherals;
35
- constructor(container: HTMLElement, positions: Locator[], pub: Publication, injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
35
+ constructor(container: HTMLElement, positions: Locator[], pub: Publication, _layout: Layout, // TODO: used by upcoming scrolled-layout support
36
+ injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
36
37
  private _listener;
37
38
  set listener(listener: FrameCommsListener);
38
39
  get listener(): FrameCommsListener;
@@ -51,6 +52,9 @@ export declare class FXLFramePoolManager {
51
52
  get threshold(): number;
52
53
  get portrait(): boolean;
53
54
  updateSpineStyle(animate: boolean, fast?: boolean): void;
55
+ private bookScale;
56
+ private bookTranslate;
57
+ private bookTransform;
54
58
  updateBookStyle(initial?: boolean): void;
55
59
  /**
56
60
  * Go to slide with particular index
@@ -26,6 +26,7 @@ export interface Zoomer {
26
26
  Y: number;
27
27
  };
28
28
  }
29
+ export declare const isTypedOMSupported: () => boolean;
29
30
  export declare class FXLPeripherals {
30
31
  private readonly manager;
31
32
  private readonly coordinator;
@@ -68,6 +69,8 @@ export declare class FXLPeripherals {
68
69
  */
69
70
  touchendHandler(e: TouchEvent): void;
70
71
  private moveFrame;
72
+ private dragTranslate;
73
+ private dragTransform;
71
74
  /**
72
75
  * touchmove event handler
73
76
  */
@@ -2,6 +2,7 @@ export * from './Navigator.ts';
2
2
  export * from './decorations/index.ts';
3
3
  export * from './webpub/index.ts';
4
4
  export * from './epub/index.ts';
5
+ export * from './divina/index.ts';
5
6
  export * from './audio/index.ts';
6
7
  export * from './helpers/index.ts';
7
8
  export * from './preferences/index.ts';
@@ -7,6 +7,7 @@ export interface KeyboardPeripheralOptions {
7
7
  export declare class KeyboardPeripherals {
8
8
  private keydownHandler?;
9
9
  private keyManager;
10
+ private readonly pagehideHandler;
10
11
  constructor(options?: KeyboardPeripheralOptions);
11
12
  private setupKeyboardPeripherals;
12
13
  destroy(): void;