@prose-reader/core 1.163.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 = {
|
|
@@ -8357,21 +8357,46 @@
|
|
|
8357
8357
|
latestContentHeightWhenLoaded: newLatestContentHeightWhenLoaded
|
|
8358
8358
|
};
|
|
8359
8359
|
};
|
|
8360
|
-
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 = ({
|
|
8361
8384
|
settings,
|
|
8362
8385
|
item,
|
|
8363
8386
|
context
|
|
8364
8387
|
}) => (stream) => stream.pipe(
|
|
8365
8388
|
rxjs.switchMap((frameElement) => {
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
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);
|
|
8371
8396
|
const spineItemUriParentPath = shared.getParentPath(item.href);
|
|
8372
|
-
const foundItem = (
|
|
8373
|
-
return `${spineItemUriParentPath
|
|
8374
|
-
`${href}`
|
|
8397
|
+
const foundItem = (_a = context.manifest) == null ? void 0 : _a.items.find(({ href }) => {
|
|
8398
|
+
return `${joinPath(spineItemUriParentPath, originalSrc).toLowerCase()}`.endsWith(
|
|
8399
|
+
`${href.toLowerCase()}`
|
|
8375
8400
|
);
|
|
8376
8401
|
});
|
|
8377
8402
|
if (!foundItem) return rxjs.of(null);
|
|
@@ -8383,22 +8408,24 @@
|
|
|
8383
8408
|
rxjs.tap((blob) => {
|
|
8384
8409
|
if (blob) {
|
|
8385
8410
|
const blobUrl = URL.createObjectURL(blob);
|
|
8386
|
-
|
|
8411
|
+
if (element.hasAttribute("src")) {
|
|
8412
|
+
element.setAttribute("src", blobUrl);
|
|
8413
|
+
} else if (element.hasAttribute("href")) {
|
|
8414
|
+
element.setAttribute("href", blobUrl);
|
|
8415
|
+
}
|
|
8387
8416
|
}
|
|
8388
8417
|
})
|
|
8389
8418
|
);
|
|
8390
8419
|
});
|
|
8391
|
-
return rxjs.combineLatest(
|
|
8420
|
+
return rxjs.combineLatest(assetsLoad$).pipe(rxjs.map(() => frameElement));
|
|
8392
8421
|
})
|
|
8393
8422
|
);
|
|
8394
8423
|
const unloadMedias = (frameElement) => {
|
|
8395
|
-
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
if (img.src.startsWith("blob:")) {
|
|
8401
|
-
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);
|
|
8402
8429
|
}
|
|
8403
8430
|
});
|
|
8404
8431
|
};
|
|
@@ -8433,7 +8460,7 @@
|
|
|
8433
8460
|
this.containerElement.appendChild(frameElement2);
|
|
8434
8461
|
}),
|
|
8435
8462
|
waitForFrameLoad,
|
|
8436
|
-
|
|
8463
|
+
loadAssets({
|
|
8437
8464
|
context: this.context,
|
|
8438
8465
|
item: this.item,
|
|
8439
8466
|
settings: this.settings
|