@readium/navigator 2.4.0-beta.9 → 2.5.0-beta.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.
- package/dist/ReadiumCSS-after-B_e3a-PY.js +592 -0
- package/dist/ReadiumCSS-after-C-T_0paD.js +530 -0
- package/dist/ReadiumCSS-after-lr-n3fz2.js +475 -0
- package/dist/ReadiumCSS-after-mXeKKPap.js +490 -0
- package/dist/ReadiumCSS-before-Bjd3POej.js +426 -0
- package/dist/ReadiumCSS-before-CfXPAGaQ.js +425 -0
- package/dist/ReadiumCSS-before-CrNWvuyE.js +425 -0
- package/dist/ReadiumCSS-before-KVen5ceo.js +425 -0
- package/dist/ReadiumCSS-default-BKAG5pGU.js +162 -0
- package/dist/ReadiumCSS-default-C63bYOYF.js +183 -0
- package/dist/ReadiumCSS-default-CclvbeNC.js +162 -0
- package/dist/ReadiumCSS-default-DnlgDaBu.js +180 -0
- package/dist/ReadiumCSS-ebpaj_fonts_patch-Dt2XliTg.js +82 -0
- package/dist/index.js +2642 -3430
- package/dist/index.umd.cjs +4407 -995
- package/package.json +2 -2
- package/src/audio/AudioNavigator.ts +155 -42
- package/src/audio/AudioPoolManager.ts +27 -14
- package/src/audio/engine/AudioEngine.ts +4 -3
- package/src/audio/engine/PreservePitchProcessor.js +166 -101
- package/src/audio/engine/PreservePitchWorklet.ts +2 -17
- package/src/audio/engine/WebAudioEngine.ts +138 -160
- package/src/audio/engine/index.ts +2 -2
- package/src/audio/index.ts +3 -3
- package/src/audio/preferences/AudioDefaults.ts +2 -2
- package/src/audio/preferences/AudioPreferences.ts +11 -11
- package/src/audio/preferences/AudioPreferencesEditor.ts +13 -13
- package/src/audio/preferences/AudioSettings.ts +3 -3
- package/src/audio/preferences/index.ts +4 -4
- package/src/audio/protection/AudioNavigatorProtector.ts +4 -4
- package/src/css/index.ts +1 -1
- package/src/epub/EpubNavigator.ts +113 -78
- package/src/epub/css/Properties.ts +15 -15
- package/src/epub/css/ReadiumCSS.ts +43 -43
- package/src/epub/css/index.ts +2 -2
- package/src/epub/frame/FrameBlobBuilder.ts +31 -31
- package/src/epub/frame/FrameComms.ts +1 -1
- package/src/epub/frame/FrameManager.ts +13 -9
- package/src/epub/frame/FramePoolManager.ts +13 -13
- package/src/epub/frame/index.ts +4 -4
- package/src/epub/fxl/FXLCoordinator.ts +3 -3
- package/src/epub/fxl/FXLFrameManager.ts +8 -8
- package/src/epub/fxl/FXLFramePoolManager.ts +18 -14
- package/src/epub/fxl/FXLPeripherals.ts +4 -4
- package/src/epub/fxl/index.ts +5 -5
- package/src/epub/helpers/scriptMode.ts +45 -0
- package/src/epub/index.ts +6 -5
- package/src/epub/preferences/EpubDefaults.ts +23 -23
- package/src/epub/preferences/EpubPreferences.ts +16 -16
- package/src/epub/preferences/EpubPreferencesEditor.ts +53 -53
- package/src/epub/preferences/EpubSettings.ts +101 -101
- package/src/epub/preferences/index.ts +4 -4
- package/src/helpers/index.ts +2 -2
- package/src/index.ts +8 -8
- package/src/injection/Injector.ts +42 -42
- package/src/injection/epubInjectables.ts +86 -17
- package/src/injection/index.ts +2 -2
- package/src/injection/webpubInjectables.ts +2 -2
- package/src/preferences/Configurable.ts +2 -2
- package/src/preferences/PreferencesEditor.ts +2 -2
- package/src/preferences/guards.ts +2 -2
- package/src/preferences/index.ts +5 -5
- package/src/protection/CopyProtector.ts +5 -1
- package/src/protection/DevToolsDetector.ts +16 -16
- package/src/protection/DragAndDropProtector.ts +14 -1
- package/src/protection/NavigatorProtector.ts +6 -6
- package/src/webpub/WebPubBlobBuilder.ts +1 -1
- package/src/webpub/WebPubFrameManager.ts +8 -8
- package/src/webpub/WebPubFramePoolManager.ts +7 -7
- package/src/webpub/WebPubNavigator.ts +27 -27
- package/src/webpub/css/Properties.ts +3 -3
- package/src/webpub/css/WebPubCSS.ts +11 -11
- package/src/webpub/css/index.ts +2 -2
- package/src/webpub/index.ts +6 -6
- package/src/webpub/preferences/WebPubDefaults.ts +12 -12
- package/src/webpub/preferences/WebPubPreferences.ts +8 -8
- package/src/webpub/preferences/WebPubPreferencesEditor.ts +31 -31
- package/src/webpub/preferences/WebPubSettings.ts +45 -45
- package/src/webpub/preferences/index.ts +4 -4
- package/types/src/audio/AudioNavigator.d.ts +34 -5
- package/types/src/audio/AudioPoolManager.d.ts +7 -4
- package/types/src/audio/engine/AudioEngine.d.ts +4 -3
- package/types/src/audio/engine/PreservePitchWorklet.d.ts +1 -4
- package/types/src/audio/engine/WebAudioEngine.d.ts +15 -9
- package/types/src/audio/engine/index.d.ts +2 -2
- package/types/src/audio/index.d.ts +3 -3
- package/types/src/audio/preferences/AudioPreferences.d.ts +9 -9
- package/types/src/audio/preferences/AudioPreferencesEditor.d.ts +4 -4
- package/types/src/audio/preferences/AudioSettings.d.ts +3 -3
- package/types/src/audio/preferences/index.d.ts +4 -4
- package/types/src/audio/protection/AudioNavigatorProtector.d.ts +2 -2
- package/types/src/css/index.d.ts +1 -1
- package/types/src/epub/EpubNavigator.d.ts +15 -14
- package/types/src/epub/css/Properties.d.ts +2 -2
- package/types/src/epub/css/ReadiumCSS.d.ts +3 -3
- package/types/src/epub/css/index.d.ts +2 -2
- package/types/src/epub/frame/FrameBlobBuilder.d.ts +1 -1
- package/types/src/epub/frame/FrameComms.d.ts +1 -1
- package/types/src/epub/frame/FrameManager.d.ts +3 -2
- package/types/src/epub/frame/FramePoolManager.d.ts +3 -3
- package/types/src/epub/frame/index.d.ts +4 -4
- package/types/src/epub/fxl/FXLFrameManager.d.ts +3 -3
- package/types/src/epub/fxl/FXLFramePoolManager.d.ts +5 -5
- package/types/src/epub/fxl/FXLPeripherals.d.ts +2 -2
- package/types/src/epub/fxl/index.d.ts +5 -5
- package/types/src/epub/helpers/scriptMode.d.ts +16 -0
- package/types/src/epub/index.d.ts +6 -5
- package/types/src/epub/preferences/EpubDefaults.d.ts +1 -1
- package/types/src/epub/preferences/EpubPreferences.d.ts +2 -2
- package/types/src/epub/preferences/EpubPreferencesEditor.d.ts +5 -5
- package/types/src/epub/preferences/EpubSettings.d.ts +4 -4
- package/types/src/epub/preferences/index.d.ts +4 -4
- package/types/src/helpers/index.d.ts +2 -2
- package/types/src/index.d.ts +8 -8
- package/types/src/injection/Injector.d.ts +1 -1
- package/types/src/injection/epubInjectables.d.ts +5 -3
- package/types/src/injection/index.d.ts +2 -2
- package/types/src/injection/webpubInjectables.d.ts +1 -1
- package/types/src/preferences/Configurable.d.ts +1 -1
- package/types/src/preferences/PreferencesEditor.d.ts +1 -1
- package/types/src/preferences/guards.d.ts +1 -1
- package/types/src/preferences/index.d.ts +5 -5
- package/types/src/protection/CopyProtector.d.ts +1 -0
- package/types/src/protection/DragAndDropProtector.d.ts +2 -0
- package/types/src/protection/NavigatorProtector.d.ts +1 -1
- package/types/src/webpub/WebPubBlobBuilder.d.ts +1 -1
- package/types/src/webpub/WebPubFrameManager.d.ts +2 -2
- package/types/src/webpub/WebPubFramePoolManager.d.ts +3 -3
- package/types/src/webpub/WebPubNavigator.d.ts +10 -10
- package/types/src/webpub/css/Properties.d.ts +2 -2
- package/types/src/webpub/css/WebPubCSS.d.ts +2 -2
- package/types/src/webpub/css/index.d.ts +2 -2
- package/types/src/webpub/index.d.ts +6 -6
- package/types/src/webpub/preferences/WebPubDefaults.d.ts +1 -1
- package/types/src/webpub/preferences/WebPubPreferences.d.ts +2 -2
- package/types/src/webpub/preferences/WebPubPreferencesEditor.d.ts +5 -5
- package/types/src/webpub/preferences/WebPubSettings.d.ts +4 -4
- package/types/src/webpub/preferences/index.d.ts +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AutomationDetector } from "./AutomationDetector";
|
|
2
|
-
import { DevToolsDetector } from "./DevToolsDetector";
|
|
3
|
-
import { IframeEmbeddingDetector } from "./IframeEmbeddingDetector";
|
|
4
|
-
import { PrintProtector } from "./PrintProtector";
|
|
5
|
-
import { ContextMenuProtector } from "./ContextMenuProtector";
|
|
1
|
+
import { AutomationDetector } from "./AutomationDetector.ts";
|
|
2
|
+
import { DevToolsDetector } from "./DevToolsDetector.ts";
|
|
3
|
+
import { IframeEmbeddingDetector } from "./IframeEmbeddingDetector.ts";
|
|
4
|
+
import { PrintProtector } from "./PrintProtector.ts";
|
|
5
|
+
import { ContextMenuProtector } from "./ContextMenuProtector.ts";
|
|
6
6
|
import { ContextMenuEvent } from "@readium/navigator-html-injectables";
|
|
7
|
-
import { IContentProtectionConfig } from "../Navigator";
|
|
7
|
+
import { IContentProtectionConfig } from "../Navigator.ts";
|
|
8
8
|
|
|
9
9
|
export const NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT = "readium:navigator:suspiciousActivity";
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Loader, ModuleName } from "@readium/navigator-html-injectables";
|
|
2
|
-
import { FrameComms } from "../epub/frame/FrameComms";
|
|
3
|
-
import { ReadiumWindow } from "../../../navigator-html-injectables/types/src/helpers/dom";
|
|
4
|
-
import { sML } from "../helpers";
|
|
5
|
-
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
|
|
2
|
+
import { FrameComms } from "../epub/frame/FrameComms.ts";
|
|
3
|
+
import type { ReadiumWindow } from "../../../navigator-html-injectables/types/src/helpers/dom";
|
|
4
|
+
import { sML } from "../helpers/index.ts";
|
|
5
|
+
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator.ts";
|
|
6
6
|
|
|
7
7
|
export class WebPubFrameManager {
|
|
8
8
|
private frame: HTMLIFrameElement;
|
|
@@ -31,7 +31,7 @@ export class WebPubFrameManager {
|
|
|
31
31
|
// Protect against background color bleeding
|
|
32
32
|
this.frame.style.backgroundColor = "#FFFFFF";
|
|
33
33
|
this.source = source;
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
// Use the provided content protection config directly without overriding defaults
|
|
36
36
|
this.contentProtectionConfig = { ...contentProtectionConfig };
|
|
37
37
|
this.keyboardPeripheralsConfig = [...keyboardPeripheralsConfig];
|
|
@@ -68,10 +68,10 @@ export class WebPubFrameManager {
|
|
|
68
68
|
|
|
69
69
|
private applyContentProtection() {
|
|
70
70
|
if (!this.comms) this.comms!.resume();
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
// Send content protection config
|
|
73
73
|
this.comms!.send("peripherals_protection", this.contentProtectionConfig);
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
// Send keyboard peripherals separately
|
|
76
76
|
if (this.keyboardPeripheralsConfig && this.keyboardPeripheralsConfig.length > 0) {
|
|
77
77
|
this.comms!.send("keyboard_peripherals", this.keyboardPeripheralsConfig);
|
|
@@ -186,4 +186,4 @@ export class WebPubFrameManager {
|
|
|
186
186
|
get ldr() {
|
|
187
187
|
return this.loader;
|
|
188
188
|
}
|
|
189
|
-
}
|
|
189
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ModuleName } from "@readium/navigator-html-injectables";
|
|
2
2
|
import { Locator, Publication } from "@readium/shared";
|
|
3
|
-
import { WebPubBlobBuilder } from "./WebPubBlobBuilder";
|
|
4
|
-
import { WebPubFrameManager } from "./WebPubFrameManager";
|
|
5
|
-
import { Injector } from "../injection/Injector";
|
|
6
|
-
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
|
|
3
|
+
import { WebPubBlobBuilder } from "./WebPubBlobBuilder.ts";
|
|
4
|
+
import { WebPubFrameManager } from "./WebPubFrameManager.ts";
|
|
5
|
+
import { Injector } from "../injection/Injector.ts";
|
|
6
|
+
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator.ts";
|
|
7
7
|
|
|
8
8
|
export class WebPubFramePoolManager {
|
|
9
9
|
private readonly container: HTMLElement;
|
|
@@ -19,7 +19,7 @@ export class WebPubFramePoolManager {
|
|
|
19
19
|
private readonly keyboardPeripheralsConfig: IKeyboardPeripheralsConfig;
|
|
20
20
|
|
|
21
21
|
constructor(
|
|
22
|
-
container: HTMLElement,
|
|
22
|
+
container: HTMLElement,
|
|
23
23
|
cssProperties?: { [key: string]: string },
|
|
24
24
|
injector?: Injector | null,
|
|
25
25
|
contentProtectionConfig: IContentProtectionConfig = {},
|
|
@@ -142,7 +142,7 @@ export class WebPubFramePoolManager {
|
|
|
142
142
|
if(!itm) return;
|
|
143
143
|
if(!this.blobs.has(href)) {
|
|
144
144
|
const blobBuilder = new WebPubBlobBuilder(
|
|
145
|
-
pub,
|
|
145
|
+
pub,
|
|
146
146
|
this.currentBaseURL || "",
|
|
147
147
|
itm,
|
|
148
148
|
{
|
|
@@ -250,4 +250,4 @@ export class WebPubFramePoolManager {
|
|
|
250
250
|
});
|
|
251
251
|
return ret as DOMRect;
|
|
252
252
|
}
|
|
253
|
-
}
|
|
253
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { Feature, Link, Locator, Publication, ReadingProgression, LocatorLocations } from "@readium/shared";
|
|
2
|
-
import { VisualNavigator, VisualNavigatorViewport, ProgressionRange } from "../Navigator";
|
|
3
|
-
import { Configurable } from "../preferences/Configurable";
|
|
4
|
-
import { WebPubFramePoolManager } from "./WebPubFramePoolManager";
|
|
2
|
+
import { VisualNavigator, VisualNavigatorViewport, ProgressionRange } from "../Navigator.ts";
|
|
3
|
+
import { Configurable } from "../preferences/Configurable.ts";
|
|
4
|
+
import { WebPubFramePoolManager } from "./WebPubFramePoolManager.ts";
|
|
5
5
|
import { BasicTextSelection, CommsEventKey, ContextMenuEvent, FrameClickEvent, KeyboardEventData, ModuleLibrary, ModuleName, SuspiciousActivityEvent, WebPubModules } from "@readium/navigator-html-injectables";
|
|
6
6
|
import * as path from "path-browserify";
|
|
7
|
-
import { WebPubFrameManager } from "./WebPubFrameManager";
|
|
8
|
-
|
|
9
|
-
import { ManagerEventKey } from "../epub/EpubNavigator";
|
|
10
|
-
import { WebPubCSS } from "./css/WebPubCSS";
|
|
11
|
-
import { WebUserProperties, WebRSProperties } from "./css/Properties";
|
|
12
|
-
import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences";
|
|
13
|
-
import { IWebPubDefaults, WebPubDefaults } from "./preferences/WebPubDefaults";
|
|
14
|
-
import { WebPubSettings } from "./preferences/WebPubSettings";
|
|
15
|
-
import { WebPubPreferencesEditor } from "./preferences/WebPubPreferencesEditor";
|
|
16
|
-
import { Injector } from "../injection/Injector";
|
|
17
|
-
import { createReadiumWebPubRules } from "../injection/webpubInjectables";
|
|
18
|
-
import { IInjectablesConfig } from "../injection/Injectable";
|
|
19
|
-
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator";
|
|
20
|
-
import { NavigatorProtector, NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT } from "../protection/NavigatorProtector";
|
|
21
|
-
import { KeyboardPeripherals, NAVIGATOR_KEYBOARD_PERIPHERAL_EVENT } from "../peripherals/KeyboardPeripherals";
|
|
7
|
+
import { WebPubFrameManager } from "./WebPubFrameManager.ts";
|
|
8
|
+
|
|
9
|
+
import { ManagerEventKey } from "../epub/EpubNavigator.ts";
|
|
10
|
+
import { WebPubCSS } from "./css/WebPubCSS.ts";
|
|
11
|
+
import { WebUserProperties, WebRSProperties } from "./css/Properties.ts";
|
|
12
|
+
import { IWebPubPreferences, WebPubPreferences } from "./preferences/WebPubPreferences.ts";
|
|
13
|
+
import { IWebPubDefaults, WebPubDefaults } from "./preferences/WebPubDefaults.ts";
|
|
14
|
+
import { WebPubSettings } from "./preferences/WebPubSettings.ts";
|
|
15
|
+
import { WebPubPreferencesEditor } from "./preferences/WebPubPreferencesEditor.ts";
|
|
16
|
+
import { Injector } from "../injection/Injector.ts";
|
|
17
|
+
import { createReadiumWebPubRules } from "../injection/webpubInjectables.ts";
|
|
18
|
+
import { IInjectablesConfig } from "../injection/Injectable.ts";
|
|
19
|
+
import { IContentProtectionConfig, IKeyboardPeripheralsConfig } from "../Navigator.ts";
|
|
20
|
+
import { NavigatorProtector, NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT } from "../protection/NavigatorProtector.ts";
|
|
21
|
+
import { KeyboardPeripherals, NAVIGATOR_KEYBOARD_PERIPHERAL_EVENT } from "../peripherals/KeyboardPeripherals.ts";
|
|
22
22
|
|
|
23
23
|
export interface WebPubNavigatorConfiguration {
|
|
24
24
|
preferences: IWebPubPreferences;
|
|
@@ -78,7 +78,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
78
78
|
private readonly _keyboardPeripheralsManager: KeyboardPeripherals | null = null;
|
|
79
79
|
private readonly _suspiciousActivityListener: ((event: Event) => void) | null = null;
|
|
80
80
|
private readonly _keyboardPeripheralListener: ((event: Event) => void) | null = null;
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
private webViewport: VisualNavigatorViewport = {
|
|
83
83
|
readingOrder: [],
|
|
84
84
|
progressions: new Map(),
|
|
@@ -103,7 +103,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
103
103
|
// Combine WebPub rules with user-provided injectables
|
|
104
104
|
const webpubRules = createReadiumWebPubRules(pub.readingOrder.items);
|
|
105
105
|
const userConfig = configuration.injectables || { rules: [], allowedDomains: [] };
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
this._injector = new Injector({
|
|
108
108
|
rules: [...webpubRules, ...userConfig.rules],
|
|
109
109
|
allowedDomains: userConfig.allowedDomains
|
|
@@ -111,7 +111,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
111
111
|
|
|
112
112
|
// Initialize content protection with provided config or default values
|
|
113
113
|
this._contentProtection = configuration.contentProtection || {};
|
|
114
|
-
|
|
114
|
+
|
|
115
115
|
// Merge keyboard peripherals
|
|
116
116
|
this._keyboardPeripherals = this.mergeKeyboardPeripherals(
|
|
117
117
|
this._contentProtection,
|
|
@@ -125,7 +125,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
125
125
|
this._contentProtection.monitorDevTools ||
|
|
126
126
|
this._contentProtection.protectPrinting?.disable) {
|
|
127
127
|
this._navigatorProtector = new NavigatorProtector(this._contentProtection);
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
// Listen for custom events from NavigatorProtector
|
|
130
130
|
this._suspiciousActivityListener = (event: Event) => {
|
|
131
131
|
const { type, ...activity } = (event as CustomEvent).detail;
|
|
@@ -137,13 +137,13 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
137
137
|
};
|
|
138
138
|
window.addEventListener(NAVIGATOR_SUSPICIOUS_ACTIVITY_EVENT, this._suspiciousActivityListener);
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
// Initialize keyboard peripherals separately (works independently of protection)
|
|
142
142
|
if (this._keyboardPeripherals.length > 0) {
|
|
143
143
|
this._keyboardPeripheralsManager = new KeyboardPeripherals({
|
|
144
144
|
keyboardPeripherals: this._keyboardPeripherals
|
|
145
145
|
});
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
// Listen for keyboard peripheral events from main window
|
|
148
148
|
this._keyboardPeripheralListener = (event: Event) => {
|
|
149
149
|
const activity = (event as CustomEvent).detail;
|
|
@@ -169,8 +169,8 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
169
169
|
await this.updateCSS(false);
|
|
170
170
|
const cssProperties = this.compileCSSProperties(this._css);
|
|
171
171
|
this.framePool = new WebPubFramePoolManager(
|
|
172
|
-
this.container,
|
|
173
|
-
cssProperties,
|
|
172
|
+
this.container,
|
|
173
|
+
cssProperties,
|
|
174
174
|
this._injector,
|
|
175
175
|
this._contentProtection,
|
|
176
176
|
this._keyboardPeripherals
|
|
@@ -611,4 +611,4 @@ export class WebPubNavigator extends VisualNavigator implements Configurable<Web
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
export const ExperimentalWebPubNavigator = WebPubNavigator;
|
|
614
|
+
export const ExperimentalWebPubNavigator = WebPubNavigator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExperimentKey, experiments, TextAlignment } from "../../preferences/Types";
|
|
2
|
-
import { BodyHyphens, Ligatures, Properties } from "../../css/Properties";
|
|
1
|
+
import { ExperimentKey, experiments, TextAlignment } from "../../preferences/Types.ts";
|
|
2
|
+
import { BodyHyphens, Ligatures, Properties } from "../../css/Properties.ts";
|
|
3
3
|
|
|
4
4
|
export interface IWebUserProperties {
|
|
5
5
|
a11yNormalize?: boolean | null;
|
|
@@ -101,4 +101,4 @@ export class WebRSProperties extends Properties {
|
|
|
101
101
|
|
|
102
102
|
return cssProperties;
|
|
103
103
|
}
|
|
104
|
-
}
|
|
104
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WebPubSettings } from "../preferences/WebPubSettings";
|
|
2
|
-
import { IWebUserProperties, WebRSProperties, WebUserProperties } from "./Properties";
|
|
1
|
+
import { WebPubSettings } from "../preferences/WebPubSettings.ts";
|
|
2
|
+
import { IWebUserProperties, WebRSProperties, WebUserProperties } from "./Properties.ts";
|
|
3
3
|
|
|
4
4
|
export interface IWebPubCSS {
|
|
5
5
|
rsProperties: WebRSProperties;
|
|
@@ -22,20 +22,20 @@ export class WebPubCSS {
|
|
|
22
22
|
|
|
23
23
|
const updated: IWebUserProperties = {
|
|
24
24
|
a11yNormalize: settings.textNormalization,
|
|
25
|
-
bodyHyphens: typeof settings.hyphens !== "boolean"
|
|
26
|
-
? null
|
|
27
|
-
: settings.hyphens
|
|
28
|
-
? "auto"
|
|
25
|
+
bodyHyphens: typeof settings.hyphens !== "boolean"
|
|
26
|
+
? null
|
|
27
|
+
: settings.hyphens
|
|
28
|
+
? "auto"
|
|
29
29
|
: "none",
|
|
30
30
|
fontFamily: settings.fontFamily,
|
|
31
31
|
fontWeight: settings.fontWeight,
|
|
32
32
|
iOSPatch: settings.iOSPatch,
|
|
33
33
|
iPadOSPatch: settings.iPadOSPatch,
|
|
34
34
|
letterSpacing: settings.letterSpacing,
|
|
35
|
-
ligatures: typeof settings.ligatures !== "boolean"
|
|
36
|
-
? null
|
|
37
|
-
: settings.ligatures
|
|
38
|
-
? "common-ligatures"
|
|
35
|
+
ligatures: typeof settings.ligatures !== "boolean"
|
|
36
|
+
? null
|
|
37
|
+
: settings.ligatures
|
|
38
|
+
? "common-ligatures"
|
|
39
39
|
: "none",
|
|
40
40
|
lineHeight: settings.lineHeight,
|
|
41
41
|
noRuby: settings.noRuby,
|
|
@@ -48,4 +48,4 @@ export class WebPubCSS {
|
|
|
48
48
|
|
|
49
49
|
this.userProperties = new WebUserProperties(updated);
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|
package/src/webpub/css/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./Properties";
|
|
2
|
-
export * from "./WebPubCSS";
|
|
1
|
+
export * from "./Properties.ts";
|
|
2
|
+
export * from "./WebPubCSS.ts";
|
package/src/webpub/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./WebPubNavigator";
|
|
2
|
-
export * from "./WebPubBlobBuilder";
|
|
3
|
-
export * from "./WebPubFrameManager";
|
|
4
|
-
export * from "./WebPubFramePoolManager";
|
|
5
|
-
export * from "./preferences";
|
|
6
|
-
export * from "./css";
|
|
1
|
+
export * from "./WebPubNavigator.ts";
|
|
2
|
+
export * from "./WebPubBlobBuilder.ts";
|
|
3
|
+
export * from "./WebPubFrameManager.ts";
|
|
4
|
+
export * from "./WebPubFramePoolManager.ts";
|
|
5
|
+
export * from "./preferences/index.ts";
|
|
6
|
+
export * from "./css/index.ts";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
2
|
ExperimentKey,
|
|
3
|
-
fontWeightRangeConfig,
|
|
4
|
-
TextAlignment,
|
|
5
|
-
zoomRangeConfig
|
|
6
|
-
} from "../../preferences/Types";
|
|
3
|
+
fontWeightRangeConfig,
|
|
4
|
+
TextAlignment,
|
|
5
|
+
zoomRangeConfig
|
|
6
|
+
} from "../../preferences/Types.ts";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
ensureBoolean,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
ensureValueInRange,
|
|
13
13
|
ensureString,
|
|
14
14
|
ensureExperiment
|
|
15
|
-
} from "../../preferences/guards";
|
|
15
|
+
} from "../../preferences/guards.ts";
|
|
16
16
|
|
|
17
|
-
import { sMLWithRequest } from "../../helpers";
|
|
17
|
+
import { sMLWithRequest } from "../../helpers/index.ts";
|
|
18
18
|
|
|
19
19
|
export interface IWebPubDefaults {
|
|
20
20
|
fontFamily?: string | null,
|
|
@@ -57,11 +57,11 @@ export class WebPubDefaults {
|
|
|
57
57
|
this.fontFamily = ensureString(defaults.fontFamily) || null;
|
|
58
58
|
this.fontWeight = ensureValueInRange(defaults.fontWeight, fontWeightRangeConfig.range) || null;
|
|
59
59
|
this.hyphens = ensureBoolean(defaults.hyphens) ?? null;
|
|
60
|
-
this.iOSPatch = defaults.iOSPatch === false
|
|
61
|
-
? false
|
|
60
|
+
this.iOSPatch = defaults.iOSPatch === false
|
|
61
|
+
? false
|
|
62
62
|
: ((sMLWithRequest.OS.iOS || sMLWithRequest.OS.iPadOS) && sMLWithRequest.iOSRequest === "mobile");
|
|
63
|
-
this.iPadOSPatch = defaults.iPadOSPatch === false
|
|
64
|
-
? false
|
|
63
|
+
this.iPadOSPatch = defaults.iPadOSPatch === false
|
|
64
|
+
? false
|
|
65
65
|
: (sMLWithRequest.OS.iPadOS && sMLWithRequest.iOSRequest === "desktop");
|
|
66
66
|
this.letterSpacing = ensureNonNegative(defaults.letterSpacing) || null;
|
|
67
67
|
this.ligatures = ensureBoolean(defaults.ligatures) ?? null;
|
|
@@ -75,4 +75,4 @@ export class WebPubDefaults {
|
|
|
75
75
|
this.zoom = ensureValueInRange(defaults.zoom, zoomRangeConfig.range) || 1;
|
|
76
76
|
this.experiments = ensureExperiment(defaults.experiments) ?? null;
|
|
77
77
|
}
|
|
78
|
-
}
|
|
78
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ConfigurablePreferences } from "../../preferences/Configurable";
|
|
1
|
+
import { ConfigurablePreferences } from "../../preferences/Configurable.ts";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
fontWeightRangeConfig,
|
|
5
|
-
TextAlignment,
|
|
6
|
-
zoomRangeConfig
|
|
7
|
-
} from "../../preferences/Types";
|
|
3
|
+
import {
|
|
4
|
+
fontWeightRangeConfig,
|
|
5
|
+
TextAlignment,
|
|
6
|
+
zoomRangeConfig
|
|
7
|
+
} from "../../preferences/Types.ts";
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
ensureBoolean,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
ensureNonNegative,
|
|
13
13
|
ensureString,
|
|
14
14
|
ensureValueInRange
|
|
15
|
-
} from "../../preferences/guards";
|
|
15
|
+
} from "../../preferences/guards.ts";
|
|
16
16
|
|
|
17
17
|
export interface IWebPubPreferences {
|
|
18
18
|
fontFamily?: string | null,
|
|
@@ -91,4 +91,4 @@ export class WebPubPreferences implements ConfigurablePreferences<WebPubPreferen
|
|
|
91
91
|
}
|
|
92
92
|
return new WebPubPreferences(merged);
|
|
93
93
|
}
|
|
94
|
-
}
|
|
94
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Feature, Metadata } from "@readium/shared";
|
|
2
2
|
|
|
3
|
-
import { IPreferencesEditor } from "../../preferences/PreferencesEditor";
|
|
4
|
-
import { WebPubPreferences } from "./WebPubPreferences";
|
|
5
|
-
import { WebPubSettings } from "./WebPubSettings";
|
|
6
|
-
import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference";
|
|
7
|
-
import {
|
|
8
|
-
fontWeightRangeConfig,
|
|
9
|
-
letterSpacingRangeConfig,
|
|
10
|
-
lineHeightRangeConfig,
|
|
11
|
-
paragraphIndentRangeConfig,
|
|
12
|
-
paragraphSpacingRangeConfig,
|
|
13
|
-
TextAlignment,
|
|
14
|
-
wordSpacingRangeConfig,
|
|
15
|
-
zoomRangeConfig
|
|
16
|
-
} from "../../preferences/Types";
|
|
3
|
+
import { IPreferencesEditor } from "../../preferences/PreferencesEditor.ts";
|
|
4
|
+
import { WebPubPreferences } from "./WebPubPreferences.ts";
|
|
5
|
+
import { WebPubSettings } from "./WebPubSettings.ts";
|
|
6
|
+
import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference.ts";
|
|
7
|
+
import {
|
|
8
|
+
fontWeightRangeConfig,
|
|
9
|
+
letterSpacingRangeConfig,
|
|
10
|
+
lineHeightRangeConfig,
|
|
11
|
+
paragraphIndentRangeConfig,
|
|
12
|
+
paragraphSpacingRangeConfig,
|
|
13
|
+
TextAlignment,
|
|
14
|
+
wordSpacingRangeConfig,
|
|
15
|
+
zoomRangeConfig
|
|
16
|
+
} from "../../preferences/Types.ts";
|
|
17
17
|
export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
18
18
|
preferences: WebPubPreferences;
|
|
19
19
|
private settings: WebPubSettings;
|
|
@@ -45,7 +45,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
45
45
|
effectiveValue: this.settings.fontFamily || null,
|
|
46
46
|
isEffective: this.isDisplayTransformable,
|
|
47
47
|
onChange: (newValue: string | null | undefined) => {
|
|
48
|
-
this.updatePreference("fontFamily", newValue
|
|
48
|
+
this.updatePreference("fontFamily", newValue ?? null);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
}
|
|
@@ -56,7 +56,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
56
56
|
effectiveValue: this.settings.fontWeight || 400,
|
|
57
57
|
isEffective: this.isDisplayTransformable,
|
|
58
58
|
onChange: (newValue: number | null | undefined) => {
|
|
59
|
-
this.updatePreference("fontWeight", newValue
|
|
59
|
+
this.updatePreference("fontWeight", newValue ?? null);
|
|
60
60
|
},
|
|
61
61
|
supportedRange: fontWeightRangeConfig.range,
|
|
62
62
|
step: fontWeightRangeConfig.step
|
|
@@ -69,7 +69,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
69
69
|
effectiveValue: this.settings.hyphens || false,
|
|
70
70
|
isEffective: this.isDisplayTransformable,
|
|
71
71
|
onChange: (newValue: boolean | null | undefined) => {
|
|
72
|
-
this.updatePreference("hyphens", newValue
|
|
72
|
+
this.updatePreference("hyphens", newValue ?? null);
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -80,18 +80,18 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
80
80
|
effectiveValue: this.settings.iOSPatch || false,
|
|
81
81
|
isEffective: true,
|
|
82
82
|
onChange: (newValue: boolean | null | undefined) => {
|
|
83
|
-
this.updatePreference("iOSPatch", newValue
|
|
83
|
+
this.updatePreference("iOSPatch", newValue ?? null);
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
get iPadOSPatch(): BooleanPreference {
|
|
89
89
|
return new BooleanPreference({
|
|
90
90
|
initialValue: this.preferences.iPadOSPatch,
|
|
91
91
|
effectiveValue: this.settings.iPadOSPatch || false,
|
|
92
92
|
isEffective: true,
|
|
93
93
|
onChange: (newValue: boolean | null | undefined) => {
|
|
94
|
-
this.updatePreference("iPadOSPatch", newValue
|
|
94
|
+
this.updatePreference("iPadOSPatch", newValue ?? null);
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -102,7 +102,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
102
102
|
effectiveValue: this.settings.letterSpacing || 0,
|
|
103
103
|
isEffective: this.isDisplayTransformable,
|
|
104
104
|
onChange: (newValue: number | null | undefined) => {
|
|
105
|
-
this.updatePreference("letterSpacing", newValue
|
|
105
|
+
this.updatePreference("letterSpacing", newValue ?? null);
|
|
106
106
|
},
|
|
107
107
|
supportedRange: letterSpacingRangeConfig.range,
|
|
108
108
|
step: letterSpacingRangeConfig.step
|
|
@@ -115,7 +115,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
115
115
|
effectiveValue: this.settings.ligatures || true,
|
|
116
116
|
isEffective: this.isDisplayTransformable,
|
|
117
117
|
onChange: (newValue: boolean | null | undefined) => {
|
|
118
|
-
this.updatePreference("ligatures", newValue
|
|
118
|
+
this.updatePreference("ligatures", newValue ?? null);
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -126,7 +126,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
126
126
|
effectiveValue: this.settings.lineHeight,
|
|
127
127
|
isEffective: this.isDisplayTransformable,
|
|
128
128
|
onChange: (newValue: number | null | undefined) => {
|
|
129
|
-
this.updatePreference("lineHeight", newValue
|
|
129
|
+
this.updatePreference("lineHeight", newValue ?? null);
|
|
130
130
|
},
|
|
131
131
|
supportedRange: lineHeightRangeConfig.range,
|
|
132
132
|
step: lineHeightRangeConfig.step
|
|
@@ -139,7 +139,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
139
139
|
effectiveValue: this.settings.noRuby || false,
|
|
140
140
|
isEffective: this.isDisplayTransformable,
|
|
141
141
|
onChange: (newValue: boolean | null | undefined) => {
|
|
142
|
-
this.updatePreference("noRuby", newValue
|
|
142
|
+
this.updatePreference("noRuby", newValue ?? null);
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
}
|
|
@@ -150,7 +150,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
150
150
|
effectiveValue: this.settings.paragraphIndent || 0,
|
|
151
151
|
isEffective: this.isDisplayTransformable,
|
|
152
152
|
onChange: (newValue: number | null | undefined) => {
|
|
153
|
-
this.updatePreference("paragraphIndent", newValue
|
|
153
|
+
this.updatePreference("paragraphIndent", newValue ?? null);
|
|
154
154
|
},
|
|
155
155
|
supportedRange: paragraphIndentRangeConfig.range,
|
|
156
156
|
step: paragraphIndentRangeConfig.step
|
|
@@ -163,7 +163,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
163
163
|
effectiveValue: this.settings.paragraphSpacing || 0,
|
|
164
164
|
isEffective: this.isDisplayTransformable,
|
|
165
165
|
onChange: (newValue: number | null | undefined) => {
|
|
166
|
-
this.updatePreference("paragraphSpacing", newValue
|
|
166
|
+
this.updatePreference("paragraphSpacing", newValue ?? null);
|
|
167
167
|
},
|
|
168
168
|
supportedRange: paragraphSpacingRangeConfig.range,
|
|
169
169
|
step: paragraphSpacingRangeConfig.step
|
|
@@ -176,7 +176,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
176
176
|
effectiveValue: this.settings.textAlign || TextAlignment.start,
|
|
177
177
|
isEffective: this.isDisplayTransformable,
|
|
178
178
|
onChange: (newValue: TextAlignment | null | undefined) => {
|
|
179
|
-
this.updatePreference("textAlign", newValue
|
|
179
|
+
this.updatePreference("textAlign", newValue ?? null);
|
|
180
180
|
},
|
|
181
181
|
supportedValues: Object.values(TextAlignment)
|
|
182
182
|
});
|
|
@@ -188,7 +188,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
188
188
|
effectiveValue: this.settings.textNormalization || false,
|
|
189
189
|
isEffective: this.isDisplayTransformable,
|
|
190
190
|
onChange: (newValue: boolean | null | undefined) => {
|
|
191
|
-
this.updatePreference("textNormalization", newValue
|
|
191
|
+
this.updatePreference("textNormalization", newValue ?? null);
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
194
|
}
|
|
@@ -199,7 +199,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
199
199
|
effectiveValue: this.settings.wordSpacing || 0,
|
|
200
200
|
isEffective: this.isDisplayTransformable,
|
|
201
201
|
onChange: (newValue: number | null | undefined) => {
|
|
202
|
-
this.updatePreference("wordSpacing", newValue
|
|
202
|
+
this.updatePreference("wordSpacing", newValue ?? null);
|
|
203
203
|
},
|
|
204
204
|
supportedRange: wordSpacingRangeConfig.range,
|
|
205
205
|
step: wordSpacingRangeConfig.step
|
|
@@ -212,10 +212,10 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
|
|
|
212
212
|
effectiveValue: this.settings.zoom || 1,
|
|
213
213
|
isEffective: CSS.supports("zoom", "1") ?? false,
|
|
214
214
|
onChange: (newValue: number | null | undefined) => {
|
|
215
|
-
this.updatePreference("zoom", newValue
|
|
215
|
+
this.updatePreference("zoom", newValue ?? null);
|
|
216
216
|
},
|
|
217
217
|
supportedRange: zoomRangeConfig.range,
|
|
218
218
|
step: zoomRangeConfig.step
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
}
|
|
221
|
+
}
|