@prose-reader/core 1.366.0 → 1.368.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
@@ -4276,25 +4276,30 @@ var ai = (e) => (t) => e(t), oi = (e, t, n) => {
4276
4276
  this.spineItemsManager.items.forEach((e) => {
4277
4277
  e.markDirty();
4278
4278
  });
4279
- }), ee((e) => e.immediate ? D(void 0) : ve(50)), A(() => this.spineItemsManager.items.reduce((t, a, o) => t.pipe(y(({ horizontalOffset: t, verticalOffset: s }) => {
4280
- let c = t % i.absoluteViewport.width === 0, l = o === e.items.length - 1, u = r.values.computedPageTurnDirection === "vertical", d = n.isRTL(), f = this.getSpreadPosition(c, d), { edgeX: p, edgeY: m } = this.getStartEdges(u, c, t, s, i.absoluteViewport.height);
4281
- return a.layout({
4282
- spreadPosition: f,
4283
- horizontalOffset: t,
4284
- isLastItem: l,
4285
- edgeX: p,
4286
- edgeY: m
4287
- }).pipe(T(({ width: e, height: t }) => {
4288
- let n = this.createSpineItemLayout(u, d, p, m, e, t, i.absoluteViewport.width);
4289
- return this.spineItemsRelativeLayouts[o] = n, {
4290
- horizontalOffset: p + e,
4291
- verticalOffset: u ? m + t : 0
4292
- };
4279
+ }), ee((e) => e.immediate ? D(void 0) : ve(50)), A(() => {
4280
+ let t = [];
4281
+ return this.spineItemsManager.items.reduce((a, o, s) => a.pipe(y(({ horizontalOffset: a, verticalOffset: c }) => {
4282
+ let l = a % i.absoluteViewport.width === 0, u = s === e.items.length - 1, d = r.values.computedPageTurnDirection === "vertical", f = n.isRTL(), p = this.getSpreadPosition(l, f), { edgeX: m, edgeY: h } = this.getStartEdges(d, l, a, c, i.absoluteViewport.height);
4283
+ return o.layout({
4284
+ spreadPosition: p,
4285
+ horizontalOffset: a,
4286
+ isLastItem: u,
4287
+ edgeX: m,
4288
+ edgeY: h
4289
+ }).pipe(T(({ width: e, height: n }) => {
4290
+ let r = this.createSpineItemLayout(d, f, m, h, e, n, i.absoluteViewport.width);
4291
+ return t[s] = r, {
4292
+ horizontalOffset: m + e,
4293
+ verticalOffset: d ? h + n : 0
4294
+ };
4295
+ }));
4296
+ })), D({
4297
+ horizontalOffset: 0,
4298
+ verticalOffset: 0
4299
+ })).pipe(M(() => {
4300
+ this.spineItemsRelativeLayouts = t;
4293
4301
  }));
4294
- })), D({
4295
- horizontalOffset: 0,
4296
- verticalOffset: 0
4297
- }))), j(this.destroy$), O()), this.layout$.subscribe(), this.watchForVerticalWritingUpdate();
4302
+ }), j(this.destroy$), O()), this.layout$.subscribe(), this.watchForVerticalWritingUpdate();
4298
4303
  }
4299
4304
  watchForVerticalWritingUpdate() {
4300
4305
  this.spineItemsObserver.itemLoad$.pipe(M((e) => {
@@ -4511,7 +4516,7 @@ var ai = (e) => (t) => e(t), oi = (e, t, n) => {
4511
4516
  }, this.unload = () => {
4512
4517
  this.renderer.unload();
4513
4518
  }, this.markDirty = () => {
4514
- this.mergeCompare({ isDirty: !0 });
4519
+ this.updateState({ isDirty: !0 });
4515
4520
  }, this.destroy = () => {
4516
4521
  this.isDestroyed || (super.destroy(), this._layout.destroy(), this.renderer.destroy(), this.containerElement.remove());
4517
4522
  }, this.isUsingVerticalWriting = () => !!this.renderer.writingMode?.startsWith("vertical"), this.layout = (e) => this._layout.layout(e), this.containerElement = $a(e, t.document);
@@ -4528,19 +4533,29 @@ var ai = (e) => (t) => e(t), oi = (e, t, n) => {
4528
4533
  };
4529
4534
  this.renderer = o ? o(s) : new Xa(s), this._layout = new Za(e, this.containerElement, t, r, this.renderer, this.settings, this.viewport);
4530
4535
  let c = this.renderer.state$.pipe(I(({ state: e, error: t }) => {
4531
- this.mergeCompare({
4536
+ this.updateState({
4532
4537
  isLoaded: e === "loaded",
4533
4538
  isError: e === "error",
4534
4539
  error: e === "error" ? t : void 0
4535
4540
  });
4536
4541
  }));
4537
4542
  this.didLayout$ = this._layout.didLayout$.pipe(I(() => {
4538
- this.mergeCompare({
4543
+ this.updateState({
4539
4544
  isDirty: !1,
4540
- isReady: this.renderer.value.state === "loaded"
4545
+ isReady: !0
4541
4546
  });
4542
4547
  }), Te()), E(c, this.didLayout$).pipe(F(this.destroy$)).subscribe();
4543
4548
  }
4549
+ updateState(e) {
4550
+ let t = {
4551
+ ...this.value,
4552
+ ...e
4553
+ };
4554
+ this.mergeCompare({
4555
+ ...t,
4556
+ isReady: t.isReady && t.isLoaded
4557
+ });
4558
+ }
4544
4559
  get isReady$() {
4545
4560
  return this.watch("isReady");
4546
4561
  }