@d-i-t-a/reader 2.4.2 → 2.4.4
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 +98 -53
- package/dist/esm/index.js.map +3 -3
- package/dist/reader.js +37 -37
- package/dist/reader.js.map +3 -3
- package/dist/types/modules/TTS/TTSModule2.d.ts +2 -3
- package/dist/types/modules/highlight/TextHighlighter.d.ts +5 -12
- package/dist/types/modules/sampleread/SampleReadEventHandler.d.ts +2 -3
- package/dist/types/modules/search/DefinitionsModule.d.ts +2 -3
- package/dist/types/navigator/IFrameNavigator.d.ts +3 -6
- package/package.json +3 -3
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(
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
|
|
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
|
-
|
|
15535
|
+
const last = Date.now() - timestamp;
|
|
15527
15536
|
if (last < wait && last >= 0) {
|
|
15528
|
-
|
|
15537
|
+
timeoutId = setTimeout(later, wait - last);
|
|
15529
15538
|
} else {
|
|
15530
|
-
|
|
15539
|
+
timeoutId = void 0;
|
|
15531
15540
|
if (!immediate) {
|
|
15532
|
-
|
|
15533
|
-
|
|
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
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
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
|
-
|
|
15543
|
-
if (!
|
|
15544
|
-
|
|
15556
|
+
const callNow = immediate && !timeoutId;
|
|
15557
|
+
if (!timeoutId) {
|
|
15558
|
+
timeoutId = setTimeout(later, wait);
|
|
15559
|
+
}
|
|
15545
15560
|
if (callNow) {
|
|
15546
|
-
|
|
15547
|
-
|
|
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 =
|
|
15552
|
-
if (
|
|
15553
|
-
|
|
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 =
|
|
15558
|
-
if (
|
|
15559
|
-
|
|
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
|
-
|
|
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.
|
|
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(
|
|
@@ -47059,7 +47082,9 @@ var _UserSettings = class _UserSettings {
|
|
|
47059
47082
|
import_loglevel2.default.log(settings.verticalScroll);
|
|
47060
47083
|
}
|
|
47061
47084
|
if (initialUserSettings.appearance) {
|
|
47062
|
-
settings.appearance = _UserSettings.parseAppearanceSetting(
|
|
47085
|
+
settings.appearance = _UserSettings.parseAppearanceSetting(
|
|
47086
|
+
initialUserSettings.appearance
|
|
47087
|
+
);
|
|
47063
47088
|
let prop = settings.userProperties.getByRef(ReadiumCSS.APPEARANCE_REF);
|
|
47064
47089
|
if (prop) {
|
|
47065
47090
|
prop.value = settings.appearance;
|
|
@@ -47611,8 +47636,9 @@ var _UserSettings = class _UserSettings {
|
|
|
47611
47636
|
return ((_a = await this.getProperty(key)) == null ? void 0 : _a.value) ?? this[name];
|
|
47612
47637
|
}
|
|
47613
47638
|
async resetUserSettings() {
|
|
47614
|
-
|
|
47639
|
+
this.store.remove(this.USERSETTINGS);
|
|
47615
47640
|
await this.reset();
|
|
47641
|
+
this.viewChangeCallback();
|
|
47616
47642
|
this.settingsChangeCallback();
|
|
47617
47643
|
}
|
|
47618
47644
|
get currentSettings() {
|
|
@@ -47637,7 +47663,9 @@ var _UserSettings = class _UserSettings {
|
|
|
47637
47663
|
async applyUserSettings(userSettings) {
|
|
47638
47664
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
47639
47665
|
if (userSettings.appearance) {
|
|
47640
|
-
this.appearance = _UserSettings.parseAppearanceSetting(
|
|
47666
|
+
this.appearance = _UserSettings.parseAppearanceSetting(
|
|
47667
|
+
userSettings.appearance
|
|
47668
|
+
);
|
|
47641
47669
|
let prop = (_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.APPEARANCE_REF);
|
|
47642
47670
|
if (prop) {
|
|
47643
47671
|
prop.value = this.appearance;
|
|
@@ -47762,9 +47790,7 @@ var _UserSettings = class _UserSettings {
|
|
|
47762
47790
|
} else {
|
|
47763
47791
|
a = inputSetting;
|
|
47764
47792
|
}
|
|
47765
|
-
return _UserSettings.appearanceValues.findIndex(
|
|
47766
|
-
(el) => el === a
|
|
47767
|
-
);
|
|
47793
|
+
return _UserSettings.appearanceValues.findIndex((el) => el === a);
|
|
47768
47794
|
}
|
|
47769
47795
|
async scroll(scroll) {
|
|
47770
47796
|
var _a, _b, _c, _d, _e;
|
|
@@ -47786,7 +47812,9 @@ var _UserSettings = class _UserSettings {
|
|
|
47786
47812
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
47787
47813
|
if (incremental === "fontSize") {
|
|
47788
47814
|
((_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.FONT_SIZE_REF)).increment();
|
|
47789
|
-
this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(
|
|
47815
|
+
this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(
|
|
47816
|
+
ReadiumCSS.FONT_SIZE_REF
|
|
47817
|
+
)) == null ? void 0 : _c.value;
|
|
47790
47818
|
let prop = (_d = this.userProperties) == null ? void 0 : _d.getByRef(ReadiumCSS.FONT_SIZE_REF);
|
|
47791
47819
|
if (prop) {
|
|
47792
47820
|
await this.storeProperty(prop);
|
|
@@ -47830,7 +47858,9 @@ var _UserSettings = class _UserSettings {
|
|
|
47830
47858
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
47831
47859
|
if (incremental === "fontSize") {
|
|
47832
47860
|
((_a = this.userProperties) == null ? void 0 : _a.getByRef(ReadiumCSS.FONT_SIZE_REF)).decrement();
|
|
47833
|
-
this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(
|
|
47861
|
+
this.fontSize = (_c = (_b = this.userProperties) == null ? void 0 : _b.getByRef(
|
|
47862
|
+
ReadiumCSS.FONT_SIZE_REF
|
|
47863
|
+
)) == null ? void 0 : _c.value;
|
|
47834
47864
|
let prop = (_d = this.userProperties) == null ? void 0 : _d.getByRef(ReadiumCSS.FONT_SIZE_REF);
|
|
47835
47865
|
if (prop) {
|
|
47836
47866
|
await this.storeProperty(prop);
|
|
@@ -49549,7 +49579,7 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
49549
49579
|
constructor(layerSettings, properties, hasEventListener, options, api) {
|
|
49550
49580
|
this.lastSelectedHighlight = void 0;
|
|
49551
49581
|
this.activeAnnotationMarkerId = void 0;
|
|
49552
|
-
this.showTool = (0, import_debounce2.
|
|
49582
|
+
this.showTool = (0, import_debounce2.default)(
|
|
49553
49583
|
(b) => {
|
|
49554
49584
|
if (!this.isAndroid()) {
|
|
49555
49585
|
this.snapSelectionToWord(b);
|
|
@@ -49559,7 +49589,7 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
49559
49589
|
navigator.userAgent.toLowerCase().indexOf("firefox") > -1 ? 200 : 100
|
|
49560
49590
|
);
|
|
49561
49591
|
this.isSelectionMenuOpen = false;
|
|
49562
|
-
this.selectionMenuOpened = (0, import_debounce2.
|
|
49592
|
+
this.selectionMenuOpened = (0, import_debounce2.default)(() => {
|
|
49563
49593
|
var _a, _b;
|
|
49564
49594
|
if (!this.isSelectionMenuOpen) {
|
|
49565
49595
|
this.isSelectionMenuOpen = true;
|
|
@@ -49568,7 +49598,7 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
49568
49598
|
this.navigator.emit("toolbox.opened", "opened");
|
|
49569
49599
|
}
|
|
49570
49600
|
}, 100);
|
|
49571
|
-
this.selectionMenuClosed = (0, import_debounce2.
|
|
49601
|
+
this.selectionMenuClosed = (0, import_debounce2.default)(() => {
|
|
49572
49602
|
var _a, _b;
|
|
49573
49603
|
if (this.isSelectionMenuOpen) {
|
|
49574
49604
|
this.isSelectionMenuOpen = false;
|
|
@@ -49577,7 +49607,7 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
49577
49607
|
this.navigator.emit("toolbox.closed", "closed");
|
|
49578
49608
|
}
|
|
49579
49609
|
}, 100);
|
|
49580
|
-
this.selection = (0, import_debounce2.
|
|
49610
|
+
this.selection = (0, import_debounce2.default)((text, selection) => {
|
|
49581
49611
|
var _a, _b;
|
|
49582
49612
|
if ((_a = this.api) == null ? void 0 : _a.selection)
|
|
49583
49613
|
(_b = this.api) == null ? void 0 : _b.selection(text, selection);
|
|
@@ -49984,7 +50014,12 @@ var TextHighlighter = class _TextHighlighter {
|
|
|
49984
50014
|
window.addEventListener("resize", this.toolboxPlacement.bind(this));
|
|
49985
50015
|
}
|
|
49986
50016
|
doc.addEventListener("selectionchange", this.toolboxPlacement.bind(this));
|
|
49987
|
-
|
|
50017
|
+
if (!this.isIOS()) {
|
|
50018
|
+
doc.addEventListener(
|
|
50019
|
+
"selectionchange",
|
|
50020
|
+
this.toolboxShowDelayed.bind(this)
|
|
50021
|
+
);
|
|
50022
|
+
}
|
|
49988
50023
|
el.addEventListener("mousedown", this.toolboxHide.bind(this));
|
|
49989
50024
|
el.addEventListener("touchstart", this.toolboxHide.bind(this));
|
|
49990
50025
|
if (this.isAndroid()) {
|
|
@@ -57093,7 +57128,7 @@ var ContentProtectionModule = class {
|
|
|
57093
57128
|
async handleResize() {
|
|
57094
57129
|
var _a;
|
|
57095
57130
|
if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
|
|
57096
|
-
const onDoResize = (0, import_debounce3.
|
|
57131
|
+
const onDoResize = (0, import_debounce3.default)(() => {
|
|
57097
57132
|
this.calcRects(this.rects);
|
|
57098
57133
|
if (this.rects !== void 0) {
|
|
57099
57134
|
this.rects.forEach(
|
|
@@ -57350,7 +57385,7 @@ var ContentProtectionModule = class {
|
|
|
57350
57385
|
return new Promise((resolve) => {
|
|
57351
57386
|
var _a;
|
|
57352
57387
|
if ((_a = this.properties) == null ? void 0 : _a.enableObfuscation) {
|
|
57353
|
-
const onDoResize = (0, import_debounce3.
|
|
57388
|
+
const onDoResize = (0, import_debounce3.default)(() => {
|
|
57354
57389
|
this.calcRects(this.rects);
|
|
57355
57390
|
if (this.rects !== void 0) {
|
|
57356
57391
|
this.rects.forEach(
|
|
@@ -57461,8 +57496,18 @@ var ContentProtectionModule = class {
|
|
|
57461
57496
|
const windowRight = windowLeft + this.wrapper.clientWidth;
|
|
57462
57497
|
const right = rect.left + rect.width;
|
|
57463
57498
|
const bottom = rect.top + rect.height;
|
|
57464
|
-
const windowTop = this.wrapper.scrollTop
|
|
57465
|
-
|
|
57499
|
+
const windowTop = this.wrapper.scrollTop - (rect.node.parentElement ? parseInt(
|
|
57500
|
+
getComputedStyle(rect.node.parentElement).lineHeight.replace(
|
|
57501
|
+
"px",
|
|
57502
|
+
""
|
|
57503
|
+
)
|
|
57504
|
+
) : 10);
|
|
57505
|
+
const windowBottom = windowTop + this.wrapper.clientHeight + (rect.node.parentElement ? parseInt(
|
|
57506
|
+
getComputedStyle(rect.node.parentElement).lineHeight.replace(
|
|
57507
|
+
"px",
|
|
57508
|
+
""
|
|
57509
|
+
)
|
|
57510
|
+
) : 10);
|
|
57466
57511
|
const isAbove = bottom < windowTop;
|
|
57467
57512
|
const isBelow = rect.top > windowBottom;
|
|
57468
57513
|
const isLeft = right < windowLeft - window.innerWidth;
|
|
@@ -58916,7 +58961,7 @@ init_polyfills();
|
|
|
58916
58961
|
var import_debounce4 = __toESM(require_debounce());
|
|
58917
58962
|
var SampleReadEventHandler = class {
|
|
58918
58963
|
constructor(navigator2) {
|
|
58919
|
-
this.enforceSampleRead = (0, import_debounce4.
|
|
58964
|
+
this.enforceSampleRead = (0, import_debounce4.default)((position) => {
|
|
58920
58965
|
var _a, _b, _c, _d, _e, _f;
|
|
58921
58966
|
let progress = Math.round(position.locations.totalProgression * 100);
|
|
58922
58967
|
let valid = false;
|
|
@@ -59240,7 +59285,7 @@ var TTSModule2 = class {
|
|
|
59240
59285
|
this.restartIndex = -1;
|
|
59241
59286
|
this.ttsQueueIndex = -1;
|
|
59242
59287
|
this.ttsQueue = void 0;
|
|
59243
|
-
this.ttsPlayQueueIndexDebounced = (0, import_debounce5.
|
|
59288
|
+
this.ttsPlayQueueIndexDebounced = (0, import_debounce5.default)((ttsQueueIndex, ttsQueue) => {
|
|
59244
59289
|
if (this.restartIndex >= 0) {
|
|
59245
59290
|
this.ttsQueueIndex = this.restartIndex;
|
|
59246
59291
|
this.restartIndex = -1;
|
|
@@ -60239,7 +60284,7 @@ var DefinitionsModule = class {
|
|
|
60239
60284
|
constructor(publication, properties, highlighter, api) {
|
|
60240
60285
|
this.currentChapterPopupResult = [];
|
|
60241
60286
|
this.currentPopupHighlights = [];
|
|
60242
|
-
this.definitions = (0, import_debounce6.
|
|
60287
|
+
this.definitions = (0, import_debounce6.default)(async () => {
|
|
60243
60288
|
await this.highlighter.destroyHighlights(4 /* Definition */);
|
|
60244
60289
|
if (this.properties.definitions) {
|
|
60245
60290
|
for (const item of this.properties.definitions) {
|
|
@@ -61373,12 +61418,12 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
|
|
|
61373
61418
|
await this.navigate(lastReadingPosition);
|
|
61374
61419
|
}
|
|
61375
61420
|
};
|
|
61376
|
-
this.savePosition = (0, import_debounce7.
|
|
61421
|
+
this.savePosition = (0, import_debounce7.default)(() => {
|
|
61377
61422
|
if (this.annotator) {
|
|
61378
61423
|
this.saveCurrentReadingPosition();
|
|
61379
61424
|
}
|
|
61380
61425
|
}, 200);
|
|
61381
|
-
this.checkResourcePosition = (0, import_debounce7.
|
|
61426
|
+
this.checkResourcePosition = (0, import_debounce7.default)(() => {
|
|
61382
61427
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
61383
61428
|
if (((_a = this.view) == null ? void 0 : _a.atStart()) && ((_b = this.view) == null ? void 0 : _b.atEnd())) {
|
|
61384
61429
|
if ((_c = this.api) == null ? void 0 : _c.resourceFitsScreen)
|
|
@@ -62011,7 +62056,7 @@ var IFrameNavigator = class _IFrameNavigator extends eventemitter3_default {
|
|
|
62011
62056
|
this.previousChapterTopAnchorElement.style.display = "none";
|
|
62012
62057
|
}
|
|
62013
62058
|
}
|
|
62014
|
-
const onDoScrolling = (0, import_debounce7.
|
|
62059
|
+
const onDoScrolling = (0, import_debounce7.default)(() => {
|
|
62015
62060
|
this.isScrolling = false;
|
|
62016
62061
|
}, 200);
|
|
62017
62062
|
const wrapper = findRequiredElement(
|