@d-i-t-a/reader 2.4.2 → 2.4.3

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
@@ -15518,53 +15518,76 @@ var require_loglevel = __commonJS({
15518
15518
  var require_debounce = __commonJS({
15519
15519
  "node_modules/debounce/index.js"(exports2, module2) {
15520
15520
  init_polyfills();
15521
- function debounce8(func, wait, immediate) {
15522
- var timeout, args, context, timestamp, result;
15523
- if (null == wait)
15524
- wait = 100;
15521
+ function debounce8(function_, wait = 100, options = {}) {
15522
+ if (typeof function_ !== "function") {
15523
+ throw new TypeError(`Expected the first parameter to be a function, got \`${typeof function_}\`.`);
15524
+ }
15525
+ if (wait < 0) {
15526
+ throw new RangeError("`wait` must not be negative.");
15527
+ }
15528
+ const { immediate } = typeof options === "boolean" ? { immediate: options } : options;
15529
+ let storedContext;
15530
+ let storedArguments;
15531
+ let timeoutId;
15532
+ let timestamp;
15533
+ let result;
15525
15534
  function later() {
15526
- var last = Date.now() - timestamp;
15535
+ const last = Date.now() - timestamp;
15527
15536
  if (last < wait && last >= 0) {
15528
- timeout = setTimeout(later, wait - last);
15537
+ timeoutId = setTimeout(later, wait - last);
15529
15538
  } else {
15530
- timeout = null;
15539
+ timeoutId = void 0;
15531
15540
  if (!immediate) {
15532
- result = func.apply(context, args);
15533
- context = args = null;
15541
+ const callContext = storedContext;
15542
+ const callArguments = storedArguments;
15543
+ storedContext = void 0;
15544
+ storedArguments = void 0;
15545
+ result = function_.apply(callContext, callArguments);
15534
15546
  }
15535
15547
  }
15536
15548
  }
15537
- ;
15538
- var debounced = function() {
15539
- context = this;
15540
- args = arguments;
15549
+ const debounced = function(...arguments_) {
15550
+ if (storedContext && this !== storedContext) {
15551
+ throw new Error("Debounced method called with different contexts.");
15552
+ }
15553
+ storedContext = this;
15554
+ storedArguments = arguments_;
15541
15555
  timestamp = Date.now();
15542
- var callNow = immediate && !timeout;
15543
- if (!timeout)
15544
- timeout = setTimeout(later, wait);
15556
+ const callNow = immediate && !timeoutId;
15557
+ if (!timeoutId) {
15558
+ timeoutId = setTimeout(later, wait);
15559
+ }
15545
15560
  if (callNow) {
15546
- result = func.apply(context, args);
15547
- context = args = null;
15561
+ const callContext = storedContext;
15562
+ const callArguments = storedArguments;
15563
+ storedContext = void 0;
15564
+ storedArguments = void 0;
15565
+ result = function_.apply(callContext, callArguments);
15548
15566
  }
15549
15567
  return result;
15550
15568
  };
15551
- debounced.clear = function() {
15552
- if (timeout) {
15553
- clearTimeout(timeout);
15554
- timeout = null;
15569
+ debounced.clear = () => {
15570
+ if (!timeoutId) {
15571
+ return;
15555
15572
  }
15573
+ clearTimeout(timeoutId);
15574
+ timeoutId = void 0;
15556
15575
  };
15557
- debounced.flush = function() {
15558
- if (timeout) {
15559
- result = func.apply(context, args);
15560
- context = args = null;
15561
- clearTimeout(timeout);
15562
- timeout = null;
15576
+ debounced.flush = () => {
15577
+ if (!timeoutId) {
15578
+ return;
15563
15579
  }
15580
+ const callContext = storedContext;
15581
+ const callArguments = storedArguments;
15582
+ storedContext = void 0;
15583
+ storedArguments = void 0;
15584
+ result = function_.apply(callContext, callArguments);
15585
+ clearTimeout(timeoutId);
15586
+ timeoutId = void 0;
15564
15587
  };
15565
15588
  return debounced;
15566
15589
  }
15567
- debounce8.debounce = debounce8;
15590
+ module2.exports.debounce = debounce8;
15568
15591
  module2.exports = debounce8;
15569
15592
  }
15570
15593
  });
@@ -46842,7 +46865,7 @@ var ReflowableBookView = class {
46842
46865
  return wrapper.clientHeight;
46843
46866
  }
46844
46867
  setIframeHeight(iframe) {
46845
- let d = (0, import_debounce.debounce)((iframe2) => {
46868
+ let d = (0, import_debounce.default)((iframe2) => {
46846
46869
  if (iframe2) {
46847
46870
  let body = iframe2.contentWindow.document.body, html = iframe2.contentWindow.document.documentElement;
46848
46871
  let height = Math.max(
@@ -49549,7 +49572,7 @@ var TextHighlighter = class _TextHighlighter {
49549
49572
  constructor(layerSettings, properties, hasEventListener, options, api) {
49550
49573
  this.lastSelectedHighlight = void 0;
49551
49574
  this.activeAnnotationMarkerId = void 0;
49552
- this.showTool = (0, import_debounce2.debounce)(
49575
+ this.showTool = (0, import_debounce2.default)(
49553
49576
  (b) => {
49554
49577
  if (!this.isAndroid()) {
49555
49578
  this.snapSelectionToWord(b);
@@ -49559,7 +49582,7 @@ var TextHighlighter = class _TextHighlighter {
49559
49582
  navigator.userAgent.toLowerCase().indexOf("firefox") > -1 ? 200 : 100
49560
49583
  );
49561
49584
  this.isSelectionMenuOpen = false;
49562
- this.selectionMenuOpened = (0, import_debounce2.debounce)(() => {
49585
+ this.selectionMenuOpened = (0, import_debounce2.default)(() => {
49563
49586
  var _a, _b;
49564
49587
  if (!this.isSelectionMenuOpen) {
49565
49588
  this.isSelectionMenuOpen = true;
@@ -49568,7 +49591,7 @@ var TextHighlighter = class _TextHighlighter {
49568
49591
  this.navigator.emit("toolbox.opened", "opened");
49569
49592
  }
49570
49593
  }, 100);
49571
- this.selectionMenuClosed = (0, import_debounce2.debounce)(() => {
49594
+ this.selectionMenuClosed = (0, import_debounce2.default)(() => {
49572
49595
  var _a, _b;
49573
49596
  if (this.isSelectionMenuOpen) {
49574
49597
  this.isSelectionMenuOpen = false;
@@ -49577,7 +49600,7 @@ var TextHighlighter = class _TextHighlighter {
49577
49600
  this.navigator.emit("toolbox.closed", "closed");
49578
49601
  }
49579
49602
  }, 100);
49580
- this.selection = (0, import_debounce2.debounce)((text, selection) => {
49603
+ this.selection = (0, import_debounce2.default)((text, selection) => {
49581
49604
  var _a, _b;
49582
49605
  if ((_a = this.api) == null ? void 0 : _a.selection)
49583
49606
  (_b = this.api) == null ? void 0 : _b.selection(text, selection);
@@ -49984,7 +50007,12 @@ var TextHighlighter = class _TextHighlighter {
49984
50007
  window.addEventListener("resize", this.toolboxPlacement.bind(this));
49985
50008
  }
49986
50009
  doc.addEventListener("selectionchange", this.toolboxPlacement.bind(this));
49987
- doc.addEventListener("selectionchange", this.toolboxShowDelayed.bind(this));
50010
+ if (!this.isIOS()) {
50011
+ doc.addEventListener(
50012
+ "selectionchange",
50013
+ this.toolboxShowDelayed.bind(this)
50014
+ );
50015
+ }
49988
50016
  el.addEventListener("mousedown", this.toolboxHide.bind(this));
49989
50017
  el.addEventListener("touchstart", this.toolboxHide.bind(this));
49990
50018
  if (this.isAndroid()) {
@@ -57093,7 +57121,7 @@ var ContentProtectionModule = class {
57093
57121
  async handleResize() {
57094
57122
  var _a;
57095
57123
  if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
57096
- const onDoResize = (0, import_debounce3.debounce)(() => {
57124
+ const onDoResize = (0, import_debounce3.default)(() => {
57097
57125
  this.calcRects(this.rects);
57098
57126
  if (this.rects !== void 0) {
57099
57127
  this.rects.forEach(
@@ -57350,7 +57378,7 @@ var ContentProtectionModule = class {
57350
57378
  return new Promise((resolve) => {
57351
57379
  var _a;
57352
57380
  if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
57353
- const onDoResize = (0, import_debounce3.debounce)(() => {
57381
+ const onDoResize = (0, import_debounce3.default)(() => {
57354
57382
  this.calcRects(this.rects);
57355
57383
  if (this.rects !== void 0) {
57356
57384
  this.rects.forEach(
@@ -58916,7 +58944,7 @@ init_polyfills();
58916
58944
  var import_debounce4 = __toESM(require_debounce());
58917
58945
  var SampleReadEventHandler = class {
58918
58946
  constructor(navigator2) {
58919
- this.enforceSampleRead = (0, import_debounce4.debounce)((position) => {
58947
+ this.enforceSampleRead = (0, import_debounce4.default)((position) => {
58920
58948
  var _a, _b, _c, _d, _e, _f;
58921
58949
  let progress = Math.round(position.locations.totalProgression * 100);
58922
58950
  let valid = false;
@@ -59240,7 +59268,7 @@ var TTSModule2 = class {
59240
59268
  this.restartIndex = -1;
59241
59269
  this.ttsQueueIndex = -1;
59242
59270
  this.ttsQueue = void 0;
59243
- this.ttsPlayQueueIndexDebounced = (0, import_debounce5.debounce)((ttsQueueIndex, ttsQueue) => {
59271
+ this.ttsPlayQueueIndexDebounced = (0, import_debounce5.default)((ttsQueueIndex, ttsQueue) => {
59244
59272
  if (this.restartIndex >= 0) {
59245
59273
  this.ttsQueueIndex = this.restartIndex;
59246
59274
  this.restartIndex = -1;
@@ -60239,7 +60267,7 @@ var DefinitionsModule = class {
60239
60267
  constructor(publication, properties, highlighter, api) {
60240
60268
  this.currentChapterPopupResult = [];
60241
60269
  this.currentPopupHighlights = [];
60242
- this.definitions = (0, import_debounce6.debounce)(async () => {
60270
+ this.definitions = (0, import_debounce6.default)(async () => {
60243
60271
  await this.highlighter.destroyHighlights(4 /* Definition */);
60244
60272
  if (this.properties.definitions) {
60245
60273
  for (const item of this.properties.definitions) {
@@ -61373,12 +61401,12 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61373
61401
  await this.navigate(lastReadingPosition);
61374
61402
  }
61375
61403
  };
61376
- this.savePosition = (0, import_debounce7.debounce)(() => {
61404
+ this.savePosition = (0, import_debounce7.default)(() => {
61377
61405
  if (this.annotator) {
61378
61406
  this.saveCurrentReadingPosition();
61379
61407
  }
61380
61408
  }, 200);
61381
- this.checkResourcePosition = (0, import_debounce7.debounce)(() => {
61409
+ this.checkResourcePosition = (0, import_debounce7.default)(() => {
61382
61410
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
61383
61411
  if (((_a = this.view) == null ? void 0 : _a.atStart()) && ((_b = this.view) == null ? void 0 : _b.atEnd())) {
61384
61412
  if ((_c = this.api) == null ? void 0 : _c.resourceFitsScreen)
@@ -62011,7 +62039,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62011
62039
  this.previousChapterTopAnchorElement.style.display = "none";
62012
62040
  }
62013
62041
  }
62014
- const onDoScrolling = (0, import_debounce7.debounce)(() => {
62042
+ const onDoScrolling = (0, import_debounce7.default)(() => {
62015
62043
  this.isScrolling = false;
62016
62044
  }, 200);
62017
62045
  const wrapper = findRequiredElement(