@readium/navigator-html-injectables 2.3.1-alpha.1 → 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 (56) hide show
  1. package/dist/index.js +344 -349
  2. package/dist/index.umd.cjs +12 -12
  3. package/package.json +8 -8
  4. package/src/comms/comms.ts +5 -5
  5. package/src/comms/index.ts +3 -3
  6. package/src/helpers/css.ts +2 -4
  7. package/src/helpers/document.ts +9 -9
  8. package/src/helpers/locator.ts +2 -2
  9. package/src/index.ts +4 -4
  10. package/src/modules/Decorator.ts +18 -18
  11. package/src/modules/Module.ts +4 -4
  12. package/src/modules/ModuleLibrary.ts +11 -11
  13. package/src/modules/Peripherals.ts +70 -61
  14. package/src/modules/index.ts +4 -4
  15. package/src/modules/setup/FixedSetup.ts +6 -6
  16. package/src/modules/setup/ReflowableSetup.ts +6 -6
  17. package/src/modules/setup/Setup.ts +5 -5
  18. package/src/modules/setup/WebPubSetup.ts +5 -5
  19. package/src/modules/snapper/ColumnSnapper.ts +20 -39
  20. package/src/modules/snapper/ScrollSnapper.ts +18 -18
  21. package/src/modules/snapper/Snapper.ts +5 -5
  22. package/src/modules/snapper/WebPubSnapper.ts +15 -15
  23. package/src/protection/BulkCopyProtector.ts +15 -15
  24. package/src/protection/KeyCombinationManager.ts +8 -8
  25. package/src/protection/PatternAnalyzer.ts +18 -18
  26. package/src/protection/PrintProtector.ts +12 -12
  27. package/src/protection/SelectionAnalyzer.ts +1 -1
  28. package/src/protection/config.ts +4 -4
  29. package/src/protection/index.ts +6 -6
  30. package/src/vendor/hypothesis/anchoring/html.ts +1 -1
  31. package/src/vendor/hypothesis/anchoring/types.ts +1 -1
  32. package/types/src/comms/comms.d.ts +2 -2
  33. package/types/src/comms/index.d.ts +3 -3
  34. package/types/src/helpers/css.d.ts +1 -2
  35. package/types/src/helpers/document.d.ts +1 -1
  36. package/types/src/index.d.ts +4 -4
  37. package/types/src/modules/Decorator.d.ts +4 -4
  38. package/types/src/modules/Module.d.ts +3 -3
  39. package/types/src/modules/ModuleLibrary.d.ts +1 -1
  40. package/types/src/modules/Peripherals.d.ts +10 -9
  41. package/types/src/modules/index.d.ts +4 -4
  42. package/types/src/modules/setup/FixedSetup.d.ts +4 -4
  43. package/types/src/modules/setup/ReflowableSetup.d.ts +3 -3
  44. package/types/src/modules/setup/Setup.d.ts +4 -4
  45. package/types/src/modules/setup/WebPubSetup.d.ts +3 -3
  46. package/types/src/modules/snapper/ColumnSnapper.d.ts +5 -5
  47. package/types/src/modules/snapper/ScrollSnapper.d.ts +5 -5
  48. package/types/src/modules/snapper/Snapper.d.ts +4 -4
  49. package/types/src/modules/snapper/WebPubSnapper.d.ts +5 -5
  50. package/types/src/protection/BulkCopyProtector.d.ts +1 -1
  51. package/types/src/protection/KeyCombinationManager.d.ts +3 -3
  52. package/types/src/protection/PrintProtector.d.ts +4 -4
  53. package/types/src/protection/config.d.ts +3 -3
  54. package/types/src/protection/index.d.ts +6 -6
  55. package/types/src/vendor/hypothesis/anchoring/html.d.ts +1 -1
  56. package/types/src/vendor/hypothesis/anchoring/types.d.ts +1 -1
@@ -1,7 +1,7 @@
1
- import { Comms } from "../comms";
2
- import { ReadiumWindow } from "../helpers/dom";
3
- import { Module } from "../modules/Module";
4
- import { ModuleName } from "../modules/ModuleLibrary";
1
+ import { Comms } from "../comms/index.ts";
2
+ import { ReadiumWindow } from "../helpers/dom.ts";
3
+ import { Module } from "../modules/Module.ts";
4
+ import { ModuleName } from "../modules/ModuleLibrary.ts";
5
5
 
6
6
  export interface PrintProtectionConfig {
7
7
  disable?: boolean;
@@ -10,7 +10,7 @@ export interface PrintProtectionConfig {
10
10
 
11
11
  export class PrintProtector extends Module {
12
12
  static readonly moduleName: ModuleName = "print_protection";
13
-
13
+
14
14
  private comms!: Comms;
15
15
  private wnd!: ReadiumWindow;
16
16
  private styleElement: HTMLStyleElement | null = null;
@@ -46,16 +46,16 @@ export class PrintProtector extends Module {
46
46
  wnd.addEventListener("beforeprint", this.beforePrintHandler);
47
47
  }
48
48
 
49
- private registerPrintHandlers() {
49
+ private registerPrintHandlers() {
50
50
  this.comms?.register("print_protection", PrintProtector.moduleName, (data: unknown) => {
51
51
  const config = data as PrintProtectionConfig;
52
-
52
+
53
53
  if (!this.configApplied) {
54
54
  this.configApplied = true;
55
55
  this.setupPrintProtection(this.wnd, config);
56
56
  this.comms?.log("Print protection configuration applied");
57
57
  }
58
-
58
+
59
59
  return true;
60
60
  });
61
61
  }
@@ -72,16 +72,16 @@ export class PrintProtector extends Module {
72
72
  wnd.removeEventListener("beforeprint", this.beforePrintHandler);
73
73
  this.beforePrintHandler = null;
74
74
  }
75
-
75
+
76
76
  if (this.styleElement?.parentNode) {
77
77
  this.styleElement.parentNode.removeChild(this.styleElement);
78
78
  this.styleElement = null;
79
79
  }
80
-
80
+
81
81
  // Unregister all print protection handlers
82
82
  this.comms?.unregisterAll(PrintProtector.moduleName);
83
-
83
+
84
84
  this.configApplied = false;
85
85
  return true;
86
86
  }
87
- }
87
+ }
@@ -10,7 +10,7 @@ export interface SelectionAnalyzerOptions {
10
10
  historySize: number;
11
11
  }
12
12
 
13
- import { SELECTION_ANALYZER_CONFIG } from './config';
13
+ import { SELECTION_ANALYZER_CONFIG } from './config.ts';
14
14
 
15
15
  export class SelectionAnalyzer {
16
16
  private events: SelectionEvent[] = [];
@@ -1,6 +1,6 @@
1
- import { BulkCopyProtectionOptions } from "./BulkCopyProtector";
2
- import { PatternAnalyzerOptions } from "./PatternAnalyzer";
3
- import { SelectionAnalyzerOptions } from "./SelectionAnalyzer";
1
+ import { BulkCopyProtectionOptions } from "./BulkCopyProtector.ts";
2
+ import { PatternAnalyzerOptions } from "./PatternAnalyzer.ts";
3
+ import { SelectionAnalyzerOptions } from "./SelectionAnalyzer.ts";
4
4
 
5
5
  export const DEFAULT_PATTERN_ANALYZER_CONFIG: PatternAnalyzerOptions = {
6
6
  maxVelocity: 200, // Reasonable default for human-like scrolling (pixels/ms)
@@ -30,4 +30,4 @@ export const BULK_COPY_CONFIG: BulkCopyProtectionOptions = {
30
30
  minThreshold: 100,
31
31
  absoluteMaxChars: 5000,
32
32
  historySize: 20
33
- }
33
+ }
@@ -1,6 +1,6 @@
1
- export * from "./BulkCopyProtector";
2
- export * from "./KeyCombinationManager";
3
- export * from "./KeyboardCombinations";
4
- export * from "./PatternAnalyzer";
5
- export * from "./SelectionAnalyzer";
6
- export * from "./PrintProtector";
1
+ export * from "./BulkCopyProtector.ts";
2
+ export * from "./KeyCombinationManager.ts";
3
+ export * from "./KeyboardCombinations.ts";
4
+ export * from "./PatternAnalyzer.ts";
5
+ export * from "./SelectionAnalyzer.ts";
6
+ export * from "./PrintProtector.ts";
@@ -4,7 +4,7 @@ import type {
4
4
  Selector,
5
5
  TextPositionSelector,
6
6
  TextQuoteSelector,
7
- } from './api-types';
7
+ } from './api-types.ts';
8
8
  import {
9
9
  MediaTimeAnchor,
10
10
  RangeAnchor,
@@ -12,7 +12,7 @@ import type {
12
12
  RangeSelector,
13
13
  TextPositionSelector,
14
14
  TextQuoteSelector,
15
- } from './api-types';
15
+ } from './api-types.ts';
16
16
  import { matchQuote } from './match-quote';
17
17
  import { TextRange, TextPosition } from './text-range';
18
18
  import { nodeFromXPath, xpathFromNode } from './xpath';
@@ -1,5 +1,5 @@
1
- import { ReadiumWindow } from "../helpers/dom";
2
- import { CommsEventKey, CommsCommandKey } from "./keys";
1
+ import { ReadiumWindow } from "../helpers/dom.ts";
2
+ import { CommsEventKey, CommsCommandKey } from "./keys.ts";
3
3
  export declare const COMMS_VERSION = 1;
4
4
  export interface CommsMessage {
5
5
  _readium: number;
@@ -1,3 +1,3 @@
1
- export * from './comms';
2
- export * from './keys';
3
- export * from './mid';
1
+ export * from './comms.ts';
2
+ export * from './keys.ts';
3
+ export * from './mid.ts';
@@ -1,5 +1,4 @@
1
- import { ReadiumWindow } from "./dom";
2
- export declare const isTypedOMSupported: boolean;
1
+ import { ReadiumWindow } from "./dom.ts";
3
2
  export declare function getProperties(wnd: ReadiumWindow): {
4
3
  [key: string]: string;
5
4
  };
@@ -1,4 +1,4 @@
1
- import { ReadiumWindow } from "./dom";
1
+ import { ReadiumWindow } from "./dom.ts";
2
2
  export declare function isRTL(wnd: ReadiumWindow): boolean;
3
3
  export declare function getColumnCountPerScreen(wnd: ReadiumWindow): number;
4
4
  /**
@@ -1,4 +1,4 @@
1
- export * from './comms';
2
- export * from './modules';
3
- export * from './Loader';
4
- export * from './protection';
1
+ export * from './comms/index.ts';
2
+ export * from './modules/index.ts';
3
+ export * from './Loader.ts';
4
+ export * from './protection/index.ts';
@@ -1,8 +1,8 @@
1
1
  import { Locator } from "@readium/shared";
2
- import { Comms } from "../comms/comms";
3
- import { Module } from "./Module";
4
- import { ModuleName } from "./ModuleLibrary";
5
- import { ReadiumWindow } from "../helpers/dom";
2
+ import { Comms } from "../comms/comms.ts";
3
+ import { Module } from "./Module.ts";
4
+ import { ModuleName } from "./ModuleLibrary.ts";
5
+ import { ReadiumWindow } from "../helpers/dom.ts";
6
6
  export declare enum Width {
7
7
  Wrap = "wrap",// Smallest width fitting the CSS border box.
8
8
  Viewport = "viewport",// Fills the whole viewport.
@@ -1,6 +1,6 @@
1
- import { Comms } from "../comms";
2
- import { ReadiumWindow } from "../helpers/dom";
3
- import { ModuleName } from "./ModuleLibrary";
1
+ import { Comms } from "../comms/index.ts";
2
+ import { ReadiumWindow } from "../helpers/dom.ts";
3
+ import { ModuleName } from "./ModuleLibrary.ts";
4
4
  export declare abstract class Module {
5
5
  static readonly moduleName: ModuleName;
6
6
  abstract mount(wnd: ReadiumWindow, comms: Comms): boolean;
@@ -1,4 +1,4 @@
1
- import { ModuleDerived } from "./Module";
1
+ import { ModuleDerived } from "./Module.ts";
2
2
  export type ModuleName = "setup" | "snapper" | "column_snapper" | "scroll_snapper" | "webpub_snapper" | "fixed_setup" | "decorator" | "reflowable_setup" | "peripherals" | "webpub_setup" | "print_protection";
3
3
  export declare const FXLModules: ModuleName[];
4
4
  export declare const ReflowableModules: ModuleName[];
@@ -1,12 +1,12 @@
1
- import { Comms } from "../comms/comms";
2
- import { Module } from "./Module";
3
- import { ReadiumWindow } from "../helpers/dom";
4
- import { BulkCopyProtectionOptions } from "../protection/BulkCopyProtector";
5
- import { SelectionAnalyzerOptions } from "../protection/SelectionAnalyzer";
6
- import { SuspiciousActivityType } from "../comms";
7
- import { KeyboardPeripheralEvent } from "../protection/KeyCombinationManager";
8
- import { SuspiciousScrollingEvent } from "./snapper/ScrollSnapper";
9
- import { SuspiciousSnappingEvent } from "./snapper/ColumnSnapper";
1
+ import { Comms } from "../comms/comms.ts";
2
+ import { Module } from "./Module.ts";
3
+ import { ReadiumWindow } from "../helpers/dom.ts";
4
+ import { BulkCopyProtectionOptions } from "../protection/BulkCopyProtector.ts";
5
+ import { SelectionAnalyzerOptions } from "../protection/SelectionAnalyzer.ts";
6
+ import { SuspiciousActivityType } from "../comms/index.ts";
7
+ import { KeyboardPeripheralEvent } from "../protection/KeyCombinationManager.ts";
8
+ import { SuspiciousScrollingEvent } from "./snapper/ScrollSnapper.ts";
9
+ import { SuspiciousSnappingEvent } from "./snapper/ColumnSnapper.ts";
10
10
  export interface FrameClickEvent {
11
11
  defaultPrevented: boolean;
12
12
  doNotDisturb: boolean;
@@ -122,6 +122,7 @@ export declare class Peripherals extends Module {
122
122
  private handleSelection;
123
123
  private addSelectionMonitoring;
124
124
  private removeSelectionMonitoring;
125
+ private onDragOver;
125
126
  private onDragStart;
126
127
  private onDrop;
127
128
  private onContext;
@@ -1,4 +1,4 @@
1
- export * from './Decorator';
2
- export * from './Module';
3
- export * from './ModuleLibrary';
4
- export * from './Peripherals';
1
+ export * from './Decorator.ts';
2
+ export * from './Module.ts';
3
+ export * from './ModuleLibrary.ts';
4
+ export * from './Peripherals.ts';
@@ -1,7 +1,7 @@
1
- import { Comms } from "../../comms/comms";
2
- import { Setup } from "./Setup";
3
- import { ModuleName } from "../ModuleLibrary";
4
- import { ReadiumWindow } from "../../helpers/dom";
1
+ import { Comms } from "../../comms/comms.ts";
2
+ import { Setup } from "./Setup.ts";
3
+ import { ModuleName } from "../ModuleLibrary.ts";
4
+ import { ReadiumWindow } from "../../helpers/dom.ts";
5
5
  export declare class FixedSetup extends Setup {
6
6
  static readonly moduleName: ModuleName;
7
7
  mount(wnd: ReadiumWindow, comms: Comms): boolean;
@@ -1,6 +1,6 @@
1
- import { Comms } from "../../comms/comms";
2
- import { Setup } from "./Setup";
3
- import { ReadiumWindow } from "../../helpers/dom";
1
+ import { Comms } from "../../comms/comms.ts";
2
+ import { Setup } from "./Setup.ts";
3
+ import { ReadiumWindow } from "../../helpers/dom.ts";
4
4
  export declare class ReflowableSetup extends Setup {
5
5
  static readonly moduleName = "reflowable_setup";
6
6
  onViewportWidthChanged(event: Event): void;
@@ -1,7 +1,7 @@
1
- import { Comms } from "../../comms/comms";
2
- import { ReadiumWindow } from "../../helpers/dom";
3
- import { Module } from "../Module";
4
- import { ModuleName } from "../ModuleLibrary";
1
+ import { Comms } from "../../comms/comms.ts";
2
+ import { ReadiumWindow } from "../../helpers/dom.ts";
3
+ import { Module } from "../Module.ts";
4
+ import { ModuleName } from "../ModuleLibrary.ts";
5
5
  export declare abstract class Setup extends Module {
6
6
  static readonly moduleName: ModuleName;
7
7
  private comms;
@@ -1,6 +1,6 @@
1
- import { Comms } from "../../comms/comms";
2
- import { ReadiumWindow } from "../../helpers/dom";
3
- import { Module } from "../Module";
1
+ import { Comms } from "../../comms/comms.ts";
2
+ import { ReadiumWindow } from "../../helpers/dom.ts";
3
+ import { Module } from "../Module.ts";
4
4
  export declare class WebPubSetup extends Module {
5
5
  static readonly moduleName = "webpub_setup";
6
6
  private comms;
@@ -1,8 +1,8 @@
1
- import { Comms } from "../../comms";
2
- import { Snapper } from "./Snapper";
3
- import { ModuleName } from "../ModuleLibrary";
4
- import { ReadiumWindow } from "../../helpers/dom";
5
- import { BaseSuspiciousActivityEvent } from "../Peripherals";
1
+ import { Comms } from "../../comms/index.ts";
2
+ import { Snapper } from "./Snapper.ts";
3
+ import { ModuleName } from "../ModuleLibrary.ts";
4
+ import { ReadiumWindow } from "../../helpers/dom.ts";
5
+ import { BaseSuspiciousActivityEvent } from "../Peripherals.ts";
6
6
  export interface SuspiciousSnappingEvent extends BaseSuspiciousActivityEvent {
7
7
  type: "suspicious_snapping";
8
8
  event: null;
@@ -1,8 +1,8 @@
1
- import { Comms } from "../../comms";
2
- import { ReadiumWindow } from "../../helpers/dom";
3
- import { ModuleName } from "../ModuleLibrary";
4
- import { Snapper } from "./Snapper";
5
- import { BaseSuspiciousActivityEvent } from "../Peripherals";
1
+ import { Comms } from "../../comms/index.ts";
2
+ import { ReadiumWindow } from "../../helpers/dom.ts";
3
+ import { ModuleName } from "../ModuleLibrary.ts";
4
+ import { Snapper } from "./Snapper.ts";
5
+ import { BaseSuspiciousActivityEvent } from "../Peripherals.ts";
6
6
  export interface SuspiciousScrollingEvent extends BaseSuspiciousActivityEvent {
7
7
  type: "suspicious_scrolling";
8
8
  scrollDelta: number;
@@ -1,7 +1,7 @@
1
- import { Comms } from "../../comms";
2
- import { ReadiumWindow } from "../../helpers/dom";
3
- import { Module } from "../Module";
4
- import { ModuleName } from "../ModuleLibrary";
1
+ import { Comms } from "../../comms/index.ts";
2
+ import { ReadiumWindow } from "../../helpers/dom.ts";
3
+ import { Module } from "../Module.ts";
4
+ import { ModuleName } from "../ModuleLibrary.ts";
5
5
  export declare abstract class Snapper extends Module {
6
6
  static readonly moduleName: ModuleName;
7
7
  private protected;
@@ -1,8 +1,8 @@
1
- import { Comms } from "../../comms/comms";
2
- import { ReadiumWindow } from "../../helpers/dom";
3
- import { ModuleName } from "../ModuleLibrary";
4
- import { Snapper } from "./Snapper";
5
- import { SuspiciousScrollingEvent } from "./ScrollSnapper";
1
+ import { Comms } from "../../comms/comms.ts";
2
+ import { ReadiumWindow } from "../../helpers/dom.ts";
3
+ import { ModuleName } from "../ModuleLibrary.ts";
4
+ import { Snapper } from "./Snapper.ts";
5
+ import { SuspiciousScrollingEvent } from "./ScrollSnapper.ts";
6
6
  export type { SuspiciousScrollingEvent };
7
7
  export declare class WebPubSnapper extends Snapper {
8
8
  static readonly moduleName: ModuleName;
@@ -1,4 +1,4 @@
1
- import { ReadiumWindow } from "../helpers/dom";
1
+ import { ReadiumWindow } from "../helpers/dom.ts";
2
2
  export interface BulkCopyProtectionOptions {
3
3
  enabled: boolean;
4
4
  maxSelectionPercent: number;
@@ -1,6 +1,6 @@
1
- import { KeyCombo, KeyboardPeripheral } from "./KeyboardCombinations";
2
- import { BaseKeyboardPeripheralEvent, KeyboardEventData } from "../modules/Peripherals";
3
- import { ReadiumWindow } from "../helpers/dom";
1
+ import { KeyCombo, KeyboardPeripheral } from "./KeyboardCombinations.ts";
2
+ import { BaseKeyboardPeripheralEvent, KeyboardEventData } from "../modules/Peripherals.ts";
3
+ import { ReadiumWindow } from "../helpers/dom.ts";
4
4
  export type KeyHandler = (event: KeyboardEvent) => void;
5
5
  export type ActivityEventDispatcher = (event: KeyboardPeripheralEvent) => void;
6
6
  export interface KeyboardPeripheralEvent extends BaseKeyboardPeripheralEvent, KeyboardEventData {
@@ -1,7 +1,7 @@
1
- import { Comms } from "../comms";
2
- import { ReadiumWindow } from "../helpers/dom";
3
- import { Module } from "../modules/Module";
4
- import { ModuleName } from "../modules/ModuleLibrary";
1
+ import { Comms } from "../comms/index.ts";
2
+ import { ReadiumWindow } from "../helpers/dom.ts";
3
+ import { Module } from "../modules/Module.ts";
4
+ import { ModuleName } from "../modules/ModuleLibrary.ts";
5
5
  export interface PrintProtectionConfig {
6
6
  disable?: boolean;
7
7
  watermark?: string;
@@ -1,6 +1,6 @@
1
- import { BulkCopyProtectionOptions } from "./BulkCopyProtector";
2
- import { PatternAnalyzerOptions } from "./PatternAnalyzer";
3
- import { SelectionAnalyzerOptions } from "./SelectionAnalyzer";
1
+ import { BulkCopyProtectionOptions } from "./BulkCopyProtector.ts";
2
+ import { PatternAnalyzerOptions } from "./PatternAnalyzer.ts";
3
+ import { SelectionAnalyzerOptions } from "./SelectionAnalyzer.ts";
4
4
  export declare const DEFAULT_PATTERN_ANALYZER_CONFIG: PatternAnalyzerOptions;
5
5
  export declare const SCROLL_PROTECTION_CONFIG: PatternAnalyzerOptions;
6
6
  export declare const SELECTION_ANALYZER_CONFIG: SelectionAnalyzerOptions;
@@ -1,6 +1,6 @@
1
- export * from "./BulkCopyProtector";
2
- export * from "./KeyCombinationManager";
3
- export * from "./KeyboardCombinations";
4
- export * from "./PatternAnalyzer";
5
- export * from "./SelectionAnalyzer";
6
- export * from "./PrintProtector";
1
+ export * from "./BulkCopyProtector.ts";
2
+ export * from "./KeyCombinationManager.ts";
3
+ export * from "./KeyboardCombinations.ts";
4
+ export * from "./PatternAnalyzer.ts";
5
+ export * from "./SelectionAnalyzer.ts";
6
+ export * from "./PrintProtector.ts";
@@ -1,4 +1,4 @@
1
- import type { MediaTimeSelector, RangeSelector, Selector, TextPositionSelector, TextQuoteSelector } from './api-types';
1
+ import type { MediaTimeSelector, RangeSelector, Selector, TextPositionSelector, TextQuoteSelector } from './api-types.ts';
2
2
  type Options = {
3
3
  hint?: number;
4
4
  };
@@ -7,7 +7,7 @@
7
7
  * 2. Insulating the rest of the code from API changes in the underlying anchoring
8
8
  * libraries.
9
9
  */
10
- import type { MediaTimeSelector, RangeSelector, TextPositionSelector, TextQuoteSelector } from './api-types';
10
+ import type { MediaTimeSelector, RangeSelector, TextPositionSelector, TextQuoteSelector } from './api-types.ts';
11
11
  /**
12
12
  * Converts between `RangeSelector` selectors and `Range` objects.
13
13
  */