@d-i-t-a/reader 2.1.0-beta.1 → 2.1.0-beta.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 +77 -63
- package/dist/esm/index.js.map +3 -3
- package/dist/injectables/click/click.js.map +1 -1
- package/dist/reader.css +1 -1216
- package/dist/reader.css.map +1 -0
- package/dist/reader.js +30 -30
- package/dist/reader.js.map +3 -3
- package/dist/types/model/Publication.d.ts +5 -5
- package/dist/types/model/user-settings/UserSettings.d.ts +4 -5
- package/dist/types/modules/AnnotationModule.d.ts +2 -2
- package/dist/types/modules/BookmarkModule.d.ts +2 -2
- package/dist/types/modules/TTS/TTSModule2.d.ts +1 -1
- package/dist/types/modules/TTS/TTSSettings.d.ts +1 -1
- package/dist/types/modules/highlight/TextHighlighter.d.ts +4 -1
- package/dist/types/modules/protection/ContentProtectionModule.d.ts +2 -2
- package/dist/types/modules/search/SearchModule.d.ts +4 -1
- package/dist/types/navigator/IFrameNavigator.d.ts +29 -25
- package/package.json +12 -10
- package/dist/reader.map.css +0 -21
package/dist/esm/index.js
CHANGED
|
@@ -10118,9 +10118,9 @@ var require_source_map = __commonJS({
|
|
|
10118
10118
|
}
|
|
10119
10119
|
});
|
|
10120
10120
|
|
|
10121
|
-
// (disabled):path
|
|
10121
|
+
// (disabled):node_modules/path/path.js
|
|
10122
10122
|
var require_path = __commonJS({
|
|
10123
|
-
"(disabled):path"() {
|
|
10123
|
+
"(disabled):node_modules/path/path.js"() {
|
|
10124
10124
|
init_polyfills();
|
|
10125
10125
|
}
|
|
10126
10126
|
});
|
|
@@ -34139,10 +34139,8 @@ function TaJsonDeserialize(json, type) {
|
|
|
34139
34139
|
|
|
34140
34140
|
// src/model/Publication.ts
|
|
34141
34141
|
var Publication = class extends import_publication.Publication {
|
|
34142
|
-
static async fromUrl(url) {
|
|
34143
|
-
const response = await fetch(url.href,
|
|
34144
|
-
credentials: "same-origin"
|
|
34145
|
-
});
|
|
34142
|
+
static async fromUrl(url, requestConfig) {
|
|
34143
|
+
const response = await fetch(url.href, requestConfig);
|
|
34146
34144
|
const manifestJSON = await response.json();
|
|
34147
34145
|
let publication = TaJsonDeserialize(manifestJSON, Publication);
|
|
34148
34146
|
publication.manifestUrl = url;
|
|
@@ -34318,7 +34316,7 @@ var Publication = class extends import_publication.Publication {
|
|
|
34318
34316
|
const decodedHref = decodeURI(href) ?? "";
|
|
34319
34317
|
return this.positions?.filter((p) => decodedHref.includes(p.href));
|
|
34320
34318
|
}
|
|
34321
|
-
async autoGeneratePositions(getContentBytesLength = fetchContentBytesLength) {
|
|
34319
|
+
async autoGeneratePositions(requestConfig, getContentBytesLength = fetchContentBytesLength) {
|
|
34322
34320
|
let startPosition = 0;
|
|
34323
34321
|
let totalContentLength = 0;
|
|
34324
34322
|
const positions = [];
|
|
@@ -34337,7 +34335,7 @@ var Publication = class extends import_publication.Publication {
|
|
|
34337
34335
|
startPosition = startPosition + 1;
|
|
34338
34336
|
} else {
|
|
34339
34337
|
let href = this.getAbsoluteHref(link.Href);
|
|
34340
|
-
let length = await getContentBytesLength(href);
|
|
34338
|
+
let length = await getContentBytesLength(href, requestConfig);
|
|
34341
34339
|
link.contentLength = length;
|
|
34342
34340
|
totalContentLength += length;
|
|
34343
34341
|
let positionLength = 1024;
|
|
@@ -34381,17 +34379,17 @@ var Publication = class extends import_publication.Publication {
|
|
|
34381
34379
|
}
|
|
34382
34380
|
this.positions = positions;
|
|
34383
34381
|
}
|
|
34384
|
-
async fetchPositionsFromService(href) {
|
|
34385
|
-
const result = await fetch(href);
|
|
34382
|
+
async fetchPositionsFromService(href, requestConfig) {
|
|
34383
|
+
const result = await fetch(href, requestConfig);
|
|
34386
34384
|
const content = await result.json();
|
|
34387
34385
|
this.positions = content.positions;
|
|
34388
34386
|
}
|
|
34389
|
-
async fetchWeightsFromService(href) {
|
|
34387
|
+
async fetchWeightsFromService(href, requestConfig) {
|
|
34390
34388
|
if (this.isFixedLayout) {
|
|
34391
34389
|
console.warn("Not fetching weights from service for fixed layout publication.");
|
|
34392
34390
|
return;
|
|
34393
34391
|
}
|
|
34394
|
-
const result = await fetch(href);
|
|
34392
|
+
const result = await fetch(href, requestConfig);
|
|
34395
34393
|
const weights = await result.json();
|
|
34396
34394
|
if (this.readingOrder !== void 0) {
|
|
34397
34395
|
this.readingOrder.forEach((link) => {
|
|
@@ -34403,8 +34401,8 @@ var Publication = class extends import_publication.Publication {
|
|
|
34403
34401
|
Publication = __decorateClass([
|
|
34404
34402
|
(0, import_ta_json_x2.JsonObject)()
|
|
34405
34403
|
], Publication);
|
|
34406
|
-
var fetchContentBytesLength = async (href) => {
|
|
34407
|
-
const r = await fetch(href);
|
|
34404
|
+
var fetchContentBytesLength = async (href, requestConfig) => {
|
|
34405
|
+
const r = await fetch(href, requestConfig);
|
|
34408
34406
|
const b = await r.blob();
|
|
34409
34407
|
return b.size;
|
|
34410
34408
|
};
|
|
@@ -34637,7 +34635,7 @@ var Popup = class {
|
|
|
34637
34635
|
absolute = absolute.substring(0, absolute.indexOf("#"));
|
|
34638
34636
|
event.preventDefault();
|
|
34639
34637
|
event.stopPropagation();
|
|
34640
|
-
await fetch(absolute).then((r) => r.text()).then(async (data) => {
|
|
34638
|
+
await fetch(absolute, this.navigator.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
34641
34639
|
const parser = new DOMParser();
|
|
34642
34640
|
const doc = parser.parseFromString(data, "text/html");
|
|
34643
34641
|
const element = doc.querySelector("#" + id2);
|
|
@@ -34687,7 +34685,7 @@ var Popup = class {
|
|
|
34687
34685
|
const d2content = document.createElement("div");
|
|
34688
34686
|
d2content.className = "d2-popover-content";
|
|
34689
34687
|
d2wrapper.appendChild(d2content);
|
|
34690
|
-
await fetch(absolute).then((r) => r.text()).then(async (data) => {
|
|
34688
|
+
await fetch(absolute, this.navigator.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
34691
34689
|
d2content.innerHTML = data;
|
|
34692
34690
|
let doc = this.navigator.iframes[0].contentDocument;
|
|
34693
34691
|
if (doc) {
|
|
@@ -37421,6 +37419,12 @@ var TextHighlighter = class {
|
|
|
37421
37419
|
constructor(delegate, layerSettings, properties, hasEventListener, options, api) {
|
|
37422
37420
|
this.lastSelectedHighlight = void 0;
|
|
37423
37421
|
this.activeAnnotationMarkerId = void 0;
|
|
37422
|
+
this.showTool = (0, import_debounce2.debounce)((b) => {
|
|
37423
|
+
if (!this.isAndroid()) {
|
|
37424
|
+
this.snapSelectionToWord(b);
|
|
37425
|
+
}
|
|
37426
|
+
this.toolboxShow();
|
|
37427
|
+
}, navigator.userAgent.toLowerCase().indexOf("firefox") > -1 ? 200 : 100);
|
|
37424
37428
|
this.isSelectionMenuOpen = false;
|
|
37425
37429
|
this.selectionMenuOpened = (0, import_debounce2.debounce)(() => {
|
|
37426
37430
|
if (!this.isSelectionMenuOpen) {
|
|
@@ -37907,14 +37911,8 @@ var TextHighlighter = class {
|
|
|
37907
37911
|
toolbox.style.display = "none";
|
|
37908
37912
|
this.selectionMenuClosed();
|
|
37909
37913
|
}
|
|
37910
|
-
toolboxShowDelayed(
|
|
37911
|
-
|
|
37912
|
-
setTimeout(function() {
|
|
37913
|
-
if (!self2.isAndroid()) {
|
|
37914
|
-
self2.snapSelectionToWord(ev.detail === 1);
|
|
37915
|
-
}
|
|
37916
|
-
self2.toolboxShow();
|
|
37917
|
-
}, 100);
|
|
37914
|
+
toolboxShowDelayed(event) {
|
|
37915
|
+
this.showTool(event.detail === 1);
|
|
37918
37916
|
}
|
|
37919
37917
|
snapSelectionToWord(trimmed = false) {
|
|
37920
37918
|
let self2 = this;
|
|
@@ -40977,7 +40975,7 @@ var MediaOverlayModule = class {
|
|
|
40977
40975
|
const moUrlFull = moUrlObjFull.toString();
|
|
40978
40976
|
let response;
|
|
40979
40977
|
try {
|
|
40980
|
-
response = await fetch(moUrlFull);
|
|
40978
|
+
response = await fetch(moUrlFull, this.delegate.requestConfig);
|
|
40981
40979
|
} catch (e) {
|
|
40982
40980
|
console.error(e, moUrlFull);
|
|
40983
40981
|
return;
|
|
@@ -42299,7 +42297,7 @@ async function searchDocDomSeek(searchInput, doc, href, title, fullWordSearch =
|
|
|
42299
42297
|
|
|
42300
42298
|
// src/modules/search/SearchModule.ts
|
|
42301
42299
|
var SearchModule = class {
|
|
42302
|
-
constructor(delegate, publication, properties, highlighter, api, headerMenu) {
|
|
42300
|
+
constructor(delegate, publication, properties, highlighter, requestConfig, api, headerMenu) {
|
|
42303
42301
|
this.currentChapterSearchResult = [];
|
|
42304
42302
|
this.bookSearchResult = [];
|
|
42305
42303
|
this.currentSearchHighlights = [];
|
|
@@ -42309,9 +42307,10 @@ var SearchModule = class {
|
|
|
42309
42307
|
this.properties = properties;
|
|
42310
42308
|
this.api = api;
|
|
42311
42309
|
this.highlighter = highlighter;
|
|
42310
|
+
this.requestConfig = requestConfig;
|
|
42312
42311
|
}
|
|
42313
42312
|
static async create(config2) {
|
|
42314
|
-
const search = new this(config2.delegate, config2.publication, config2, config2.highlighter, config2.api, config2.headerMenu);
|
|
42313
|
+
const search = new this(config2.delegate, config2.publication, config2, config2.highlighter, config2.requestConfig, config2.api, config2.headerMenu);
|
|
42315
42314
|
await search.start();
|
|
42316
42315
|
return search;
|
|
42317
42316
|
}
|
|
@@ -42737,9 +42736,9 @@ var SearchModule = class {
|
|
|
42737
42736
|
}
|
|
42738
42737
|
if (tocItem) {
|
|
42739
42738
|
let href = this.publication.getAbsoluteHref(tocItem.Href);
|
|
42740
|
-
await fetch(href).then((r) => r.text()).then(async (data) => {
|
|
42739
|
+
await fetch(href, this.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
42741
42740
|
let parser = new DOMParser();
|
|
42742
|
-
let doc = parser.parseFromString(data, "application/xhtml+xml");
|
|
42741
|
+
let doc = parser.parseFromString(this.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
42743
42742
|
if (tocItem) {
|
|
42744
42743
|
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
42745
42744
|
result.forEach((searchItem) => {
|
|
@@ -42755,6 +42754,16 @@ var SearchModule = class {
|
|
|
42755
42754
|
}
|
|
42756
42755
|
}
|
|
42757
42756
|
}
|
|
42757
|
+
decodeBase64(base64) {
|
|
42758
|
+
const text = atob(base64);
|
|
42759
|
+
const length = text.length;
|
|
42760
|
+
const bytes = new Uint8Array(length);
|
|
42761
|
+
for (let i = 0; i < length; i++) {
|
|
42762
|
+
bytes[i] = text.charCodeAt(i);
|
|
42763
|
+
}
|
|
42764
|
+
const decoder = new TextDecoder();
|
|
42765
|
+
return decoder.decode(bytes);
|
|
42766
|
+
}
|
|
42758
42767
|
async searchChapter(term) {
|
|
42759
42768
|
let localSearchResultBook = [];
|
|
42760
42769
|
const linkHref = this.publication.getAbsoluteHref(this.publication.readingOrder[this.delegate.currentResource() ?? 0].Href);
|
|
@@ -42764,9 +42773,9 @@ var SearchModule = class {
|
|
|
42764
42773
|
}
|
|
42765
42774
|
if (tocItem) {
|
|
42766
42775
|
let href = this.publication.getAbsoluteHref(tocItem.Href);
|
|
42767
|
-
await fetch(href).then((r) => r.text()).then(async (data) => {
|
|
42776
|
+
await fetch(href, this.requestConfig).then((r) => r.text()).then(async (data) => {
|
|
42768
42777
|
let parser = new DOMParser();
|
|
42769
|
-
let doc = parser.parseFromString(data, "application/xhtml+xml");
|
|
42778
|
+
let doc = parser.parseFromString(this.requestConfig?.encoded ? this.decodeBase64(data) : data, "application/xhtml+xml");
|
|
42770
42779
|
if (tocItem) {
|
|
42771
42780
|
searchDocDomSeek(term, doc, tocItem.Href, tocItem.Title).then((result) => {
|
|
42772
42781
|
result.forEach((searchItem) => {
|
|
@@ -43431,11 +43440,10 @@ var SampleReadEventHandler = class {
|
|
|
43431
43440
|
// src/navigator/IFrameNavigator.ts
|
|
43432
43441
|
var import_eventemitter3 = __toModule(require_eventemitter3());
|
|
43433
43442
|
var IFrameNavigator = class extends import_eventemitter3.default {
|
|
43434
|
-
constructor(settings, annotator = void 0, upLinkConfig = void 0, initialLastReadingPosition = void 0, publication,
|
|
43443
|
+
constructor(settings, annotator = void 0, upLinkConfig = void 0, initialLastReadingPosition = void 0, publication, api, rights, tts, injectables, attributes, services, sample, requestConfig) {
|
|
43435
43444
|
super();
|
|
43436
43445
|
this.iframes = [];
|
|
43437
43446
|
this.sideNavExpanded = false;
|
|
43438
|
-
this.material = false;
|
|
43439
43447
|
this.currentChapterLink = { href: "" };
|
|
43440
43448
|
this.currentSpreadLinks = {};
|
|
43441
43449
|
this.upLink = void 0;
|
|
@@ -43506,7 +43514,6 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
43506
43514
|
this.upLinkConfig = upLinkConfig;
|
|
43507
43515
|
this.initialLastReadingPosition = initialLastReadingPosition;
|
|
43508
43516
|
this.publication = publication;
|
|
43509
|
-
this.material = material;
|
|
43510
43517
|
this.api = api;
|
|
43511
43518
|
this.rights = rights ?? {
|
|
43512
43519
|
autoGeneratePositions: false,
|
|
@@ -43529,10 +43536,11 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
43529
43536
|
this.attributes = attributes || { margin: 0 };
|
|
43530
43537
|
this.services = services;
|
|
43531
43538
|
this.sample = sample;
|
|
43539
|
+
this.requestConfig = requestConfig;
|
|
43532
43540
|
this.sampleReadEventHandler = new SampleReadEventHandler(this);
|
|
43533
43541
|
}
|
|
43534
43542
|
static async create(config2) {
|
|
43535
|
-
const navigator2 = new this(config2.settings, config2.annotator || void 0, config2.upLink || void 0, config2.initialLastReadingPosition || void 0, config2.publication, config2.
|
|
43543
|
+
const navigator2 = new this(config2.settings, config2.annotator || void 0, config2.upLink || void 0, config2.initialLastReadingPosition || void 0, config2.publication, config2.api, config2.rights, config2.tts, config2.injectables, config2.attributes || { margin: 0 }, config2.services, config2.sample);
|
|
43536
43544
|
await navigator2.start(config2.mainElement, config2.headerMenu, config2.footerMenu);
|
|
43537
43545
|
return new Promise((resolve) => resolve(navigator2));
|
|
43538
43546
|
}
|
|
@@ -44385,7 +44393,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44385
44393
|
if (isSameOrigin) {
|
|
44386
44394
|
this.iframes[0].src = this.currentChapterLink.href;
|
|
44387
44395
|
} else {
|
|
44388
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content2) => {
|
|
44396
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content2) => {
|
|
44389
44397
|
writeIframeDoc.call(this, content2, this.currentChapterLink.href);
|
|
44390
44398
|
});
|
|
44391
44399
|
}
|
|
@@ -44406,7 +44414,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44406
44414
|
if (isSameOrigin) {
|
|
44407
44415
|
this.iframes[1].src = href;
|
|
44408
44416
|
} else {
|
|
44409
|
-
fetch(href).then((r) => r.text()).then(async (content2) => {
|
|
44417
|
+
fetch(href, this.requestConfig).then((r) => r.text()).then(async (content2) => {
|
|
44410
44418
|
writeIframe2Doc.call(this, content2, href);
|
|
44411
44419
|
this.currentSpreadLinks.right = {
|
|
44412
44420
|
href
|
|
@@ -44435,7 +44443,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44435
44443
|
if (isSameOrigin) {
|
|
44436
44444
|
this.iframes[0].src = href;
|
|
44437
44445
|
} else {
|
|
44438
|
-
fetch(href).then((r) => r.text()).then(async (content2) => {
|
|
44446
|
+
fetch(href, this.requestConfig).then((r) => r.text()).then(async (content2) => {
|
|
44439
44447
|
writeIframeDoc.call(this, content2, href);
|
|
44440
44448
|
});
|
|
44441
44449
|
}
|
|
@@ -44456,7 +44464,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44456
44464
|
if (isSameOrigin) {
|
|
44457
44465
|
this.iframes[1].src = this.currentChapterLink.href;
|
|
44458
44466
|
} else {
|
|
44459
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content2) => {
|
|
44467
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content2) => {
|
|
44460
44468
|
writeIframe2Doc.call(this, content2, this.currentChapterLink.href);
|
|
44461
44469
|
});
|
|
44462
44470
|
}
|
|
@@ -44475,7 +44483,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44475
44483
|
if (isSameOrigin) {
|
|
44476
44484
|
this.iframes[0].src = this.currentChapterLink.href;
|
|
44477
44485
|
} else {
|
|
44478
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content2) => {
|
|
44486
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content2) => {
|
|
44479
44487
|
writeIframeDoc.call(this, content2, this.currentChapterLink.href);
|
|
44480
44488
|
});
|
|
44481
44489
|
}
|
|
@@ -44493,7 +44501,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44493
44501
|
if (isSameOrigin) {
|
|
44494
44502
|
this.iframes[0].src = this.currentChapterLink.href;
|
|
44495
44503
|
} else {
|
|
44496
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content2) => {
|
|
44504
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content2) => {
|
|
44497
44505
|
writeIframeDoc.call(this, content2, this.currentChapterLink.href);
|
|
44498
44506
|
});
|
|
44499
44507
|
}
|
|
@@ -44526,7 +44534,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44526
44534
|
}
|
|
44527
44535
|
}
|
|
44528
44536
|
} else {
|
|
44529
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content) => {
|
|
44537
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44530
44538
|
writeIframeDoc.call(this, content, this.currentChapterLink.href);
|
|
44531
44539
|
});
|
|
44532
44540
|
if (this.iframes.length === 2) {
|
|
@@ -44537,7 +44545,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44537
44545
|
this.currentSpreadLinks.right = {
|
|
44538
44546
|
href
|
|
44539
44547
|
};
|
|
44540
|
-
fetch(href).then((r) => r.text()).then(async (content) => {
|
|
44548
|
+
fetch(href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44541
44549
|
writeIframe2Doc.call(this, content, href);
|
|
44542
44550
|
});
|
|
44543
44551
|
}
|
|
@@ -44560,14 +44568,14 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44560
44568
|
this.iframes[1].src = this.currentChapterLink.href;
|
|
44561
44569
|
}
|
|
44562
44570
|
} else {
|
|
44563
|
-
fetch(href).then((r) => r.text()).then(async (content) => {
|
|
44571
|
+
fetch(href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44564
44572
|
writeIframeDoc.call(this, content, href);
|
|
44565
44573
|
});
|
|
44566
44574
|
if (this.iframes.length === 2) {
|
|
44567
44575
|
this.currentSpreadLinks.right = {
|
|
44568
44576
|
href: this.currentChapterLink.href
|
|
44569
44577
|
};
|
|
44570
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content) => {
|
|
44578
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44571
44579
|
writeIframe2Doc.call(this, content, this.currentChapterLink.href);
|
|
44572
44580
|
});
|
|
44573
44581
|
}
|
|
@@ -44583,7 +44591,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44583
44591
|
if (isSameOrigin) {
|
|
44584
44592
|
this.iframes[1].src = this.currentChapterLink.href;
|
|
44585
44593
|
} else {
|
|
44586
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content) => {
|
|
44594
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44587
44595
|
writeIframe2Doc.call(this, content, this.currentChapterLink.href);
|
|
44588
44596
|
});
|
|
44589
44597
|
}
|
|
@@ -44596,7 +44604,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44596
44604
|
if (isSameOrigin) {
|
|
44597
44605
|
this.iframes[0].src = this.currentChapterLink.href;
|
|
44598
44606
|
} else {
|
|
44599
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content) => {
|
|
44607
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44600
44608
|
writeIframeDoc.call(this, content, this.currentChapterLink.href);
|
|
44601
44609
|
});
|
|
44602
44610
|
}
|
|
@@ -44608,7 +44616,7 @@ var IFrameNavigator = class extends import_eventemitter3.default {
|
|
|
44608
44616
|
if (isSameOrigin) {
|
|
44609
44617
|
this.iframes[0].src = this.currentChapterLink.href;
|
|
44610
44618
|
} else {
|
|
44611
|
-
fetch(this.currentChapterLink.href).then((r) => r.text()).then(async (content) => {
|
|
44619
|
+
fetch(this.currentChapterLink.href, this.requestConfig).then((r) => r.text()).then(async (content) => {
|
|
44612
44620
|
writeIframeDoc.call(this, content, this.currentChapterLink.href);
|
|
44613
44621
|
});
|
|
44614
44622
|
}
|
|
@@ -46426,7 +46434,7 @@ var TTSModule2 = class {
|
|
|
46426
46434
|
var restOfTheText;
|
|
46427
46435
|
if (ttsQueueItem && selectionInfo && selectionInfo.cleanText) {
|
|
46428
46436
|
const sentence = getTtsQueueItemRefText(ttsQueueItem);
|
|
46429
|
-
let startIndex =
|
|
46437
|
+
let startIndex = selectionInfo.rangeInfo.startOffset;
|
|
46430
46438
|
let textToBeSpoken = selectionInfo.cleanText;
|
|
46431
46439
|
if (ttsQueueItemEnd && idx + 1 === idxEnd) {
|
|
46432
46440
|
const sentenceEnd = getTtsQueueItemRefText(ttsQueueItemEnd);
|
|
@@ -46434,20 +46442,20 @@ var TTSModule2 = class {
|
|
|
46434
46442
|
textToBeSpoken = sentence.slice(startIndex, sentence.length);
|
|
46435
46443
|
restOfTheText = selectionInfo.cleanText.replace(textToBeSpoken, "").trim();
|
|
46436
46444
|
} else if (idxEnd > idx) {
|
|
46437
|
-
let
|
|
46445
|
+
let mergedSentences = "";
|
|
46438
46446
|
for (let i = idx + 1; i < idxEnd; i++) {
|
|
46439
46447
|
const ttsQueueItemInBetween = getTtsQueueItemRef(ttsQueue, i);
|
|
46440
46448
|
if (ttsQueueItemInBetween) {
|
|
46441
46449
|
const sentenceInBetween = getTtsQueueItemRefText(ttsQueueItemInBetween);
|
|
46442
|
-
|
|
46450
|
+
mergedSentences += sentenceInBetween;
|
|
46443
46451
|
restOfTheText = selectionInfo.cleanText.replace(sentenceInBetween, "");
|
|
46444
46452
|
}
|
|
46445
46453
|
}
|
|
46446
46454
|
if (ttsQueueItemEnd) {
|
|
46447
46455
|
const sentenceEnd = getTtsQueueItemRefText(ttsQueueItemEnd);
|
|
46448
|
-
|
|
46456
|
+
mergedSentences += " " + sentenceEnd;
|
|
46449
46457
|
}
|
|
46450
|
-
startIndex = (sentence + " " +
|
|
46458
|
+
startIndex = (sentence + " " + mergedSentences).indexOf(selectionInfo.cleanText);
|
|
46451
46459
|
textToBeSpoken = sentence.slice(startIndex, sentence.length);
|
|
46452
46460
|
restOfTheText = restOfTheText.replace(textToBeSpoken, "").trim();
|
|
46453
46461
|
}
|
|
@@ -48317,9 +48325,16 @@ var D2Reader = class {
|
|
|
48317
48325
|
const mainElement = findRequiredElement(document, "#D2Reader-Container");
|
|
48318
48326
|
const headerMenu = findElement(document, "#headerMenu");
|
|
48319
48327
|
const footerMenu = findElement(document, "#footerMenu");
|
|
48320
|
-
|
|
48328
|
+
let webPubManifestUrl = initialConfig.url;
|
|
48329
|
+
let publication;
|
|
48330
|
+
if (initialConfig.publication) {
|
|
48331
|
+
publication = TaJsonDeserialize(initialConfig.publication, Publication);
|
|
48332
|
+
publication.manifestUrl = new URL(webPubManifestUrl);
|
|
48333
|
+
} else {
|
|
48334
|
+
publication = await Publication.fromUrl(webPubManifestUrl, initialConfig.requestConfig);
|
|
48335
|
+
}
|
|
48321
48336
|
const store = new LocalStorageStore({
|
|
48322
|
-
prefix:
|
|
48337
|
+
prefix: publication.manifestUrl,
|
|
48323
48338
|
useLocalStorage: initialConfig.useLocalStorage ?? false
|
|
48324
48339
|
});
|
|
48325
48340
|
const settingsStore = new LocalStorageStore({
|
|
@@ -48332,17 +48347,16 @@ var D2Reader = class {
|
|
|
48332
48347
|
});
|
|
48333
48348
|
const annotator = new LocalAnnotator({ store });
|
|
48334
48349
|
const upLink = initialConfig.upLinkUrl ?? void 0;
|
|
48335
|
-
const publication = await Publication.fromUrl(webPubManifestUrl);
|
|
48336
48350
|
publication.sample = initialConfig.sample;
|
|
48337
48351
|
rights = updateConfig(rights, publication);
|
|
48338
48352
|
if (rights.autoGeneratePositions) {
|
|
48339
|
-
await publication.autoGeneratePositions();
|
|
48353
|
+
await publication.autoGeneratePositions(initialConfig.requestConfig);
|
|
48340
48354
|
} else {
|
|
48341
48355
|
if (initialConfig.services?.positions) {
|
|
48342
|
-
await publication.fetchPositionsFromService(initialConfig.services?.positions.href);
|
|
48356
|
+
await publication.fetchPositionsFromService(initialConfig.services?.positions.href, initialConfig.requestConfig);
|
|
48343
48357
|
}
|
|
48344
48358
|
if (initialConfig.services?.weight) {
|
|
48345
|
-
await publication.fetchWeightsFromService(initialConfig.services?.weight.href);
|
|
48359
|
+
await publication.fetchWeightsFromService(initialConfig.services?.weight.href, initialConfig.requestConfig);
|
|
48346
48360
|
}
|
|
48347
48361
|
}
|
|
48348
48362
|
const layers = await LayerSettings.create({ store: layerStore });
|
|
@@ -48350,7 +48364,6 @@ var D2Reader = class {
|
|
|
48350
48364
|
store: settingsStore,
|
|
48351
48365
|
initialUserSettings: initialConfig.userSettings,
|
|
48352
48366
|
headerMenu,
|
|
48353
|
-
material: initialConfig.material,
|
|
48354
48367
|
api: initialConfig.api,
|
|
48355
48368
|
injectables: (publication.Metadata.Rendition?.Layout ?? "unknown") === "fixed" ? initialConfig.injectablesFixed : initialConfig.injectables,
|
|
48356
48369
|
layout: (publication.Metadata.Rendition?.Layout ?? "unknown") === "fixed" ? "fixed" : "reflowable"
|
|
@@ -48364,12 +48377,12 @@ var D2Reader = class {
|
|
|
48364
48377
|
annotator,
|
|
48365
48378
|
upLink,
|
|
48366
48379
|
initialLastReadingPosition: initialConfig.lastReadingPosition,
|
|
48367
|
-
material: initialConfig.material,
|
|
48368
48380
|
api: initialConfig.api,
|
|
48369
48381
|
rights,
|
|
48370
48382
|
tts: initialConfig.tts,
|
|
48371
48383
|
sample: initialConfig.sample,
|
|
48372
|
-
|
|
48384
|
+
requestConfig: initialConfig.requestConfig,
|
|
48385
|
+
injectables: (publication.Metadata.Rendition?.Layout ?? "unknown") === "fixed" ? initialConfig.injectablesFixed ?? [] : initialConfig.injectables,
|
|
48373
48386
|
attributes: initialConfig.attributes,
|
|
48374
48387
|
services: initialConfig.services
|
|
48375
48388
|
});
|
|
@@ -48414,7 +48427,8 @@ var D2Reader = class {
|
|
|
48414
48427
|
headerMenu,
|
|
48415
48428
|
delegate: navigator2,
|
|
48416
48429
|
publication,
|
|
48417
|
-
highlighter
|
|
48430
|
+
highlighter,
|
|
48431
|
+
requestConfig: initialConfig.requestConfig
|
|
48418
48432
|
}, initialConfig.search)) : void 0;
|
|
48419
48433
|
const definitionsModule = rights.enableDefinitions ? await DefinitionsModule.create(__spreadValues({
|
|
48420
48434
|
delegate: navigator2,
|