@readium/navigator 2.0.0 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",
@@ -31,9 +31,9 @@
31
31
  "types": "./types/src/index.d.ts",
32
32
  "exports": {
33
33
  ".": {
34
+ "types": "./types/src/index.d.ts",
34
35
  "import": "./dist/index.js",
35
- "require": "./dist/index.umd.cjs",
36
- "types": "./types/src/index.d.ts"
36
+ "require": "./dist/index.umd.cjs"
37
37
  }
38
38
  },
39
39
  "files": [
@@ -48,17 +48,17 @@
48
48
  "build": "tsc && vite build"
49
49
  },
50
50
  "devDependencies": {
51
- "@laynezh/vite-plugin-lib-assets": "^0.5.25",
52
- "@readium/css": ">=2.0.0-beta.18",
51
+ "@laynezh/vite-plugin-lib-assets": "^2.1.0",
52
+ "@readium/css": "2.0.0-beta.19",
53
53
  "@readium/navigator-html-injectables": "workspace:*",
54
54
  "@readium/shared": "workspace:*",
55
55
  "@types/path-browserify": "^1.0.3",
56
56
  "css-selector-generator": "^3.6.9",
57
57
  "path-browserify": "^1.0.1",
58
58
  "tslib": "^2.8.1",
59
- "typescript": "^5.6.3",
60
- "typescript-plugin-css-modules": "^5.1.0",
59
+ "typescript": "^5.9.2",
60
+ "typescript-plugin-css-modules": "^5.2.0",
61
61
  "user-agent-data-types": "^0.4.2",
62
- "vite": "^4.5.5"
62
+ "vite": "^7.1.5"
63
63
  }
64
64
  }
@@ -1,4 +1,4 @@
1
- import { TextAlignment, Theme } from "../../preferences/Types";
1
+ import { TextAlignment } from "../../preferences/Types";
2
2
 
3
3
  export type BodyHyphens = "auto" | "none";
4
4
  export type BoxSizing = "content-box" | "border-box";
@@ -51,7 +51,6 @@ abstract class Properties {
51
51
  export interface IUserProperties {
52
52
  advancedSettings?: boolean | null;
53
53
  a11yNormalize?: boolean | null;
54
- appearance?: Theme | null;
55
54
  backgroundColor?: string | null;
56
55
  blendFilter?: boolean | null;
57
56
  bodyHyphens?: BodyHyphens | null;
@@ -87,7 +86,6 @@ export interface IUserProperties {
87
86
 
88
87
  export class UserProperties extends Properties {
89
88
  a11yNormalize: boolean | null;
90
- appearance: Theme | null;
91
89
  backgroundColor: string | null;
92
90
  blendFilter: boolean | null;
93
91
  bodyHyphens: BodyHyphens | null;
@@ -123,7 +121,6 @@ export class UserProperties extends Properties {
123
121
  constructor(props: IUserProperties) {
124
122
  super();
125
123
  this.a11yNormalize = props.a11yNormalize ?? null;
126
- this.appearance = props.appearance ?? null;
127
124
  this.backgroundColor = props.backgroundColor ?? null;
128
125
  this.blendFilter = props.blendFilter ?? null;
129
126
  this.bodyHyphens = props.bodyHyphens ?? null;
@@ -161,7 +158,6 @@ export class UserProperties extends Properties {
161
158
  const cssProperties: { [key: string]: string } = {};
162
159
 
163
160
  if (this.a11yNormalize) cssProperties["--USER__a11yNormalize"] = this.toFlag("a11y");
164
- if (this.appearance) cssProperties["--USER__appearance"] = this.toFlag(this.appearance);
165
161
  if (this.backgroundColor) cssProperties["--USER__backgroundColor"] = this.backgroundColor;
166
162
  if (this.blendFilter) cssProperties["--USER__blendFilter"] = this.toFlag("blend");
167
163
  if (this.bodyHyphens) cssProperties["--USER__bodyHyphens"] = this.bodyHyphens;
@@ -73,7 +73,6 @@ export class ReadiumCSS {
73
73
 
74
74
  const updated: IUserProperties = {
75
75
  a11yNormalize: settings.textNormalization,
76
- appearance: settings.theme,
77
76
  backgroundColor: settings.backgroundColor,
78
77
  blendFilter: settings.blendFilter,
79
78
  bodyHyphens: typeof settings.hyphens !== "boolean"
@@ -161,12 +160,17 @@ export class ReadiumCSS {
161
160
  // TODO: As scroll shows, the effective line-length
162
161
  // should be the same as uncompensated when scale >= 1
163
162
  private paginate(scale: number | null, ignoreCompensation: boolean | null, colCount?: number | null) {
164
- const constrainedWidth = Math.round(getContentWidth(this.containerParent) - (this.constraint));
163
+ const constrainedWidth = Math.round(getContentWidth(this.containerParent) - this.constraint);
165
164
  const metrics = this.getCompensatedMetrics(scale, ignoreCompensation);
166
- const zoomCompensation = metrics.zoomCompensation;
167
- const optimal = metrics.optimal;
168
- const minimal = metrics.minimal;
169
- const maximal = metrics.maximal;
165
+ const { zoomCompensation, optimal, minimal, maximal } = metrics;
166
+
167
+ // Helper function for single column width calculation
168
+ const getSingleColWidth = (): number => {
169
+ if (constrainedWidth >= optimal && maximal !== null) {
170
+ return Math.min(Math.round(maximal * zoomCompensation), constrainedWidth);
171
+ }
172
+ return constrainedWidth;
173
+ };
170
174
 
171
175
  let RCSSColCount = 1;
172
176
  let effectiveContainerWidth = constrainedWidth;
@@ -180,13 +184,12 @@ export class ReadiumCSS {
180
184
  }
181
185
 
182
186
  if (colCount === null) {
183
- if (constrainedWidth < optimal || maximal === null) {
184
- RCSSColCount = 1;
185
- effectiveContainerWidth = constrainedWidth;
186
- } else {
187
+ if (constrainedWidth >= optimal && maximal !== null) {
187
188
  RCSSColCount = Math.floor(constrainedWidth / optimal);
188
189
  const requiredWidth = Math.round(RCSSColCount * (maximal * zoomCompensation));
189
190
  effectiveContainerWidth = Math.min(requiredWidth, constrainedWidth);
191
+ } else {
192
+ effectiveContainerWidth = getSingleColWidth();
190
193
  }
191
194
  } else if (colCount > 1) {
192
195
  const minRequiredWidth = Math.round(colCount * (minimal !== null ? minimal : optimal));
@@ -202,25 +205,22 @@ export class ReadiumCSS {
202
205
  } else {
203
206
  if (minimal !== null && constrainedWidth < Math.round(colCount * minimal)) {
204
207
  RCSSColCount = Math.floor(constrainedWidth / minimal);
208
+ if (RCSSColCount <= 1) {
209
+ RCSSColCount = 1;
210
+ effectiveContainerWidth = getSingleColWidth();
211
+ } else {
212
+ const requiredWidth = Math.round(RCSSColCount * (optimal * zoomCompensation));
213
+ effectiveContainerWidth = Math.min(requiredWidth, constrainedWidth);
214
+ }
205
215
  } else {
206
216
  RCSSColCount = colCount;
217
+ const requiredWidth = Math.round(RCSSColCount * (optimal * zoomCompensation));
218
+ effectiveContainerWidth = Math.min(requiredWidth, constrainedWidth);
207
219
  }
208
- const requiredWidth = Math.round((RCSSColCount * (optimal * zoomCompensation)));
209
- effectiveContainerWidth = Math.min(requiredWidth, constrainedWidth);
210
220
  }
211
221
  } else {
212
222
  RCSSColCount = 1;
213
-
214
- if (constrainedWidth >= optimal) {
215
- if (maximal === null) {
216
- effectiveContainerWidth = constrainedWidth
217
- } else {
218
- const requiredWidth = Math.round(maximal * zoomCompensation);
219
- effectiveContainerWidth = Math.min(requiredWidth, constrainedWidth);
220
- }
221
- } else {
222
- effectiveContainerWidth = constrainedWidth
223
- }
223
+ effectiveContainerWidth = getSingleColWidth();
224
224
  }
225
225
 
226
226
  return {
@@ -2,8 +2,7 @@ import {
2
2
  fontSizeRangeConfig,
3
3
  fontWeightRangeConfig,
4
4
  fontWidthRangeConfig,
5
- TextAlignment,
6
- Theme
5
+ TextAlignment
7
6
  } from "../../preferences/Types";
8
7
 
9
8
  import {
@@ -59,7 +58,6 @@ export interface IEpubDefaults {
59
58
  textAlign?: TextAlignment | null,
60
59
  textColor?: string | null,
61
60
  textNormalization?: boolean | null,
62
- theme?: Theme | null,
63
61
  visitedColor?: string | null,
64
62
  wordSpacing?: number | null
65
63
  }
@@ -103,7 +101,6 @@ export class EpubDefaults {
103
101
  textAlign: TextAlignment | null;
104
102
  textColor: string | null;
105
103
  textNormalization: boolean | null;
106
- theme: Theme | null;
107
104
  visitedColor: string | null;
108
105
  wordSpacing: number | null;
109
106
 
@@ -150,7 +147,6 @@ export class EpubDefaults {
150
147
  this.textAlign = ensureEnumValue<TextAlignment>(defaults.textAlign, TextAlignment) || null;
151
148
  this.textColor = ensureString(defaults.textColor) || null;
152
149
  this.textNormalization = ensureBoolean(defaults.textNormalization) ?? false;
153
- this.theme = ensureEnumValue<Theme>(defaults.theme, Theme) || null;
154
150
  this.visitedColor = ensureString(defaults.visitedColor) || null;
155
151
  this.wordSpacing = ensureNonNegative(defaults.wordSpacing) || null;
156
152
 
@@ -2,7 +2,6 @@ import { ConfigurablePreferences } from "../../preferences/Configurable";
2
2
 
3
3
  import {
4
4
  TextAlignment,
5
- Theme,
6
5
  fontSizeRangeConfig,
7
6
  fontWeightRangeConfig,
8
7
  fontWidthRangeConfig
@@ -56,7 +55,6 @@ export interface IEpubPreferences {
56
55
  textAlign?: TextAlignment | null,
57
56
  textColor?: string | null,
58
57
  textNormalization?: boolean | null,
59
- theme?: Theme | null,
60
58
  visitedColor?: string | null,
61
59
  wordSpacing?: number | null
62
60
  }
@@ -100,7 +98,6 @@ export class EpubPreferences implements ConfigurablePreferences {
100
98
  textAlign?: TextAlignment | null;
101
99
  textColor?: string | null;
102
100
  textNormalization?: boolean | null;
103
- theme?: Theme | null;
104
101
  visitedColor?: string | null;
105
102
  wordSpacing?: number | null;
106
103
 
@@ -140,7 +137,6 @@ export class EpubPreferences implements ConfigurablePreferences {
140
137
  this.textAlign = ensureEnumValue<TextAlignment>(preferences.textAlign, TextAlignment);
141
138
  this.textColor = ensureString(preferences.textColor);
142
139
  this.textNormalization = ensureBoolean(preferences.textNormalization);
143
- this.theme = ensureEnumValue<Theme>(preferences.theme, Theme);
144
140
  this.visitedColor = ensureString(preferences.visitedColor);
145
141
  this.wordSpacing = ensureNonNegative(preferences.wordSpacing);
146
142
 
@@ -5,13 +5,12 @@ import { EpubSettings } from "./EpubSettings";
5
5
  import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference";
6
6
  import {
7
7
  TextAlignment,
8
- Theme,
9
8
  fontSizeRangeConfig,
10
9
  fontWeightRangeConfig,
11
10
  fontWidthRangeConfig
12
11
  } from "../../preferences/Types";
13
12
 
14
- import defaultColors from "@readium/css/css/vars/day.json";
13
+ import defaultColors from "@readium/css/css/vars/colors.json";
15
14
 
16
15
  // WIP: will change cos’ of all the missing pieces
17
16
  export class EpubPreferencesEditor implements IPreferencesEditor {
@@ -483,18 +482,6 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
483
482
  });
484
483
  }
485
484
 
486
- get theme(): EnumPreference<Theme> {
487
- return new EnumPreference<Theme>({
488
- initialValue: this.preferences.theme,
489
- effectiveValue: this.settings.theme || null,
490
- isEffective: this.layout !== Layout.fixed,
491
- onChange: (newValue: Theme | null | undefined) => {
492
- this.updatePreference("theme", newValue || null);
493
- },
494
- supportedValues: Object.values(Theme)
495
- });
496
- }
497
-
498
485
  get visitedColor(): Preference<string> {
499
486
  return new Preference<string>({
500
487
  initialValue: this.preferences.visitedColor,
@@ -1,5 +1,5 @@
1
1
  import { ConfigurableSettings } from "../../preferences/Configurable";
2
- import { TextAlignment, Theme } from "../../preferences/Types";
2
+ import { TextAlignment } from "../../preferences/Types";
3
3
  import { EpubDefaults } from "./EpubDefaults";
4
4
  import { EpubPreferences } from "./EpubPreferences";
5
5
 
@@ -44,7 +44,6 @@ export interface IEpubSettings {
44
44
  textAlign?: TextAlignment | null,
45
45
  textColor?: string | null,
46
46
  textNormalization?: boolean | null,
47
- theme?: Theme | null,
48
47
  visitedColor?: string | null,
49
48
  wordSpacing?: number | null
50
49
  }
@@ -88,7 +87,6 @@ export class EpubSettings implements ConfigurableSettings {
88
87
  textAlign: TextAlignment | null;
89
88
  textColor: string | null;
90
89
  textNormalization: boolean | null;
91
- theme: Theme | null;
92
90
  visitedColor: string | null;
93
91
  wordSpacing: number | null;
94
92
 
@@ -225,7 +223,6 @@ export class EpubSettings implements ConfigurableSettings {
225
223
  this.textNormalization = typeof preferences.textNormalization === "boolean"
226
224
  ? preferences.textNormalization
227
225
  : defaults.textNormalization ?? null;
228
- this.theme = preferences.theme || defaults.theme || null;
229
226
  this.visitedColor = preferences.visitedColor || defaults.visitedColor || null;
230
227
  this.wordSpacing = preferences.wordSpacing !== undefined
231
228
  ? preferences.wordSpacing
@@ -5,12 +5,6 @@ export enum TextAlignment {
5
5
  justify = "justify"
6
6
  };
7
7
 
8
- export enum Theme {
9
- sepia = "sepia",
10
- night = "night",
11
- custom = "custom"
12
- }
13
-
14
8
  export type RangeConfig = {
15
9
  range: [number, number],
16
10
  step: number
@@ -1,4 +1,4 @@
1
- import { TextAlignment, Theme } from "../../preferences/Types";
1
+ import { TextAlignment } from "../../preferences/Types";
2
2
  export type BodyHyphens = "auto" | "none";
3
3
  export type BoxSizing = "content-box" | "border-box";
4
4
  export type FontOpticalSizing = "auto" | "none";
@@ -22,7 +22,6 @@ declare abstract class Properties {
22
22
  export interface IUserProperties {
23
23
  advancedSettings?: boolean | null;
24
24
  a11yNormalize?: boolean | null;
25
- appearance?: Theme | null;
26
25
  backgroundColor?: string | null;
27
26
  blendFilter?: boolean | null;
28
27
  bodyHyphens?: BodyHyphens | null;
@@ -57,7 +56,6 @@ export interface IUserProperties {
57
56
  }
58
57
  export declare class UserProperties extends Properties {
59
58
  a11yNormalize: boolean | null;
60
- appearance: Theme | null;
61
59
  backgroundColor: string | null;
62
60
  blendFilter: boolean | null;
63
61
  bodyHyphens: BodyHyphens | null;
@@ -1,4 +1,4 @@
1
- import { TextAlignment, Theme } from "../../preferences/Types";
1
+ import { TextAlignment } from "../../preferences/Types";
2
2
  export interface IEpubDefaults {
3
3
  backgroundColor?: string | null;
4
4
  blendFilter?: boolean | null;
@@ -36,7 +36,6 @@ export interface IEpubDefaults {
36
36
  textAlign?: TextAlignment | null;
37
37
  textColor?: string | null;
38
38
  textNormalization?: boolean | null;
39
- theme?: Theme | null;
40
39
  visitedColor?: string | null;
41
40
  wordSpacing?: number | null;
42
41
  }
@@ -77,7 +76,6 @@ export declare class EpubDefaults {
77
76
  textAlign: TextAlignment | null;
78
77
  textColor: string | null;
79
78
  textNormalization: boolean | null;
80
- theme: Theme | null;
81
79
  visitedColor: string | null;
82
80
  wordSpacing: number | null;
83
81
  constructor(defaults: IEpubDefaults);
@@ -1,5 +1,5 @@
1
1
  import { ConfigurablePreferences } from "../../preferences/Configurable";
2
- import { TextAlignment, Theme } from "../../preferences/Types";
2
+ import { TextAlignment } from "../../preferences/Types";
3
3
  export interface IEpubPreferences {
4
4
  backgroundColor?: string | null;
5
5
  blendFilter?: boolean | null;
@@ -37,7 +37,6 @@ export interface IEpubPreferences {
37
37
  textAlign?: TextAlignment | null;
38
38
  textColor?: string | null;
39
39
  textNormalization?: boolean | null;
40
- theme?: Theme | null;
41
40
  visitedColor?: string | null;
42
41
  wordSpacing?: number | null;
43
42
  }
@@ -78,7 +77,6 @@ export declare class EpubPreferences implements ConfigurablePreferences {
78
77
  textAlign?: TextAlignment | null;
79
78
  textColor?: string | null;
80
79
  textNormalization?: boolean | null;
81
- theme?: Theme | null;
82
80
  visitedColor?: string | null;
83
81
  wordSpacing?: number | null;
84
82
  constructor(preferences?: IEpubPreferences);
@@ -3,7 +3,7 @@ import { IPreferencesEditor } from "../../preferences/PreferencesEditor";
3
3
  import { EpubPreferences } from "./EpubPreferences";
4
4
  import { EpubSettings } from "./EpubSettings";
5
5
  import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference";
6
- import { TextAlignment, Theme } from "../../preferences/Types";
6
+ import { TextAlignment } from "../../preferences/Types";
7
7
  export declare class EpubPreferencesEditor implements IPreferencesEditor {
8
8
  preferences: EpubPreferences;
9
9
  private settings;
@@ -48,7 +48,6 @@ export declare class EpubPreferencesEditor implements IPreferencesEditor {
48
48
  get textAlign(): EnumPreference<TextAlignment>;
49
49
  get textColor(): Preference<string>;
50
50
  get textNormalization(): BooleanPreference;
51
- get theme(): EnumPreference<Theme>;
52
51
  get visitedColor(): Preference<string>;
53
52
  get wordSpacing(): RangePreference<number>;
54
53
  }
@@ -1,5 +1,5 @@
1
1
  import { ConfigurableSettings } from "../../preferences/Configurable";
2
- import { TextAlignment, Theme } from "../../preferences/Types";
2
+ import { TextAlignment } from "../../preferences/Types";
3
3
  import { EpubDefaults } from "./EpubDefaults";
4
4
  import { EpubPreferences } from "./EpubPreferences";
5
5
  export interface IEpubSettings {
@@ -39,7 +39,6 @@ export interface IEpubSettings {
39
39
  textAlign?: TextAlignment | null;
40
40
  textColor?: string | null;
41
41
  textNormalization?: boolean | null;
42
- theme?: Theme | null;
43
42
  visitedColor?: string | null;
44
43
  wordSpacing?: number | null;
45
44
  }
@@ -80,7 +79,6 @@ export declare class EpubSettings implements ConfigurableSettings {
80
79
  textAlign: TextAlignment | null;
81
80
  textColor: string | null;
82
81
  textNormalization: boolean | null;
83
- theme: Theme | null;
84
82
  visitedColor: string | null;
85
83
  wordSpacing: number | null;
86
84
  constructor(preferences: EpubPreferences, defaults: EpubDefaults);
@@ -4,11 +4,6 @@ export declare enum TextAlignment {
4
4
  right = "right",
5
5
  justify = "justify"
6
6
  }
7
- export declare enum Theme {
8
- sepia = "sepia",
9
- night = "night",
10
- custom = "custom"
11
- }
12
7
  export type RangeConfig = {
13
8
  range: [number, number];
14
9
  step: number;