@readium/navigator 2.0.0-beta.8 → 2.0.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.
@@ -1,10 +1,9 @@
1
- import { EPUBLayout, Metadata, ReadingProgression } from "@readium/shared";
1
+ import { Layout, Metadata, ReadingProgression } from "@readium/shared";
2
2
  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
6
  import {
7
- LayoutStrategy,
8
7
  TextAlignment,
9
8
  Theme,
10
9
  fontSizeRangeConfig,
@@ -19,13 +18,13 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
19
18
  preferences: EpubPreferences;
20
19
  private settings: EpubSettings;
21
20
  private metadata: Metadata | null;
22
- private layout: EPUBLayout;
21
+ private layout: Layout;
23
22
 
24
23
  constructor(initialPreferences: EpubPreferences, settings: EpubSettings, metadata: Metadata) {
25
24
  this.preferences = initialPreferences;
26
25
  this.settings = settings;
27
26
  this.metadata = metadata;
28
- this.layout = this.metadata?.getPresentation()?.layout || EPUBLayout.reflowable;
27
+ this.layout = this.metadata?.effectiveLayout || Layout.reflowable;
29
28
  }
30
29
 
31
30
  clear() {
@@ -61,7 +60,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
61
60
  return new Preference<number>({
62
61
  initialValue: this.preferences.columnCount,
63
62
  effectiveValue: this.settings.columnCount || null,
64
- isEffective: this.layout === EPUBLayout.reflowable && !this.settings.scroll,
63
+ isEffective: this.layout !== Layout.fixed && !this.settings.scroll,
65
64
  onChange: (newValue: number | null | undefined) => {
66
65
  this.updatePreference("columnCount", newValue || null);
67
66
  }
@@ -96,7 +95,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
96
95
  return new BooleanPreference({
97
96
  initialValue: this.preferences.deprecatedFontSize,
98
97
  effectiveValue: CSS.supports("zoom", "1") ? this.settings.deprecatedFontSize || false : true,
99
- isEffective: this.layout === EPUBLayout.reflowable,
98
+ isEffective: this.layout !== Layout.fixed,
100
99
  onChange: (newValue: boolean | null | undefined) => {
101
100
  this.updatePreference("deprecatedFontSize", newValue || null);
102
101
  }
@@ -107,7 +106,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
107
106
  return new Preference<string>({
108
107
  initialValue: this.preferences.fontFamily,
109
108
  effectiveValue: this.settings.fontFamily || null,
110
- isEffective: this.layout === EPUBLayout.reflowable,
109
+ isEffective: this.layout !== Layout.fixed,
111
110
  onChange: (newValue: string | null | undefined) => {
112
111
  this.updatePreference("fontFamily", newValue || null);
113
112
  }
@@ -118,7 +117,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
118
117
  return new RangePreference<number>({
119
118
  initialValue: this.preferences.fontSize,
120
119
  effectiveValue: this.settings.fontSize || 1,
121
- isEffective: this.layout === EPUBLayout.reflowable,
120
+ isEffective: this.layout !== Layout.fixed,
122
121
  onChange: (newValue: number | null | undefined) => {
123
122
  this.updatePreference("fontSize", newValue || null);
124
123
  },
@@ -131,7 +130,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
131
130
  return new BooleanPreference({
132
131
  initialValue: this.preferences.fontSizeNormalize,
133
132
  effectiveValue: this.settings.fontSizeNormalize || false,
134
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.fontSizeNormalize !== null,
133
+ isEffective: this.layout !== Layout.fixed && this.preferences.fontSizeNormalize !== null,
135
134
  onChange: (newValue: boolean | null | undefined) => {
136
135
  this.updatePreference("fontSizeNormalize", newValue || null);
137
136
  }
@@ -142,7 +141,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
142
141
  return new BooleanPreference({
143
142
  initialValue: this.preferences.fontOpticalSizing,
144
143
  effectiveValue: this.settings.fontOpticalSizing || true,
145
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.fontOpticalSizing !== null,
144
+ isEffective: this.layout !== Layout.fixed && this.preferences.fontOpticalSizing !== null,
146
145
  onChange: (newValue: boolean | null | undefined) => {
147
146
  this.updatePreference("fontOpticalSizing", newValue || null);
148
147
  }
@@ -153,7 +152,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
153
152
  return new RangePreference<number>({
154
153
  initialValue: this.preferences.fontWeight,
155
154
  effectiveValue: this.settings.fontWeight || 400,
156
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.fontWeight !== null,
155
+ isEffective: this.layout !== Layout.fixed && this.preferences.fontWeight !== null,
157
156
  onChange: (newValue: number | null | undefined) => {
158
157
  this.updatePreference("fontWeight", newValue || null);
159
158
  },
@@ -166,7 +165,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
166
165
  return new RangePreference<number>({
167
166
  initialValue: this.preferences.fontWidth,
168
167
  effectiveValue: this.settings.fontWidth || 100,
169
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.fontWidth !== null,
168
+ isEffective: this.layout !== Layout.fixed && this.preferences.fontWidth !== null,
170
169
  onChange: (newValue: number | null | undefined) => {
171
170
  this.updatePreference("fontWidth", newValue || null);
172
171
  },
@@ -179,7 +178,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
179
178
  return new BooleanPreference({
180
179
  initialValue: this.preferences.hyphens,
181
180
  effectiveValue: this.settings.hyphens || false,
182
- isEffective: this.layout === EPUBLayout.reflowable && this.metadata?.effectiveReadingProgression === ReadingProgression.ltr && this.preferences.hyphens !== null,
181
+ isEffective: this.layout !== Layout.fixed && this.metadata?.effectiveReadingProgression === ReadingProgression.ltr && this.preferences.hyphens !== null,
183
182
  onChange: (newValue: boolean | null | undefined) => {
184
183
  this.updatePreference("hyphens", newValue || null);
185
184
  }
@@ -212,34 +211,33 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
212
211
  });
213
212
  }
214
213
 
214
+ get iOSPatch(): BooleanPreference {
215
+ return new BooleanPreference({
216
+ initialValue: this.preferences.iOSPatch,
217
+ effectiveValue: this.settings.iOSPatch || false,
218
+ isEffective: this.layout !== Layout.fixed,
219
+ onChange: (newValue: boolean | null | undefined) => {
220
+ this.updatePreference("iOSPatch", newValue || null);
221
+ }
222
+ });
223
+ }
224
+
215
225
  get iPadOSPatch(): BooleanPreference {
216
226
  return new BooleanPreference({
217
227
  initialValue: this.preferences.iPadOSPatch,
218
228
  effectiveValue: this.settings.iPadOSPatch || false,
219
- isEffective: this.layout === EPUBLayout.reflowable,
229
+ isEffective: this.layout !== Layout.fixed,
220
230
  onChange: (newValue: boolean | null | undefined) => {
221
231
  this.updatePreference("iPadOSPatch", newValue || null);
222
232
  }
223
233
  });
224
234
  }
225
235
 
226
- get layoutStrategy(): EnumPreference<LayoutStrategy> {
227
- return new EnumPreference<LayoutStrategy>({
228
- initialValue: this.preferences.layoutStrategy,
229
- effectiveValue: this.settings.layoutStrategy,
230
- isEffective: this.layout === EPUBLayout.reflowable,
231
- onChange: (newValue: LayoutStrategy | null | undefined) => {
232
- this.updatePreference("layoutStrategy", newValue || null);
233
- },
234
- supportedValues: Object.values(LayoutStrategy)
235
- })
236
- }
237
-
238
236
  get letterSpacing(): RangePreference<number> {
239
237
  return new RangePreference<number>({
240
238
  initialValue: this.preferences.letterSpacing,
241
239
  effectiveValue: this.settings.letterSpacing || 0,
242
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.letterSpacing !== null,
240
+ isEffective: this.layout !== Layout.fixed && this.preferences.letterSpacing !== null,
243
241
  onChange: (newValue: number | null | undefined) => {
244
242
  this.updatePreference("letterSpacing", newValue || null);
245
243
  },
@@ -252,7 +250,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
252
250
  return new BooleanPreference({
253
251
  initialValue: this.preferences.ligatures,
254
252
  effectiveValue: this.settings.ligatures || true,
255
- isEffective: this.layout === EPUBLayout.reflowable
253
+ isEffective: this.layout !== Layout.fixed
256
254
  && this.metadata?.languages?.some(lang => lang === "ar" || lang === "fa")
257
255
  && this.preferences.ligatures !== null || false,
258
256
  onChange: (newValue: boolean | null | undefined) => {
@@ -265,7 +263,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
265
263
  return new RangePreference<number>({
266
264
  initialValue: this.preferences.lineHeight,
267
265
  effectiveValue: this.settings.lineHeight,
268
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.lineHeight !== null,
266
+ isEffective: this.layout !== Layout.fixed && this.preferences.lineHeight !== null,
269
267
  onChange: (newValue: number | null | undefined) => {
270
268
  this.updatePreference("lineHeight", newValue || null);
271
269
  },
@@ -278,7 +276,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
278
276
  return new Preference<string>({
279
277
  initialValue: this.preferences.linkColor,
280
278
  effectiveValue: this.settings.linkColor || defaultColors.RS__linkColor,
281
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.linkColor !== null,
279
+ isEffective: this.layout !== Layout.fixed && this.preferences.linkColor !== null,
282
280
  onChange: (newValue: string | null | undefined) => {
283
281
  this.updatePreference("linkColor", newValue || null);
284
282
  }
@@ -289,7 +287,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
289
287
  return new RangePreference<number>({
290
288
  initialValue: this.preferences.maximalLineLength,
291
289
  effectiveValue: this.settings.maximalLineLength,
292
- isEffective: this.layout === EPUBLayout.reflowable,
290
+ isEffective: this.layout !== Layout.fixed,
293
291
  onChange: (newValue: number | null | undefined) => {
294
292
  this.updatePreference("maximalLineLength", newValue);
295
293
  },
@@ -302,7 +300,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
302
300
  return new RangePreference<number>({
303
301
  initialValue: this.preferences.minimalLineLength,
304
302
  effectiveValue: this.settings.minimalLineLength,
305
- isEffective: this.layout === EPUBLayout.reflowable,
303
+ isEffective: this.layout !== Layout.fixed,
306
304
  onChange: (newValue: number | null | undefined) => {
307
305
  this.updatePreference("minimalLineLength", newValue);
308
306
  },
@@ -315,7 +313,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
315
313
  return new BooleanPreference({
316
314
  initialValue: this.preferences.noRuby,
317
315
  effectiveValue: this.settings.noRuby || false,
318
- isEffective: this.layout === EPUBLayout.reflowable && this.metadata?.languages?.includes("ja") || false,
316
+ isEffective: this.layout !== Layout.fixed && this.metadata?.languages?.includes("ja") || false,
319
317
  onChange: (newValue: boolean | null | undefined) => {
320
318
  this.updatePreference("noRuby", newValue || null);
321
319
  }
@@ -326,7 +324,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
326
324
  return new RangePreference<number>({
327
325
  initialValue: this.preferences.optimalLineLength,
328
326
  effectiveValue: this.settings.optimalLineLength,
329
- isEffective: this.layout === EPUBLayout.reflowable,
327
+ isEffective: this.layout !== Layout.fixed,
330
328
  onChange: (newValue: number | null | undefined) => {
331
329
  this.updatePreference("optimalLineLength", newValue as number);
332
330
  },
@@ -339,7 +337,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
339
337
  return new Preference<number>({
340
338
  initialValue: this.preferences.pageGutter,
341
339
  effectiveValue: this.settings.pageGutter,
342
- isEffective: this.layout === EPUBLayout.reflowable,
340
+ isEffective: this.layout !== Layout.fixed,
343
341
  onChange: (newValue: number | null | undefined) => {
344
342
  this.updatePreference("pageGutter", newValue || null);
345
343
  }
@@ -350,7 +348,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
350
348
  return new RangePreference<number>({
351
349
  initialValue: this.preferences.paragraphIndent,
352
350
  effectiveValue: this.settings.paragraphIndent || 0,
353
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.paragraphIndent !== null,
351
+ isEffective: this.layout !== Layout.fixed && this.preferences.paragraphIndent !== null,
354
352
  onChange: (newValue: number | null | undefined) => {
355
353
  this.updatePreference("paragraphIndent", newValue || null);
356
354
  },
@@ -363,7 +361,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
363
361
  return new RangePreference<number>({
364
362
  initialValue: this.preferences.paragraphSpacing,
365
363
  effectiveValue: this.settings.paragraphSpacing || 0,
366
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.paragraphSpacing !== null,
364
+ isEffective: this.layout !== Layout.fixed && this.preferences.paragraphSpacing !== null,
367
365
  onChange: (newValue: number | null | undefined) => {
368
366
  this.updatePreference("paragraphSpacing", newValue || null);
369
367
  },
@@ -376,7 +374,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
376
374
  return new BooleanPreference({
377
375
  initialValue: this.preferences.scroll,
378
376
  effectiveValue: this.settings.scroll || false,
379
- isEffective: this.layout === EPUBLayout.reflowable,
377
+ isEffective: this.layout !== Layout.fixed,
380
378
  onChange: (newValue: boolean | null | undefined) => {
381
379
  this.updatePreference("scroll", newValue || null);
382
380
  }
@@ -387,7 +385,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
387
385
  return new Preference<number>({
388
386
  initialValue: this.preferences.scrollPaddingTop,
389
387
  effectiveValue: this.settings.scrollPaddingTop || 0,
390
- isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingTop !== null,
388
+ isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingTop !== null,
391
389
  onChange: (newValue: number | null | undefined) => {
392
390
  this.updatePreference("scrollPaddingTop", newValue || null);
393
391
  }
@@ -398,7 +396,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
398
396
  return new Preference<number>({
399
397
  initialValue: this.preferences.scrollPaddingBottom,
400
398
  effectiveValue: this.settings.scrollPaddingBottom || 0,
401
- isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingBottom !== null,
399
+ isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingBottom !== null,
402
400
  onChange: (newValue: number | null | undefined) => {
403
401
  this.updatePreference("scrollPaddingBottom", newValue || null);
404
402
  }
@@ -410,7 +408,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
410
408
  return new Preference<number>({
411
409
  initialValue: this.preferences.scrollPaddingLeft,
412
410
  effectiveValue: this.settings.scrollPaddingLeft || 0,
413
- isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingLeft !== null,
411
+ isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingLeft !== null,
414
412
  onChange: (newValue: number | null | undefined) => {
415
413
  this.updatePreference("scrollPaddingLeft", newValue || null);
416
414
  }
@@ -421,7 +419,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
421
419
  return new Preference<number>({
422
420
  initialValue: this.preferences.scrollPaddingRight,
423
421
  effectiveValue: this.settings.scrollPaddingRight || 0,
424
- isEffective: this.layout === EPUBLayout.reflowable && !!this.settings.scroll && this.preferences.scrollPaddingRight !== null,
422
+ isEffective: this.layout !== Layout.fixed && !!this.settings.scroll && this.preferences.scrollPaddingRight !== null,
425
423
  onChange: (newValue: number | null | undefined) => {
426
424
  this.updatePreference("scrollPaddingRight", newValue || null);
427
425
  }
@@ -433,7 +431,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
433
431
  return new Preference<string>({
434
432
  initialValue: this.preferences.selectionBackgroundColor,
435
433
  effectiveValue: this.settings.selectionBackgroundColor || defaultColors.RS__selectionBackgroundColor,
436
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.selectionBackgroundColor !== null,
434
+ isEffective: this.layout !== Layout.fixed && this.preferences.selectionBackgroundColor !== null,
437
435
  onChange: (newValue: string | null | undefined) => {
438
436
  this.updatePreference("selectionBackgroundColor", newValue || null);
439
437
  }
@@ -444,7 +442,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
444
442
  return new Preference<string>({
445
443
  initialValue: this.preferences.selectionTextColor,
446
444
  effectiveValue: this.settings.selectionTextColor || defaultColors.RS__selectionTextColor,
447
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.selectionTextColor !== null,
445
+ isEffective: this.layout !== Layout.fixed && this.preferences.selectionTextColor !== null,
448
446
  onChange: (newValue: string | null | undefined) => {
449
447
  this.updatePreference("selectionTextColor", newValue || null);
450
448
  }
@@ -455,7 +453,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
455
453
  return new EnumPreference<TextAlignment>({
456
454
  initialValue: this.preferences.textAlign,
457
455
  effectiveValue: this.settings.textAlign || TextAlignment.start,
458
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.textAlign !== null,
456
+ isEffective: this.layout !== Layout.fixed && this.preferences.textAlign !== null,
459
457
  onChange: (newValue: TextAlignment | null | undefined) => {
460
458
  this.updatePreference("textAlign", newValue || null);
461
459
  },
@@ -467,7 +465,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
467
465
  return new Preference<string>({
468
466
  initialValue: this.preferences.textColor,
469
467
  effectiveValue: this.settings.textColor || defaultColors.RS__textColor,
470
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.textColor !== null,
468
+ isEffective: this.layout !== Layout.fixed && this.preferences.textColor !== null,
471
469
  onChange: (newValue: string | null | undefined) => {
472
470
  this.updatePreference("textColor", newValue || null);
473
471
  }
@@ -478,7 +476,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
478
476
  return new BooleanPreference({
479
477
  initialValue: this.preferences.textNormalization,
480
478
  effectiveValue: this.settings.textNormalization || false,
481
- isEffective: this.layout === EPUBLayout.reflowable,
479
+ isEffective: this.layout !== Layout.fixed,
482
480
  onChange: (newValue: boolean | null | undefined) => {
483
481
  this.updatePreference("textNormalization", newValue || null);
484
482
  }
@@ -489,7 +487,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
489
487
  return new EnumPreference<Theme>({
490
488
  initialValue: this.preferences.theme,
491
489
  effectiveValue: this.settings.theme || null,
492
- isEffective: this.layout === EPUBLayout.reflowable,
490
+ isEffective: this.layout !== Layout.fixed,
493
491
  onChange: (newValue: Theme | null | undefined) => {
494
492
  this.updatePreference("theme", newValue || null);
495
493
  },
@@ -501,7 +499,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
501
499
  return new Preference<string>({
502
500
  initialValue: this.preferences.visitedColor,
503
501
  effectiveValue: this.settings.visitedColor || defaultColors.RS__visitedColor,
504
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.visitedColor !== null,
502
+ isEffective: this.layout !== Layout.fixed && this.preferences.visitedColor !== null,
505
503
  onChange: (newValue: string | null | undefined) => {
506
504
  this.updatePreference("visitedColor", newValue || null);
507
505
  }
@@ -512,7 +510,7 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
512
510
  return new RangePreference<number>({
513
511
  initialValue: this.preferences.wordSpacing,
514
512
  effectiveValue: this.settings.wordSpacing || 0,
515
- isEffective: this.layout === EPUBLayout.reflowable && this.preferences.wordSpacing !== null,
513
+ isEffective: this.layout !== Layout.fixed && this.preferences.wordSpacing !== null,
516
514
  onChange: (newValue: number | null | undefined) => {
517
515
  this.updatePreference("wordSpacing", newValue || null);
518
516
  },
@@ -1,5 +1,5 @@
1
1
  import { ConfigurableSettings } from "../../preferences/Configurable";
2
- import { LayoutStrategy, TextAlignment, Theme } from "../../preferences/Types";
2
+ import { TextAlignment, Theme } from "../../preferences/Types";
3
3
  import { EpubDefaults } from "./EpubDefaults";
4
4
  import { EpubPreferences } from "./EpubPreferences";
5
5
 
@@ -21,8 +21,8 @@ export interface IEpubSettings {
21
21
  hyphens?: boolean | null,
22
22
  invertFilter?: boolean | number | null,
23
23
  invertGaijiFilter: boolean | number | null,
24
+ iOSPatch?: boolean | null,
24
25
  iPadOSPatch?: boolean | null,
25
- layoutStrategy?: LayoutStrategy | null,
26
26
  letterSpacing?: number | null,
27
27
  ligatures?: boolean | null,
28
28
  lineHeight?: number | null,
@@ -65,8 +65,8 @@ export class EpubSettings implements ConfigurableSettings {
65
65
  hyphens: boolean | null;
66
66
  invertFilter: boolean | number | null;
67
67
  invertGaijiFilter: boolean | number | null;
68
+ iOSPatch: boolean;
68
69
  iPadOSPatch: boolean;
69
- layoutStrategy: LayoutStrategy | null;
70
70
  letterSpacing: number | null;
71
71
  ligatures: boolean | null;
72
72
  lineHeight: number | null;
@@ -140,6 +140,13 @@ export class EpubSettings implements ConfigurableSettings {
140
140
  this.invertGaijiFilter = typeof preferences.invertGaijiFilter === "boolean"
141
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
148
+ ? ((sMLWithRequest.OS.iOS || sMLWithRequest.OS.iPadOS) && sMLWithRequest.iOSRequest === "mobile")
149
+ : defaults.iOSPatch;
143
150
  this.iPadOSPatch = this.deprecatedFontSize
144
151
  ? false
145
152
  : preferences.iPadOSPatch === false
@@ -147,7 +154,6 @@ export class EpubSettings implements ConfigurableSettings {
147
154
  : preferences.iPadOSPatch === true
148
155
  ? (sMLWithRequest.OS.iPadOS && sMLWithRequest.iOSRequest === "desktop")
149
156
  : defaults.iPadOSPatch;
150
- this.layoutStrategy = preferences.layoutStrategy || defaults.layoutStrategy || null;
151
157
  this.letterSpacing = preferences.letterSpacing !== undefined
152
158
  ? preferences.letterSpacing
153
159
  : defaults.letterSpacing !== undefined
@@ -11,12 +11,6 @@ export enum Theme {
11
11
  custom = "custom"
12
12
  }
13
13
 
14
- export enum LayoutStrategy {
15
- margin = "margin",
16
- lineLength = "lineLength",
17
- columns = "columns"
18
- }
19
-
20
14
  export type RangeConfig = {
21
15
  range: [number, number],
22
16
  step: number
@@ -1,5 +1,14 @@
1
1
  import { Link, Locator, Publication, ReadingProgression } from "@readium/shared";
2
2
  type cbb = (ok: boolean) => void;
3
+ export interface ProgressionRange {
4
+ start: number;
5
+ end: number;
6
+ }
7
+ export interface VisualNavigatorViewport {
8
+ readingOrder: string[];
9
+ progressions: Map<string, ProgressionRange>;
10
+ positions: number[] | null;
11
+ }
3
12
  export declare abstract class Navigator {
4
13
  abstract get publication(): Publication;
5
14
  abstract get currentLocator(): Locator;
@@ -1,5 +1,5 @@
1
- import { EPUBLayout, Link, Locator, Publication, ReadingProgression } from "@readium/shared";
2
- import { Configurable, ConfigurablePreferences, ConfigurableSettings, VisualNavigator } from "../";
1
+ import { Layout, Link, Locator, Publication, ReadingProgression } from "@readium/shared";
2
+ import { Configurable, ConfigurablePreferences, ConfigurableSettings, VisualNavigator, VisualNavigatorViewport } from "../";
3
3
  import { FramePoolManager } from "./frame/FramePoolManager";
4
4
  import { FXLFramePoolManager } from "./fxl/FXLFramePoolManager";
5
5
  import { CommsEventKey } from "@readium/navigator-html-injectables";
@@ -22,6 +22,7 @@ export interface EpubNavigatorListeners {
22
22
  click: (e: FrameClickEvent) => boolean;
23
23
  zoom: (scale: number) => void;
24
24
  miscPointer: (amount: number) => void;
25
+ scroll: (delta: number) => void;
25
26
  customEvent: (key: string, data: unknown) => void;
26
27
  handleLocator: (locator: Locator) => boolean;
27
28
  textSelected: (selection: BasicTextSelection) => void;
@@ -35,15 +36,16 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
35
36
  private currentLocation;
36
37
  private lastLocationInView;
37
38
  private currentProgression;
38
- readonly layout: EPUBLayout;
39
+ private _layout;
39
40
  private _preferences;
40
41
  private _defaults;
41
42
  private _settings;
42
43
  private _css;
43
44
  private _preferencesEditor;
44
45
  private resizeObserver;
46
+ private reflowViewport;
45
47
  constructor(container: HTMLElement, pub: Publication, listeners: EpubNavigatorListeners, positions?: Locator[], initialPosition?: Locator | undefined, configuration?: EpubNavigatorConfiguration);
46
- static determineLayout(pub: Publication): EPUBLayout;
48
+ static determineLayout(pub: Publication, scroll?: boolean): Layout;
47
49
  load(): Promise<void>;
48
50
  get settings(): Readonly<EpubSettings>;
49
51
  get preferencesEditor(): EpubPreferencesEditor;
@@ -54,6 +56,7 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
54
56
  private compileCSSProperties;
55
57
  private commitCSS;
56
58
  resizeHandler(): Promise<void>;
59
+ get layout(): Layout;
57
60
  get ownerWindow(): Window & typeof globalThis;
58
61
  /**
59
62
  * Exposed to the public to compensate for lack of implemented readium conveniences
@@ -78,13 +81,18 @@ export declare class EpubNavigator extends VisualNavigator implements Configurab
78
81
  private changeResource;
79
82
  private findLastPositionInProgressionRange;
80
83
  private findNearestPositions;
84
+ private updateViewport;
81
85
  private syncLocation;
82
86
  goBackward(_: boolean, cb: (ok: boolean) => void): void;
83
87
  goForward(_: boolean, cb: (ok: boolean) => void): void;
84
88
  get currentLocator(): Locator;
85
- get currentPositionNumbers(): number[];
89
+ get viewport(): VisualNavigatorViewport;
90
+ get isScrollStart(): boolean;
91
+ get isScrollEnd(): boolean;
92
+ get canGoBackward(): boolean;
93
+ get canGoForward(): boolean;
86
94
  get readingProgression(): ReadingProgression;
87
- setReadingProgression(newProgression: ReadingProgression): Promise<void>;
95
+ private setLayout;
88
96
  get publication(): Publication;
89
97
  private loadLocator;
90
98
  go(locator: Locator, _: boolean, cb: (ok: boolean) => void): void;
@@ -37,6 +37,7 @@ export interface IUserProperties {
37
37
  fontWidth?: FontWidth | null;
38
38
  invertFilter?: boolean | number | null;
39
39
  invertGaijiFilter?: boolean | number | null;
40
+ iOSPatch?: boolean | null;
40
41
  iPadOSPatch?: boolean | null;
41
42
  letterSpacing?: number | null;
42
43
  ligatures?: Ligatures | null;
@@ -71,6 +72,7 @@ export declare class UserProperties extends Properties {
71
72
  fontWidth: FontWidth | null;
72
73
  invertFilter: boolean | number | null;
73
74
  invertGaijiFilter: boolean | number | null;
75
+ iOSPatch: boolean | null;
74
76
  iPadOSPatch: boolean | null;
75
77
  letterSpacing: number | null;
76
78
  ligatures: Ligatures | null;
@@ -1,5 +1,4 @@
1
1
  import { LineLengths } from "../../helpers";
2
- import { LayoutStrategy } from "../../preferences";
3
2
  import { EpubSettings } from "../preferences/EpubSettings";
4
3
  import { RSProperties, UserProperties } from "./Properties";
5
4
  export interface IReadiumCSS {
@@ -8,7 +7,6 @@ export interface IReadiumCSS {
8
7
  lineLengths: LineLengths;
9
8
  container: HTMLElement;
10
9
  constraint: number;
11
- layoutStrategy?: LayoutStrategy | null;
12
10
  }
13
11
  export declare class ReadiumCSS {
14
12
  rsProperties: RSProperties;
@@ -17,7 +15,6 @@ export declare class ReadiumCSS {
17
15
  container: HTMLElement;
18
16
  containerParent: HTMLElement;
19
17
  constraint: number;
20
- layoutStrategy: LayoutStrategy;
21
18
  private cachedColCount;
22
19
  private effectiveContainerWidth;
23
20
  constructor(props: IReadiumCSS);
@@ -3,6 +3,7 @@ import { Locator, Publication, Page, Link } from "@readium/shared";
3
3
  import { FrameCommsListener } from "../frame";
4
4
  import { FXLFrameManager } from "./FXLFrameManager";
5
5
  import { FXLPeripherals } from "./FXLPeripherals";
6
+ import { VisualNavigatorViewport } from "../../Navigator";
6
7
  export declare class FXLFramePoolManager {
7
8
  private readonly container;
8
9
  private readonly positions;
@@ -86,6 +87,7 @@ export declare class FXLFramePoolManager {
86
87
  update(pub: Publication, locator: Locator, modules: ModuleName[], _force?: boolean): Promise<void>;
87
88
  get currentFrames(): (FXLFrameManager | undefined)[];
88
89
  get currentBounds(): DOMRect;
89
- get currentNumbers(): number[];
90
+ get viewport(): VisualNavigatorViewport;
91
+ private getCurrentNumbers;
90
92
  deselect(): void;
91
93
  }
@@ -1,4 +1,15 @@
1
1
  import { Link, Publication } from "@readium/shared";
2
+ export declare enum Orientation {
3
+ auto = "auto",
4
+ landscape = "landscape",
5
+ portrait = "portrait"
6
+ }
7
+ export declare enum Spread {
8
+ auto = "auto",
9
+ both = "both",
10
+ none = "none",
11
+ landscape = "landscape"
12
+ }
2
13
  export declare class FXLSpreader {
3
14
  shift: boolean;
4
15
  private spreads;
@@ -1,4 +1,4 @@
1
- import { LayoutStrategy, TextAlignment, Theme } from "../../preferences/Types";
1
+ import { TextAlignment, Theme } from "../../preferences/Types";
2
2
  export interface IEpubDefaults {
3
3
  backgroundColor?: string | null;
4
4
  blendFilter?: boolean | null;
@@ -15,8 +15,8 @@ export interface IEpubDefaults {
15
15
  hyphens?: boolean | null;
16
16
  invertFilter?: boolean | number | null;
17
17
  invertGaijiFilter?: boolean | number | null;
18
+ iOSPatch?: boolean | null;
18
19
  iPadOSPatch?: boolean | null;
19
- layoutStrategy?: LayoutStrategy | null;
20
20
  letterSpacing?: number | null;
21
21
  ligatures?: boolean | null;
22
22
  lineHeight?: number | null;
@@ -56,8 +56,8 @@ export declare class EpubDefaults {
56
56
  hyphens: boolean | null;
57
57
  invertFilter: boolean | number | null;
58
58
  invertGaijiFilter: boolean | number | null;
59
+ iOSPatch: boolean;
59
60
  iPadOSPatch: boolean;
60
- layoutStrategy: LayoutStrategy | null;
61
61
  letterSpacing: number | null;
62
62
  ligatures: boolean | null;
63
63
  lineHeight: number | null;
@@ -1,5 +1,5 @@
1
1
  import { ConfigurablePreferences } from "../../preferences/Configurable";
2
- import { LayoutStrategy, TextAlignment, Theme } from "../../preferences/Types";
2
+ import { TextAlignment, Theme } from "../../preferences/Types";
3
3
  export interface IEpubPreferences {
4
4
  backgroundColor?: string | null;
5
5
  blendFilter?: boolean | null;
@@ -16,8 +16,8 @@ export interface IEpubPreferences {
16
16
  hyphens?: boolean | null;
17
17
  invertFilter?: boolean | number | null;
18
18
  invertGaijiFilter?: boolean | number | null;
19
+ iOSPatch?: boolean | null;
19
20
  iPadOSPatch?: boolean | null;
20
- layoutStrategy?: LayoutStrategy | null;
21
21
  letterSpacing?: number | null;
22
22
  ligatures?: boolean | null;
23
23
  lineHeight?: number | null;
@@ -57,8 +57,8 @@ export declare class EpubPreferences implements ConfigurablePreferences {
57
57
  hyphens?: boolean | null;
58
58
  invertFilter?: boolean | number | null;
59
59
  invertGaijiFilter?: boolean | number | null;
60
+ iOSPatch?: boolean | null;
60
61
  iPadOSPatch?: boolean | null;
61
- layoutStrategy?: LayoutStrategy | null;
62
62
  letterSpacing?: number | null;
63
63
  ligatures?: boolean | null;
64
64
  lineHeight?: number | null;
@@ -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 { LayoutStrategy, TextAlignment, Theme } from "../../preferences/Types";
6
+ import { TextAlignment, Theme } from "../../preferences/Types";
7
7
  export declare class EpubPreferencesEditor implements IPreferencesEditor {
8
8
  preferences: EpubPreferences;
9
9
  private settings;
@@ -27,8 +27,8 @@ export declare class EpubPreferencesEditor implements IPreferencesEditor {
27
27
  get hyphens(): BooleanPreference;
28
28
  get invertFilter(): RangePreference<number>;
29
29
  get invertGaijiFilter(): RangePreference<number>;
30
+ get iOSPatch(): BooleanPreference;
30
31
  get iPadOSPatch(): BooleanPreference;
31
- get layoutStrategy(): EnumPreference<LayoutStrategy>;
32
32
  get letterSpacing(): RangePreference<number>;
33
33
  get ligatures(): BooleanPreference;
34
34
  get lineHeight(): RangePreference<number>;