From 7d2d38d359b43068639a742bc1a0cb3e41ccf323 Mon Sep 17 00:00:00 2001 From: Jiminy Panoz Date: Thu, 30 Oct 2025 16:19:44 +0100 Subject: [PATCH 1/5] Expose cframes for WebPub We really want to remove this instead of relying on it but webpub proto needs it ATM for the webkit scroll patch, and there is not much time to do something else. --- navigator/src/webpub/WebPubNavigator.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/navigator/src/webpub/WebPubNavigator.ts b/navigator/src/webpub/WebPubNavigator.ts index c3fca2f9..bb4905da 100644 --- a/navigator/src/webpub/WebPubNavigator.ts +++ b/navigator/src/webpub/WebPubNavigator.ts @@ -4,6 +4,8 @@ import { Configurable } from "../preferences/Configurable"; import { WebPubFramePoolManager } from "./WebPubFramePoolManager"; import { BasicTextSelection, CommsEventKey, FrameClickEvent, ModuleLibrary, ModuleName, WebPubModules } from "@readium/navigator-html-injectables"; import * as path from "path-browserify"; +import { WebPubFrameManager } from "./WebPubFrameManager"; + import { ManagerEventKey } from "../epub/EpubNavigator"; import { WebPubCSS } from "./css/WebPubCSS"; import { WebUserProperties } from "./css/Properties"; @@ -12,7 +14,6 @@ import { IWebPubDefaults, WebPubDefaults } from "./preferences/WebPubDefaults"; import { WebPubSettings } from "./preferences/WebPubSettings"; import { IPreferencesEditor } from "../preferences/PreferencesEditor"; import { WebPubPreferencesEditor } from "./preferences/WebPubPreferencesEditor"; - export interface WebPubNavigatorConfiguration { preferences: IWebPubPreferences; defaults: IWebPubDefaults; @@ -146,6 +147,14 @@ export class WebPubNavigator extends VisualNavigator implements Configurable Date: Thu, 30 Oct 2025 16:29:33 +0100 Subject: [PATCH 2/5] Fix check in WebPubPrefsEditor --- .../preferences/WebPubPreferencesEditor.ts | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/navigator/src/webpub/preferences/WebPubPreferencesEditor.ts b/navigator/src/webpub/preferences/WebPubPreferencesEditor.ts index 67e66d7f..10158a4d 100644 --- a/navigator/src/webpub/preferences/WebPubPreferencesEditor.ts +++ b/navigator/src/webpub/preferences/WebPubPreferencesEditor.ts @@ -33,11 +33,17 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { this.preferences[key] = value; } + private get isDisplayTransformable(): boolean { + return this.metadata?.accessibility?.feature?.some( + f => f.value === Feature.DISPLAY_TRANSFORMABILITY.value + ) ?? false; // Default to false if no metadata + } + get fontFamily(): Preference { return new Preference({ initialValue: this.preferences.fontFamily, effectiveValue: this.settings.fontFamily || null, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: string | null | undefined) => { this.updatePreference("fontFamily", newValue || null); } @@ -48,7 +54,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new RangePreference({ initialValue: this.preferences.fontWeight, effectiveValue: this.settings.fontWeight || 400, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: number | null | undefined) => { this.updatePreference("fontWeight", newValue || null); }, @@ -61,7 +67,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new BooleanPreference({ initialValue: this.preferences.hyphens, effectiveValue: this.settings.hyphens || false, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: boolean | null | undefined) => { this.updatePreference("hyphens", newValue || null); } @@ -72,7 +78,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new RangePreference({ initialValue: this.preferences.letterSpacing, effectiveValue: this.settings.letterSpacing || 0, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: number | null | undefined) => { this.updatePreference("letterSpacing", newValue || null); }, @@ -85,7 +91,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new BooleanPreference({ initialValue: this.preferences.ligatures, effectiveValue: this.settings.ligatures || true, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: boolean | null | undefined) => { this.updatePreference("ligatures", newValue || null); } @@ -96,7 +102,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new RangePreference({ initialValue: this.preferences.lineHeight, effectiveValue: this.settings.lineHeight, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: number | null | undefined) => { this.updatePreference("lineHeight", newValue || null); }, @@ -109,7 +115,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new BooleanPreference({ initialValue: this.preferences.noRuby, effectiveValue: this.settings.noRuby || false, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: boolean | null | undefined) => { this.updatePreference("noRuby", newValue || null); } @@ -120,7 +126,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new RangePreference({ initialValue: this.preferences.paragraphIndent, effectiveValue: this.settings.paragraphIndent || 0, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: number | null | undefined) => { this.updatePreference("paragraphIndent", newValue || null); }, @@ -133,7 +139,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new RangePreference({ initialValue: this.preferences.paragraphSpacing, effectiveValue: this.settings.paragraphSpacing || 0, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: number | null | undefined) => { this.updatePreference("paragraphSpacing", newValue || null); }, @@ -146,7 +152,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new EnumPreference({ initialValue: this.preferences.textAlign, effectiveValue: this.settings.textAlign || TextAlignment.start, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: TextAlignment | null | undefined) => { this.updatePreference("textAlign", newValue || null); }, @@ -158,7 +164,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new BooleanPreference({ initialValue: this.preferences.textNormalization, effectiveValue: this.settings.textNormalization || false, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: boolean | null | undefined) => { this.updatePreference("textNormalization", newValue || null); } @@ -169,7 +175,7 @@ export class WebPubPreferencesEditor implements IPreferencesEditor { return new RangePreference({ initialValue: this.preferences.wordSpacing, effectiveValue: this.settings.wordSpacing || 0, - isEffective: this.metadata?.accessibility?.feature?.includes(Feature.DISPLAY_TRANSFORMABILITY) ?? false, + isEffective: this.isDisplayTransformable, onChange: (newValue: number | null | undefined) => { this.updatePreference("wordSpacing", newValue || null); }, From 6b2dbb9339f9323a8485164082f59651157068d4 Mon Sep 17 00:00:00 2001 From: Jiminy Panoz Date: Thu, 30 Oct 2025 16:30:55 +0100 Subject: [PATCH 3/5] Bump version --- navigator/CHANGELOG.MD | 6 ++++++ navigator/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/navigator/CHANGELOG.MD b/navigator/CHANGELOG.MD index 7c602b2a..7fffe02f 100644 --- a/navigator/CHANGELOG.MD +++ b/navigator/CHANGELOG.MD @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.2.2] - 2025-10-30 + +### Fixed + +- Corrects `isEffective` check in `WebPubPreferencesEditor` + ## [2.2.1] - 2025-10-28 ### Added diff --git a/navigator/package.json b/navigator/package.json index 7a4b1c08..9a6e6c92 100644 --- a/navigator/package.json +++ b/navigator/package.json @@ -1,6 +1,6 @@ { "name": "@readium/navigator", - "version": "2.2.1", + "version": "2.2.2", "type": "module", "description": "Next generation SDK for publications in Web Apps", "author": "readium", From 2c2f8043b813677bd5bf479a2c08322ff26ed2b9 Mon Sep 17 00:00:00 2001 From: Jiminy Panoz Date: Thu, 30 Oct 2025 16:53:25 +0100 Subject: [PATCH 4/5] Guard WebPubSettings Filter settings assignment on displayTransformability --- navigator/src/webpub/WebPubNavigator.ts | 12 +- .../src/webpub/preferences/WebPubSettings.ts | 116 +++++++++--------- 2 files changed, 68 insertions(+), 60 deletions(-) diff --git a/navigator/src/webpub/WebPubNavigator.ts b/navigator/src/webpub/WebPubNavigator.ts index bb4905da..aaddd62f 100644 --- a/navigator/src/webpub/WebPubNavigator.ts +++ b/navigator/src/webpub/WebPubNavigator.ts @@ -1,4 +1,4 @@ -import { Link, Locator, Publication, ReadingProgression, LocatorLocations } from "@readium/shared"; +import { Feature, Link, Locator, Publication, ReadingProgression, LocatorLocations } from "@readium/shared"; import { VisualNavigator, VisualNavigatorViewport, ProgressionRange } from "../Navigator"; import { Configurable } from "../preferences/Configurable"; import { WebPubFramePoolManager } from "./WebPubFramePoolManager"; @@ -72,7 +72,7 @@ export class WebPubNavigator extends VisualNavigator implements Configurable f.value === Feature.DISPLAY_TRANSFORMABILITY.value + ) ?? false; + } + public eventListener(key: CommsEventKey | ManagerEventKey, data: unknown) { switch (key) { case "_pong": diff --git a/navigator/src/webpub/preferences/WebPubSettings.ts b/navigator/src/webpub/preferences/WebPubSettings.ts index fcde8db1..ad9b598f 100644 --- a/navigator/src/webpub/preferences/WebPubSettings.ts +++ b/navigator/src/webpub/preferences/WebPubSettings.ts @@ -20,65 +20,67 @@ export interface IWebPubSettings { } export class WebPubSettings implements ConfigurableSettings { - fontFamily: string | null; - fontWeight: number | null; - hyphens: boolean | null; - letterSpacing: number | null; - ligatures: boolean | null; - lineHeight: number | null; - noRuby: boolean | null; - paragraphIndent: number | null; - paragraphSpacing: number | null; - textAlign: TextAlignment | null; - textNormalization: boolean | null; - wordSpacing: number | null; + fontFamily: string | null = null; + fontWeight: number | null = null; + hyphens: boolean | null = null; + letterSpacing: number | null = null; + ligatures: boolean | null = null; + lineHeight: number | null = null; + noRuby: boolean | null = null; + paragraphIndent: number | null = null; + paragraphSpacing: number | null = null; + textAlign: TextAlignment | null = null; + textNormalization: boolean | null = null; + wordSpacing: number | null = null; zoom: number | null; - constructor(preferences: WebPubPreferences, defaults: WebPubDefaults) { - this.fontFamily = preferences.fontFamily || defaults.fontFamily || null; - this.fontWeight = preferences.fontWeight !== undefined - ? preferences.fontWeight - : defaults.fontWeight !== undefined - ? defaults.fontWeight - : null; - this.hyphens = typeof preferences.hyphens === "boolean" - ? preferences.hyphens - : defaults.hyphens ?? null; - this.letterSpacing = preferences.letterSpacing !== undefined - ? preferences.letterSpacing - : defaults.letterSpacing !== undefined - ? defaults.letterSpacing - : null; - this.ligatures = typeof preferences.ligatures === "boolean" - ? preferences.ligatures - : defaults.ligatures ?? null; - this.lineHeight = preferences.lineHeight !== undefined - ? preferences.lineHeight - : defaults.lineHeight !== undefined - ? defaults.lineHeight - : null; - this.noRuby = typeof preferences.noRuby === "boolean" - ? preferences.noRuby - : defaults.noRuby ?? null; - this.paragraphIndent = preferences.paragraphIndent !== undefined - ? preferences.paragraphIndent - : defaults.paragraphIndent !== undefined - ? defaults.paragraphIndent - : null; - this.paragraphSpacing = preferences.paragraphSpacing !== undefined - ? preferences.paragraphSpacing - : defaults.paragraphSpacing !== undefined - ? defaults.paragraphSpacing - : null; - this.textAlign = preferences.textAlign || defaults.textAlign || null; - this.textNormalization = typeof preferences.textNormalization === "boolean" - ? preferences.textNormalization - : defaults.textNormalization ?? null; - this.wordSpacing = preferences.wordSpacing !== undefined - ? preferences.wordSpacing - : defaults.wordSpacing !== undefined - ? defaults.wordSpacing - : null; + constructor(preferences: WebPubPreferences, defaults: WebPubDefaults, hasDisplayTransformability: boolean) { + if (hasDisplayTransformability) { + this.fontFamily = preferences.fontFamily || defaults.fontFamily || null; + this.fontWeight = preferences.fontWeight !== undefined + ? preferences.fontWeight + : defaults.fontWeight !== undefined + ? defaults.fontWeight + : null; + this.hyphens = typeof preferences.hyphens === "boolean" + ? preferences.hyphens + : defaults.hyphens ?? null; + this.letterSpacing = preferences.letterSpacing !== undefined + ? preferences.letterSpacing + : defaults.letterSpacing !== undefined + ? defaults.letterSpacing + : null; + this.ligatures = typeof preferences.ligatures === "boolean" + ? preferences.ligatures + : defaults.ligatures ?? null; + this.lineHeight = preferences.lineHeight !== undefined + ? preferences.lineHeight + : defaults.lineHeight !== undefined + ? defaults.lineHeight + : null; + this.noRuby = typeof preferences.noRuby === "boolean" + ? preferences.noRuby + : defaults.noRuby ?? null; + this.paragraphIndent = preferences.paragraphIndent !== undefined + ? preferences.paragraphIndent + : defaults.paragraphIndent !== undefined + ? defaults.paragraphIndent + : null; + this.paragraphSpacing = preferences.paragraphSpacing !== undefined + ? preferences.paragraphSpacing + : defaults.paragraphSpacing !== undefined + ? defaults.paragraphSpacing + : null; + this.textAlign = preferences.textAlign || defaults.textAlign || null; + this.textNormalization = typeof preferences.textNormalization === "boolean" + ? preferences.textNormalization + : defaults.textNormalization ?? null; + this.wordSpacing = preferences.wordSpacing !== undefined + ? preferences.wordSpacing + : defaults.wordSpacing !== undefined + ? defaults.wordSpacing + : null; + } this.zoom = preferences.zoom !== undefined ? preferences.zoom : defaults.zoom !== undefined From ce13cf15b295c19303cdc29f1a0461bc90a0ffc0 Mon Sep 17 00:00:00 2001 From: Jiminy Panoz Date: Thu, 30 Oct 2025 17:03:56 +0100 Subject: [PATCH 5/5] Update changelog --- navigator/CHANGELOG.MD | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/navigator/CHANGELOG.MD b/navigator/CHANGELOG.MD index 7fffe02f..b53fadf4 100644 --- a/navigator/CHANGELOG.MD +++ b/navigator/CHANGELOG.MD @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2.2.2] - 2025-10-30 +### Added + +- Guard `WebPubSettings` assignment on `displayTransformability` + ### Fixed - Corrects `isEffective` check in `WebPubPreferencesEditor`