@d-i-t-a/reader 2.3.8 → 2.3.10

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
@@ -12262,7 +12262,7 @@ var require_parse = __commonJS({
12262
12262
  try {
12263
12263
  parser.parse();
12264
12264
  } catch (e) {
12265
- if (false) {
12265
+ if (true) {
12266
12266
  if (e.name === "CssSyntaxError" && opts && opts.from) {
12267
12267
  if (/\.scss$/i.test(opts.from)) {
12268
12268
  e.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser";
@@ -12456,7 +12456,7 @@ var require_lazy_result = __commonJS({
12456
12456
  return this.css;
12457
12457
  }
12458
12458
  then(onFulfilled, onRejected) {
12459
- if (false) {
12459
+ if (true) {
12460
12460
  if (!("from" in this.opts)) {
12461
12461
  warnOnce("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
12462
12462
  }
@@ -12603,7 +12603,7 @@ var require_lazy_result = __commonJS({
12603
12603
  error.plugin = plugin.postcssPlugin;
12604
12604
  error.setMessage();
12605
12605
  } else if (plugin.postcssVersion) {
12606
- if (false) {
12606
+ if (true) {
12607
12607
  let pluginName = plugin.postcssPlugin;
12608
12608
  let pluginVer = plugin.postcssVersion;
12609
12609
  let runtimeVer = this.result.processor.version;
@@ -12849,7 +12849,7 @@ var require_no_work_result = __commonJS({
12849
12849
  return this._css;
12850
12850
  }
12851
12851
  then(onFulfilled, onRejected) {
12852
- if (false) {
12852
+ if (true) {
12853
12853
  if (!("from" in this._opts)) {
12854
12854
  warnOnce("Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.");
12855
12855
  }
@@ -12918,7 +12918,7 @@ var require_processor = __commonJS({
12918
12918
  } else if (typeof i === "function") {
12919
12919
  normalized.push(i);
12920
12920
  } else if (typeof i === "object" && (i.parse || i.stringify)) {
12921
- if (false) {
12921
+ if (true) {
12922
12922
  throw new Error("PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation.");
12923
12923
  }
12924
12924
  } else {
@@ -52528,7 +52528,9 @@ var TextHighlighter = class {
52528
52528
  let drawUnderline = false;
52529
52529
  let drawStrikeThrough = false;
52530
52530
  let drawBackground = false;
52531
- const doNotMergeHorizontallyAlignedRects = drawUnderline || drawStrikeThrough || drawBackground;
52531
+ let doNotMergeHorizontallyAlignedRects = drawUnderline || drawStrikeThrough || drawBackground;
52532
+ import_loglevel5.default.debug(doNotMergeHorizontallyAlignedRects);
52533
+ doNotMergeHorizontallyAlignedRects = true;
52532
52534
  const clientRects = getClientRectsNoOverlap(range, doNotMergeHorizontallyAlignedRects);
52533
52535
  const roundedCorner = 3;
52534
52536
  const underlineThickness = 2;
@@ -55228,7 +55230,7 @@ function delay(t, v) {
55228
55230
  setTimeout(resolve.bind(null, v), t);
55229
55231
  });
55230
55232
  }
55231
- var IS_DEV = false;
55233
+ var IS_DEV = true;
55232
55234
  import_loglevel13.default.setLevel(IS_DEV ? "trace" : "warn", true);
55233
55235
 
55234
55236
  // src/modules/protection/ContentProtectionModule.ts
@@ -57473,11 +57475,6 @@ var TTSModule2 = class {
57473
57475
  let doc = this.navigator.iframes[0].contentDocument;
57474
57476
  if (doc) {
57475
57477
  let selection = this.highlighter.dom(doc.body).getSelection();
57476
- if (selection.isCollapsed) {
57477
- let doc2 = this.navigator.iframes[0].contentDocument;
57478
- const selectionInfo = this.navigator.annotationModule?.annotator?.getTemporarySelectionInfo(doc2);
57479
- selection.addRange(selectionInfo.range);
57480
- }
57481
57478
  let range = selection.getRangeAt(0);
57482
57479
  let node = selection.anchorNode;
57483
57480
  while (range.toString().indexOf(" ") !== 0) {
@@ -57560,6 +57557,11 @@ var TTSModule2 = class {
57560
57557
  }
57561
57558
  }
57562
57559
  async speak(selectionInfo, partial, callback) {
57560
+ if (!partial) {
57561
+ if (this.navigator.rights.enableContentProtection) {
57562
+ this.navigator.contentProtectionModule?.deactivate();
57563
+ }
57564
+ }
57563
57565
  if (this.api?.started)
57564
57566
  this.api?.started();
57565
57567
  this.navigator.emit("readaloud.started", "started");
@@ -57616,6 +57618,10 @@ var TTSModule2 = class {
57616
57618
  restOfTheText = restOfTheText.replace(textToBeSpoken, "").trim();
57617
57619
  }
57618
57620
  utterance = new SpeechSynthesisUtterance(textToBeSpoken);
57621
+ utterance.rate = this.tts.rate;
57622
+ utterance.pitch = this.tts.pitch;
57623
+ utterance.volume = this.tts.volume;
57624
+ this.setVoice(this, utterance);
57619
57625
  import_loglevel18.default.log(selectionInfo);
57620
57626
  import_loglevel18.default.log(textToBeSpoken, selectionInfo.range?.commonAncestorContainer.textContent);
57621
57627
  import_loglevel18.default.log(ttsQueueItem);
@@ -57638,19 +57644,85 @@ var TTSModule2 = class {
57638
57644
  utterance.rate = this.tts.rate;
57639
57645
  utterance.pitch = this.tts.pitch;
57640
57646
  utterance.volume = this.tts.volume;
57647
+ this.setVoice(self2, utterance);
57648
+ this.index = 0;
57649
+ function onend() {
57650
+ utterance.onend = function() {
57651
+ if (idxEnd > idx) {
57652
+ idx = idx + 1;
57653
+ if (idx !== idxEnd) {
57654
+ const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
57655
+ if (ttsQueueItem) {
57656
+ const sentence = getTtsQueueItemRefText(ttsQueueItem);
57657
+ utterance = new SpeechSynthesisUtterance(sentence);
57658
+ utterance.rate = self2.tts.rate;
57659
+ utterance.pitch = self2.tts.pitch;
57660
+ utterance.volume = self2.tts.volume;
57661
+ self2.setVoice(self2, utterance);
57662
+ utterance.onboundary = (ev) => {
57663
+ self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
57664
+ };
57665
+ setTimeout(() => {
57666
+ window.speechSynthesis.speak(utterance);
57667
+ }, 0);
57668
+ onend();
57669
+ }
57670
+ } else {
57671
+ const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
57672
+ if (ttsQueueItem) {
57673
+ utterance = new SpeechSynthesisUtterance(restOfTheText);
57674
+ utterance.rate = self2.tts.rate;
57675
+ utterance.pitch = self2.tts.pitch;
57676
+ utterance.volume = self2.tts.volume;
57677
+ self2.setVoice(self2, utterance);
57678
+ utterance.onboundary = (ev) => {
57679
+ self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
57680
+ };
57681
+ setTimeout(() => {
57682
+ window.speechSynthesis.speak(utterance);
57683
+ }, 0);
57684
+ onend();
57685
+ }
57686
+ if (idx > idxEnd) {
57687
+ import_loglevel18.default.log("utterance ended");
57688
+ self2.highlighter.doneSpeaking();
57689
+ self2.api?.finished();
57690
+ self2.navigator.emit("readaloud.finished", "finished");
57691
+ }
57692
+ }
57693
+ } else {
57694
+ import_loglevel18.default.log("utterance ended");
57695
+ self2.highlighter.doneSpeaking();
57696
+ self2.api?.finished();
57697
+ self2.navigator.emit("readaloud.finished", "finished");
57698
+ }
57699
+ };
57700
+ }
57701
+ setTimeout(() => {
57702
+ window.speechSynthesis.speak(utterance);
57703
+ if (!partial) {
57704
+ if (this.navigator.rights.enableContentProtection) {
57705
+ this.navigator.contentProtectionModule?.recalculate(200);
57706
+ }
57707
+ }
57708
+ }, 0);
57709
+ onend();
57710
+ callback();
57711
+ }
57712
+ setVoice(self2, utterance) {
57641
57713
  import_loglevel18.default.log("this.tts.voice.lang", this.tts.voice.lang);
57642
- var initialVoiceHasHyphen = true;
57714
+ let initialVoiceHasHyphen = true;
57643
57715
  if (this.tts.voice && this.tts.voice.lang) {
57644
57716
  initialVoiceHasHyphen = this.tts.voice.lang.indexOf("-") !== -1;
57645
- if (initialVoiceHasHyphen === false) {
57717
+ if (!initialVoiceHasHyphen) {
57646
57718
  this.tts.voice.lang = this.tts.voice.lang.replace("_", "-");
57647
57719
  initialVoiceHasHyphen = true;
57648
57720
  }
57649
57721
  }
57650
57722
  import_loglevel18.default.log("initialVoiceHasHyphen", initialVoiceHasHyphen);
57651
57723
  import_loglevel18.default.log("voices", this.voices);
57652
- var initialVoice;
57653
- if (initialVoiceHasHyphen === true) {
57724
+ let initialVoice;
57725
+ if (initialVoiceHasHyphen) {
57654
57726
  initialVoice = this.tts.voice && this.tts.voice.lang && this.tts.voice.name ? this.voices.filter((v) => {
57655
57727
  var lang = v.lang.replace("_", "-");
57656
57728
  return lang === this.tts.voice.lang && v.name === this.tts.voice.name;
@@ -57667,10 +57739,10 @@ var TTSModule2 = class {
57667
57739
  }
57668
57740
  }
57669
57741
  import_loglevel18.default.log("initialVoice", initialVoice);
57670
- var publicationVoiceHasHyphen = self2.navigator.publication.Metadata.Language[0].indexOf("-") !== -1;
57742
+ const publicationVoiceHasHyphen = self2.navigator.publication.Metadata.Language[0].indexOf("-") !== -1;
57671
57743
  import_loglevel18.default.log("publicationVoiceHasHyphen", publicationVoiceHasHyphen);
57672
- var publicationVoice;
57673
- if (publicationVoiceHasHyphen === true) {
57744
+ let publicationVoice;
57745
+ if (publicationVoiceHasHyphen) {
57674
57746
  publicationVoice = this.tts.voice && this.tts.voice.usePublication ? this.voices.filter((v) => {
57675
57747
  var lang = v.lang.replace("_", "-");
57676
57748
  return lang.startsWith(self2.navigator.publication.Metadata.Language[0]) || lang.endsWith(self2.navigator.publication.Metadata.Language[0].toUpperCase());
@@ -57681,24 +57753,24 @@ var TTSModule2 = class {
57681
57753
  })[0] : void 0;
57682
57754
  }
57683
57755
  import_loglevel18.default.log("publicationVoice", publicationVoice);
57684
- var defaultVoiceHasHyphen = navigator.language.indexOf("-") !== -1;
57756
+ const defaultVoiceHasHyphen = navigator.language.indexOf("-") !== -1;
57685
57757
  import_loglevel18.default.log("defaultVoiceHasHyphen", defaultVoiceHasHyphen);
57686
- var defaultVoice;
57687
- if (defaultVoiceHasHyphen === true) {
57758
+ let defaultVoice;
57759
+ if (defaultVoiceHasHyphen) {
57688
57760
  defaultVoice = this.voices.filter((voice) => {
57689
- var lang = voice.lang.replace("_", "-");
57690
- return lang === navigator.language && voice.localService === true;
57761
+ const lang = voice.lang.replace("_", "-");
57762
+ return lang === navigator.language && voice.localService;
57691
57763
  })[0];
57692
57764
  } else {
57693
57765
  defaultVoice = this.voices.filter((voice) => {
57694
- var lang = voice.lang;
57695
- return lang === navigator.language && voice.localService === true;
57766
+ const lang = voice.lang;
57767
+ return lang === navigator.language && voice.localService;
57696
57768
  })[0];
57697
57769
  }
57698
57770
  if (defaultVoice === void 0) {
57699
57771
  defaultVoice = this.voices.filter((voice) => {
57700
- var lang = voice.lang;
57701
- return lang.includes(navigator.language) && voice.localService === true;
57772
+ const lang = voice.lang;
57773
+ return lang.includes(navigator.language) && voice.localService;
57702
57774
  })[0];
57703
57775
  }
57704
57776
  import_loglevel18.default.log("defaultVoice", defaultVoice);
@@ -57718,58 +57790,11 @@ var TTSModule2 = class {
57718
57790
  import_loglevel18.default.log("utterance.lang", utterance.lang);
57719
57791
  }
57720
57792
  import_loglevel18.default.log("navigator.language", navigator.language);
57721
- setTimeout(() => {
57722
- window.speechSynthesis.speak(utterance);
57723
- }, 0);
57724
- this.index = 0;
57725
- function onend() {
57726
- utterance.onend = function() {
57727
- if (idxEnd > idx) {
57728
- idx = idx + 1;
57729
- if (idx !== idxEnd) {
57730
- const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
57731
- if (ttsQueueItem) {
57732
- const sentence = getTtsQueueItemRefText(ttsQueueItem);
57733
- utterance = new SpeechSynthesisUtterance(sentence);
57734
- utterance.onboundary = (ev) => {
57735
- self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
57736
- };
57737
- setTimeout(() => {
57738
- window.speechSynthesis.speak(utterance);
57739
- }, 0);
57740
- onend();
57741
- }
57742
- } else {
57743
- const ttsQueueItem = getTtsQueueItemRef(ttsQueue, idx);
57744
- if (ttsQueueItem) {
57745
- utterance = new SpeechSynthesisUtterance(restOfTheText);
57746
- utterance.onboundary = (ev) => {
57747
- self2.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
57748
- };
57749
- setTimeout(() => {
57750
- window.speechSynthesis.speak(utterance);
57751
- }, 0);
57752
- onend();
57753
- }
57754
- if (idx > idxEnd) {
57755
- import_loglevel18.default.log("utterance ended");
57756
- self2.highlighter.doneSpeaking();
57757
- self2.api?.finished();
57758
- self2.navigator.emit("readaloud.finished", "finished");
57759
- }
57760
- }
57761
- } else {
57762
- import_loglevel18.default.log("utterance ended");
57763
- self2.highlighter.doneSpeaking();
57764
- self2.api?.finished();
57765
- self2.navigator.emit("readaloud.finished", "finished");
57766
- }
57767
- };
57768
- }
57769
- onend();
57770
- callback();
57771
57793
  }
57772
57794
  speakPlay() {
57795
+ if (this.navigator.rights.enableContentProtection) {
57796
+ this.navigator.contentProtectionModule?.deactivate();
57797
+ }
57773
57798
  this.scrollPartial = true;
57774
57799
  this.cancel(false);
57775
57800
  if (this.api?.started)
@@ -57819,6 +57844,9 @@ var TTSModule2 = class {
57819
57844
  this.startTTSSession(ttsQueue, ttsQueueIndex);
57820
57845
  }, 200);
57821
57846
  }
57847
+ if (this.navigator.rights.enableContentProtection) {
57848
+ this.navigator.contentProtectionModule?.recalculate(200);
57849
+ }
57822
57850
  }
57823
57851
  speakPause() {
57824
57852
  if (window.speechSynthesis.speaking) {
@@ -58033,87 +58061,8 @@ var TTSModule2 = class {
58033
58061
  utterance.rate = this.tts.rate;
58034
58062
  utterance.pitch = this.tts.pitch;
58035
58063
  utterance.volume = this.tts.volume;
58036
- import_loglevel18.default.log("this.tts.voice.lang", this.tts.voice.lang);
58037
- var initialVoiceHasHyphen = true;
58038
- if (this.tts.voice && this.tts.voice.lang) {
58039
- initialVoiceHasHyphen = this.tts.voice.lang.indexOf("-") !== -1;
58040
- if (initialVoiceHasHyphen === false) {
58041
- this.tts.voice.lang = this.tts.voice.lang.replace("_", "-");
58042
- initialVoiceHasHyphen = true;
58043
- }
58044
- }
58045
- import_loglevel18.default.log("initialVoiceHasHyphen", initialVoiceHasHyphen);
58046
- import_loglevel18.default.log("voices", this.voices);
58047
- var initialVoice;
58048
- if (initialVoiceHasHyphen === true) {
58049
- initialVoice = this.tts.voice && this.tts.voice.lang && this.tts.voice.name ? this.voices.filter((v) => {
58050
- var lang = v.lang.replace("_", "-");
58051
- return lang === this.tts.voice.lang && v.name === this.tts.voice.name;
58052
- })[0] : void 0;
58053
- if (initialVoice === void 0) {
58054
- initialVoice = this.tts.voice && this.tts.voice.lang ? this.voices.filter((v) => v.lang.replace("_", "-") === this.tts.voice.lang)[0] : void 0;
58055
- }
58056
- } else {
58057
- initialVoice = this.tts.voice && this.tts.voice.lang && this.tts.voice.name ? this.voices.filter((v) => {
58058
- return v.lang === this.tts.voice.lang && v.name === this.tts.voice.name;
58059
- })[0] : void 0;
58060
- if (initialVoice === void 0) {
58061
- initialVoice = this.tts.voice && this.tts.voice.lang ? this.voices.filter((v) => v.lang === this.tts.voice.lang)[0] : void 0;
58062
- }
58063
- }
58064
- import_loglevel18.default.log("initialVoice", initialVoice);
58065
- var self2 = this;
58066
- var publicationVoiceHasHyphen = self2.navigator.publication.Metadata.Language[0].indexOf("-") !== -1;
58067
- import_loglevel18.default.log("publicationVoiceHasHyphen", publicationVoiceHasHyphen);
58068
- var publicationVoice;
58069
- if (publicationVoiceHasHyphen === true) {
58070
- publicationVoice = this.tts.voice && this.tts.voice.usePublication ? this.voices.filter((v) => {
58071
- var lang = v.lang.replace("_", "-");
58072
- return lang.startsWith(self2.navigator.publication.Metadata.Language[0]) || lang.endsWith(self2.navigator.publication.Metadata.Language[0].toUpperCase());
58073
- })[0] : void 0;
58074
- } else {
58075
- publicationVoice = this.tts.voice && this.tts.voice.usePublication ? this.voices.filter((v) => {
58076
- return v.lang.startsWith(self2.navigator.publication.Metadata.Language[0]) || v.lang.endsWith(self2.navigator.publication.Metadata.Language[0].toUpperCase());
58077
- })[0] : void 0;
58078
- }
58079
- import_loglevel18.default.log("publicationVoice", publicationVoice);
58080
- var defaultVoiceHasHyphen = navigator.language.indexOf("-") !== -1;
58081
- import_loglevel18.default.log("defaultVoiceHasHyphen", defaultVoiceHasHyphen);
58082
- var defaultVoice;
58083
- if (defaultVoiceHasHyphen === true) {
58084
- defaultVoice = this.voices.filter((voice) => {
58085
- var lang = voice.lang.replace("_", "-");
58086
- return lang === navigator.language && voice.localService === true;
58087
- })[0];
58088
- } else {
58089
- defaultVoice = this.voices.filter((voice) => {
58090
- var lang = voice.lang;
58091
- return lang === navigator.language && voice.localService === true;
58092
- })[0];
58093
- }
58094
- if (defaultVoice === void 0) {
58095
- defaultVoice = this.voices.filter((voice) => {
58096
- var lang = voice.lang;
58097
- return lang.includes(navigator.language) && voice.localService === true;
58098
- })[0];
58099
- }
58100
- import_loglevel18.default.log("defaultVoice", defaultVoice);
58101
- if (initialVoice) {
58102
- import_loglevel18.default.log("initialVoice");
58103
- utterance.voice = initialVoice;
58104
- } else if (publicationVoice) {
58105
- import_loglevel18.default.log("publicationVoice");
58106
- utterance.voice = publicationVoice;
58107
- } else if (defaultVoice) {
58108
- import_loglevel18.default.log("defaultVoice");
58109
- utterance.voice = defaultVoice;
58110
- }
58111
- if (utterance.voice !== void 0 && utterance.voice !== null) {
58112
- utterance.lang = utterance.voice.lang;
58113
- import_loglevel18.default.log("utterance.voice.lang", utterance.voice.lang);
58114
- import_loglevel18.default.log("utterance.lang", utterance.lang);
58115
- }
58116
- import_loglevel18.default.log("navigator.language", navigator.language);
58064
+ const self2 = this;
58065
+ this.setVoice(self2, utterance);
58117
58066
  utterance.onboundary = (ev) => {
58118
58067
  import_loglevel18.default.log(ev.name);
58119
58068
  this.updateTTSInfo(ttsQueueItem, ev.charIndex, ev.charLength, 0, utterance.text);
@@ -58208,7 +58157,7 @@ var TTSModule2 = class {
58208
58157
  const range = new Range();
58209
58158
  range.setStart(rangeStartNode, rangeStartOffset);
58210
58159
  range.setEnd(rangeEndNode, rangeEndOffset);
58211
- var self2 = this;
58160
+ const self2 = this;
58212
58161
  const rangeInfo = convertRange(range, getCssSelector);
58213
58162
  if (!rangeInfo) {
58214
58163
  return;