@prose-reader/core 1.247.0 → 1.249.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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { switchMap as w, of as v, fromEvent as Y, take as wt, map as S, from as O, takeUntil as T, Observable as te, defer as ke, Subject as j, combineLatest as k, merge as x, EMPTY as G, withLatestFrom as D, NEVER as ge, tap as P, share as R, BehaviorSubject as W, filter as L, first as U, mergeMap as Pe, endWith as me, finalize as le, catchError as xt, lastValueFrom as tn, scheduled as nn, animationFrameScheduler as se, exhaustMap as Ue, debounceTime as Se, distinctUntilChanged as z, throttleTime as on, startWith as Q, shareReplay as Z, switchScan as sn, defaultIfEmpty as rn, forkJoin as an, delay as ve, timer as $e, ReplaySubject as it, identity as we, skip as Pt, reduce as cn, concatMap as ot } from "rxjs";
1
+ import { switchMap as w, of as v, fromEvent as Y, take as wt, map as S, from as O, takeUntil as T, Observable as te, defer as ke, Subject as j, combineLatest as k, merge as x, EMPTY as G, NEVER as ge, tap as P, share as D, BehaviorSubject as W, withLatestFrom as A, filter as L, first as U, mergeMap as Pe, endWith as me, finalize as le, catchError as xt, lastValueFrom as tn, scheduled as nn, animationFrameScheduler as se, exhaustMap as Ue, debounceTime as Se, distinctUntilChanged as z, throttleTime as on, startWith as Q, shareReplay as Z, switchScan as sn, defaultIfEmpty as rn, forkJoin as an, delay as ve, timer as $e, ReplaySubject as it, identity as we, skip as Pt, reduce as cn, concatMap as ot } from "rxjs";
2
2
  import { Report as un, isShallowEqual as N, shallowMergeIfDefined as xe, getParentPath as ln, parseContentType as pn, detectMimeTypeFromName as Le, arrayEqual as dn } from "@prose-reader/shared";
3
3
  import { isShallowEqual as Zs } from "@prose-reader/shared";
4
4
  import { switchMap as _, first as $t, map as J, distinctUntilChanged as pe, startWith as gn, shareReplay as Me, tap as V, pairwise as hn, take as mn, takeUntil as q, filter as oe, debounceTime as fn, skip as Tt, mergeMap as yn, catchError as st } from "rxjs/operators";
@@ -582,8 +582,10 @@ const Hn = (n) => (e) => {
582
582
  };
583
583
  }, Bn = (n) => (e) => {
584
584
  const t = n(e), i = (o) => Y(o, "keyup").pipe(
585
- D(t.settings.values$),
586
- S(([s, { pageTurnDirection: r }]) => {
585
+ S((s) => {
586
+ const { pageTurnDirection: r, computedPageTurnMode: a } = t.settings.values;
587
+ if (a === "scrollable")
588
+ return s;
587
589
  if (r === "horizontal") {
588
590
  if (s.key === "ArrowRight")
589
591
  return t.navigation.turnRight();
@@ -634,7 +636,7 @@ const Hn = (n) => (e) => {
634
636
  P((e) => {
635
637
  e.preventDefault();
636
638
  }),
637
- R()
639
+ D()
638
640
  );
639
641
  class B {
640
642
  constructor() {
@@ -647,30 +649,30 @@ class B {
647
649
  const Fe = class Fe extends B {
648
650
  constructor(e) {
649
651
  super(), this.triggerSubject = new j(), this.stateSubject = new W("idle"), this.unload$ = this.triggerSubject.pipe(
650
- D(this.stateSubject),
652
+ A(this.stateSubject),
651
653
  L(
652
654
  ([o, s]) => o.type === "unload" && s !== "idle" && s !== "unloading"
653
655
  ),
654
656
  S(() => {
655
657
  }),
656
- R()
658
+ D()
657
659
  ), this.load$ = this.triggerSubject.pipe(
658
- D(this.stateSubject),
660
+ A(this.stateSubject),
659
661
  L(
660
662
  ([o, s]) => o.type === "load" && s !== "loaded" && s !== "loading"
661
663
  ),
662
664
  S(() => {
663
665
  }),
664
- R()
666
+ D()
665
667
  ), this.context = e.context, this.settings = e.settings, this.hookManager = e.hookManager, this.item = e.item, this.containerElement = e.containerElement, this.resourcesHandler = e.resourcesHandler, this.viewport = e.viewport;
666
668
  const t = this.triggerSubject.pipe(
667
- D(this.stateSubject),
669
+ A(this.stateSubject),
668
670
  L(
669
671
  ([o, s]) => o.type === "unload" && s !== "idle" && s !== "unloading"
670
672
  ),
671
673
  S(() => {
672
674
  }),
673
- R()
675
+ D()
674
676
  );
675
677
  this.loaded$ = this.load$.pipe(
676
678
  w(() => (this.stateSubject.next("loading"), this.onCreateDocument().pipe(U()).pipe(
@@ -697,7 +699,7 @@ const Fe = class Fe extends B {
697
699
  }),
698
700
  T(t)
699
701
  ))),
700
- R()
702
+ D()
701
703
  );
702
704
  const i = t.pipe(
703
705
  w(() => (this.stateSubject.next("unloading"), this.context.bridgeEvent.viewportFree$.pipe(
@@ -1635,9 +1637,9 @@ const Pi = (n) => k([
1635
1637
  const m = r.spineItemsManager.get(d.id), f = !!(d.mediaType ?? Le(d.href))?.startsWith("image/"), { pageHorizontalMargin: I = 0, pageVerticalMargin: b = 0 } = a.values, F = r.viewport.pageSize;
1636
1638
  if (m?.renditionLayout === "reflowable" && !f) {
1637
1639
  let $ = F.width - I * 2;
1638
- const A = F.height - b * 2;
1640
+ const R = F.height - b * 2;
1639
1641
  let X = F.width - I * 2, H = I * 2;
1640
- m.isUsingVerticalWriting() && (X = F.width - I * 2, $ = A, H = b * 2);
1642
+ m.isUsingVerticalWriting() && (X = F.width - I * 2, $ = R, H = b * 2);
1641
1643
  const ne = m?.renderer.getDocumentFrame();
1642
1644
  ne && ee(
1643
1645
  ne,
@@ -1648,11 +1650,11 @@ const Pi = (n) => k([
1648
1650
  margin: ${b}px ${I}px !important;
1649
1651
  column-gap: ${H}px !important;
1650
1652
  column-width: ${$}px !important;
1651
- height: ${A}px !important;
1653
+ height: ${R}px !important;
1652
1654
  }
1653
1655
  img, video, audio, object, svg {
1654
1656
  -max-width: ${$}px !important;
1655
- -max-height: ${A}px !important;
1657
+ -max-height: ${R}px !important;
1656
1658
  }
1657
1659
  table {
1658
1660
  max-width: ${$}px !important;
@@ -2379,7 +2381,7 @@ class Ui extends B {
2379
2381
  }
2380
2382
  }
2381
2383
  const zi = (n) => n.pagination.state$.pipe(
2382
- D(n.context.manifest$, n.settings.values$),
2384
+ A(n.context.manifest$, n.settings.values$),
2383
2385
  S(
2384
2386
  ([
2385
2387
  e,
@@ -2512,7 +2514,7 @@ const zi = (n) => n.pagination.state$.pipe(
2512
2514
  );
2513
2515
  }, Gi = (n, e, t, i, o) => o.isReady$.pipe(
2514
2516
  U(),
2515
- D(n.layoutInfo$),
2517
+ A(n.layoutInfo$),
2516
2518
  S(([s, r]) => {
2517
2519
  const a = n.context, c = a.manifest?.renditionLayout === "pre-paginated", u = a.manifest?.spineItems.length || 0, l = a.manifest?.spineItems.slice(0, e).reduce((f, I) => f + (I.progressionWeight ?? 0), 0) || 0, p = n.spineItemsManager.getSpineItemIndex(o) ?? 0, g = n.context.manifest?.spineItems.length ?? 0, h = r.pages.filter((f) => f.itemIndex === p).length ?? 0, d = a.manifest?.spineItems[e]?.progressionWeight ?? // if no progressionWeight is defined we "assume" the document weight to be
2518
2520
  // relative to the total number of documents
@@ -2532,7 +2534,7 @@ const zi = (n) => n.pagination.state$.pipe(
2532
2534
  })
2533
2535
  ), Zi = (n) => n.spine.layout$.pipe(
2534
2536
  Se(10, se),
2535
- D(n.pagination.state$),
2537
+ A(n.pagination.state$),
2536
2538
  S(() => ({
2537
2539
  numberOfPagesPerItems: n.spineItemsManager.items.reduce(
2538
2540
  (t, i) => [...t, i.numberOfPages],
@@ -2775,7 +2777,7 @@ const zi = (n) => n.pagination.state$.pipe(
2775
2777
  let t = n?.itemPageIndex;
2776
2778
  const { itemIndex: i, ...o } = e.cfi.parseCfi(n.cfi), s = e.spineItemsManager.get(i);
2777
2779
  return s ? Rt().pipe(
2778
- D(s.isReady$),
2780
+ A(s.isReady$),
2779
2781
  S(([, r]) => {
2780
2782
  const {
2781
2783
  node: a = null,
@@ -3163,19 +3165,19 @@ const go = (n) => n.watch("isLoaded").pipe(
3163
3165
  S((l) => !!l),
3164
3166
  z(),
3165
3167
  L((l) => l),
3166
- R()
3168
+ D()
3167
3169
  ), a = r.pipe(
3168
3170
  w(() => s),
3169
3171
  z(),
3170
3172
  L((l) => !l),
3171
- R()
3173
+ D()
3172
3174
  ), c = o.pipe(
3173
3175
  L((l) => l?.type === "over"),
3174
- R()
3176
+ D()
3175
3177
  ), u = t.context.watch("rootElement").pipe(
3176
3178
  L(Ge),
3177
3179
  w((l) => Y(l, "pointerdown")),
3178
- D(s),
3180
+ A(s),
3179
3181
  S(([, l]) => l),
3180
3182
  Q(void 0),
3181
3183
  Z({ refCount: !0, bufferSize: 1 })
@@ -3632,7 +3634,7 @@ class Mo extends B {
3632
3634
  );
3633
3635
  const r = this.spine.element$.pipe(
3634
3636
  L(Ge),
3635
- D(this.element$),
3637
+ A(this.element$),
3636
3638
  P(([l, p]) => {
3637
3639
  p.style.cssText = `
3638
3640
  height: 100%;
@@ -3656,7 +3658,7 @@ class Mo extends B {
3656
3658
  P(() => {
3657
3659
  ht.info("layout", e.values);
3658
3660
  }),
3659
- R()
3661
+ D()
3660
3662
  );
3661
3663
  const u = this.navigateSubject.pipe(
3662
3664
  P((l) => {
@@ -3843,7 +3845,7 @@ class Eo extends ae {
3843
3845
  (p) => t.watch(["computedPageTurnMode"]).pipe(
3844
3846
  w(
3845
3847
  ({ computedPageTurnMode: g }) => g === "controlled" ? ge : Y(p, "scroll").pipe(
3846
- D(l),
3848
+ A(l),
3847
3849
  L(
3848
3850
  ([, h]) => !h
3849
3851
  ),
@@ -3852,7 +3854,7 @@ class Eo extends ae {
3852
3854
  )
3853
3855
  )
3854
3856
  ),
3855
- R()
3857
+ D()
3856
3858
  ), x(r, a, c).pipe(T(this.destroy$)).subscribe();
3857
3859
  }
3858
3860
  update(e) {
@@ -3892,7 +3894,7 @@ const Do = () => (n) => n.pipe(
3892
3894
  ...i
3893
3895
  }))
3894
3896
  ), Ro = (n, e, t) => n.bridgeEvent.pagination$.pipe(
3895
- D(e),
3897
+ A(e),
3896
3898
  L(
3897
3899
  ([i, o]) => i.navigationId === o.id
3898
3900
  ),
@@ -4077,8 +4079,8 @@ const Do = () => (n) => n.pipe(
4077
4079
  position: F,
4078
4080
  threshold: p,
4079
4081
  restrictToScreen: !1
4080
- }), A = l === "forward" || l === "anchor" ? $?.beginIndex : $?.endIndex;
4081
- return e.get(A);
4082
+ }), R = l === "forward" || l === "anchor" ? $?.beginIndex : $?.endIndex;
4083
+ return e.get(R);
4082
4084
  }
4083
4085
  return a && g === "scrollable" ? i.getSpineItemFromPosition(a) : e.get(0);
4084
4086
  };
@@ -4388,7 +4390,7 @@ class Bo extends B {
4388
4390
  Z(1)
4389
4391
  ), this.locker = new Bt();
4390
4392
  const u = i.pipe(
4391
- D(this.navigationSubject),
4393
+ A(this.navigationSubject),
4392
4394
  Ao({
4393
4395
  navigationResolver: r
4394
4396
  }),
@@ -4428,7 +4430,7 @@ class Bo extends B {
4428
4430
  spineItemsManager: a.spineItemsManager,
4429
4431
  settings: e
4430
4432
  }),
4431
- D(c),
4433
+ A(c),
4432
4434
  w(([f, I]) => {
4433
4435
  const b = f.navigation.cfi || f.navigation.url || e.values.computedPageTurnMode === "scrollable" || I;
4434
4436
  return v(f).pipe(
@@ -4447,9 +4449,9 @@ class Bo extends B {
4447
4449
  navigationResolver: r
4448
4450
  }),
4449
4451
  S((f) => f.navigation),
4450
- R()
4452
+ D()
4451
4453
  ), l = u.pipe(
4452
- D(c),
4454
+ A(c),
4453
4455
  L(([, f]) => f),
4454
4456
  w(([f]) => {
4455
4457
  const I = this.locker.lock();
@@ -4468,7 +4470,7 @@ class Bo extends B {
4468
4470
  T(u)
4469
4471
  );
4470
4472
  }),
4471
- R()
4473
+ D()
4472
4474
  ), p = x(
4473
4475
  o.layout$,
4474
4476
  a.layout$
@@ -4539,7 +4541,7 @@ class Bo extends B {
4539
4541
  navigationResolver: r
4540
4542
  }),
4541
4543
  S(({ navigation: f }) => f),
4542
- R()
4544
+ D()
4543
4545
  ), h = Ro(
4544
4546
  t,
4545
4547
  this.navigationSubject,
@@ -4560,11 +4562,11 @@ class Bo extends B {
4560
4562
  })
4561
4563
  ), y = (f) => f.pipe(
4562
4564
  P(([I, b]) => {
4563
- const F = I.type === "scroll", $ = I.meta.triggeredBy === "pagination", A = I.meta.triggeredBy === "restoration", X = N(
4565
+ const F = I.type === "scroll", $ = I.meta.triggeredBy === "pagination", R = I.meta.triggeredBy === "restoration", X = N(
4564
4566
  b.position,
4565
4567
  I.position
4566
4568
  );
4567
- if (F && !A || $ || X)
4569
+ if (F && !R || $ || X)
4568
4570
  return;
4569
4571
  const H = {
4570
4572
  position: I.position,
@@ -4582,7 +4584,7 @@ class Bo extends B {
4582
4584
  })
4583
4585
  );
4584
4586
  d.pipe(
4585
- D(this.navigationSubject),
4587
+ A(this.navigationSubject),
4586
4588
  /**
4587
4589
  * @important
4588
4590
  *
@@ -5256,7 +5258,7 @@ class rs extends B {
5256
5258
  });
5257
5259
  return this.context.bridgeEvent.navigationUnlocked$.pipe(
5258
5260
  wt(1),
5259
- D(this.context.bridgeEvent.navigation$),
5261
+ A(this.context.bridgeEvent.navigation$),
5260
5262
  P(([, u]) => {
5261
5263
  const { position: l } = u, p = this.pagination.value, {
5262
5264
  beginIndex: g,
@@ -5272,9 +5274,9 @@ class rs extends B {
5272
5274
  }) ?? {}, { endPageIndex: b = 0 } = c({
5273
5275
  spineItem: m,
5274
5276
  position: l
5275
- }) ?? {}, F = y === void 0 || Be(y) || p.beginSpineItemIndex !== g, $ = p.endSpineItemIndex !== h || f === void 0 || Be(f), A = F ? he(d.item) : y, X = $ ? he(m.item) : f, H = d.numberOfPages, ne = m.numberOfPages;
5277
+ }) ?? {}, F = y === void 0 || Be(y) || p.beginSpineItemIndex !== g, $ = p.endSpineItemIndex !== h || f === void 0 || Be(f), R = F ? he(d.item) : y, X = $ ? he(m.item) : f, H = d.numberOfPages, ne = m.numberOfPages;
5276
5278
  this.pagination.update({
5277
- beginCfi: A,
5279
+ beginCfi: R,
5278
5280
  beginNumberOfPagesInSpineItem: H,
5279
5281
  beginPageIndexInSpineItem: I,
5280
5282
  beginSpineItemIndex: g,
@@ -5488,11 +5490,11 @@ class ps extends B {
5488
5490
  )
5489
5491
  );
5490
5492
  }),
5491
- R()
5493
+ D()
5492
5494
  ), this.layout$ = this.layoutProcess$.pipe(
5493
5495
  L((c) => c.type === "end"),
5494
5496
  S((c) => c.data),
5495
- R()
5497
+ D()
5496
5498
  );
5497
5499
  }
5498
5500
  validateDimension(e, t, i) {
@@ -5652,7 +5654,7 @@ class gs extends B {
5652
5654
  // be dangerous.
5653
5655
  Se(100, se),
5654
5656
  Ce(this.context.bridgeEvent.viewportFree$),
5655
- D(this.context.bridgeEvent.navigation$, r),
5657
+ A(this.context.bridgeEvent.navigation$, r),
5656
5658
  S(([, u, l]) => {
5657
5659
  const { numberOfAdjacentSpineItemToPreLoad: p } = o.values, { beginIndex: g = 0, endIndex: h = 0 } = i.getVisibleSpineItemsFromPosition({
5658
5660
  position: u.position,
@@ -5897,7 +5899,7 @@ const fs = ({
5897
5899
  useAbsoluteViewport: I = !0,
5898
5900
  viewport: b
5899
5901
  }) => {
5900
- const F = y.numberOfPages, A = Array.from(Array(F)).map((ne, Ie) => {
5902
+ const F = y.numberOfPages, R = Array.from(Array(F)).map((ne, Ie) => {
5901
5903
  const Ee = t.getSpineItemPositionFromPageIndex({
5902
5904
  pageIndex: Ie,
5903
5905
  spineItem: y
@@ -5934,7 +5936,7 @@ const fs = ({
5934
5936
  return en ? [...ne, Ee] : ne;
5935
5937
  },
5936
5938
  []
5937
- ), X = A[0], H = A[A.length - 1] ?? X;
5939
+ ), X = R[0], H = R[R.length - 1] ?? X;
5938
5940
  if (!(X === void 0 || H === void 0))
5939
5941
  return {
5940
5942
  beginPageIndex: X,
@@ -6036,7 +6038,7 @@ class xs extends ae {
6036
6038
  super({ pages: [] }), this.spineLayout = e, this.spineItemsManager = t, this.spineItemLocator = i, this.context = o, this.locator = s, this.viewport = r, this.fromSpineItemPageIndex = (a, c) => this.value.pages.find(
6037
6039
  (u) => u.itemIndex === a.index && u.pageIndex === c
6038
6040
  ), this.fromAbsolutePageIndex = (a) => this.value.pages.reduce((c, u) => c || (u.absolutePageIndex === a ? u : c), void 0), this.observeFromAbsolutePageIndex = (a) => this.pipe(S(() => this.fromAbsolutePageIndex(a))), this.layout$ = e.layout$.pipe(
6039
- D(r),
6041
+ A(r),
6040
6042
  w(([, { pageSize: a }]) => {
6041
6043
  const c = t.items.reduce(
6042
6044
  (l, p, g) => {
@@ -6089,7 +6091,7 @@ class xs extends ae {
6089
6091
  );
6090
6092
  }),
6091
6093
  S((a) => (vs.info("Pages layout", a), { pages: a })),
6092
- R()
6094
+ D()
6093
6095
  ), this.layout$.pipe(T(this.destroy$)).subscribe(this.next.bind(this));
6094
6096
  }
6095
6097
  }
@@ -6102,7 +6104,7 @@ class Ps extends B {
6102
6104
  );
6103
6105
  return x(...o);
6104
6106
  }),
6105
- R()
6107
+ D()
6106
6108
  ), this.itemResize$ = this.spineItemsManager.items$.pipe(
6107
6109
  w((i) => {
6108
6110
  const o = i.map(
@@ -6112,7 +6114,7 @@ class Ps extends B {
6112
6114
  );
6113
6115
  return x(...o);
6114
6116
  }),
6115
- R()
6117
+ D()
6116
6118
  );
6117
6119
  }
6118
6120
  }
@@ -6149,7 +6151,7 @@ const $s = ({
6149
6151
  top: I,
6150
6152
  left: b
6151
6153
  });
6152
- const F = d + b, $ = m + I, A = new _e({
6154
+ const F = d + b, $ = m + I, R = new _e({
6153
6155
  left: b,
6154
6156
  right: F,
6155
6157
  top: I,
@@ -6162,7 +6164,7 @@ const $s = ({
6162
6164
  return {
6163
6165
  horizontalOffset: F,
6164
6166
  verticalOffset: $,
6165
- layoutPosition: A
6167
+ layoutPosition: R
6166
6168
  };
6167
6169
  }
6168
6170
  a.layout.adjustPositionOfElement(
@@ -6267,7 +6269,7 @@ class Ts extends B {
6267
6269
  })
6268
6270
  );
6269
6271
  }),
6270
- R()
6272
+ D()
6271
6273
  ), x(this.layout$).pipe(T(this.destroy$)).subscribe();
6272
6274
  }
6273
6275
  layout() {
@@ -6530,13 +6532,13 @@ const Cs = (n) => {
6530
6532
  const m = () => {
6531
6533
  t.next();
6532
6534
  }, y = ($) => {
6533
- const { containerElement: A, manifest: X } = $;
6535
+ const { containerElement: R, manifest: X } = $;
6534
6536
  if (s.manifest) {
6535
6537
  E.warn("loading a new book is not supported yet");
6536
6538
  return;
6537
6539
  }
6538
6540
  E.log("load", { options: $ });
6539
- const H = Es(A, e);
6541
+ const H = Es(R, e);
6540
6542
  s.update({
6541
6543
  manifest: X,
6542
6544
  rootElement: H