@readium/navigator 2.2.9 → 2.3.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 (65) hide show
  1. package/dist/index.js +2786 -1791
  2. package/dist/index.umd.cjs +79 -86
  3. package/package.json +2 -3
  4. package/src/Navigator.ts +76 -0
  5. package/src/epub/EpubNavigator.ts +93 -10
  6. package/src/epub/css/Properties.ts +8 -8
  7. package/src/epub/css/ReadiumCSS.ts +7 -5
  8. package/src/epub/frame/FrameManager.ts +38 -2
  9. package/src/epub/frame/FramePoolManager.ts +9 -2
  10. package/src/epub/fxl/FXLFrameManager.ts +31 -2
  11. package/src/epub/fxl/FXLFramePoolManager.ts +9 -3
  12. package/src/epub/preferences/EpubDefaults.ts +6 -6
  13. package/src/epub/preferences/EpubPreferences.ts +6 -6
  14. package/src/epub/preferences/EpubPreferencesEditor.ts +1 -3
  15. package/src/epub/preferences/EpubSettings.ts +5 -7
  16. package/src/helpers/lineLength.ts +4 -6
  17. package/src/injection/epubInjectables.ts +11 -3
  18. package/src/injection/webpubInjectables.ts +12 -2
  19. package/src/peripherals/KeyboardPeripherals.ts +53 -0
  20. package/src/protection/AutomationDetector.ts +66 -0
  21. package/src/protection/ContextMenuProtector.ts +46 -0
  22. package/src/protection/DevToolsDetector.ts +291 -0
  23. package/src/protection/IframeEmbeddingDetector.ts +73 -0
  24. package/src/protection/NavigatorProtector.ts +95 -0
  25. package/src/protection/PrintProtector.ts +58 -0
  26. package/src/protection/utils/WorkerConsole.ts +84 -0
  27. package/src/protection/utils/console.ts +16 -0
  28. package/src/protection/utils/match.ts +18 -0
  29. package/src/protection/utils/platform.ts +22 -0
  30. package/src/webpub/WebPubFrameManager.ts +38 -5
  31. package/src/webpub/WebPubFramePoolManager.ts +9 -2
  32. package/src/webpub/WebPubNavigator.ts +91 -7
  33. package/types/src/Navigator.d.ts +14 -0
  34. package/types/src/epub/EpubNavigator.d.ts +14 -2
  35. package/types/src/epub/css/Properties.d.ts +4 -0
  36. package/types/src/epub/frame/FrameManager.d.ts +5 -1
  37. package/types/src/epub/frame/FramePoolManager.d.ts +4 -1
  38. package/types/src/epub/fxl/FXLFrameManager.d.ts +5 -1
  39. package/types/src/epub/fxl/FXLFramePoolManager.d.ts +4 -2
  40. package/types/src/epub/preferences/EpubDefaults.d.ts +4 -0
  41. package/types/src/epub/preferences/EpubPreferences.d.ts +4 -0
  42. package/types/src/epub/preferences/EpubPreferencesEditor.d.ts +2 -0
  43. package/types/src/epub/preferences/EpubSettings.d.ts +4 -0
  44. package/types/src/helpers/lineLength.d.ts +2 -3
  45. package/types/src/injection/epubInjectables.d.ts +2 -2
  46. package/types/src/injection/webpubInjectables.d.ts +2 -1
  47. package/types/src/peripherals/KeyboardPeripherals.d.ts +13 -0
  48. package/types/src/protection/AutomationDetector.d.ts +14 -0
  49. package/types/src/protection/ContextMenuProtector.d.ts +11 -0
  50. package/types/src/protection/DevToolsDetector.d.ts +75 -0
  51. package/types/src/protection/IframeEmbeddingDetector.d.ts +14 -0
  52. package/types/src/protection/NavigatorProtector.d.ts +12 -0
  53. package/types/src/protection/PrintProtector.d.ts +13 -0
  54. package/types/src/protection/utils/WorkerConsole.d.ts +15 -0
  55. package/types/src/protection/utils/console.d.ts +6 -0
  56. package/types/src/protection/utils/match.d.ts +8 -0
  57. package/types/src/protection/utils/platform.d.ts +4 -0
  58. package/types/src/webpub/WebPubFrameManager.d.ts +5 -1
  59. package/types/src/webpub/WebPubFramePoolManager.d.ts +4 -1
  60. package/types/src/webpub/WebPubNavigator.d.ts +13 -1
  61. package/dist/assets/AccessibleDfA-Bold.woff2 +0 -0
  62. package/dist/assets/AccessibleDfA-Italic.woff2 +0 -0
  63. package/dist/assets/AccessibleDfA-Regular.woff +0 -0
  64. package/dist/assets/AccessibleDfA-Regular.woff2 +0 -0
  65. package/dist/assets/iAWriterDuospace-Regular.ttf +0 -0
@@ -1,5 +1,9 @@
1
1
  import { Link, Locator, Publication, ReadingProgression } from "@readium/shared";
2
+ import { ContentProtectionConfig, PrintProtectionConfig, KeyboardPeripheral } from "@readium/navigator-html-injectables";
2
3
  type cbb = (ok: boolean) => void;
4
+ export type IKeyboardPeripheralsConfig = Array<Omit<KeyboardPeripheral, 'type'> & {
5
+ type: Exclude<string, 'developer_tools' | 'select_all' | 'print' | 'save'>;
6
+ }>;
3
7
  export interface ProgressionRange {
4
8
  start: number;
5
9
  end: number;
@@ -9,6 +13,11 @@ export interface VisualNavigatorViewport {
9
13
  progressions: Map<string, ProgressionRange>;
10
14
  positions: number[] | null;
11
15
  }
16
+ export interface IContentProtectionConfig extends ContentProtectionConfig {
17
+ protectPrinting?: PrintProtectionConfig;
18
+ checkAutomation?: boolean;
19
+ checkIFrameEmbedding?: boolean;
20
+ }
12
21
  export declare abstract class Navigator {
13
22
  abstract get publication(): Publication;
14
23
  abstract get currentLocator(): Locator;
@@ -32,6 +41,11 @@ export declare abstract class Navigator {
32
41
  * Destroy all resources associated with this navigator. Synonymous with "unmount"
33
42
  */
34
43
  abstract destroy(): void;
44
+ /**
45
+ * Merges keyboard peripherals from content protection config with user-provided peripherals
46
+ * Content protection peripherals are added first for priority, then user peripherals are added only if they don't conflict
47
+ */
48
+ protected mergeKeyboardPeripherals(config: IContentProtectionConfig, keyboardPeripherals?: IKeyboardPeripheralsConfig): IKeyboardPeripheralsConfig;
35
49
  }
36
50
  export declare abstract class VisualNavigator extends Navigator {
37
51
  /**
@@ -2,8 +2,8 @@ import { Layout, Link, Locator, Publication, ReadingProgression } from "@readium
2
2
  import { Configurable, ConfigurablePreferences, ConfigurableSettings, VisualNavigator, VisualNavigatorViewport } from "../";
3
3
  import { FramePoolManager } from "./frame/FramePoolManager";
4
4
  import { FXLFramePoolManager } from "./fxl/FXLFramePoolManager";
5
- import { CommsEventKey } from "@readium/navigator-html-injectables";
6
- import { BasicTextSelection, FrameClickEvent } from "@readium/navigator-html-injectables";
5
+ import { CommsEventKey, ContextMenuEvent, KeyboardEventData } from "@readium/navigator-html-injectables";
6
+ import { BasicTextSelection, FrameClickEvent, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
7
7
  import { FXLFrameManager } from "./fxl/FXLFrameManager";
8
8
  import { FrameManager } from "./frame/FrameManager";
9
9
  import { IEpubPreferences, EpubPreferences } from "./preferences/EpubPreferences";
@@ -11,11 +11,14 @@ import { IEpubDefaults } from "./preferences/EpubDefaults";
11
11
  import { EpubSettings } from "./preferences";
12
12
  import { EpubPreferencesEditor } from "./preferences/EpubPreferencesEditor";
13
13
  import { IInjectablesConfig } from "../injection/Injectable";
14
+ import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
14
15
  export type ManagerEventKey = "zoom";
15
16
  export interface EpubNavigatorConfiguration {
16
17
  preferences: IEpubPreferences;
17
18
  defaults: IEpubDefaults;
18
19
  injectables?: IInjectablesConfig;
20
+ contentProtection?: IContentProtectionConfig;
21
+ keyboardPeripherals?: IKeyboardPeripheralsConfig;
19
22
  }
20
23
  export interface EpubNavigatorListeners {
21
24
  frameLoaded: (wnd: Window) => void;
@@ -28,6 +31,9 @@ export interface EpubNavigatorListeners {
28
31
  customEvent: (key: string, data: unknown) => void;
29
32
  handleLocator: (locator: Locator) => boolean;
30
33
  textSelected: (selection: BasicTextSelection) => void;
34
+ contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
35
+ contextMenu: (data: ContextMenuEvent) => void;
36
+ peripheral: (data: KeyboardEventData) => void;
31
37
  }
32
38
  export declare class EpubNavigator extends VisualNavigator implements Configurable<ConfigurableSettings, ConfigurablePreferences> {
33
39
  private readonly pub;
@@ -45,6 +51,12 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
45
51
  private _css;
46
52
  private _preferencesEditor;
47
53
  private readonly _injector;
54
+ private readonly _contentProtection;
55
+ private readonly _keyboardPeripherals;
56
+ private readonly _navigatorProtector;
57
+ private readonly _keyboardPeripheralsManager;
58
+ private readonly _suspiciousActivityListener;
59
+ private readonly _keyboardPeripheralListener;
48
60
  private resizeObserver;
49
61
  private reflowViewport;
50
62
  constructor(container: HTMLElement, pub: Publication, listeners: EpubNavigatorListeners, positions?: Locator[], initialPosition?: Locator | undefined, configuration?: EpubNavigatorConfiguration);
@@ -104,6 +104,8 @@ export interface IRSProperties {
104
104
  sansSerifJaV?: string | null;
105
105
  sansTf?: string | null;
106
106
  scrollPaddingBottom?: number | null;
107
+ scrollPaddingLeft?: number | null;
108
+ scrollPaddingRight?: number | null;
107
109
  scrollPaddingTop?: number | null;
108
110
  secondaryColor?: string | null;
109
111
  selectionBackgroundColor?: string | null;
@@ -146,6 +148,8 @@ export declare class RSProperties extends Properties {
146
148
  sansSerifJaV: string | null;
147
149
  sansTf: string | null;
148
150
  scrollPaddingBottom: number | null;
151
+ scrollPaddingLeft: number | null;
152
+ scrollPaddingRight: number | null;
149
153
  scrollPaddingTop: number | null;
150
154
  secondaryColor: string | null;
151
155
  selectionBackgroundColor: string | null;
@@ -1,5 +1,6 @@
1
1
  import { Loader, ModuleName } from "@readium/navigator-html-injectables";
2
2
  import { FrameComms } from "./FrameComms";
3
+ import type { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../../Navigator";
3
4
  export declare class FrameManager {
4
5
  private frame;
5
6
  private loader;
@@ -7,9 +8,12 @@ export declare class FrameManager {
7
8
  private comms;
8
9
  private hidden;
9
10
  private destroyed;
11
+ private readonly contentProtectionConfig;
12
+ private readonly keyboardPeripheralsConfig;
10
13
  private currModules;
11
- constructor(source: string);
14
+ constructor(source: string, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
12
15
  load(modules: ModuleName[]): Promise<Window>;
16
+ private applyContentProtection;
13
17
  destroy(): Promise<void>;
14
18
  hide(): Promise<void>;
15
19
  show(atProgress?: number): Promise<void>;
@@ -2,6 +2,7 @@ import { ModuleName } from "@readium/navigator-html-injectables";
2
2
  import { Locator, Publication } from "@readium/shared";
3
3
  import { FrameManager } from "./FrameManager";
4
4
  import { Injector } from "../../injection/Injector";
5
+ import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../../Navigator";
5
6
  export declare class FramePoolManager {
6
7
  private readonly container;
7
8
  private readonly positions;
@@ -13,9 +14,11 @@ export declare class FramePoolManager {
13
14
  private pendingUpdates;
14
15
  private currentBaseURL;
15
16
  private readonly injector;
17
+ private readonly contentProtectionConfig;
18
+ private readonly keyboardPeripheralsConfig;
16
19
  constructor(container: HTMLElement, positions: Locator[], cssProperties?: {
17
20
  [key: string]: string;
18
- }, injector?: Injector | null);
21
+ }, injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
19
22
  destroy(): Promise<void>;
20
23
  update(pub: Publication, locator: Locator, modules: ModuleName[], force?: boolean): Promise<void>;
21
24
  setCSSProperties(properties: {
@@ -2,18 +2,21 @@ import { Loader, ModuleName } from "@readium/navigator-html-injectables";
2
2
  import { Page, ReadingProgression } from "@readium/shared";
3
3
  import { FrameComms } from "../frame/FrameComms";
4
4
  import { FXLPeripherals } from "./FXLPeripherals";
5
+ import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../../Navigator";
5
6
  export declare class FXLFrameManager {
6
7
  private frame;
7
8
  private loader;
8
9
  source: string;
9
10
  private comms;
10
11
  private readonly peripherals;
12
+ private readonly contentProtectionConfig;
13
+ private readonly keyboardPeripheralsConfig;
11
14
  private currModules;
12
15
  wrapper: HTMLDivElement;
13
16
  debugHref: string;
14
17
  private loadPromise;
15
18
  private showPromise;
16
- constructor(peripherals: FXLPeripherals, direction: ReadingProgression, debugHref: string);
19
+ constructor(peripherals: FXLPeripherals, direction: ReadingProgression, debugHref: string, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
17
20
  load(modules: ModuleName[], source: string): Promise<Window>;
18
21
  loadPageSize(): {
19
22
  width: number;
@@ -24,6 +27,7 @@ export declare class FXLFrameManager {
24
27
  unload(): Promise<void>;
25
28
  deselect(): void;
26
29
  unfocus(): Promise<void>;
30
+ private applyContentProtection;
27
31
  private cachedPage;
28
32
  show(page: Page): Promise<void>;
29
33
  activate(): Promise<void>;
@@ -3,7 +3,7 @@ import { Locator, Publication, Page, Link } from "@readium/shared";
3
3
  import { FrameCommsListener } from "../frame";
4
4
  import { FXLFrameManager } from "./FXLFrameManager";
5
5
  import { FXLPeripherals } from "./FXLPeripherals";
6
- import { VisualNavigatorViewport } from "../../Navigator";
6
+ import { VisualNavigatorViewport, IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../../Navigator";
7
7
  import { Injector } from "../../injection/Injector";
8
8
  export declare class FXLFramePoolManager {
9
9
  private readonly container;
@@ -16,6 +16,8 @@ export declare class FXLFramePoolManager {
16
16
  private currentBaseURL;
17
17
  private previousFrames;
18
18
  private readonly injector;
19
+ private readonly contentProtectionConfig;
20
+ private readonly keyboardPeripheralsConfig;
19
21
  private readonly bookElement;
20
22
  readonly spineElement: HTMLDivElement;
21
23
  private readonly pub;
@@ -30,7 +32,7 @@ export declare class FXLFramePoolManager {
30
32
  private containerHeightCached;
31
33
  private resizeTimeout;
32
34
  readonly peripherals: FXLPeripherals;
33
- constructor(container: HTMLElement, positions: Locator[], pub: Publication, injector?: Injector | null);
35
+ constructor(container: HTMLElement, positions: Locator[], pub: Publication, injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
34
36
  private _listener;
35
37
  set listener(listener: FrameCommsListener);
36
38
  get listener(): FrameCommsListener;
@@ -31,6 +31,8 @@ export interface IEpubDefaults {
31
31
  scroll?: boolean | null;
32
32
  scrollPaddingTop?: number | null;
33
33
  scrollPaddingBottom?: number | null;
34
+ scrollPaddingLeft?: number | null;
35
+ scrollPaddingRight?: number | null;
34
36
  selectionBackgroundColor?: string | null;
35
37
  selectionTextColor?: string | null;
36
38
  textAlign?: TextAlignment | null;
@@ -72,6 +74,8 @@ export declare class EpubDefaults {
72
74
  scroll: boolean | null;
73
75
  scrollPaddingTop: number | null;
74
76
  scrollPaddingBottom: number | null;
77
+ scrollPaddingLeft: number | null;
78
+ scrollPaddingRight: number | null;
75
79
  selectionBackgroundColor: string | null;
76
80
  selectionTextColor: string | null;
77
81
  textAlign: TextAlignment | null;
@@ -32,6 +32,8 @@ export interface IEpubPreferences {
32
32
  scroll?: boolean | null;
33
33
  scrollPaddingTop?: number | null;
34
34
  scrollPaddingBottom?: number | null;
35
+ scrollPaddingLeft?: number | null;
36
+ scrollPaddingRight?: number | null;
35
37
  selectionBackgroundColor?: string | null;
36
38
  selectionTextColor?: string | null;
37
39
  textAlign?: TextAlignment | null;
@@ -72,6 +74,8 @@ export declare class EpubPreferences implements ConfigurablePreferences {
72
74
  scroll?: boolean | null;
73
75
  scrollPaddingTop?: number | null;
74
76
  scrollPaddingBottom?: number | null;
77
+ scrollPaddingLeft?: number | null;
78
+ scrollPaddingRight?: number | null;
75
79
  selectionBackgroundColor?: string | null;
76
80
  selectionTextColor?: string | null;
77
81
  textAlign?: TextAlignment | null;
@@ -43,6 +43,8 @@ export declare class EpubPreferencesEditor implements IPreferencesEditor {
43
43
  get scroll(): BooleanPreference;
44
44
  get scrollPaddingTop(): Preference<number>;
45
45
  get scrollPaddingBottom(): Preference<number>;
46
+ get scrollPaddingLeft(): Preference<number>;
47
+ get scrollPaddingRight(): Preference<number>;
46
48
  get selectionBackgroundColor(): Preference<string>;
47
49
  get selectionTextColor(): Preference<string>;
48
50
  get textAlign(): EnumPreference<TextAlignment>;
@@ -34,6 +34,8 @@ export interface IEpubSettings {
34
34
  scroll?: boolean | null;
35
35
  scrollPaddingTop?: number | null;
36
36
  scrollPaddingBottom?: number | null;
37
+ scrollPaddingLeft?: number | null;
38
+ scrollPaddingRight?: number | null;
37
39
  selectionBackgroundColor?: string | null;
38
40
  selectionTextColor?: string | null;
39
41
  textAlign?: TextAlignment | null;
@@ -75,6 +77,8 @@ export declare class EpubSettings implements ConfigurableSettings {
75
77
  scroll: boolean | null;
76
78
  scrollPaddingTop: number | null;
77
79
  scrollPaddingBottom: number | null;
80
+ scrollPaddingLeft: number | null;
81
+ scrollPaddingRight: number | null;
78
82
  selectionBackgroundColor: string | null;
79
83
  selectionTextColor: string | null;
80
84
  textAlign: TextAlignment | null;
@@ -8,7 +8,7 @@ export interface ILineLengthsConfig {
8
8
  maxChars?: number | null;
9
9
  baseFontSize?: number | null;
10
10
  sample?: string | null;
11
- pageGutter?: number | null;
11
+ padding?: number | null;
12
12
  fontFace?: string | ICustomFontFace | null;
13
13
  letterSpacing?: number | null;
14
14
  wordSpacing?: number | null;
@@ -29,12 +29,11 @@ export declare class LineLengths {
29
29
  private _baseFontSize;
30
30
  private _fontFace;
31
31
  private _sample;
32
- private _pageGutter;
32
+ private _padding;
33
33
  private _letterSpacing;
34
34
  private _wordSpacing;
35
35
  private _isCJK;
36
36
  private _getRelative;
37
- private _padding;
38
37
  private _minDivider;
39
38
  private _maxMultiplier;
40
39
  private _approximatedWordSpaces;
@@ -1,6 +1,6 @@
1
1
  import { IInjectableRule } from "../injection/Injectable";
2
- import { Metadata } from "@readium/shared";
2
+ import { Metadata, Link } from "@readium/shared";
3
3
  /**
4
4
  * Creates injectable rules for EPUB content documents
5
5
  */
6
- export declare function createReadiumEpubRules(metadata: Metadata): IInjectableRule[];
6
+ export declare function createReadiumEpubRules(metadata: Metadata, readingOrderItems: Link[]): IInjectableRule[];
@@ -1,5 +1,6 @@
1
1
  import { IInjectableRule } from "../injection/Injectable";
2
+ import { Link } from "@readium/shared";
2
3
  /**
3
4
  * Creates injectable rules for WebPub content documents
4
5
  */
5
- export declare function createReadiumWebPubRules(): IInjectableRule[];
6
+ export declare function createReadiumWebPubRules(readingOrderItems: Link[]): IInjectableRule[];
@@ -0,0 +1,13 @@
1
+ import { KeyboardPeripheral } from "@readium/navigator-html-injectables";
2
+ export declare const NAVIGATOR_KEYBOARD_PERIPHERAL_EVENT = "readium:navigator:keyboardPeripheral";
3
+ export interface KeyboardPeripheralOptions {
4
+ /** Array of keyboard peripherals to configure */
5
+ keyboardPeripherals?: KeyboardPeripheral[];
6
+ }
7
+ export declare class KeyboardPeripherals {
8
+ private keydownHandler?;
9
+ private keyManager;
10
+ constructor(options?: KeyboardPeripheralOptions);
11
+ private setupKeyboardPeripherals;
12
+ destroy(): void;
13
+ }
@@ -0,0 +1,14 @@
1
+ export interface AutomationDetectorOptions {
2
+ /** Callback when an automation tool is detected */
3
+ onDetected?: (tool: string) => void;
4
+ }
5
+ export declare class AutomationDetector {
6
+ private options;
7
+ private detectedTools;
8
+ private observer?;
9
+ constructor(options: AutomationDetectorOptions);
10
+ private isAutomationToolPresent;
11
+ private setupDetection;
12
+ private handleDetected;
13
+ destroy(): void;
14
+ }
@@ -0,0 +1,11 @@
1
+ import { ContextMenuEvent } from "@readium/navigator-html-injectables";
2
+ export interface ContextMenuProtectionOptions {
3
+ onContextMenuBlocked?: (event: ContextMenuEvent) => void;
4
+ }
5
+ export declare class ContextMenuProtector {
6
+ private contextMenuHandler?;
7
+ private onContextMenuBlocked?;
8
+ constructor(options?: ContextMenuProtectionOptions);
9
+ private handleContextMenu;
10
+ destroy(): void;
11
+ }
@@ -0,0 +1,75 @@
1
+ export interface DevToolsDetectorOptions {
2
+ /** Callback when Developer Tools are detected as open */
3
+ onDetected?: () => void;
4
+ /** Callback when Developer Tools are detected as closed */
5
+ onClosed?: () => void;
6
+ /** Detection interval in milliseconds (default: 1000) */
7
+ interval?: number;
8
+ /** Enable debugger-based detection (fallback, impacts UX) */
9
+ enableDebuggerDetection?: boolean;
10
+ }
11
+ export declare class DevToolsDetector {
12
+ private options;
13
+ private isOpen;
14
+ private intervalId?;
15
+ private checkCount;
16
+ private maxChecks;
17
+ private maxPrintTime;
18
+ private largeObjectArray;
19
+ private workerConsole?;
20
+ constructor(options?: DevToolsDetectorOptions);
21
+ /**
22
+ * Create large object array for performance testing
23
+ */
24
+ private createLargeObjectArray;
25
+ /**
26
+ * Get cached large object array
27
+ */
28
+ private getLargeObjectArray;
29
+ /**
30
+ * Performance-based detection using console.table timing
31
+ */
32
+ private calcTablePrintTime;
33
+ /**
34
+ * Performance-based detection using console.log timing
35
+ */
36
+ private calcLogPrintTime;
37
+ /**
38
+ * Check if performance-based detection is enabled for current browser
39
+ */
40
+ private isPerformanceDetectionEnabled;
41
+ /**
42
+ * Check if debugger detection is enabled for current browser
43
+ */
44
+ private isDebuggerDetectionEnabled;
45
+ /**
46
+ * Performance-based detection using large object timing differences
47
+ */
48
+ private checkPerformanceBased;
49
+ /**
50
+ * Debugger-based detection (fallback method)
51
+ * WARNING: This method impacts user experience
52
+ */
53
+ private checkDebuggerBased;
54
+ /**
55
+ * Main detection method combining multiple approaches
56
+ * Prioritizes performance-based detection
57
+ */
58
+ private detectDevTools;
59
+ /**
60
+ * Start continuous detection monitoring
61
+ */
62
+ private startDetection;
63
+ /**
64
+ * Get current DevTools state
65
+ */
66
+ isDevToolsOpen(): boolean;
67
+ /**
68
+ * Force an immediate check
69
+ */
70
+ checkNow(): Promise<boolean>;
71
+ /**
72
+ * Stop detection and cleanup resources
73
+ */
74
+ destroy(): void;
75
+ }
@@ -0,0 +1,14 @@
1
+ export interface IframeEmbeddingDetectorOptions {
2
+ /** Callback when iframe embedding is detected */
3
+ onDetected?: (isCrossOrigin: boolean) => void;
4
+ }
5
+ export declare class IframeEmbeddingDetector {
6
+ private options;
7
+ private observer?;
8
+ private detected;
9
+ constructor(options: IframeEmbeddingDetectorOptions);
10
+ private isIframed;
11
+ private setupDetection;
12
+ private handleDetected;
13
+ destroy(): void;
14
+ }
@@ -0,0 +1,12 @@
1
+ import { IContentProtectionConfig } from "../Navigator";
2
+ export declare const NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT = "readium:navigator:suspiciousActivity";
3
+ export declare class NavigatorProtector {
4
+ private automationDetector?;
5
+ private devToolsDetector?;
6
+ private iframeEmbeddingDetector?;
7
+ private printProtector?;
8
+ private contextMenuProtector?;
9
+ private dispatchSuspiciousActivity;
10
+ constructor(config?: IContentProtectionConfig);
11
+ destroy(): void;
12
+ }
@@ -0,0 +1,13 @@
1
+ export interface NavigatorPrintProtectionConfig {
2
+ disable?: boolean;
3
+ watermark?: string;
4
+ onPrintAttempt?: () => void;
5
+ }
6
+ export declare class PrintProtector {
7
+ private styleElement;
8
+ private beforePrintHandler;
9
+ private onPrintAttempt?;
10
+ constructor(config?: NavigatorPrintProtectionConfig);
11
+ private setupPrintProtection;
12
+ destroy(): void;
13
+ }
@@ -0,0 +1,15 @@
1
+ export type WorkerConsoleMethod<Args extends any[]> = (...args: Args) => Promise<{
2
+ time: number;
3
+ }>;
4
+ export declare class WorkerConsole {
5
+ static workerScript: string;
6
+ private readonly worker;
7
+ private readonly blobUrl;
8
+ private callbacks;
9
+ readonly log: WorkerConsoleMethod<Parameters<Console['log']>>;
10
+ readonly table: WorkerConsoleMethod<Parameters<Console['table']>>;
11
+ readonly clear: WorkerConsoleMethod<Parameters<Console['clear']>>;
12
+ constructor(worker: Worker, blobUrl: string);
13
+ private send;
14
+ destroy(): void;
15
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Cache console methods to prevent third-party code from hooking them
3
+ */
4
+ export declare const log: (...data: any[]) => void;
5
+ export declare const table: (tabularData?: any, properties?: string[]) => void;
6
+ export declare const clear: () => void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Match utilities for browser compatibility checking
3
+ */
4
+ export interface MatchOptions {
5
+ includes: (() => boolean)[];
6
+ excludes: (() => boolean)[];
7
+ }
8
+ export declare function match(options: MatchOptions): boolean;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Platform detection utilities
3
+ */
4
+ export declare function isBrave(): Promise<boolean>;
@@ -1,5 +1,6 @@
1
1
  import { Loader, ModuleName } from "@readium/navigator-html-injectables";
2
2
  import { FrameComms } from "../epub/frame/FrameComms";
3
+ import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
3
4
  export declare class WebPubFrameManager {
4
5
  private frame;
5
6
  private loader;
@@ -7,9 +8,12 @@ export declare class WebPubFrameManager {
7
8
  private comms;
8
9
  private hidden;
9
10
  private destroyed;
11
+ private readonly contentProtectionConfig;
12
+ private readonly keyboardPeripheralsConfig;
10
13
  private currModules;
11
- constructor(source: string);
14
+ constructor(source: string, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
12
15
  load(modules?: ModuleName[]): Promise<Window>;
16
+ private applyContentProtection;
13
17
  destroy(): Promise<void>;
14
18
  hide(): Promise<void>;
15
19
  show(atProgress?: number): Promise<void>;
@@ -2,6 +2,7 @@ import { ModuleName } from "@readium/navigator-html-injectables";
2
2
  import { Locator, Publication } from "@readium/shared";
3
3
  import { WebPubFrameManager } from "./WebPubFrameManager";
4
4
  import { Injector } from "../injection/Injector";
5
+ import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
5
6
  export declare class WebPubFramePoolManager {
6
7
  private readonly container;
7
8
  private _currentFrame;
@@ -12,9 +13,11 @@ export declare class WebPubFramePoolManager {
12
13
  private pendingUpdates;
13
14
  private currentBaseURL;
14
15
  private readonly injector?;
16
+ private readonly contentProtectionConfig;
17
+ private readonly keyboardPeripheralsConfig;
15
18
  constructor(container: HTMLElement, cssProperties?: {
16
19
  [key: string]: string;
17
- }, injector?: Injector | null);
20
+ }, injector?: Injector | null, contentProtectionConfig?: IContentProtectionConfig, keyboardPeripheralsConfig?: IKeyboardPeripheralsConfig);
18
21
  destroy(): Promise<void>;
19
22
  update(pub: Publication, locator: Locator, modules: ModuleName[]): Promise<void>;
20
23
  setCSSProperties(properties: {
@@ -1,7 +1,7 @@
1
1
  import { Link, Locator, Publication, ReadingProgression } from "@readium/shared";
2
2
  import { VisualNavigator, VisualNavigatorViewport } from "../Navigator";
3
3
  import { Configurable } from "../preferences/Configurable";
4
- import { BasicTextSelection, CommsEventKey, FrameClickEvent } from "@readium/navigator-html-injectables";
4
+ import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, KeyboardEventData, SuspiciousActivityEvent } from "@readium/navigator-html-injectables";
5
5
  import { WebPubFrameManager } from "./WebPubFrameManager";
6
6
  import { ManagerEventKey } from "../epub/EpubNavigator";
7
7
  import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences";
@@ -9,10 +9,13 @@ import { IWebPubDefaults } from "./preferences/WebPubDefaults";
9
9
  import { WebPubSettings } from "./preferences/WebPubSettings";
10
10
  import { IPreferencesEditor } from "../preferences/PreferencesEditor";
11
11
  import { IInjectablesConfig } from "../injection/Injectable";
12
+ import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
12
13
  export interface WebPubNavigatorConfiguration {
13
14
  preferences: IWebPubPreferences;
14
15
  defaults: IWebPubDefaults;
15
16
  injectables?: IInjectablesConfig;
17
+ contentProtection?: IContentProtectionConfig;
18
+ keyboardPeripherals?: IKeyboardPeripheralsConfig;
16
19
  }
17
20
  export interface WebPubNavigatorListeners {
18
21
  frameLoaded: (wnd: Window) => void;
@@ -24,6 +27,9 @@ export interface WebPubNavigatorListeners {
24
27
  customEvent: (key: string, data: unknown) => void;
25
28
  handleLocator: (locator: Locator) => boolean;
26
29
  textSelected: (selection: BasicTextSelection) => void;
30
+ contentProtection: (type: string, data: SuspiciousActivityEvent) => void;
31
+ contextMenu: (data: ContextMenuEvent) => void;
32
+ peripheral: (data: KeyboardEventData) => void;
27
33
  }
28
34
  export declare class WebPubNavigator extends VisualNavigator implements Configurable<WebPubSettings, WebPubPreferences> {
29
35
  private readonly pub;
@@ -38,6 +44,12 @@ export declare class WebPubNavigator extends VisualNavigator implements Configur
38
44
  private _css;
39
45
  private _preferencesEditor;
40
46
  private readonly _injector;
47
+ private readonly _contentProtection;
48
+ private readonly _keyboardPeripherals;
49
+ private readonly _navigatorProtector;
50
+ private readonly _keyboardPeripheralsManager;
51
+ private readonly _suspiciousActivityListener;
52
+ private readonly _keyboardPeripheralListener;
41
53
  private webViewport;
42
54
  constructor(container: HTMLElement, pub: Publication, listeners: WebPubNavigatorListeners, initialPosition?: Locator | undefined, configuration?: WebPubNavigatorConfiguration);
43
55
  load(): Promise<void>;