@readium/navigator 2.0.0-beta.4 → 2.0.0-beta.6

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-beta.4",
3
+ "version": "2.0.0-beta.6",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "@laynezh/vite-plugin-lib-assets": "^0.5.25",
52
- "@readium/css": ">=2.0.0-beta.13",
52
+ "@readium/css": ">=2.0.0-beta.14",
53
53
  "@readium/navigator-html-injectables": "workspace:*",
54
54
  "@readium/shared": "workspace:*",
55
55
  "@types/path-browserify": "^1.0.3",
@@ -58,6 +58,7 @@
58
58
  "tslib": "^2.8.1",
59
59
  "typescript": "^5.6.3",
60
60
  "typescript-plugin-css-modules": "^5.1.0",
61
+ "user-agent-data-types": "^0.4.2",
61
62
  "vite": "^4.5.5"
62
63
  }
63
64
  }
@@ -60,7 +60,6 @@ export interface IUserProperties {
60
60
  deprecatedFontSize?: boolean | null;
61
61
  fontFamily?: string | null;
62
62
  fontOpticalSizing?: FontOpticalSizing | null;
63
- fontOverride?: boolean | null;
64
63
  fontSize?: number | null;
65
64
  fontSizeNormalize?: boolean | null;
66
65
  fontWeight?: number | null;
@@ -96,7 +95,6 @@ export class UserProperties extends Properties {
96
95
  deprecatedFontSize: boolean | null;
97
96
  fontFamily: string | null;
98
97
  fontOpticalSizing: FontOpticalSizing | null;
99
- fontOverride: boolean | null;
100
98
  fontSize: number | null;
101
99
  fontSizeNormalize: boolean | null;
102
100
  fontWeight: number | null;
@@ -132,7 +130,6 @@ export class UserProperties extends Properties {
132
130
  this.deprecatedFontSize = props.deprecatedFontSize ?? null;
133
131
  this.fontFamily = props.fontFamily ?? null;
134
132
  this.fontOpticalSizing = props.fontOpticalSizing ?? null;
135
- this.fontOverride = props.fontOverride ?? null;
136
133
  this.fontSize = props.fontSize ?? null;
137
134
  this.fontSizeNormalize = props.fontSizeNormalize ?? null;
138
135
  this.fontWeight = props.fontWeight ?? null;
@@ -174,7 +171,6 @@ export class UserProperties extends Properties {
174
171
  if (this.deprecatedFontSize) cssProperties["--USER__fontSizeImplementation"] = this.toFlag("deprecatedFontSize");
175
172
  if (this.fontFamily) cssProperties["--USER__fontFamily"] = this.fontFamily;
176
173
  if (this.fontOpticalSizing != null) cssProperties["--USER__fontOpticalSizing"] = this.fontOpticalSizing;
177
- if (this.fontOverride) cssProperties["--USER__fontOverride"] = this.toFlag("font");
178
174
  if (this.fontSize != null) cssProperties["--USER__fontSize"] = this.toPercentage(this.fontSize, true);
179
175
  if (this.fontSizeNormalize) cssProperties["--USER__fontSizeNormalize"] = this.toFlag("normalize");
180
176
  if (this.fontWeight != null) cssProperties["--USER__fontWeight"] = this.toUnitless(this.fontWeight);
@@ -234,6 +230,7 @@ export interface IRSProperties {
234
230
  maxMediaHeight?: number | null;
235
231
  modernTf?: string | null;
236
232
  monospaceTf?: string | null;
233
+ noOverflow?: boolean | null;
237
234
  noVerticalPagination?: boolean | null;
238
235
  oldStyleTf?: string | null;
239
236
  pageGutter?: number | null;
@@ -273,6 +270,7 @@ export class RSProperties extends Properties {
273
270
  maxMediaHeight: number | null;
274
271
  modernTf: string | null;
275
272
  monospaceTf: string | null;
273
+ noOverflow: boolean | null;
276
274
  noVerticalPagination: boolean | null;
277
275
  oldStyleTf: string | null;
278
276
  pageGutter: number | null;
@@ -312,6 +310,7 @@ export class RSProperties extends Properties {
312
310
  this.maxMediaHeight = props.maxMediaHeight ?? null;
313
311
  this.modernTf = props.modernTf ?? null;
314
312
  this.monospaceTf = props.monospaceTf ?? null;
313
+ this.noOverflow = props.noOverflow ?? null;
315
314
  this.noVerticalPagination = props.noVerticalPagination ?? null;
316
315
  this.oldStyleTf = props.oldStyleTf ?? null;
317
316
  this.pageGutter = props.pageGutter ?? null;
@@ -353,6 +352,7 @@ export class RSProperties extends Properties {
353
352
  if (this.maxMediaHeight) cssProperties["--RS__maxMediaHeight"] = this.toVh(this.maxMediaHeight);
354
353
  if (this.modernTf) cssProperties["--RS__modernTf"] = this.modernTf;
355
354
  if (this.monospaceTf) cssProperties["--RS__monospaceTf"] = this.monospaceTf;
355
+ if (this.noOverflow) cssProperties["--RS__disableOverflow"] = this.toFlag("noOverflow");
356
356
  if (this.noVerticalPagination) cssProperties["--RS__disablePagination"] = this.toFlag("noVerticalPagination");
357
357
  if (this.oldStyleTf) cssProperties["--RS__oldStyleTf"] = this.oldStyleTf;
358
358
  if (this.pageGutter != null) cssProperties["--RS__pageGutter"] = this.toPx(this.pageGutter);
@@ -85,12 +85,6 @@ export class ReadiumCSS {
85
85
  : settings.fontOpticalSizing
86
86
  ? "auto"
87
87
  : "none",
88
- fontOverride: settings.fontOverride !== null
89
- ? settings.fontOverride
90
- : (settings.textNormalization || settings.fontFamily
91
- ? true
92
- : false
93
- ),
94
88
  fontSize: settings.fontSize,
95
89
  fontSizeNormalize: settings.fontSizeNormalize,
96
90
  fontWeight: settings.fontWeight,
@@ -32,7 +32,6 @@ export interface IEpubDefaults {
32
32
  fontSize?: number | null,
33
33
  fontSizeNormalize?: boolean | null,
34
34
  fontOpticalSizing?: boolean | null,
35
- fontOverride?: boolean | null,
36
35
  fontWeight?: number | null,
37
36
  fontWidth?: number | null,
38
37
  hyphens?: boolean | null,
@@ -73,7 +72,6 @@ export class EpubDefaults {
73
72
  fontSize: number | null;
74
73
  fontSizeNormalize: boolean | null;
75
74
  fontOpticalSizing: boolean | null;
76
- fontOverride: boolean | null;
77
75
  fontWeight: number | null;
78
76
  fontWidth: number | null;
79
77
  hyphens: boolean | null;
@@ -116,7 +114,6 @@ export class EpubDefaults {
116
114
  this.fontSize = ensureValueInRange(defaults.fontSize, fontSizeRangeConfig.range) || 1;
117
115
  this.fontSizeNormalize = ensureBoolean(defaults.fontSizeNormalize) ?? false;
118
116
  this.fontOpticalSizing = ensureBoolean(defaults.fontOpticalSizing) ?? null;
119
- this.fontOverride = ensureBoolean(defaults.fontOverride) ?? null;
120
117
  this.fontWeight = ensureValueInRange(defaults.fontWeight, fontWeightRangeConfig.range) || null;
121
118
  this.fontWidth = ensureValueInRange(defaults.fontWidth,fontWidthRangeConfig.range) || null;
122
119
  this.hyphens = ensureBoolean(defaults.hyphens) ?? null;
@@ -29,7 +29,6 @@ export interface IEpubPreferences {
29
29
  fontSize?: number | null,
30
30
  fontSizeNormalize?: boolean | null,
31
31
  fontOpticalSizing?: boolean | null,
32
- fontOverride?: boolean | null,
33
32
  fontWeight?: number | null,
34
33
  fontWidth?: number | null,
35
34
  hyphens?: boolean | null,
@@ -70,7 +69,6 @@ export class EpubPreferences implements ConfigurablePreferences {
70
69
  fontSize?: number | null;
71
70
  fontSizeNormalize?: boolean | null;
72
71
  fontOpticalSizing?: boolean | null;
73
- fontOverride?: boolean | null;
74
72
  fontWeight?: number | null;
75
73
  fontWidth?: number | null;
76
74
  hyphens?: boolean | null;
@@ -110,7 +108,6 @@ export class EpubPreferences implements ConfigurablePreferences {
110
108
  this.fontSize = ensureValueInRange(preferences.fontSize, fontSizeRangeConfig.range);
111
109
  this.fontSizeNormalize = ensureBoolean(preferences.fontSizeNormalize);
112
110
  this.fontOpticalSizing = ensureBoolean(preferences.fontOpticalSizing);
113
- this.fontOverride = ensureBoolean(preferences.fontOverride);
114
111
  this.fontWeight = ensureValueInRange(preferences.fontWeight, fontWeightRangeConfig.range);
115
112
  this.fontWidth = ensureValueInRange(preferences.fontWidth,fontWidthRangeConfig.range);
116
113
  this.hyphens = ensureBoolean(preferences.hyphens);
@@ -12,7 +12,7 @@ import {
12
12
  fontWidthRangeConfig
13
13
  } from "../../preferences/Types";
14
14
 
15
- import dayMode from "@readium/css/css/vars/day.json";
15
+ import defaultColors from "@readium/css/css/vars/day.json";
16
16
 
17
17
  // WIP: will change cos’ of all the missing pieces
18
18
  export class EpubPreferencesEditor implements IPreferencesEditor {
@@ -39,7 +39,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
39
39
  get backgroundColor(): Preference<string> {
40
40
  return new Preference<string>({
41
41
  initialValue: this.preferences.backgroundColor,
42
- effectiveValue: this.settings.backgroundColor || dayMode.RS__backgroundColor,
42
+ effectiveValue: this.settings.backgroundColor || defaultColors.RS__backgroundColor,
43
43
  isEffective: this.preferences.backgroundColor !== null,
44
44
  onChange: (newValue: string | null | undefined) => {
45
45
  this.updatePreference("backgroundColor", newValue || null);
@@ -149,17 +149,6 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
149
149
  });
150
150
  }
151
151
 
152
- get fontOverride(): BooleanPreference {
153
- return new BooleanPreference({
154
- initialValue: this.preferences.fontOverride,
155
- effectiveValue: this.settings.fontOverride || false,
156
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.fontOverride !== null,
157
- onChange: (newValue: boolean | null | undefined) => {
158
- this.updatePreference("fontOverride", newValue || null);
159
- }
160
- });
161
- }
162
-
163
152
  get fontWeight(): RangePreference<number> {
164
153
  return new RangePreference<number>({
165
154
  initialValue: this.preferences.fontWeight,
@@ -288,7 +277,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
288
277
  get linkColor(): Preference<string> {
289
278
  return new Preference<string>({
290
279
  initialValue: this.preferences.linkColor,
291
- effectiveValue: this.settings.linkColor || dayMode.RS__linkColor,
280
+ effectiveValue: this.settings.linkColor || defaultColors.RS__linkColor,
292
281
  isEffective: this.layout === EPUBLayout.reflowable && this.preferences.linkColor !== null,
293
282
  onChange: (newValue: string | null | undefined) => {
294
283
  this.updatePreference("linkColor", newValue || null);
@@ -397,7 +386,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
397
386
  get selectionBackgroundColor(): Preference<string> {
398
387
  return new Preference<string>({
399
388
  initialValue: this.preferences.selectionBackgroundColor,
400
- effectiveValue: this.settings.selectionBackgroundColor || dayMode.RS__selectionBackgroundColor,
389
+ effectiveValue: this.settings.selectionBackgroundColor || defaultColors.RS__selectionBackgroundColor,
401
390
  isEffective: this.layout === EPUBLayout.reflowable && this.preferences.selectionBackgroundColor !== null,
402
391
  onChange: (newValue: string | null | undefined) => {
403
392
  this.updatePreference("selectionBackgroundColor", newValue || null);
@@ -408,7 +397,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
408
397
  get selectionTextColor(): Preference<string> {
409
398
  return new Preference<string>({
410
399
  initialValue: this.preferences.selectionTextColor,
411
- effectiveValue: this.settings.selectionTextColor || dayMode.RS__selectionTextColor,
400
+ effectiveValue: this.settings.selectionTextColor || defaultColors.RS__selectionTextColor,
412
401
  isEffective: this.layout === EPUBLayout.reflowable && this.preferences.selectionTextColor !== null,
413
402
  onChange: (newValue: string | null | undefined) => {
414
403
  this.updatePreference("selectionTextColor", newValue || null);
@@ -431,7 +420,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
431
420
  get textColor(): Preference<string> {
432
421
  return new Preference<string>({
433
422
  initialValue: this.preferences.textColor,
434
- effectiveValue: this.settings.textColor || dayMode.RS__textColor,
423
+ effectiveValue: this.settings.textColor || defaultColors.RS__textColor,
435
424
  isEffective: this.layout === EPUBLayout.reflowable && this.preferences.textColor !== null,
436
425
  onChange: (newValue: string | null | undefined) => {
437
426
  this.updatePreference("textColor", newValue || null);
@@ -453,7 +442,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
453
442
  get theme(): EnumPreference<Theme> {
454
443
  return new EnumPreference<Theme>({
455
444
  initialValue: this.preferences.theme,
456
- effectiveValue: this.settings.theme || Theme.day,
445
+ effectiveValue: this.settings.theme || null,
457
446
  isEffective: this.layout === EPUBLayout.reflowable,
458
447
  onChange: (newValue: Theme | null | undefined) => {
459
448
  this.updatePreference("theme", newValue || null);
@@ -465,7 +454,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
465
454
  get visitedColor(): Preference<string> {
466
455
  return new Preference<string>({
467
456
  initialValue: this.preferences.visitedColor,
468
- effectiveValue: this.settings.visitedColor || dayMode.RS__visitedColor,
457
+ effectiveValue: this.settings.visitedColor || defaultColors.RS__visitedColor,
469
458
  isEffective: this.layout === EPUBLayout.reflowable && this.preferences.visitedColor !== null,
470
459
  onChange: (newValue: string | null | undefined) => {
471
460
  this.updatePreference("visitedColor", newValue || null);
@@ -16,7 +16,6 @@ export interface IEpubSettings {
16
16
  fontSize?: number | null,
17
17
  fontSizeNormalize?: boolean | null,
18
18
  fontOpticalSizing?: boolean | null,
19
- fontOverride?: boolean | null,
20
19
  fontWeight?: number | null,
21
20
  fontWidth?: number | null,
22
21
  hyphens?: boolean | null,
@@ -57,7 +56,6 @@ export class EpubSettings implements ConfigurableSettings {
57
56
  fontSize: number | null;
58
57
  fontSizeNormalize: boolean | null;
59
58
  fontOpticalSizing: boolean | null;
60
- fontOverride: boolean | null;
61
59
  fontWeight: number | null;
62
60
  fontWidth: number | null;
63
61
  hyphens: boolean | null;
@@ -115,9 +113,6 @@ export class EpubSettings implements ConfigurableSettings {
115
113
  this.fontOpticalSizing = typeof preferences.fontOpticalSizing === "boolean"
116
114
  ? preferences.fontOpticalSizing
117
115
  : defaults.fontOpticalSizing ?? null;
118
- this.fontOverride = typeof preferences.fontOverride === "boolean"
119
- ? preferences.fontOverride
120
- : defaults.fontOverride ?? null;
121
116
  this.fontWeight = preferences.fontWeight !== undefined
122
117
  ? preferences.fontWeight
123
118
  : defaults.fontWeight !== undefined
@@ -8,6 +8,7 @@
8
8
  * Portions of this code come from the sML library
9
9
  * Current version: 1.0.36
10
10
  */
11
+ /// <reference types="user-agent-data-types" />
11
12
 
12
13
  declare interface OSFlags {
13
14
  iOS: number[];
@@ -46,13 +47,17 @@ declare interface UAFlags {
46
47
 
47
48
  declare type iOSRequest = "mobile" | "desktop" | undefined;
48
49
 
50
+ // Fallback when global 'navigator' is not available, such as in SSR environments.
51
+ const userAgent = () => typeof navigator === "undefined" ? "" : (navigator.userAgent || "");
52
+ const userAgentData = () => typeof navigator === "undefined" ? undefined : (navigator.userAgentData || undefined);
53
+
49
54
  class sMLFactory {
50
55
  OS: OSFlags;
51
56
  UA: UAFlags;
52
57
  Env!: string[];
53
58
 
54
59
  constructor() {
55
- const NUAD = (navigator as any).userAgentData, NUA = navigator.userAgent;
60
+ const NUAD = userAgentData(), NUA = userAgent();
56
61
 
57
62
  const _sV = (V?: string | number) => (typeof V === "string" || typeof V === "number") && V ? String(V).replace(/_/g, ".").split(".").map(I => parseInt(I) || 0) : [];
58
63
  const _dV = (Pre="") => {
@@ -84,7 +89,7 @@ class sMLFactory {
84
89
  })({} as OSFlags));
85
90
 
86
91
  this.UA = ((UA: UAFlags) => { let _OK = false;
87
- if(NUAD && Array.isArray(NUAD.brands)) { const BnV = NUAD.brands.reduce((BnV: string[], _: any) => { (BnV[_.brand] as any) = [_.version * 1]; return BnV; }, {});
92
+ if(NUAD && Array.isArray(NUAD.brands)) { const BnV = NUAD.brands.reduce((BnV: Record<string, number[]>, _: NavigatorUABrandVersion) => { BnV[_.brand] = [(_.version as any) * 1]; return BnV; }, {});
88
93
  if(BnV["Google Chrome"]) _OK = true, UA.Blink = UA.Chromium = BnV["Chromium"] || [], UA.Chrome = BnV["Google Chrome"];
89
94
  else if(BnV["Microsoft Edge"]) _OK = true, UA.Blink = UA.Chromium = BnV["Chromium"] || [], UA.Edge = BnV["Microsoft Edge"];
90
95
  else if(BnV["Opera"]) _OK = true, UA.Blink = UA.Chromium = BnV["Chromium"] || [], UA.Opera = BnV["Opera"];
@@ -121,7 +126,7 @@ class sMLFactory {
121
126
 
122
127
  class sMLFactoryWithRequest extends sMLFactory {
123
128
  get iOSRequest(): iOSRequest {
124
- const NUAD = (navigator as any).userAgentData, NUA = navigator.userAgent;
129
+ const NUAD = userAgentData(), NUA = userAgent();
125
130
 
126
131
  if (this.OS.iOS && !this.OS.iPadOS) {
127
132
  return "mobile";
@@ -6,7 +6,6 @@ export enum TextAlignment {
6
6
  };
7
7
 
8
8
  export enum Theme {
9
- day = "day",
10
9
  sepia = "sepia",
11
10
  night = "night",
12
11
  custom = "custom"
@@ -31,7 +31,6 @@ export interface IUserProperties {
31
31
  deprecatedFontSize?: boolean | null;
32
32
  fontFamily?: string | null;
33
33
  fontOpticalSizing?: FontOpticalSizing | null;
34
- fontOverride?: boolean | null;
35
34
  fontSize?: number | null;
36
35
  fontSizeNormalize?: boolean | null;
37
36
  fontWeight?: number | null;
@@ -66,7 +65,6 @@ export declare class UserProperties extends Properties {
66
65
  deprecatedFontSize: boolean | null;
67
66
  fontFamily: string | null;
68
67
  fontOpticalSizing: FontOpticalSizing | null;
69
- fontOverride: boolean | null;
70
68
  fontSize: number | null;
71
69
  fontSizeNormalize: boolean | null;
72
70
  fontWeight: number | null;
@@ -114,6 +112,7 @@ export interface IRSProperties {
114
112
  maxMediaHeight?: number | null;
115
113
  modernTf?: string | null;
116
114
  monospaceTf?: string | null;
115
+ noOverflow?: boolean | null;
117
116
  noVerticalPagination?: boolean | null;
118
117
  oldStyleTf?: string | null;
119
118
  pageGutter?: number | null;
@@ -152,6 +151,7 @@ export declare class RSProperties extends Properties {
152
151
  maxMediaHeight: number | null;
153
152
  modernTf: string | null;
154
153
  monospaceTf: string | null;
154
+ noOverflow: boolean | null;
155
155
  noVerticalPagination: boolean | null;
156
156
  oldStyleTf: string | null;
157
157
  pageGutter: number | null;
@@ -10,7 +10,6 @@ export interface IEpubDefaults {
10
10
  fontSize?: number | null;
11
11
  fontSizeNormalize?: boolean | null;
12
12
  fontOpticalSizing?: boolean | null;
13
- fontOverride?: boolean | null;
14
13
  fontWeight?: number | null;
15
14
  fontWidth?: number | null;
16
15
  hyphens?: boolean | null;
@@ -50,7 +49,6 @@ export declare class EpubDefaults {
50
49
  fontSize: number | null;
51
50
  fontSizeNormalize: boolean | null;
52
51
  fontOpticalSizing: boolean | null;
53
- fontOverride: boolean | null;
54
52
  fontWeight: number | null;
55
53
  fontWidth: number | null;
56
54
  hyphens: boolean | null;
@@ -11,7 +11,6 @@ export interface IEpubPreferences {
11
11
  fontSize?: number | null;
12
12
  fontSizeNormalize?: boolean | null;
13
13
  fontOpticalSizing?: boolean | null;
14
- fontOverride?: boolean | null;
15
14
  fontWeight?: number | null;
16
15
  fontWidth?: number | null;
17
16
  hyphens?: boolean | null;
@@ -51,7 +50,6 @@ export declare class EpubPreferences implements ConfigurablePreferences {
51
50
  fontSize?: number | null;
52
51
  fontSizeNormalize?: boolean | null;
53
52
  fontOpticalSizing?: boolean | null;
54
- fontOverride?: boolean | null;
55
53
  fontWeight?: number | null;
56
54
  fontWidth?: number | null;
57
55
  hyphens?: boolean | null;
@@ -22,7 +22,6 @@ export declare class EpubPreferencesEditor implements IPreferencesEditor {
22
22
  get fontSize(): RangePreference<number>;
23
23
  get fontSizeNormalize(): BooleanPreference;
24
24
  get fontOpticalSizing(): BooleanPreference;
25
- get fontOverride(): BooleanPreference;
26
25
  get fontWeight(): RangePreference<number>;
27
26
  get fontWidth(): RangePreference<number>;
28
27
  get hyphens(): BooleanPreference;
@@ -13,7 +13,6 @@ export interface IEpubSettings {
13
13
  fontSize?: number | null;
14
14
  fontSizeNormalize?: boolean | null;
15
15
  fontOpticalSizing?: boolean | null;
16
- fontOverride?: boolean | null;
17
16
  fontWeight?: number | null;
18
17
  fontWidth?: number | null;
19
18
  hyphens?: boolean | null;
@@ -53,7 +52,6 @@ export declare class EpubSettings implements ConfigurableSettings {
53
52
  fontSize: number | null;
54
53
  fontSizeNormalize: boolean | null;
55
54
  fontOpticalSizing: boolean | null;
56
- fontOverride: boolean | null;
57
55
  fontWeight: number | null;
58
56
  fontWidth: number | null;
59
57
  hyphens: boolean | null;
@@ -5,7 +5,6 @@ export declare enum TextAlignment {
5
5
  justify = "justify"
6
6
  }
7
7
  export declare enum Theme {
8
- day = "day",
9
8
  sepia = "sepia",
10
9
  night = "night",
11
10
  custom = "custom"