@d-i-t-a/reader 2.0.0-beta.10 → 2.0.0-beta.13

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/esm/index.js CHANGED
@@ -52390,6 +52390,7 @@ var MediaOverlaySettings = class {
52390
52390
  this.volume = 1;
52391
52391
  this.rate = 1;
52392
52392
  this.playing = false;
52393
+ this.resourceReady = false;
52393
52394
  this.wait = 1;
52394
52395
  this.settingsChangeCallback = () => {
52395
52396
  };
@@ -52687,7 +52688,7 @@ var MediaOverlayModule = class {
52687
52688
  console.log("ontimeupdate");
52688
52689
  this.trackCurrentTime();
52689
52690
  };
52690
- this.ensureOnTimeUpdate = (remove) => {
52691
+ this.ensureOnTimeUpdate = (remove, replace) => {
52691
52692
  if (this.audioElement) {
52692
52693
  if (remove) {
52693
52694
  if (this.__ontimeupdate) {
@@ -52696,8 +52697,11 @@ var MediaOverlayModule = class {
52696
52697
  cancelAnimationFrame(this.myReq);
52697
52698
  }
52698
52699
  } else {
52699
- if (!this.__ontimeupdate) {
52700
+ if (!this.__ontimeupdate || replace) {
52700
52701
  this.__ontimeupdate = true;
52702
+ if (replace) {
52703
+ this.audioElement.removeEventListener("timeupdate", this.ontimeupdate);
52704
+ }
52701
52705
  this.audioElement.addEventListener("timeupdate", this.ontimeupdate);
52702
52706
  }
52703
52707
  }
@@ -52741,7 +52745,7 @@ var MediaOverlayModule = class {
52741
52745
  async playLink() {
52742
52746
  let link = this.currentLinks[this.currentLinkIndex];
52743
52747
  if (link?.Properties?.MediaOverlay) {
52744
- this.ensureOnTimeUpdate(false);
52748
+ this.ensureOnTimeUpdate(false, false);
52745
52749
  const moUrl = link.Properties?.MediaOverlay;
52746
52750
  const moUrlObjFull = new URL(moUrl, this.publication.manifestUrl);
52747
52751
  const moUrlFull = moUrlObjFull.toString();
@@ -52781,6 +52785,7 @@ var MediaOverlayModule = class {
52781
52785
  await this.playLink();
52782
52786
  } else {
52783
52787
  if (this.settings.autoTurn && this.settings.playing) {
52788
+ this.audioElement.pause();
52784
52789
  this.delegate.nextResource();
52785
52790
  } else {
52786
52791
  this.stopReadAloud();
@@ -52962,6 +52967,7 @@ var MediaOverlayModule = class {
52962
52967
  } else {
52963
52968
  this.audioElement.pause();
52964
52969
  if (this.settings.autoTurn && this.settings.playing) {
52970
+ this.audioElement.pause();
52965
52971
  this.delegate.nextResource();
52966
52972
  } else {
52967
52973
  this.stopReadAloud();
@@ -52999,6 +53005,7 @@ var MediaOverlayModule = class {
52999
53005
  } else {
53000
53006
  this.audioElement.pause();
53001
53007
  if (this.settings.autoTurn && this.settings.playing) {
53008
+ this.audioElement.pause();
53002
53009
  this.delegate.nextResource();
53003
53010
  } else {
53004
53011
  this.stopReadAloud();
@@ -53106,17 +53113,22 @@ var MediaOverlayModule = class {
53106
53113
  if (IS_DEV) {
53107
53114
  console.log("playMediaOverlaysAudio() - playClip() - _currentAudioElement.play()");
53108
53115
  }
53109
- this.ensureOnTimeUpdate(false);
53116
+ this.ensureOnTimeUpdate(false, false);
53110
53117
  this.audioElement.playbackRate = this.settings.rate;
53111
53118
  this.audioElement.volume = this.settings.volume;
53112
53119
  if (this.settings.playing) {
53113
- if (!initial) {
53114
- setTimeout(async () => {
53115
- await this.audioElement.play();
53116
- }, this.settings.wait);
53117
- } else {
53118
- await this.audioElement.play();
53119
- }
53120
+ let checkReady = function() {
53121
+ if (!self2.settings.resourceReady) {
53122
+ setTimeout(checkReady, 200);
53123
+ } else {
53124
+ setTimeout(async () => {
53125
+ await self2.audioElement.play();
53126
+ self2.ensureOnTimeUpdate(false, true);
53127
+ }, self2.settings.wait * 1200);
53128
+ }
53129
+ };
53130
+ let self2 = this;
53131
+ checkReady();
53120
53132
  }
53121
53133
  } else {
53122
53134
  if (IS_DEV) {
@@ -53127,18 +53139,23 @@ var MediaOverlayModule = class {
53127
53139
  if (IS_DEV) {
53128
53140
  console.log("playMediaOverlaysAudio() - playClip() - ontimeupdateSeeked - .play()");
53129
53141
  }
53130
- this.ensureOnTimeUpdate(false);
53142
+ this.ensureOnTimeUpdate(false, false);
53131
53143
  if (this.audioElement) {
53132
53144
  this.audioElement.playbackRate = this.settings.rate;
53133
53145
  this.audioElement.volume = this.settings.volume;
53134
53146
  if (this.settings.playing) {
53135
- if (!initial) {
53136
- setTimeout(async () => {
53137
- await this.audioElement.play();
53138
- }, this.settings.wait);
53139
- } else {
53140
- await this.audioElement.play();
53141
- }
53147
+ let checkReady = function() {
53148
+ if (!self2.settings.resourceReady) {
53149
+ setTimeout(checkReady, 200);
53150
+ } else {
53151
+ setTimeout(async () => {
53152
+ await self2.audioElement.play();
53153
+ self2.ensureOnTimeUpdate(false, true);
53154
+ }, self2.settings.wait * 1200);
53155
+ }
53156
+ };
53157
+ let self2 = this;
53158
+ checkReady();
53142
53159
  }
53143
53160
  }
53144
53161
  };
@@ -53147,7 +53164,7 @@ var MediaOverlayModule = class {
53147
53164
  }
53148
53165
  } else {
53149
53166
  const contiguous = this.previousAudioUrl === this.currentAudioUrl && typeof this.previousAudioEnd !== "undefined" && this.previousAudioEnd > timeToSeekTo - 0.02 && this.previousAudioEnd <= timeToSeekTo && this.audioElement.currentTime >= timeToSeekTo - 0.1;
53150
- this.ensureOnTimeUpdate(false);
53167
+ this.ensureOnTimeUpdate(false, false);
53151
53168
  if (contiguous) {
53152
53169
  if (IS_DEV) {
53153
53170
  console.log("playMediaOverlaysAudio() - playClip() - ensureOnTimeUpdate");
@@ -53204,6 +53221,7 @@ var MediaOverlayModule = class {
53204
53221
  await this.playLink();
53205
53222
  } else {
53206
53223
  if (this.settings.autoTurn && this.settings.playing) {
53224
+ this.audioElement.pause();
53207
53225
  this.delegate.nextResource();
53208
53226
  } else {
53209
53227
  this.stopReadAloud();
@@ -53795,18 +53813,25 @@ var ContentProtectionModule = class {
53795
53813
  }
53796
53814
  }
53797
53815
  recalculate(delay2 = 0) {
53798
- if (this.properties?.enableObfuscation) {
53799
- const onDoResize = (0, import_debounce3.debounce)(() => {
53800
- this.calcRects(this.rects);
53801
- if (this.rects !== void 0) {
53802
- this.rects.forEach((rect) => this.toggleRect(rect, this.securityContainer, this.isHacked));
53816
+ return new Promise((resolve) => {
53817
+ if (this.properties?.enableObfuscation) {
53818
+ const onDoResize = (0, import_debounce3.debounce)(() => {
53819
+ this.calcRects(this.rects);
53820
+ if (this.rects !== void 0) {
53821
+ this.rects.forEach((rect) => this.toggleRect(rect, this.securityContainer, this.isHacked));
53822
+ }
53823
+ resolve(true);
53824
+ }, delay2);
53825
+ if (this.rects) {
53826
+ this.observe();
53827
+ onDoResize();
53828
+ } else {
53829
+ resolve(false);
53803
53830
  }
53804
- }, delay2);
53805
- if (this.rects) {
53806
- this.observe();
53807
- onDoResize();
53831
+ } else {
53832
+ resolve(false);
53808
53833
  }
53809
- }
53834
+ });
53810
53835
  }
53811
53836
  calcRects(rects) {
53812
53837
  if (rects !== void 0) {
@@ -56089,6 +56114,11 @@ var IFrameNavigator = class extends import_events.default {
56089
56114
  this.view?.goToProgression(bookViewPosition);
56090
56115
  }
56091
56116
  this.newPosition = void 0;
56117
+ if (this.rights?.enableContentProtection) {
56118
+ if (this.contentProtectionModule !== void 0) {
56119
+ await this.contentProtectionModule.recalculate(10);
56120
+ }
56121
+ }
56092
56122
  this.hideLoadingMessage();
56093
56123
  this.showIframeContents();
56094
56124
  if (this.rights.enableMediaOverlays && this.mediaOverlayModule !== void 0 && this.hasMediaOverlays) {
@@ -56097,6 +56127,11 @@ var IFrameNavigator = class extends import_events.default {
56097
56127
  }
56098
56128
  await this.updatePositionInfo();
56099
56129
  await this.view?.setSize();
56130
+ setTimeout(() => {
56131
+ if (this.mediaOverlayModule !== void 0) {
56132
+ this.mediaOverlayModule.settings.resourceReady = true;
56133
+ }
56134
+ }, 300);
56100
56135
  }, 200);
56101
56136
  return new Promise((resolve) => resolve());
56102
56137
  } catch (err) {
@@ -57401,6 +57436,9 @@ var IFrameNavigator = class extends import_events.default {
57401
57436
  this.loadingMessage.style.display = "block";
57402
57437
  this.loadingMessage.classList.add("is-loading");
57403
57438
  }
57439
+ if (this.mediaOverlayModule !== void 0) {
57440
+ this.mediaOverlayModule.settings.resourceReady = false;
57441
+ }
57404
57442
  }
57405
57443
  hideIframeContents() {
57406
57444
  this.isBeingStyled = true;