@prose-reader/core 1.162.0 → 1.164.0
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/index.umd.cjs
CHANGED
|
@@ -5567,7 +5567,7 @@
|
|
|
5567
5567
|
if (this.renditionLayout === `pre-paginated`) {
|
|
5568
5568
|
this.lastLayoutDims = {
|
|
5569
5569
|
height: this.context.getPageSize().height,
|
|
5570
|
-
width:
|
|
5570
|
+
width: params.minimumWidth
|
|
5571
5571
|
};
|
|
5572
5572
|
} else {
|
|
5573
5573
|
this.lastLayoutDims = {
|
|
@@ -6804,9 +6804,8 @@
|
|
|
6804
6804
|
const margin = 0;
|
|
6805
6805
|
const marginTop = 0;
|
|
6806
6806
|
const marginBottom = 0;
|
|
6807
|
-
const isReflow = true;
|
|
6808
6807
|
const containerElementWidth = dimensions.width;
|
|
6809
|
-
const containerElementEvenWidth = containerElementWidth
|
|
6808
|
+
const containerElementEvenWidth = containerElementWidth;
|
|
6810
6809
|
element.style.setProperty(`overflow`, `hidden`);
|
|
6811
6810
|
element.style.height = `${dimensions.height - marginTop - marginBottom}px`;
|
|
6812
6811
|
element.style.width = `${containerElementEvenWidth - 2 * margin}px`;
|
|
@@ -8358,21 +8357,46 @@
|
|
|
8358
8357
|
latestContentHeightWhenLoaded: newLatestContentHeightWhenLoaded
|
|
8359
8358
|
};
|
|
8360
8359
|
};
|
|
8361
|
-
const
|
|
8360
|
+
const joinPath = (base, path) => {
|
|
8361
|
+
const isFileProtocol = base.startsWith("file://");
|
|
8362
|
+
const tempBase = isFileProtocol ? base.replace("file://", "http://") : base;
|
|
8363
|
+
const result = new URL(path, tempBase).toString();
|
|
8364
|
+
return isFileProtocol ? result.replace("http://", "file://") : result;
|
|
8365
|
+
};
|
|
8366
|
+
const getElementsWithAssets = (document2) => {
|
|
8367
|
+
const RESOURCE_ELEMENTS = [
|
|
8368
|
+
"img",
|
|
8369
|
+
// Images
|
|
8370
|
+
"video",
|
|
8371
|
+
// Video files
|
|
8372
|
+
"audio",
|
|
8373
|
+
// Audio files
|
|
8374
|
+
"source",
|
|
8375
|
+
// Source elements within video/audio
|
|
8376
|
+
"link",
|
|
8377
|
+
// Stylesheets and other linked resources
|
|
8378
|
+
"script"
|
|
8379
|
+
// JavaScript files
|
|
8380
|
+
].join(",");
|
|
8381
|
+
return Array.from((document2 == null ? void 0 : document2.querySelectorAll(RESOURCE_ELEMENTS)) || []);
|
|
8382
|
+
};
|
|
8383
|
+
const loadAssets = ({
|
|
8362
8384
|
settings,
|
|
8363
8385
|
item,
|
|
8364
8386
|
context
|
|
8365
8387
|
}) => (stream) => stream.pipe(
|
|
8366
8388
|
rxjs.switchMap((frameElement) => {
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8389
|
+
const elementsWithAsset = getElementsWithAssets(
|
|
8390
|
+
frameElement.contentDocument
|
|
8391
|
+
);
|
|
8392
|
+
const assetsLoad$ = Array.from(elementsWithAsset).map((element) => {
|
|
8393
|
+
var _a;
|
|
8394
|
+
const originalSrc = element.getAttribute("src") || element.getAttribute("href");
|
|
8395
|
+
if (!originalSrc) return rxjs.of(null);
|
|
8372
8396
|
const spineItemUriParentPath = shared.getParentPath(item.href);
|
|
8373
|
-
const foundItem = (
|
|
8374
|
-
return `${spineItemUriParentPath
|
|
8375
|
-
`${href}`
|
|
8397
|
+
const foundItem = (_a = context.manifest) == null ? void 0 : _a.items.find(({ href }) => {
|
|
8398
|
+
return `${joinPath(spineItemUriParentPath, originalSrc).toLowerCase()}`.endsWith(
|
|
8399
|
+
`${href.toLowerCase()}`
|
|
8376
8400
|
);
|
|
8377
8401
|
});
|
|
8378
8402
|
if (!foundItem) return rxjs.of(null);
|
|
@@ -8384,22 +8408,24 @@
|
|
|
8384
8408
|
rxjs.tap((blob) => {
|
|
8385
8409
|
if (blob) {
|
|
8386
8410
|
const blobUrl = URL.createObjectURL(blob);
|
|
8387
|
-
|
|
8411
|
+
if (element.hasAttribute("src")) {
|
|
8412
|
+
element.setAttribute("src", blobUrl);
|
|
8413
|
+
} else if (element.hasAttribute("href")) {
|
|
8414
|
+
element.setAttribute("href", blobUrl);
|
|
8415
|
+
}
|
|
8388
8416
|
}
|
|
8389
8417
|
})
|
|
8390
8418
|
);
|
|
8391
8419
|
});
|
|
8392
|
-
return rxjs.combineLatest(
|
|
8420
|
+
return rxjs.combineLatest(assetsLoad$).pipe(rxjs.map(() => frameElement));
|
|
8393
8421
|
})
|
|
8394
8422
|
);
|
|
8395
8423
|
const unloadMedias = (frameElement) => {
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
if (img.src.startsWith("blob:")) {
|
|
8402
|
-
URL.revokeObjectURL(img.src);
|
|
8424
|
+
const elementsWithAsset = getElementsWithAssets(frameElement == null ? void 0 : frameElement.contentDocument);
|
|
8425
|
+
elementsWithAsset.forEach((element) => {
|
|
8426
|
+
const url = element.getAttribute("src") || element.getAttribute("href");
|
|
8427
|
+
if (url == null ? void 0 : url.startsWith("blob:")) {
|
|
8428
|
+
URL.revokeObjectURL(url);
|
|
8403
8429
|
}
|
|
8404
8430
|
});
|
|
8405
8431
|
};
|
|
@@ -8434,7 +8460,7 @@
|
|
|
8434
8460
|
this.containerElement.appendChild(frameElement2);
|
|
8435
8461
|
}),
|
|
8436
8462
|
waitForFrameLoad,
|
|
8437
|
-
|
|
8463
|
+
loadAssets({
|
|
8438
8464
|
context: this.context,
|
|
8439
8465
|
item: this.item,
|
|
8440
8466
|
settings: this.settings
|