@prose-reader/core 1.58.0 → 1.60.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 (38) hide show
  1. package/dist/createReaderWithEnhancer.d.ts +4 -48
  2. package/dist/enhancers/fonts/SettingsManager.d.ts +10 -0
  3. package/dist/enhancers/fonts/fonts.d.ts +7 -0
  4. package/dist/enhancers/fonts/types.d.ts +9 -0
  5. package/dist/enhancers/layoutEnhancer/SettingsManager.d.ts +10 -0
  6. package/dist/enhancers/layoutEnhancer/layoutEnhancer.d.ts +5 -8
  7. package/dist/enhancers/layoutEnhancer/types.d.ts +5 -7
  8. package/dist/index.js +290 -212
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.umd.cjs +223 -145
  11. package/dist/index.umd.cjs.map +1 -1
  12. package/dist/reader.d.ts +2 -2
  13. package/dist/settings/ReaderSettingsManager.d.ts +32 -0
  14. package/dist/settings/SettingsInterface.d.ts +13 -0
  15. package/dist/settings/SettingsManagerOverload.d.ts +23 -0
  16. package/dist/settings/types.d.ts +7 -6
  17. package/dist/spine/createSpine.d.ts +2 -2
  18. package/dist/spine/locationResolver.d.ts +2 -2
  19. package/dist/spine/navigationResolver.d.ts +2 -2
  20. package/dist/spineItem/commonSpineItem.d.ts +2 -2
  21. package/dist/spineItem/createSpineItem.d.ts +2 -2
  22. package/dist/spineItem/frameItem/frameItem.d.ts +2 -2
  23. package/dist/spineItem/frameItem/loader.d.ts +2 -2
  24. package/dist/spineItem/navigationResolver.d.ts +2 -2
  25. package/dist/spineItem/prePaginatedSpineItem.d.ts +2 -2
  26. package/dist/spineItem/reflowableSpineItem.d.ts +2 -2
  27. package/dist/spineItemManager.d.ts +2 -2
  28. package/dist/types/reader.d.ts +4 -4
  29. package/dist/utils/objects.d.ts +1 -0
  30. package/dist/viewportNavigator/panViewportNavigator.d.ts +2 -2
  31. package/dist/viewportNavigator/scrollViewportNavigator.d.ts +2 -2
  32. package/dist/viewportNavigator/viewportNavigator.d.ts +2 -2
  33. package/package.json +3 -3
  34. package/dist/enhancers/fonts.d.ts +0 -19
  35. package/dist/settings/SettingsManager.d.ts +0 -14
  36. package/dist/settings/defaultSettings.d.ts +0 -3
  37. package/dist/settings/getComputedSettings.d.ts +0 -4
  38. package/dist/utils/compose.d.ts +0 -8
@@ -1,7 +1,15 @@
1
1
  (function(global, factory) {
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("rxjs"), require("rxjs/operators"), require("@prose-reader/shared")) : typeof define === "function" && define.amd ? define(["exports", "rxjs", "rxjs/operators", "@prose-reader/shared"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.prose = {}, global.rxjs, global.operators, global.shared));
3
3
  })(this, function(exports2, rxjs, operators, shared) {
4
- "use strict";
4
+ "use strict";var __typeError = (msg) => {
5
+ throw TypeError(msg);
6
+ };
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+
12
+ var _context;
5
13
  const chromeEnhancer = (next) => (options) => {
6
14
  const reader = next(options);
7
15
  reader.context.state$.pipe(rxjs.takeUntil(reader.$.destroy$)).subscribe(({ containerElement }) => {
@@ -73,21 +81,98 @@
73
81
  reader.readAsDataURL(data);
74
82
  });
75
83
  };
84
+ function shallowMergeIfDefined(obj1, obj2) {
85
+ const result = { ...obj1 };
86
+ for (const key in obj2) {
87
+ if (Object.prototype.hasOwnProperty.call(obj2, key)) {
88
+ const value = obj2[key];
89
+ if (value !== void 0 || !(key in obj1)) {
90
+ result[key] = value;
91
+ }
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+ class SettingsManagerOverload {
97
+ constructor(initialSettings, settingsManager) {
98
+ this.settingsManager = settingsManager;
99
+ this.inputSettings = shallowMergeIfDefined(this.getDefaultSettings(), initialSettings);
100
+ this.outputSettings = this.computeOutputSettings();
101
+ this.outputSettingsUpdateSubject = new rxjs.Subject();
102
+ this.settings$ = rxjs.combineLatest([
103
+ this.settingsManager.settings$,
104
+ this.outputSettingsUpdateSubject.pipe(operators.startWith(this.outputSettings))
105
+ ]).pipe(
106
+ operators.map(([parentSettings, settings]) => ({ ...parentSettings, ...settings })),
107
+ operators.shareReplay(1)
108
+ );
109
+ this.settings$.subscribe();
110
+ }
111
+ _prepareUpdate(settings) {
112
+ const parentInputSettings = this.getCleanedParentInputSettings(settings);
113
+ const parentManagerPreparedUpdate = this.settingsManager._prepareUpdate(parentInputSettings);
114
+ this.inputSettings = { ...this.inputSettings, ...settings };
115
+ const outputSettings = this.computeOutputSettings();
116
+ const hasChanged = this.hasSettingsChanged(outputSettings);
117
+ console.log({ outputSettings, hasChanged, parentManagerPreparedUpdate });
118
+ return {
119
+ hasChanged: hasChanged || parentManagerPreparedUpdate.hasChanged,
120
+ commit: () => {
121
+ this.outputSettings = outputSettings;
122
+ if (!parentManagerPreparedUpdate.hasChanged && hasChanged) {
123
+ this.outputSettingsUpdateSubject.next(outputSettings);
124
+ }
125
+ parentManagerPreparedUpdate.commit();
126
+ }
127
+ };
128
+ }
129
+ update(settings) {
130
+ const { commit } = this._prepareUpdate(settings);
131
+ commit();
132
+ }
133
+ get settings() {
134
+ return {
135
+ ...this.settingsManager.settings,
136
+ ...this.outputSettings
137
+ };
138
+ }
139
+ destroy() {
140
+ this.outputSettingsUpdateSubject.complete();
141
+ }
142
+ }
143
+ let SettingsManager$1 = class SettingsManager extends SettingsManagerOverload {
144
+ computeOutputSettings() {
145
+ return this.inputSettings;
146
+ }
147
+ hasSettingsChanged(newOutputSettings) {
148
+ return !isShallowEqual(this.outputSettings, newOutputSettings);
149
+ }
150
+ getCleanedParentInputSettings(settings) {
151
+ const { fontJustification, fontScale, fontWeight, lineHeight, ...rest } = settings;
152
+ return rest;
153
+ }
154
+ getDefaultSettings() {
155
+ return {
156
+ fontScale: 1,
157
+ fontWeight: "publisher",
158
+ lineHeight: "publisher",
159
+ fontJustification: "publisher"
160
+ };
161
+ }
162
+ };
76
163
  const fontsEnhancer = (next) => (options) => {
77
- const {
78
- fontScale = 1,
79
- lineHeight = `publisher`,
80
- fontWeight = `publisher`,
81
- fontJustification = `publisher`
82
- } = options;
164
+ const { fontScale, lineHeight, fontWeight, fontJustification } = options;
83
165
  const changes$ = new rxjs.Subject();
84
- const settings$ = new rxjs.BehaviorSubject({
85
- fontScale,
86
- lineHeight,
87
- fontWeight,
88
- fontJustification
89
- });
90
166
  const reader = next(options);
167
+ const settingsManager = new SettingsManager$1(
168
+ {
169
+ fontScale,
170
+ lineHeight,
171
+ fontWeight,
172
+ fontJustification
173
+ },
174
+ reader.settings
175
+ );
91
176
  const getStyle = () => `
92
177
  ${/*
93
178
  Ideally, we would like to use !important but it could break publisher specific
@@ -99,10 +184,10 @@
99
184
  */
100
185
  ``}
101
186
  body {
102
- ${settings$.value.fontScale !== 1 ? `font-size: ${settings$.value.fontScale}em !important;` : ``}
103
- ${settings$.value.lineHeight !== `publisher` ? `line-height: ${settings$.value.lineHeight} !important;` : ``}
104
- ${settings$.value.fontWeight !== `publisher` ? `font-weight: ${settings$.value.fontWeight} !important;` : ``}
105
- ${settings$.value.fontJustification !== `publisher` ? `text-align: ${settings$.value.fontJustification} !important;` : ``}
187
+ ${settingsManager.settings.fontScale !== 1 ? `font-size: ${settingsManager.settings.fontScale}em !important;` : ``}
188
+ ${settingsManager.settings.lineHeight !== `publisher` ? `line-height: ${settingsManager.settings.lineHeight} !important;` : ``}
189
+ ${settingsManager.settings.fontWeight !== `publisher` ? `font-weight: ${settingsManager.settings.fontWeight} !important;` : ``}
190
+ ${settingsManager.settings.fontJustification !== `publisher` ? `text-align: ${settingsManager.settings.fontJustification} !important;` : ``}
106
191
  }
107
192
  `;
108
193
  const applyChangeToSpineItem = (requireLayout) => {
@@ -132,42 +217,15 @@
132
217
  return false;
133
218
  })
134
219
  );
135
- const newSettings$ = changes$.pipe(
136
- operators.withLatestFrom(settings$),
137
- rxjs.map(([changes, settings]) => ({
138
- fontJustification: changes.fontJustification ?? settings.fontJustification,
139
- fontWeight: changes.fontWeight ?? settings.fontWeight,
140
- lineHeight: changes.lineHeight ?? settings.lineHeight,
141
- fontScale: Math.max(0.01, changes.fontScale ?? settings.fontScale)
142
- })),
143
- operators.distinctUntilChanged(isShallowEqual),
144
- operators.shareReplay(1)
145
- );
146
- newSettings$.subscribe(settings$);
147
- settings$.pipe(shouldRequireLayout, operators.tap(applyChangeToSpineItem), rxjs.takeUntil(reader.$.destroy$)).subscribe();
148
- const settingsMerge$ = rxjs.combineLatest([reader.settings.settings$, settings$]).pipe(
149
- rxjs.map(([innerSettings, settings]) => ({
150
- ...innerSettings,
151
- ...settings
152
- }))
153
- );
154
- const setSettings = (settings) => {
155
- const { fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2, ...passthroughSettings } = settings;
156
- changes$.next({ fontJustification: fontJustification2, fontScale: fontScale2, fontWeight: fontWeight2, lineHeight: lineHeight2 });
157
- reader.settings.setSettings(passthroughSettings);
158
- };
220
+ settingsManager.settings$.pipe(shouldRequireLayout, operators.tap(applyChangeToSpineItem), rxjs.takeUntil(reader.$.destroy$)).subscribe();
159
221
  return {
160
222
  ...reader,
161
223
  destroy: () => {
162
224
  changes$.complete();
163
- settings$.complete();
225
+ settingsManager.destroy();
164
226
  reader.destroy();
165
227
  },
166
- settings: {
167
- ...reader.settings,
168
- setSettings,
169
- settings$: settingsMerge$
170
- }
228
+ settings: settingsManager
171
229
  };
172
230
  };
173
231
  const hotkeysEnhancer = (next) => (options) => {
@@ -293,14 +351,37 @@
293
351
  function isDefined(arg) {
294
352
  return arg !== null && arg !== void 0;
295
353
  }
354
+ class SettingsManager extends SettingsManagerOverload {
355
+ computeOutputSettings() {
356
+ return this.inputSettings;
357
+ }
358
+ hasSettingsChanged(newOutputSettings) {
359
+ return !isShallowEqual(this.outputSettings, newOutputSettings);
360
+ }
361
+ getCleanedParentInputSettings(settings) {
362
+ const { layoutAutoResize, pageHorizontalMargin, pageVerticalMargin, ...rest } = settings;
363
+ return rest;
364
+ }
365
+ getDefaultSettings() {
366
+ return {
367
+ layoutAutoResize: "container",
368
+ pageHorizontalMargin: 24,
369
+ pageVerticalMargin: 24
370
+ };
371
+ }
372
+ }
296
373
  const SHOULD_NOT_LAYOUT = false;
297
374
  const layoutEnhancer = (next) => (options) => {
298
- const { pageHorizontalMargin = 24, pageVerticalMargin = 24 } = options;
375
+ const { pageHorizontalMargin, pageVerticalMargin, layoutAutoResize } = options;
299
376
  const reader = next(options);
300
- const settingsSubject$ = new rxjs.BehaviorSubject({
301
- pageHorizontalMargin,
302
- pageVerticalMargin
303
- });
377
+ const settingsManager = new SettingsManager(
378
+ {
379
+ pageHorizontalMargin,
380
+ pageVerticalMargin,
381
+ layoutAutoResize
382
+ },
383
+ reader.settings
384
+ );
304
385
  reader.hookManager.register(`onViewportOffsetAdjust`, () => {
305
386
  let hasRedrawn = false;
306
387
  reader.spine.manipulateSpineItems(({ frame }) => {
@@ -313,7 +394,7 @@
313
394
  });
314
395
  reader.hookManager.register(`item.onLayoutBeforeMeasurement`, ({ frame, minimumWidth, item, isImageType }) => {
315
396
  var _a, _b;
316
- const { pageHorizontalMargin: pageHorizontalMargin2 = 0, pageVerticalMargin: pageVerticalMargin2 = 0 } = settingsSubject$.value;
397
+ const { pageHorizontalMargin: pageHorizontalMargin2 = 0, pageVerticalMargin: pageVerticalMargin2 = 0 } = settingsManager.settings;
317
398
  const pageSize = reader.context.getPageSize();
318
399
  if (item.renditionLayout === `reflowable` && frame.getIsReady() && !isImageType() && !frame.getViewportDimensions()) {
319
400
  let columnWidth = pageSize.width - pageHorizontalMargin2 * 2;
@@ -367,7 +448,7 @@
367
448
  }
368
449
  const movingSafePan$ = createMovingSafePan$(reader);
369
450
  movingSafePan$.subscribe();
370
- settingsSubject$.pipe(
451
+ settingsManager.settings$.pipe(
371
452
  mapKeysTo([`pageHorizontalMargin`, `pageVerticalMargin`]),
372
453
  operators.distinctUntilChanged(isShallowEqual),
373
454
  operators.skip(1),
@@ -376,32 +457,14 @@
376
457
  }),
377
458
  operators.takeUntil(reader.$.destroy$)
378
459
  ).subscribe();
379
- const settings$ = rxjs.combineLatest([reader.settings.settings$, settingsSubject$.asObservable()]).pipe(
380
- operators.map(([innerSettings, settings]) => ({
381
- ...innerSettings,
382
- ...settings
383
- }))
384
- );
385
- const setSettings = ({ pageVerticalMargin: pageVerticalMargin2, pageHorizontalMargin: pageHorizontalMargin2, ...rest }) => {
386
- if (pageHorizontalMargin2 !== void 0 || pageVerticalMargin2 !== void 0) {
387
- settingsSubject$.next({
388
- pageHorizontalMargin: pageHorizontalMargin2 ?? settingsSubject$.value.pageHorizontalMargin,
389
- pageVerticalMargin: pageVerticalMargin2 ?? settingsSubject$.value.pageVerticalMargin
390
- });
391
- }
392
- reader.settings.setSettings(rest);
393
- };
394
460
  return {
395
461
  ...reader,
396
462
  destroy: () => {
463
+ settingsManager.destroy();
397
464
  reader.destroy();
398
465
  observer == null ? void 0 : observer.disconnect();
399
466
  },
400
- settings: {
401
- ...reader.settings,
402
- setSettings,
403
- settings$
404
- }
467
+ settings: settingsManager
405
468
  };
406
469
  };
407
470
  const ROOT_NAMESPACE = `@prose-reader/core`;
@@ -5158,7 +5221,7 @@
5158
5221
  }),
5159
5222
  operators.switchMap(([, currentEvent]) => {
5160
5223
  if ((currentEvent == null ? void 0 : currentEvent.type) !== `manualAdjust`) return rxjs.EMPTY;
5161
- const animationDuration = currentEvent.animation === `snap` ? settings.settings.computedSnapAnimationDuration : settings.settings.computedPageTurnAnimationDuration;
5224
+ const animationDuration = currentEvent.animation === `snap` ? settings.settings.snapAnimationDuration : settings.settings.computedPageTurnAnimationDuration;
5162
5225
  const pageTurnAnimation = currentEvent.animation === `snap` ? `slide` : settings.settings.computedPageTurnAnimation;
5163
5226
  return rxjs.of(currentEvent).pipe(
5164
5227
  /**
@@ -5506,96 +5569,111 @@
5506
5569
  generateFromRange
5507
5570
  };
5508
5571
  };
5509
- const getComputedSettings = (settings, context) => {
5510
- const manifest = context.manifest;
5511
- const hasVerticalWriting = context.state.hasVerticalWriting ?? false;
5512
- const computedSettings = {
5513
- computedPageTurnDirection: settings.pageTurnDirection,
5514
- computedPageTurnAnimation: settings.pageTurnAnimation,
5515
- computedPageTurnMode: `controlled`,
5516
- computedPageTurnAnimationDuration: 0,
5517
- computedSnapAnimationDuration: 0
5518
- };
5519
- if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`) {
5520
- computedSettings.computedPageTurnMode = `scrollable`;
5521
- computedSettings.computedPageTurnDirection = `vertical`;
5522
- } else if (manifest && settings.pageTurnMode === `scrollable` && (manifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated(manifest))) {
5523
- Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
5524
- computedSettings.computedPageTurnAnimation = `none`;
5525
- computedSettings.computedPageTurnMode = `controlled`;
5526
- } else if (settings.pageTurnMode === `scrollable`) {
5527
- computedSettings.computedPageTurnMode = `scrollable`;
5528
- computedSettings.computedPageTurnDirection = `vertical`;
5529
- }
5530
- if (hasVerticalWriting && computedSettings.computedPageTurnAnimation === `slide`) {
5531
- Report.warn(
5532
- `pageTurnAnimation ${computedSettings.computedPageTurnAnimation} incompatible with current book, switching back to default`
5533
- );
5534
- computedSettings.computedPageTurnAnimation = `none`;
5535
- }
5536
- if (computedSettings.computedPageTurnMode === `scrollable`) {
5537
- computedSettings.computedPageTurnAnimationDuration = 0;
5538
- computedSettings.computedPageTurnAnimation = `none`;
5539
- } else {
5540
- computedSettings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
5541
- }
5542
- return computedSettings;
5543
- };
5544
- const defaultSettings = {
5545
- forceSinglePageMode: false,
5546
- pageTurnAnimation: `none`,
5547
- // computedPageTurnAnimation: `none`,
5548
- pageTurnDirection: `horizontal`,
5549
- // computedPageTurnDirection: `horizontal`,
5550
- pageTurnAnimationDuration: void 0,
5551
- // computedPageTurnAnimationDuration: 0,
5552
- pageTurnMode: `controlled`,
5553
- // computedPageTurnMode: `controlled`,
5554
- // computedSnapAnimationDuration: 300,
5555
- navigationSnapThreshold: 0.3,
5556
- numberOfAdjacentSpineItemToPreLoad: 0
5557
- };
5558
- class SettingsManager {
5572
+ class ReaderSettingsManager {
5559
5573
  constructor(initialSettings, context) {
5560
- this._context = context;
5574
+ __privateAdd(this, _context);
5575
+ __privateSet(this, _context, context);
5561
5576
  const settingsWithDefaults = {
5562
- ...defaultSettings,
5577
+ ...this.getDefaultSettings(),
5563
5578
  ...initialSettings
5564
5579
  };
5565
- const computedSettings = getComputedSettings(settingsWithDefaults, context);
5566
- const settings = { ...settingsWithDefaults, ...computedSettings };
5567
- this._settingsSubject$ = new rxjs.BehaviorSubject(settings);
5568
- this.settings$ = this._settingsSubject$.asObservable().pipe(operators.distinctUntilChanged(isShallowEqual));
5580
+ const outputSettings = this.getOutputSettings(settingsWithDefaults);
5581
+ this.outputSettings = outputSettings;
5582
+ this.outputSettingsUpdateSubject = new rxjs.Subject();
5583
+ this.settings$ = this.outputSettingsUpdateSubject.asObservable().pipe(operators.startWith(this.settings), operators.shareReplay(1));
5569
5584
  const recomputeSettingsOnContextChange$ = rxjs.combineLatest([context.hasVerticalWriting$, context.manifest$]).pipe(
5570
5585
  operators.tap(() => {
5571
- this._updateSettings(this.settings);
5586
+ this.update(this.settings);
5572
5587
  })
5573
5588
  );
5574
- const updateContextOnSettingsChanges$ = this._settingsSubject$.pipe(
5589
+ const updateContextOnSettingsChanges$ = this.settings$.pipe(
5575
5590
  operators.tap(({ forceSinglePageMode }) => {
5576
5591
  context.update({ forceSinglePageMode });
5577
5592
  })
5578
5593
  );
5579
5594
  rxjs.merge(recomputeSettingsOnContextChange$, updateContextOnSettingsChanges$).pipe(operators.takeUntil(context.destroy$)).subscribe();
5595
+ this.settings$.subscribe();
5580
5596
  }
5581
- // @see https://github.com/microsoft/TypeScript/issues/17293
5582
- _updateSettings(settings) {
5583
- const computed = getComputedSettings(settings, this._context);
5584
- const newMergedSettings = { ...settings, ...computed };
5585
- this._settingsSubject$.next(newMergedSettings);
5597
+ getComputedSettings(settings) {
5598
+ const manifest = __privateGet(this, _context).manifest;
5599
+ const hasVerticalWriting = __privateGet(this, _context).state.hasVerticalWriting ?? false;
5600
+ const computedSettings = {
5601
+ computedPageTurnDirection: settings.pageTurnDirection,
5602
+ computedPageTurnAnimation: settings.pageTurnAnimation,
5603
+ computedPageTurnMode: `controlled`,
5604
+ computedPageTurnAnimationDuration: 0
5605
+ };
5606
+ if ((manifest == null ? void 0 : manifest.renditionFlow) === `scrolled-continuous`) {
5607
+ computedSettings.computedPageTurnMode = `scrollable`;
5608
+ computedSettings.computedPageTurnDirection = `vertical`;
5609
+ } else if (manifest && settings.pageTurnMode === `scrollable` && (manifest.renditionLayout !== `pre-paginated` || !areAllItemsPrePaginated(manifest))) {
5610
+ Report.warn(`pageTurnMode ${settings.pageTurnMode} incompatible with current book, switching back to default`);
5611
+ computedSettings.computedPageTurnAnimation = `none`;
5612
+ computedSettings.computedPageTurnMode = `controlled`;
5613
+ } else if (settings.pageTurnMode === `scrollable`) {
5614
+ computedSettings.computedPageTurnMode = `scrollable`;
5615
+ computedSettings.computedPageTurnDirection = `vertical`;
5616
+ }
5617
+ if (hasVerticalWriting && computedSettings.computedPageTurnAnimation === `slide`) {
5618
+ Report.warn(
5619
+ `pageTurnAnimation ${computedSettings.computedPageTurnAnimation} incompatible with current book, switching back to default`
5620
+ );
5621
+ computedSettings.computedPageTurnAnimation = `none`;
5622
+ }
5623
+ if (computedSettings.computedPageTurnMode === `scrollable`) {
5624
+ computedSettings.computedPageTurnAnimationDuration = 0;
5625
+ computedSettings.computedPageTurnAnimation = `none`;
5626
+ } else {
5627
+ computedSettings.computedPageTurnAnimationDuration = settings.pageTurnAnimationDuration !== void 0 ? settings.pageTurnAnimationDuration : 300;
5628
+ }
5629
+ return computedSettings;
5630
+ }
5631
+ _prepareUpdate(settings) {
5632
+ const state = this.getOutputSettings(settings);
5633
+ const hasChanged = !isShallowEqual(this.outputSettings, state);
5634
+ return {
5635
+ hasChanged,
5636
+ state,
5637
+ commit: () => {
5638
+ this.outputSettings = state;
5639
+ if (hasChanged) {
5640
+ this.outputSettingsUpdateSubject.next(state);
5641
+ }
5642
+ }
5643
+ };
5644
+ }
5645
+ getOutputSettings(inputSettings) {
5646
+ const computedSettings = this.getComputedSettings({ ...this.outputSettings, ...inputSettings });
5647
+ return { ...this.outputSettings, ...inputSettings, ...computedSettings };
5648
+ }
5649
+ getDefaultSettings() {
5650
+ return {
5651
+ forceSinglePageMode: false,
5652
+ pageTurnAnimation: `none`,
5653
+ // computedPageTurnAnimation: `none`,
5654
+ pageTurnDirection: `horizontal`,
5655
+ // computedPageTurnDirection: `horizontal`,
5656
+ pageTurnAnimationDuration: void 0,
5657
+ // computedPageTurnAnimationDuration: 0,
5658
+ pageTurnMode: `controlled`,
5659
+ // computedPageTurnMode: `controlled`,
5660
+ snapAnimationDuration: 300,
5661
+ navigationSnapThreshold: 0.3,
5662
+ numberOfAdjacentSpineItemToPreLoad: 0
5663
+ };
5586
5664
  }
5587
- setSettings(settings) {
5588
- if (Object.keys(settings).length === 0) return;
5589
- const newMergedSettings = { ...this._settingsSubject$.value, ...settings };
5590
- this._updateSettings(newMergedSettings);
5665
+ update(settings) {
5666
+ const { commit } = this._prepareUpdate(settings);
5667
+ commit();
5591
5668
  }
5592
5669
  get settings() {
5593
- return this._settingsSubject$.getValue();
5670
+ return this.outputSettings;
5594
5671
  }
5595
5672
  destroy() {
5596
- this._settingsSubject$.complete();
5673
+ this.outputSettingsUpdateSubject.complete();
5597
5674
  }
5598
5675
  }
5676
+ _context = new WeakMap();
5599
5677
  class HookManager {
5600
5678
  constructor() {
5601
5679
  this._hooks = [];
@@ -5678,7 +5756,7 @@
5678
5756
  const viewportStateSubject = new rxjs.BehaviorSubject(`free`);
5679
5757
  const hookManager = new HookManager();
5680
5758
  const context = new Context();
5681
- const settingsManager = new SettingsManager(inputSettings, context);
5759
+ const settingsManager = new ReaderSettingsManager(inputSettings, context);
5682
5760
  const spineItemManager = createSpineItemManager({ context, settings: settingsManager });
5683
5761
  const pagination = createPagination({ context, spineItemManager });
5684
5762
  const elementSubject$ = new rxjs.BehaviorSubject(void 0);