@readium/navigator 2.4.0-beta.8 → 2.4.0

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 (126) hide show
  1. package/dist/index.js +1307 -1253
  2. package/dist/index.umd.cjs +196 -133
  3. package/package.json +2 -2
  4. package/src/audio/AudioNavigator.ts +178 -52
  5. package/src/audio/AudioPoolManager.ts +27 -14
  6. package/src/audio/engine/AudioEngine.ts +4 -3
  7. package/src/audio/engine/PreservePitchProcessor.js +166 -101
  8. package/src/audio/engine/PreservePitchWorklet.ts +2 -17
  9. package/src/audio/engine/WebAudioEngine.ts +138 -160
  10. package/src/audio/engine/index.ts +2 -2
  11. package/src/audio/index.ts +3 -4
  12. package/src/audio/preferences/AudioDefaults.ts +2 -2
  13. package/src/audio/preferences/AudioPreferences.ts +11 -11
  14. package/src/audio/preferences/AudioPreferencesEditor.ts +13 -13
  15. package/src/audio/preferences/AudioSettings.ts +3 -3
  16. package/src/audio/preferences/index.ts +4 -4
  17. package/src/audio/protection/AudioNavigatorProtector.ts +4 -4
  18. package/src/css/index.ts +1 -1
  19. package/src/epub/EpubNavigator.ts +52 -52
  20. package/src/epub/css/Properties.ts +15 -15
  21. package/src/epub/css/ReadiumCSS.ts +43 -43
  22. package/src/epub/css/index.ts +2 -2
  23. package/src/epub/frame/FrameBlobBuilder.ts +10 -11
  24. package/src/epub/frame/FrameComms.ts +1 -1
  25. package/src/epub/frame/FrameManager.ts +9 -9
  26. package/src/epub/frame/FramePoolManager.ts +13 -13
  27. package/src/epub/frame/index.ts +4 -4
  28. package/src/epub/fxl/FXLCoordinator.ts +3 -3
  29. package/src/epub/fxl/FXLFrameManager.ts +8 -8
  30. package/src/epub/fxl/FXLFramePoolManager.ts +13 -13
  31. package/src/epub/fxl/FXLPeripherals.ts +4 -4
  32. package/src/epub/fxl/index.ts +5 -5
  33. package/src/epub/index.ts +5 -5
  34. package/src/epub/preferences/EpubDefaults.ts +23 -23
  35. package/src/epub/preferences/EpubPreferences.ts +16 -16
  36. package/src/epub/preferences/EpubPreferencesEditor.ts +53 -53
  37. package/src/epub/preferences/EpubSettings.ts +101 -101
  38. package/src/epub/preferences/index.ts +4 -4
  39. package/src/helpers/index.ts +2 -2
  40. package/src/index.ts +8 -9
  41. package/src/injection/Injector.ts +42 -42
  42. package/src/injection/epubInjectables.ts +8 -8
  43. package/src/injection/index.ts +2 -2
  44. package/src/injection/webpubInjectables.ts +1 -1
  45. package/src/preferences/Configurable.ts +2 -2
  46. package/src/preferences/PreferencesEditor.ts +2 -2
  47. package/src/preferences/guards.ts +2 -2
  48. package/src/preferences/index.ts +5 -5
  49. package/src/protection/CopyProtector.ts +5 -1
  50. package/src/protection/DevToolsDetector.ts +16 -16
  51. package/src/protection/DragAndDropProtector.ts +14 -1
  52. package/src/protection/NavigatorProtector.ts +6 -6
  53. package/src/webpub/WebPubBlobBuilder.ts +1 -1
  54. package/src/webpub/WebPubFrameManager.ts +8 -8
  55. package/src/webpub/WebPubFramePoolManager.ts +7 -7
  56. package/src/webpub/WebPubNavigator.ts +27 -27
  57. package/src/webpub/css/Properties.ts +3 -3
  58. package/src/webpub/css/WebPubCSS.ts +11 -11
  59. package/src/webpub/css/index.ts +2 -2
  60. package/src/webpub/index.ts +6 -6
  61. package/src/webpub/preferences/WebPubDefaults.ts +12 -12
  62. package/src/webpub/preferences/WebPubPreferences.ts +8 -8
  63. package/src/webpub/preferences/WebPubPreferencesEditor.ts +31 -31
  64. package/src/webpub/preferences/WebPubSettings.ts +45 -45
  65. package/src/webpub/preferences/index.ts +4 -4
  66. package/types/src/audio/AudioNavigator.d.ts +39 -9
  67. package/types/src/audio/AudioPoolManager.d.ts +7 -4
  68. package/types/src/audio/engine/AudioEngine.d.ts +4 -3
  69. package/types/src/audio/engine/PreservePitchWorklet.d.ts +1 -4
  70. package/types/src/audio/engine/WebAudioEngine.d.ts +15 -9
  71. package/types/src/audio/engine/index.d.ts +2 -2
  72. package/types/src/audio/index.d.ts +3 -4
  73. package/types/src/audio/preferences/AudioPreferences.d.ts +9 -9
  74. package/types/src/audio/preferences/AudioPreferencesEditor.d.ts +4 -4
  75. package/types/src/audio/preferences/AudioSettings.d.ts +3 -3
  76. package/types/src/audio/preferences/index.d.ts +4 -4
  77. package/types/src/audio/protection/AudioNavigatorProtector.d.ts +2 -2
  78. package/types/src/css/index.d.ts +1 -1
  79. package/types/src/epub/EpubNavigator.d.ts +11 -11
  80. package/types/src/epub/css/Properties.d.ts +2 -2
  81. package/types/src/epub/css/ReadiumCSS.d.ts +3 -3
  82. package/types/src/epub/css/index.d.ts +2 -2
  83. package/types/src/epub/frame/FrameBlobBuilder.d.ts +1 -1
  84. package/types/src/epub/frame/FrameComms.d.ts +1 -1
  85. package/types/src/epub/frame/FrameManager.d.ts +2 -2
  86. package/types/src/epub/frame/FramePoolManager.d.ts +3 -3
  87. package/types/src/epub/frame/index.d.ts +4 -4
  88. package/types/src/epub/fxl/FXLFrameManager.d.ts +3 -3
  89. package/types/src/epub/fxl/FXLFramePoolManager.d.ts +5 -5
  90. package/types/src/epub/fxl/FXLPeripherals.d.ts +2 -2
  91. package/types/src/epub/fxl/index.d.ts +5 -5
  92. package/types/src/epub/index.d.ts +5 -5
  93. package/types/src/epub/preferences/EpubDefaults.d.ts +1 -1
  94. package/types/src/epub/preferences/EpubPreferences.d.ts +2 -2
  95. package/types/src/epub/preferences/EpubPreferencesEditor.d.ts +5 -5
  96. package/types/src/epub/preferences/EpubSettings.d.ts +4 -4
  97. package/types/src/epub/preferences/index.d.ts +4 -4
  98. package/types/src/helpers/index.d.ts +2 -2
  99. package/types/src/index.d.ts +8 -9
  100. package/types/src/injection/Injector.d.ts +1 -1
  101. package/types/src/injection/epubInjectables.d.ts +1 -1
  102. package/types/src/injection/index.d.ts +2 -2
  103. package/types/src/preferences/Configurable.d.ts +1 -1
  104. package/types/src/preferences/PreferencesEditor.d.ts +1 -1
  105. package/types/src/preferences/guards.d.ts +1 -1
  106. package/types/src/preferences/index.d.ts +5 -5
  107. package/types/src/protection/CopyProtector.d.ts +1 -0
  108. package/types/src/protection/DragAndDropProtector.d.ts +2 -0
  109. package/types/src/protection/NavigatorProtector.d.ts +1 -1
  110. package/types/src/webpub/WebPubBlobBuilder.d.ts +1 -1
  111. package/types/src/webpub/WebPubFrameManager.d.ts +2 -2
  112. package/types/src/webpub/WebPubFramePoolManager.d.ts +3 -3
  113. package/types/src/webpub/WebPubNavigator.d.ts +10 -10
  114. package/types/src/webpub/css/Properties.d.ts +2 -2
  115. package/types/src/webpub/css/WebPubCSS.d.ts +2 -2
  116. package/types/src/webpub/css/index.d.ts +2 -2
  117. package/types/src/webpub/index.d.ts +6 -6
  118. package/types/src/webpub/preferences/WebPubDefaults.d.ts +1 -1
  119. package/types/src/webpub/preferences/WebPubPreferences.d.ts +2 -2
  120. package/types/src/webpub/preferences/WebPubPreferencesEditor.d.ts +5 -5
  121. package/types/src/webpub/preferences/WebPubSettings.d.ts +4 -4
  122. package/types/src/webpub/preferences/index.d.ts +4 -4
  123. package/src/Timeline.ts +0 -58
  124. package/src/audio/AudioTimeline.ts +0 -156
  125. package/types/src/Timeline.d.ts +0 -48
  126. package/types/src/audio/AudioTimeline.d.ts +0 -34
@@ -1,21 +1,21 @@
1
1
  import { Layout, Metadata, ReadingProgression } from "@readium/shared";
2
- import { IPreferencesEditor } from "../../preferences/PreferencesEditor";
3
- import { EpubPreferences } from "./EpubPreferences";
4
- import { EpubSettings } from "./EpubSettings";
5
- import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference";
6
- import {
7
- TextAlignment,
8
- filterRangeConfig,
9
- fontSizeRangeConfig,
10
- fontWeightRangeConfig,
11
- fontWidthRangeConfig,
2
+ import { IPreferencesEditor } from "../../preferences/PreferencesEditor.ts";
3
+ import { EpubPreferences } from "./EpubPreferences.ts";
4
+ import { EpubSettings } from "./EpubSettings.ts";
5
+ import { BooleanPreference, EnumPreference, Preference, RangePreference } from "../../preferences/Preference.ts";
6
+ import {
7
+ TextAlignment,
8
+ filterRangeConfig,
9
+ fontSizeRangeConfig,
10
+ fontWeightRangeConfig,
11
+ fontWidthRangeConfig,
12
12
  letterSpacingRangeConfig,
13
13
  lineHeightRangeConfig,
14
14
  lineLengthRangeConfig,
15
15
  paragraphIndentRangeConfig,
16
16
  paragraphSpacingRangeConfig,
17
17
  wordSpacingRangeConfig
18
- } from "../../preferences/Types";
18
+ } from "../../preferences/Types.ts";
19
19
 
20
20
  import defaultColors from "@readium/css/css/vars/colors.json";
21
21
 
@@ -47,7 +47,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
47
47
  effectiveValue: this.settings.backgroundColor || defaultColors.RS__backgroundColor,
48
48
  isEffective: this.preferences.backgroundColor !== null,
49
49
  onChange: (newValue: string | null | undefined) => {
50
- this.updatePreference("backgroundColor", newValue || null);
50
+ this.updatePreference("backgroundColor", newValue ?? null);
51
51
  }
52
52
  });
53
53
  }
@@ -57,7 +57,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
57
57
  effectiveValue: this.settings.blendFilter || false,
58
58
  isEffective: this.preferences.blendFilter !== null,
59
59
  onChange: (newValue: boolean | null | undefined) => {
60
- this.updatePreference("blendFilter", newValue || null);
60
+ this.updatePreference("blendFilter", newValue ?? null);
61
61
  }
62
62
  });
63
63
  }
@@ -68,7 +68,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
68
68
  effectiveValue: this.settings.columnCount || null,
69
69
  isEffective: this.layout !== Layout.fixed && !this.settings.scroll,
70
70
  onChange: (newValue: number | null | undefined) => {
71
- this.updatePreference("columnCount", newValue || null);
71
+ this.updatePreference("columnCount", newValue ?? null);
72
72
  }
73
73
  });
74
74
  }
@@ -79,7 +79,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
79
79
  effectiveValue: this.preferences.constraint || 0,
80
80
  isEffective: true,
81
81
  onChange: (newValue: number | null | undefined) => {
82
- this.updatePreference("constraint", newValue || null);
82
+ this.updatePreference("constraint", newValue ?? null);
83
83
  }
84
84
  })
85
85
  }
@@ -90,7 +90,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
90
90
  effectiveValue: typeof this.settings.darkenFilter === "boolean" ? 100 : this.settings.darkenFilter || 0,
91
91
  isEffective: this.settings.darkenFilter !== null,
92
92
  onChange: (newValue: number | boolean | null | undefined) => {
93
- this.updatePreference("darkenFilter", newValue || null);
93
+ this.updatePreference("darkenFilter", newValue ?? null);
94
94
  },
95
95
  supportedRange: filterRangeConfig.range,
96
96
  step: filterRangeConfig.step
@@ -103,7 +103,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
103
103
  effectiveValue: CSS.supports("zoom", "1") ? this.settings.deprecatedFontSize || false : true,
104
104
  isEffective: this.layout !== Layout.fixed,
105
105
  onChange: (newValue: boolean | null | undefined) => {
106
- this.updatePreference("deprecatedFontSize", newValue || null);
106
+ this.updatePreference("deprecatedFontSize", newValue ?? null);
107
107
  }
108
108
  });
109
109
  }
@@ -114,7 +114,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
114
114
  effectiveValue: this.settings.fontFamily || null,
115
115
  isEffective: this.layout !== Layout.fixed,
116
116
  onChange: (newValue: string | null | undefined) => {
117
- this.updatePreference("fontFamily", newValue || null);
117
+ this.updatePreference("fontFamily", newValue ?? null);
118
118
  }
119
119
  });
120
120
  }
@@ -125,7 +125,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
125
125
  effectiveValue: this.settings.fontSize || 1,
126
126
  isEffective: this.layout !== Layout.fixed,
127
127
  onChange: (newValue: number | null | undefined) => {
128
- this.updatePreference("fontSize", newValue || null);
128
+ this.updatePreference("fontSize", newValue ?? null);
129
129
  },
130
130
  supportedRange: fontSizeRangeConfig.range,
131
131
  step: fontSizeRangeConfig.step
@@ -138,7 +138,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
138
138
  effectiveValue: this.settings.fontSizeNormalize || false,
139
139
  isEffective: this.layout !== Layout.fixed && this.preferences.fontSizeNormalize !== null,
140
140
  onChange: (newValue: boolean | null | undefined) => {
141
- this.updatePreference("fontSizeNormalize", newValue || null);
141
+ this.updatePreference("fontSizeNormalize", newValue ?? null);
142
142
  }
143
143
  });
144
144
  }
@@ -149,7 +149,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
149
149
  effectiveValue: this.settings.fontOpticalSizing || true,
150
150
  isEffective: this.layout !== Layout.fixed && this.preferences.fontOpticalSizing !== null,
151
151
  onChange: (newValue: boolean | null | undefined) => {
152
- this.updatePreference("fontOpticalSizing", newValue || null);
152
+ this.updatePreference("fontOpticalSizing", newValue ?? null);
153
153
  }
154
154
  });
155
155
  }
@@ -160,7 +160,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
160
160
  effectiveValue: this.settings.fontWeight || 400,
161
161
  isEffective: this.layout !== Layout.fixed && this.preferences.fontWeight !== null,
162
162
  onChange: (newValue: number | null | undefined) => {
163
- this.updatePreference("fontWeight", newValue || null);
163
+ this.updatePreference("fontWeight", newValue ?? null);
164
164
  },
165
165
  supportedRange: fontWeightRangeConfig.range,
166
166
  step: fontWeightRangeConfig.step
@@ -173,7 +173,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
173
173
  effectiveValue: this.settings.fontWidth || 100,
174
174
  isEffective: this.layout !== Layout.fixed && this.preferences.fontWidth !== null,
175
175
  onChange: (newValue: number | null | undefined) => {
176
- this.updatePreference("fontWidth", newValue || null);
176
+ this.updatePreference("fontWidth", newValue ?? null);
177
177
  },
178
178
  supportedRange: fontWidthRangeConfig.range,
179
179
  step: fontWidthRangeConfig.step
@@ -186,7 +186,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
186
186
  effectiveValue: this.settings.hyphens || false,
187
187
  isEffective: this.layout !== Layout.fixed && this.metadata?.effectiveReadingProgression === ReadingProgression.ltr && this.preferences.hyphens !== null,
188
188
  onChange: (newValue: boolean | null | undefined) => {
189
- this.updatePreference("hyphens", newValue || null);
189
+ this.updatePreference("hyphens", newValue ?? null);
190
190
  }
191
191
  });
192
192
  }
@@ -197,7 +197,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
197
197
  effectiveValue: typeof this.settings.invertFilter === "boolean" ? 100 : this.settings.invertFilter || 0,
198
198
  isEffective: this.settings.invertFilter !== null,
199
199
  onChange: (newValue: number | boolean | null | undefined) => {
200
- this.updatePreference("invertFilter", newValue || null);
200
+ this.updatePreference("invertFilter", newValue ?? null);
201
201
  },
202
202
  supportedRange: filterRangeConfig.range,
203
203
  step: filterRangeConfig.step
@@ -210,7 +210,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
210
210
  effectiveValue: typeof this.settings.invertGaijiFilter === "boolean" ? 100 : this.settings.invertGaijiFilter || 0,
211
211
  isEffective: this.preferences.invertGaijiFilter !== null,
212
212
  onChange: (newValue: number | boolean | null | undefined) => {
213
- this.updatePreference("invertGaijiFilter", newValue || null);
213
+ this.updatePreference("invertGaijiFilter", newValue ?? null);
214
214
  },
215
215
  supportedRange: filterRangeConfig.range,
216
216
  step: filterRangeConfig.step
@@ -223,7 +223,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
223
223
  effectiveValue: this.settings.iOSPatch || false,
224
224
  isEffective: this.layout !== Layout.fixed,
225
225
  onChange: (newValue: boolean | null | undefined) => {
226
- this.updatePreference("iOSPatch", newValue || null);
226
+ this.updatePreference("iOSPatch", newValue ?? null);
227
227
  }
228
228
  });
229
229
  }
@@ -234,7 +234,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
234
234
  effectiveValue: this.settings.iPadOSPatch || false,
235
235
  isEffective: this.layout !== Layout.fixed,
236
236
  onChange: (newValue: boolean | null | undefined) => {
237
- this.updatePreference("iPadOSPatch", newValue || null);
237
+ this.updatePreference("iPadOSPatch", newValue ?? null);
238
238
  }
239
239
  });
240
240
  }
@@ -245,7 +245,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
245
245
  effectiveValue: this.settings.letterSpacing || 0,
246
246
  isEffective: this.layout !== Layout.fixed && this.preferences.letterSpacing !== null,
247
247
  onChange: (newValue: number | null | undefined) => {
248
- this.updatePreference("letterSpacing", newValue || null);
248
+ this.updatePreference("letterSpacing", newValue ?? null);
249
249
  },
250
250
  supportedRange: letterSpacingRangeConfig.range,
251
251
  step: letterSpacingRangeConfig.step
@@ -261,12 +261,12 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
261
261
  if (this.preferences.ligatures === null) {
262
262
  return false;
263
263
  }
264
-
264
+
265
265
  // Disable for fixed layout
266
266
  if (this.layout === Layout.fixed) {
267
267
  return false;
268
268
  }
269
-
269
+
270
270
  // Check for languages/scripts that should disable ligatures
271
271
  // ReadiumCSS does not apply in CJK
272
272
  const primaryLang = this.metadata?.languages?.[0]?.toLowerCase();
@@ -276,12 +276,12 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
276
276
  return false;
277
277
  }
278
278
  }
279
-
279
+
280
280
  // Enable by default
281
281
  return true;
282
282
  })(),
283
283
  onChange: (newValue: boolean | null | undefined) => {
284
- this.updatePreference("ligatures", newValue || null);
284
+ this.updatePreference("ligatures", newValue ?? null);
285
285
  }
286
286
  });
287
287
  }
@@ -292,7 +292,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
292
292
  effectiveValue: this.settings.lineHeight,
293
293
  isEffective: this.layout !== Layout.fixed && this.preferences.lineHeight !== null,
294
294
  onChange: (newValue: number | null | undefined) => {
295
- this.updatePreference("lineHeight", newValue || null);
295
+ this.updatePreference("lineHeight", newValue ?? null);
296
296
  },
297
297
  supportedRange: lineHeightRangeConfig.range,
298
298
  step: lineHeightRangeConfig.step
@@ -305,7 +305,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
305
305
  effectiveValue: this.settings.linkColor || defaultColors.RS__linkColor,
306
306
  isEffective: this.layout !== Layout.fixed && this.preferences.linkColor !== null,
307
307
  onChange: (newValue: string | null | undefined) => {
308
- this.updatePreference("linkColor", newValue || null);
308
+ this.updatePreference("linkColor", newValue ?? null);
309
309
  }
310
310
  });
311
311
  }
@@ -342,7 +342,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
342
342
  effectiveValue: this.settings.noRuby || false,
343
343
  isEffective: this.layout !== Layout.fixed && this.metadata?.languages?.includes("ja") || false,
344
344
  onChange: (newValue: boolean | null | undefined) => {
345
- this.updatePreference("noRuby", newValue || null);
345
+ this.updatePreference("noRuby", newValue ?? null);
346
346
  }
347
347
  });
348
348
  }
@@ -366,7 +366,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
366
366
  effectiveValue: this.settings.pageGutter,
367
367
  isEffective: this.layout !== Layout.fixed && !this.settings.scroll,
368
368
  onChange: (newValue: number | null | undefined) => {
369
- this.updatePreference("pageGutter", newValue || null);
369
+ this.updatePreference("pageGutter", newValue ?? null);
370
370
  }
371
371
  });
372
372
  }
@@ -377,7 +377,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
377
377
  effectiveValue: this.settings.paragraphIndent || 0,
378
378
  isEffective: this.layout !== Layout.fixed && this.preferences.paragraphIndent !== null,
379
379
  onChange: (newValue: number | null | undefined) => {
380
- this.updatePreference("paragraphIndent", newValue || null);
380
+ this.updatePreference("paragraphIndent", newValue ?? null);
381
381
  },
382
382
  supportedRange: paragraphIndentRangeConfig.range,
383
383
  step: paragraphIndentRangeConfig.step
@@ -390,7 +390,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
390
390
  effectiveValue: this.settings.paragraphSpacing || 0,
391
391
  isEffective: this.layout !== Layout.fixed && this.preferences.paragraphSpacing !== null,
392
392
  onChange: (newValue: number | null | undefined) => {
393
- this.updatePreference("paragraphSpacing", newValue || null);
393
+ this.updatePreference("paragraphSpacing", newValue ?? null);
394
394
  },
395
395
  supportedRange: paragraphSpacingRangeConfig.range,
396
396
  step: paragraphSpacingRangeConfig.step
@@ -403,7 +403,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
403
403
  effectiveValue: this.settings.scroll || false,
404
404
  isEffective: this.layout !== Layout.fixed,
405
405
  onChange: (newValue: boolean | null | undefined) => {
406
- this.updatePreference("scroll", newValue || null);
406
+ this.updatePreference("scroll", newValue ?? null);
407
407
  }
408
408
  });
409
409
  }
@@ -414,7 +414,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
414
414
  effectiveValue: this.settings.scrollPaddingTop || 0,
415
415
  isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingTop !== null,
416
416
  onChange: (newValue: number | null | undefined) => {
417
- this.updatePreference("scrollPaddingTop", newValue || null);
417
+ this.updatePreference("scrollPaddingTop", newValue ?? null);
418
418
  }
419
419
  });
420
420
  }
@@ -425,7 +425,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
425
425
  effectiveValue: this.settings.scrollPaddingBottom || 0,
426
426
  isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingBottom !== null,
427
427
  onChange: (newValue: number | null | undefined) => {
428
- this.updatePreference("scrollPaddingBottom", newValue || null);
428
+ this.updatePreference("scrollPaddingBottom", newValue ?? null);
429
429
  }
430
430
  });
431
431
  }
@@ -436,7 +436,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
436
436
  effectiveValue: this.settings.scrollPaddingLeft || 0,
437
437
  isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingLeft !== null,
438
438
  onChange: (newValue: number | null | undefined) => {
439
- this.updatePreference("scrollPaddingLeft", newValue || null);
439
+ this.updatePreference("scrollPaddingLeft", newValue ?? null);
440
440
  }
441
441
  });
442
442
  }
@@ -447,10 +447,10 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
447
447
  effectiveValue: this.settings.scrollPaddingRight || 0,
448
448
  isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingRight !== null,
449
449
  onChange: (newValue: number | null | undefined) => {
450
- this.updatePreference("scrollPaddingRight", newValue || null);
450
+ this.updatePreference("scrollPaddingRight", newValue ?? null);
451
451
  }
452
452
  });
453
- }
453
+ }
454
454
 
455
455
  get selectionBackgroundColor(): Preference<string> {
456
456
  return new Preference<string>({
@@ -458,7 +458,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
458
458
  effectiveValue: this.settings.selectionBackgroundColor || defaultColors.RS__selectionBackgroundColor,
459
459
  isEffective: this.layout !== Layout.fixed && this.preferences.selectionBackgroundColor !== null,
460
460
  onChange: (newValue: string | null | undefined) => {
461
- this.updatePreference("selectionBackgroundColor", newValue || null);
461
+ this.updatePreference("selectionBackgroundColor", newValue ?? null);
462
462
  }
463
463
  });
464
464
  }
@@ -469,7 +469,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
469
469
  effectiveValue: this.settings.selectionTextColor || defaultColors.RS__selectionTextColor,
470
470
  isEffective: this.layout !== Layout.fixed && this.preferences.selectionTextColor !== null,
471
471
  onChange: (newValue: string | null | undefined) => {
472
- this.updatePreference("selectionTextColor", newValue || null);
472
+ this.updatePreference("selectionTextColor", newValue ?? null);
473
473
  }
474
474
  });
475
475
  }
@@ -480,7 +480,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
480
480
  effectiveValue: this.settings.textAlign || TextAlignment.start,
481
481
  isEffective: this.layout !== Layout.fixed && this.preferences.textAlign !== null,
482
482
  onChange: (newValue: TextAlignment | null | undefined) => {
483
- this.updatePreference("textAlign", newValue || null);
483
+ this.updatePreference("textAlign", newValue ?? null);
484
484
  },
485
485
  supportedValues: Object.values(TextAlignment)
486
486
  });
@@ -492,7 +492,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
492
492
  effectiveValue: this.settings.textColor || defaultColors.RS__textColor,
493
493
  isEffective: this.layout !== Layout.fixed && this.preferences.textColor !== null,
494
494
  onChange: (newValue: string | null | undefined) => {
495
- this.updatePreference("textColor", newValue || null);
495
+ this.updatePreference("textColor", newValue ?? null);
496
496
  }
497
497
  });
498
498
  }
@@ -503,7 +503,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
503
503
  effectiveValue: this.settings.textNormalization || false,
504
504
  isEffective: this.layout !== Layout.fixed,
505
505
  onChange: (newValue: boolean | null | undefined) => {
506
- this.updatePreference("textNormalization", newValue || null);
506
+ this.updatePreference("textNormalization", newValue ?? null);
507
507
  }
508
508
  });
509
509
  }
@@ -514,7 +514,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
514
514
  effectiveValue: this.settings.visitedColor || defaultColors.RS__visitedColor,
515
515
  isEffective: this.layout !== Layout.fixed && this.preferences.visitedColor !== null,
516
516
  onChange: (newValue: string | null | undefined) => {
517
- this.updatePreference("visitedColor", newValue || null);
517
+ this.updatePreference("visitedColor", newValue ?? null);
518
518
  }
519
519
  });
520
520
  }
@@ -525,10 +525,10 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
525
525
  effectiveValue: this.settings.wordSpacing || 0,
526
526
  isEffective: this.layout !== Layout.fixed && this.preferences.wordSpacing !== null,
527
527
  onChange: (newValue: number | null | undefined) => {
528
- this.updatePreference("wordSpacing", newValue || null);
528
+ this.updatePreference("wordSpacing", newValue ?? null);
529
529
  },
530
530
  supportedRange: wordSpacingRangeConfig.range,
531
531
  step: wordSpacingRangeConfig.step
532
532
  });
533
533
  }
534
- }
534
+ }
@@ -1,9 +1,9 @@
1
- import { ConfigurableSettings } from "../../preferences/Configurable";
2
- import { ExperimentKey, TextAlignment } from "../../preferences/Types";
3
- import { EpubDefaults } from "./EpubDefaults";
4
- import { EpubPreferences } from "./EpubPreferences";
1
+ import { ConfigurableSettings } from "../../preferences/Configurable.ts";
2
+ import { ExperimentKey, TextAlignment } from "../../preferences/Types.ts";
3
+ import { EpubDefaults } from "./EpubDefaults.ts";
4
+ import { EpubPreferences } from "./EpubPreferences.ts";
5
5
 
6
- import { sMLWithRequest } from "../../helpers";
6
+ import { sMLWithRequest } from "../../helpers/index.ts";
7
7
 
8
8
  export interface IEpubSettings {
9
9
  backgroundColor?: string | null,
@@ -94,142 +94,142 @@ export class EpubSettings implements ConfigurableSettings {
94
94
 
95
95
  constructor(preferences: EpubPreferences, defaults: EpubDefaults) {
96
96
  this.backgroundColor = preferences.backgroundColor || defaults.backgroundColor || null;
97
- this.blendFilter = typeof preferences.blendFilter === "boolean"
98
- ? preferences.blendFilter
97
+ this.blendFilter = typeof preferences.blendFilter === "boolean"
98
+ ? preferences.blendFilter
99
99
  : defaults.blendFilter ?? null;
100
- this.columnCount = preferences.columnCount !== undefined
101
- ? preferences.columnCount
102
- : defaults.columnCount !== undefined
103
- ? defaults.columnCount
100
+ this.columnCount = preferences.columnCount !== undefined
101
+ ? preferences.columnCount
102
+ : defaults.columnCount !== undefined
103
+ ? defaults.columnCount
104
104
  : null;
105
105
  this.constraint = preferences.constraint || defaults.constraint;
106
- this.darkenFilter = typeof preferences.darkenFilter === "boolean"
107
- ? preferences.darkenFilter
106
+ this.darkenFilter = typeof preferences.darkenFilter === "boolean"
107
+ ? preferences.darkenFilter
108
108
  : defaults.darkenFilter ?? null;
109
- this.deprecatedFontSize = typeof preferences.deprecatedFontSize === "boolean"
110
- ? preferences.deprecatedFontSize
109
+ this.deprecatedFontSize = typeof preferences.deprecatedFontSize === "boolean"
110
+ ? preferences.deprecatedFontSize
111
111
  : defaults.deprecatedFontSize ?? null;
112
112
  this.fontFamily = preferences.fontFamily || defaults.fontFamily || null;
113
- this.fontSize = preferences.fontSize !== undefined
114
- ? preferences.fontSize
115
- : defaults.fontSize !== undefined
116
- ? defaults.fontSize
113
+ this.fontSize = preferences.fontSize !== undefined
114
+ ? preferences.fontSize
115
+ : defaults.fontSize !== undefined
116
+ ? defaults.fontSize
117
117
  : null;
118
- this.fontSizeNormalize = typeof preferences.fontSizeNormalize === "boolean"
119
- ? preferences.fontSizeNormalize
118
+ this.fontSizeNormalize = typeof preferences.fontSizeNormalize === "boolean"
119
+ ? preferences.fontSizeNormalize
120
120
  : defaults.fontSizeNormalize ?? null;
121
- this.fontOpticalSizing = typeof preferences.fontOpticalSizing === "boolean"
122
- ? preferences.fontOpticalSizing
121
+ this.fontOpticalSizing = typeof preferences.fontOpticalSizing === "boolean"
122
+ ? preferences.fontOpticalSizing
123
123
  : defaults.fontOpticalSizing ?? null;
124
- this.fontWeight = preferences.fontWeight !== undefined
125
- ? preferences.fontWeight
126
- : defaults.fontWeight !== undefined
127
- ? defaults.fontWeight
124
+ this.fontWeight = preferences.fontWeight !== undefined
125
+ ? preferences.fontWeight
126
+ : defaults.fontWeight !== undefined
127
+ ? defaults.fontWeight
128
128
  : null;
129
- this.fontWidth = preferences.fontWidth !== undefined
130
- ? preferences.fontWidth
131
- : defaults.fontWidth !== undefined
132
- ? defaults.fontWidth
129
+ this.fontWidth = preferences.fontWidth !== undefined
130
+ ? preferences.fontWidth
131
+ : defaults.fontWidth !== undefined
132
+ ? defaults.fontWidth
133
133
  : null;
134
- this.hyphens = typeof preferences.hyphens === "boolean"
135
- ? preferences.hyphens
134
+ this.hyphens = typeof preferences.hyphens === "boolean"
135
+ ? preferences.hyphens
136
136
  : defaults.hyphens ?? null;
137
- this.invertFilter = typeof preferences.invertFilter === "boolean"
138
- ? preferences.invertFilter
137
+ this.invertFilter = typeof preferences.invertFilter === "boolean"
138
+ ? preferences.invertFilter
139
139
  : defaults.invertFilter ?? null;
140
- this.invertGaijiFilter = typeof preferences.invertGaijiFilter === "boolean"
141
- ? preferences.invertGaijiFilter
140
+ this.invertGaijiFilter = typeof preferences.invertGaijiFilter === "boolean"
141
+ ? preferences.invertGaijiFilter
142
142
  : defaults.invertGaijiFilter ?? null;
143
- this.iOSPatch = this.deprecatedFontSize
144
- ? false
145
- : preferences.iOSPatch === false
146
- ? false
147
- : preferences.iOSPatch === true
143
+ this.iOSPatch = this.deprecatedFontSize
144
+ ? false
145
+ : preferences.iOSPatch === false
146
+ ? false
147
+ : preferences.iOSPatch === true
148
148
  ? ((sMLWithRequest.OS.iOS || sMLWithRequest.OS.iPadOS) && sMLWithRequest.iOSRequest === "mobile")
149
149
  : defaults.iOSPatch;
150
- this.iPadOSPatch = this.deprecatedFontSize
151
- ? false
152
- : preferences.iPadOSPatch === false
153
- ? false
154
- : preferences.iPadOSPatch === true
155
- ? (sMLWithRequest.OS.iPadOS && sMLWithRequest.iOSRequest === "desktop")
150
+ this.iPadOSPatch = this.deprecatedFontSize
151
+ ? false
152
+ : preferences.iPadOSPatch === false
153
+ ? false
154
+ : preferences.iPadOSPatch === true
155
+ ? (sMLWithRequest.OS.iPadOS && sMLWithRequest.iOSRequest === "desktop")
156
156
  : defaults.iPadOSPatch;
157
- this.letterSpacing = preferences.letterSpacing !== undefined
158
- ? preferences.letterSpacing
159
- : defaults.letterSpacing !== undefined
160
- ? defaults.letterSpacing
157
+ this.letterSpacing = preferences.letterSpacing !== undefined
158
+ ? preferences.letterSpacing
159
+ : defaults.letterSpacing !== undefined
160
+ ? defaults.letterSpacing
161
161
  : null;
162
162
  this.ligatures = typeof preferences.ligatures === "boolean"
163
- ? preferences.ligatures
163
+ ? preferences.ligatures
164
164
  : defaults.ligatures ?? null;
165
- this.lineHeight = preferences.lineHeight !== undefined
166
- ? preferences.lineHeight
167
- : defaults.lineHeight !== undefined
168
- ? defaults.lineHeight
165
+ this.lineHeight = preferences.lineHeight !== undefined
166
+ ? preferences.lineHeight
167
+ : defaults.lineHeight !== undefined
168
+ ? defaults.lineHeight
169
169
  : null;
170
170
  this.linkColor = preferences.linkColor || defaults.linkColor || null;
171
- this.maximalLineLength = preferences.maximalLineLength === null
172
- ? null
171
+ this.maximalLineLength = preferences.maximalLineLength === null
172
+ ? null
173
173
  : preferences.maximalLineLength || defaults.maximalLineLength || null;
174
- this.minimalLineLength = preferences.minimalLineLength === null
175
- ? null
174
+ this.minimalLineLength = preferences.minimalLineLength === null
175
+ ? null
176
176
  : preferences.minimalLineLength || defaults.minimalLineLength || null;
177
- this.noRuby = typeof preferences.noRuby === "boolean"
178
- ? preferences.noRuby
177
+ this.noRuby = typeof preferences.noRuby === "boolean"
178
+ ? preferences.noRuby
179
179
  : defaults.noRuby ?? null;
180
180
  this.optimalLineLength = preferences.optimalLineLength || defaults.optimalLineLength;
181
- this.pageGutter = preferences.pageGutter !== undefined
182
- ? preferences.pageGutter
183
- : defaults.pageGutter !== undefined
184
- ? defaults.pageGutter
181
+ this.pageGutter = preferences.pageGutter !== undefined
182
+ ? preferences.pageGutter
183
+ : defaults.pageGutter !== undefined
184
+ ? defaults.pageGutter
185
185
  : null;
186
- this.paragraphIndent = preferences.paragraphIndent !== undefined
187
- ? preferences.paragraphIndent
188
- : defaults.paragraphIndent !== undefined
189
- ? defaults.paragraphIndent
186
+ this.paragraphIndent = preferences.paragraphIndent !== undefined
187
+ ? preferences.paragraphIndent
188
+ : defaults.paragraphIndent !== undefined
189
+ ? defaults.paragraphIndent
190
190
  : null;
191
- this.paragraphSpacing = preferences.paragraphSpacing !== undefined
192
- ? preferences.paragraphSpacing
193
- : defaults.paragraphSpacing !== undefined
194
- ? defaults.paragraphSpacing
191
+ this.paragraphSpacing = preferences.paragraphSpacing !== undefined
192
+ ? preferences.paragraphSpacing
193
+ : defaults.paragraphSpacing !== undefined
194
+ ? defaults.paragraphSpacing
195
195
  : null;
196
- this.scroll = typeof preferences.scroll === "boolean"
197
- ? preferences.scroll
196
+ this.scroll = typeof preferences.scroll === "boolean"
197
+ ? preferences.scroll
198
198
  : defaults.scroll ?? null;
199
- this.scrollPaddingTop = preferences.scrollPaddingTop !== undefined
200
- ? preferences.scrollPaddingTop
201
- : defaults.scrollPaddingTop !== undefined
202
- ? defaults.scrollPaddingTop
199
+ this.scrollPaddingTop = preferences.scrollPaddingTop !== undefined
200
+ ? preferences.scrollPaddingTop
201
+ : defaults.scrollPaddingTop !== undefined
202
+ ? defaults.scrollPaddingTop
203
203
  : null;
204
- this.scrollPaddingBottom = preferences.scrollPaddingBottom !== undefined
205
- ? preferences.scrollPaddingBottom
206
- : defaults.scrollPaddingBottom !== undefined
207
- ? defaults.scrollPaddingBottom
208
- : null;
209
- this.scrollPaddingLeft = preferences.scrollPaddingLeft !== undefined
210
- ? preferences.scrollPaddingLeft
211
- : defaults.scrollPaddingLeft !== undefined
212
- ? defaults.scrollPaddingLeft
204
+ this.scrollPaddingBottom = preferences.scrollPaddingBottom !== undefined
205
+ ? preferences.scrollPaddingBottom
206
+ : defaults.scrollPaddingBottom !== undefined
207
+ ? defaults.scrollPaddingBottom
213
208
  : null;
214
- this.scrollPaddingRight = preferences.scrollPaddingRight !== undefined
215
- ? preferences.scrollPaddingRight
216
- : defaults.scrollPaddingRight !== undefined
217
- ? defaults.scrollPaddingRight
209
+ this.scrollPaddingLeft = preferences.scrollPaddingLeft !== undefined
210
+ ? preferences.scrollPaddingLeft
211
+ : defaults.scrollPaddingLeft !== undefined
212
+ ? defaults.scrollPaddingLeft
213
+ : null;
214
+ this.scrollPaddingRight = preferences.scrollPaddingRight !== undefined
215
+ ? preferences.scrollPaddingRight
216
+ : defaults.scrollPaddingRight !== undefined
217
+ ? defaults.scrollPaddingRight
218
218
  : null;
219
219
  this.selectionBackgroundColor = preferences.selectionBackgroundColor || defaults.selectionBackgroundColor || null;
220
220
  this.selectionTextColor = preferences.selectionTextColor || defaults.selectionTextColor || null;
221
221
  this.textAlign = preferences.textAlign || defaults.textAlign || null;
222
222
  this.textColor = preferences.textColor || defaults.textColor || null;
223
- this.textNormalization = typeof preferences.textNormalization === "boolean"
224
- ? preferences.textNormalization
223
+ this.textNormalization = typeof preferences.textNormalization === "boolean"
224
+ ? preferences.textNormalization
225
225
  : defaults.textNormalization ?? null;
226
226
  this.visitedColor = preferences.visitedColor || defaults.visitedColor || null;
227
- this.wordSpacing = preferences.wordSpacing !== undefined
228
- ? preferences.wordSpacing
229
- : defaults.wordSpacing !== undefined
230
- ? defaults.wordSpacing
227
+ this.wordSpacing = preferences.wordSpacing !== undefined
228
+ ? preferences.wordSpacing
229
+ : defaults.wordSpacing !== undefined
230
+ ? defaults.wordSpacing
231
231
  : null;
232
232
 
233
233
  this.experiments = defaults.experiments || null;
234
234
  }
235
- }
235
+ }
@@ -1,4 +1,4 @@
1
- export * from "./EpubDefaults";
2
- export * from "./EpubPreferencesEditor";
3
- export * from "./EpubPreferences";
4
- export * from "./EpubSettings";
1
+ export * from "./EpubDefaults.ts";
2
+ export * from "./EpubPreferencesEditor.ts";
3
+ export * from "./EpubPreferences.ts";
4
+ export * from "./EpubSettings.ts";
@@ -1,2 +1,2 @@
1
- export * from "./lineLength";
2
- export * from './sML';
1
+ export * from "./lineLength.ts";
2
+ export * from './sML.ts';