@d-i-t-a/reader 2.4.1 → 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
@@ -2914,7 +2914,7 @@ var require_browser2 = __commonJS({
2914
2914
  exports2.load = load2;
2915
2915
  exports2.useColors = useColors;
2916
2916
  exports2.storage = localstorage();
2917
- exports2.destroy = (() => {
2917
+ exports2.destroy = /* @__PURE__ */ (() => {
2918
2918
  let warned = false;
2919
2919
  return () => {
2920
2920
  if (!warned) {
@@ -8141,7 +8141,7 @@ var require_node = __commonJS({
8141
8141
  "node_modules/domhandler/lib/node.js"(exports2) {
8142
8142
  "use strict";
8143
8143
  init_polyfills();
8144
- var __extends3 = exports2 && exports2.__extends || function() {
8144
+ var __extends3 = exports2 && exports2.__extends || /* @__PURE__ */ function() {
8145
8145
  var extendStatics3 = function(d, b) {
8146
8146
  extendStatics3 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
8147
8147
  d2.__proto__ = b2;
@@ -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
  });
@@ -16395,7 +16418,7 @@ var require_lodash = __commonJS({
16395
16418
  }
16396
16419
  return new LodashWrapper(value);
16397
16420
  }
16398
- var baseCreate = function() {
16421
+ var baseCreate = /* @__PURE__ */ function() {
16399
16422
  function object() {
16400
16423
  }
16401
16424
  return function(proto) {
@@ -19702,7 +19725,7 @@ var require_lodash = __commonJS({
19702
19725
  var gte = createRelationalOperation(function(value, other) {
19703
19726
  return value >= other;
19704
19727
  });
19705
- var isArguments = baseIsArguments(function() {
19728
+ var isArguments = baseIsArguments(/* @__PURE__ */ function() {
19706
19729
  return arguments;
19707
19730
  }()) ? baseIsArguments : function(value) {
19708
19731
  return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
@@ -21783,7 +21806,7 @@ var require_devtools_detector = __commonJS({
21783
21806
  }();
21784
21807
  }, function(t, n) {
21785
21808
  var e;
21786
- e = function() {
21809
+ e = /* @__PURE__ */ function() {
21787
21810
  return this;
21788
21811
  }();
21789
21812
  try {
@@ -24893,7 +24916,7 @@ var require_regexp_tree = __commonJS({
24893
24916
  "node_modules/regexp-tree/dist/parser/generated/regexp-tree.js"(exports2, module2) {
24894
24917
  "use strict";
24895
24918
  init_polyfills();
24896
- var _slicedToArray = function() {
24919
+ var _slicedToArray = /* @__PURE__ */ function() {
24897
24920
  function sliceIterator(arr, i) {
24898
24921
  var _arr = [];
24899
24922
  var _n = true;
@@ -26059,7 +26082,7 @@ var require_node_path = __commonJS({
26059
26082
  "node_modules/regexp-tree/dist/traverse/node-path.js"(exports2, module2) {
26060
26083
  "use strict";
26061
26084
  init_polyfills();
26062
- var _createClass = function() {
26085
+ var _createClass = /* @__PURE__ */ function() {
26063
26086
  function defineProperties(target, props) {
26064
26087
  for (var i = 0; i < props.length; i++) {
26065
26088
  var descriptor = props[i];
@@ -26632,7 +26655,7 @@ var require_transform = __commonJS({
26632
26655
  "node_modules/regexp-tree/dist/transform/index.js"(exports2, module2) {
26633
26656
  "use strict";
26634
26657
  init_polyfills();
26635
- var _createClass = function() {
26658
+ var _createClass = /* @__PURE__ */ function() {
26636
26659
  function defineProperties(target, props) {
26637
26660
  for (var i = 0; i < props.length; i++) {
26638
26661
  var descriptor = props[i];
@@ -28175,7 +28198,7 @@ var require_nfa = __commonJS({
28175
28198
  "node_modules/regexp-tree/dist/interpreter/finite-automaton/nfa/nfa.js"(exports2, module2) {
28176
28199
  "use strict";
28177
28200
  init_polyfills();
28178
- var _slicedToArray = function() {
28201
+ var _slicedToArray = /* @__PURE__ */ function() {
28179
28202
  function sliceIterator(arr, i) {
28180
28203
  var _arr = [];
28181
28204
  var _n = true;
@@ -28211,7 +28234,7 @@ var require_nfa = __commonJS({
28211
28234
  }
28212
28235
  };
28213
28236
  }();
28214
- var _createClass = function() {
28237
+ var _createClass = /* @__PURE__ */ function() {
28215
28238
  function defineProperties(target, props) {
28216
28239
  for (var i = 0; i < props.length; i++) {
28217
28240
  var descriptor = props[i];
@@ -28419,7 +28442,7 @@ var require_dfa_minimizer = __commonJS({
28419
28442
  "node_modules/regexp-tree/dist/interpreter/finite-automaton/dfa/dfa-minimizer.js"(exports2, module2) {
28420
28443
  "use strict";
28421
28444
  init_polyfills();
28422
- var _slicedToArray = function() {
28445
+ var _slicedToArray = /* @__PURE__ */ function() {
28423
28446
  function sliceIterator(arr, i) {
28424
28447
  var _arr = [];
28425
28448
  var _n = true;
@@ -28764,7 +28787,7 @@ var require_dfa = __commonJS({
28764
28787
  "node_modules/regexp-tree/dist/interpreter/finite-automaton/dfa/dfa.js"(exports2, module2) {
28765
28788
  "use strict";
28766
28789
  init_polyfills();
28767
- var _createClass = function() {
28790
+ var _createClass = /* @__PURE__ */ function() {
28768
28791
  function defineProperties(target, props) {
28769
28792
  for (var i = 0; i < props.length; i++) {
28770
28793
  var descriptor = props[i];
@@ -29085,7 +29108,7 @@ var require_state = __commonJS({
29085
29108
  "node_modules/regexp-tree/dist/interpreter/finite-automaton/state.js"(exports2, module2) {
29086
29109
  "use strict";
29087
29110
  init_polyfills();
29088
- var _createClass = function() {
29111
+ var _createClass = /* @__PURE__ */ function() {
29089
29112
  function defineProperties(target, props) {
29090
29113
  for (var i = 0; i < props.length; i++) {
29091
29114
  var descriptor = props[i];
@@ -29155,7 +29178,7 @@ var require_nfa_state = __commonJS({
29155
29178
  "node_modules/regexp-tree/dist/interpreter/finite-automaton/nfa/nfa-state.js"(exports2, module2) {
29156
29179
  "use strict";
29157
29180
  init_polyfills();
29158
- var _createClass = function() {
29181
+ var _createClass = /* @__PURE__ */ function() {
29159
29182
  function defineProperties(target, props) {
29160
29183
  for (var i = 0; i < props.length; i++) {
29161
29184
  var descriptor = props[i];
@@ -29626,7 +29649,7 @@ var require_runtime = __commonJS({
29626
29649
  "node_modules/regexp-tree/dist/compat-transpiler/runtime/index.js"(exports2, module2) {
29627
29650
  "use strict";
29628
29651
  init_polyfills();
29629
- var _createClass = function() {
29652
+ var _createClass = /* @__PURE__ */ function() {
29630
29653
  function defineProperties(target, props) {
29631
29654
  for (var i = 0; i < props.length; i++) {
29632
29655
  var descriptor = props[i];
@@ -31929,7 +31952,7 @@ var require_jscrypto = __commonJS({
31929
31952
  this.generateKeyStreamAndEncrypt(n5, t5, this.Hn.blockSize, this.Hn), this.Cn = r2;
31930
31953
  }, t4;
31931
31954
  }(t3), t3;
31932
- }(B.T), z = function() {
31955
+ }(B.T), z = /* @__PURE__ */ function() {
31933
31956
  var n3 = function(t3, r2) {
31934
31957
  return (n3 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n4, t4) {
31935
31958
  n4.__proto__ = t4;
@@ -31966,7 +31989,7 @@ var require_jscrypto = __commonJS({
31966
31989
  n5[t5 + f2] ^= u2[f2];
31967
31990
  }, t4;
31968
31991
  }(t3), t3.Decryptor = t3.Encryptor, t3;
31969
- }(B.T), U = function() {
31992
+ }(B.T), U = /* @__PURE__ */ function() {
31970
31993
  var n3 = function(t3, r2) {
31971
31994
  return (n3 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n4, t4) {
31972
31995
  n4.__proto__ = t4;
@@ -32004,7 +32027,7 @@ var require_jscrypto = __commonJS({
32004
32027
  this.Hn.decryptBlock(n5, t5);
32005
32028
  }, t4;
32006
32029
  }(t3), t3;
32007
- }(B.T), F = function() {
32030
+ }(B.T), F = /* @__PURE__ */ function() {
32008
32031
  var n3 = function(t3, r2) {
32009
32032
  return (n3 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n4, t4) {
32010
32033
  n4.__proto__ = t4;
@@ -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()) {
@@ -55132,7 +55160,7 @@ var regexes = [
55132
55160
  ]
55133
55161
  },
55134
55162
  {
55135
- regex: /Edge?\/(\d+)(\.(\d+)|)(\.(\d+)|)/,
55163
+ regex: /Edge?\/(\d+)\.(\d+)(\.(\d+)|)/,
55136
55164
  family: "edge"
55137
55165
  },
55138
55166
  {
@@ -55158,9 +55186,10 @@ var regexes = [
55158
55186
  /**
55159
55187
  * Safari on iPad have desktop-like useragent
55160
55188
  * Some versions contains letter subversions
55189
+ * GNOME Web (X11) is based on WebKit and should be detected as Safari
55161
55190
  */
55162
55191
  {
55163
- regex: /Maci.+ Version\/(\d+)\.(\d+)([.,](\d+)|)( \(\w+\)|)( Mobile\/\w+|) Safari\//,
55192
+ regex: /(Maci|X11).+ Version\/(\d+)\.(\d+)([.,](\d+)|)( \(\w+\)|)( Mobile\/\w+|) Safari\//,
55164
55193
  family: "safari"
55165
55194
  },
55166
55195
  /**
@@ -57092,7 +57121,7 @@ var ContentProtectionModule = class {
57092
57121
  async handleResize() {
57093
57122
  var _a;
57094
57123
  if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
57095
- const onDoResize = (0, import_debounce3.debounce)(() => {
57124
+ const onDoResize = (0, import_debounce3.default)(() => {
57096
57125
  this.calcRects(this.rects);
57097
57126
  if (this.rects !== void 0) {
57098
57127
  this.rects.forEach(
@@ -57349,7 +57378,7 @@ var ContentProtectionModule = class {
57349
57378
  return new Promise((resolve) => {
57350
57379
  var _a;
57351
57380
  if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
57352
- const onDoResize = (0, import_debounce3.debounce)(() => {
57381
+ const onDoResize = (0, import_debounce3.default)(() => {
57353
57382
  this.calcRects(this.rects);
57354
57383
  if (this.rects !== void 0) {
57355
57384
  this.rects.forEach(
@@ -58915,7 +58944,7 @@ init_polyfills();
58915
58944
  var import_debounce4 = __toESM(require_debounce());
58916
58945
  var SampleReadEventHandler = class {
58917
58946
  constructor(navigator2) {
58918
- this.enforceSampleRead = (0, import_debounce4.debounce)((position) => {
58947
+ this.enforceSampleRead = (0, import_debounce4.default)((position) => {
58919
58948
  var _a, _b, _c, _d, _e, _f;
58920
58949
  let progress = Math.round(position.locations.totalProgression * 100);
58921
58950
  let valid = false;
@@ -59004,7 +59033,7 @@ var SampleReadEventHandler = class {
59004
59033
  if (this.navigator.errorMessage) {
59005
59034
  this.navigator.errorMessage.style.display = "block";
59006
59035
  this.navigator.errorMessage.style.backgroundColor = "rgb(255, 255, 255)";
59007
- this.navigator.errorMessage.innerHTML = "<span>" + ((_f = this.navigator.sample) == null ? void 0 : _f.popup) + "</span>";
59036
+ this.navigator.errorMessage.innerHTML = `<span>${(_f = this.navigator.sample) == null ? void 0 : _f.popup}</span>` ?? "";
59008
59037
  }
59009
59038
  } else {
59010
59039
  this.navigator.iframes[0].focus();
@@ -59239,7 +59268,7 @@ var TTSModule2 = class {
59239
59268
  this.restartIndex = -1;
59240
59269
  this.ttsQueueIndex = -1;
59241
59270
  this.ttsQueue = void 0;
59242
- this.ttsPlayQueueIndexDebounced = (0, import_debounce5.debounce)((ttsQueueIndex, ttsQueue) => {
59271
+ this.ttsPlayQueueIndexDebounced = (0, import_debounce5.default)((ttsQueueIndex, ttsQueue) => {
59243
59272
  if (this.restartIndex >= 0) {
59244
59273
  this.ttsQueueIndex = this.restartIndex;
59245
59274
  this.restartIndex = -1;
@@ -60238,7 +60267,7 @@ var DefinitionsModule = class {
60238
60267
  constructor(publication, properties, highlighter, api) {
60239
60268
  this.currentChapterPopupResult = [];
60240
60269
  this.currentPopupHighlights = [];
60241
- this.definitions = (0, import_debounce6.debounce)(async () => {
60270
+ this.definitions = (0, import_debounce6.default)(async () => {
60242
60271
  await this.highlighter.destroyHighlights(4 /* Definition */);
60243
60272
  if (this.properties.definitions) {
60244
60273
  for (const item of this.properties.definitions) {
@@ -61372,12 +61401,12 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
61372
61401
  await this.navigate(lastReadingPosition);
61373
61402
  }
61374
61403
  };
61375
- this.savePosition = (0, import_debounce7.debounce)(() => {
61404
+ this.savePosition = (0, import_debounce7.default)(() => {
61376
61405
  if (this.annotator) {
61377
61406
  this.saveCurrentReadingPosition();
61378
61407
  }
61379
61408
  }, 200);
61380
- this.checkResourcePosition = (0, import_debounce7.debounce)(() => {
61409
+ this.checkResourcePosition = (0, import_debounce7.default)(() => {
61381
61410
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
61382
61411
  if (((_a = this.view) == null ? void 0 : _a.atStart()) && ((_b = this.view) == null ? void 0 : _b.atEnd())) {
61383
61412
  if ((_c = this.api) == null ? void 0 : _c.resourceFitsScreen)
@@ -62010,7 +62039,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
62010
62039
  this.previousChapterTopAnchorElement.style.display = "none";
62011
62040
  }
62012
62041
  }
62013
- const onDoScrolling = (0, import_debounce7.debounce)(() => {
62042
+ const onDoScrolling = (0, import_debounce7.default)(() => {
62014
62043
  this.isScrolling = false;
62015
62044
  }, 200);
62016
62045
  const wrapper = findRequiredElement(