@prose-reader/core 1.130.0 → 1.131.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/cfi/generate/generateCfiFromRange.d.ts +1 -6
- package/dist/createReaderWithEnhancer.d.ts +9 -9
- package/dist/enhancers/html/renderer/HtmlRenderer.d.ts +1 -0
- package/dist/enhancers/html/renderer/attachFrameSrc.d.ts +1 -1
- package/dist/enhancers/html/renderer/medias.d.ts +10 -0
- package/dist/enhancers/layoutEnhancer/types.d.ts +1 -0
- package/dist/enhancers/media/ImageRenderer.d.ts +1 -0
- package/dist/enhancers/pagination/enhancer.d.ts +7 -1
- package/dist/enhancers/pagination/locate.d.ts +32 -0
- package/dist/enhancers/selection/selection.d.ts +3 -3
- package/dist/enhancers/selection/selectionEnhancer.d.ts +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +345 -76
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +335 -66
- package/dist/index.umd.cjs.map +1 -1
- package/dist/navigation/consolidation/consolidateWithPagination.d.ts +24 -0
- package/dist/reader.d.ts +1 -6
- package/dist/spineItem/SpineItem.d.ts +1 -1
- package/dist/spineItem/renderer/DefaultRenderer.d.ts +1 -0
- package/dist/spineItem/renderer/DocumentRenderer.d.ts +8 -1
- package/dist/spineItem/{ResourceHandler.d.ts → resources/ResourceHandler.d.ts} +1 -1
- package/dist/utils/rxjs.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -406,6 +406,25 @@
|
|
|
406
406
|
return stream;
|
|
407
407
|
};
|
|
408
408
|
};
|
|
409
|
+
function idle() {
|
|
410
|
+
return new rxjs.Observable((observer) => {
|
|
411
|
+
if (window.requestIdleCallback) {
|
|
412
|
+
const handle = window.requestIdleCallback(() => {
|
|
413
|
+
observer.next();
|
|
414
|
+
observer.complete();
|
|
415
|
+
});
|
|
416
|
+
return () => cancelIdleCallback(handle);
|
|
417
|
+
}
|
|
418
|
+
const timeout = setTimeout(() => {
|
|
419
|
+
observer.next();
|
|
420
|
+
observer.complete();
|
|
421
|
+
}, 1);
|
|
422
|
+
return () => clearTimeout(timeout);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function deferIdle(callback) {
|
|
426
|
+
return rxjs.defer(() => idle().pipe(operators.switchMap(callback)));
|
|
427
|
+
}
|
|
409
428
|
const fixReflowable = (reader) => {
|
|
410
429
|
reader.hookManager.register(
|
|
411
430
|
`item.onAfterLayout`,
|
|
@@ -449,6 +468,8 @@
|
|
|
449
468
|
pageHorizontalMargin,
|
|
450
469
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
451
470
|
pageVerticalMargin,
|
|
471
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
472
|
+
layoutLayerTransition,
|
|
452
473
|
...rest
|
|
453
474
|
} = settings;
|
|
454
475
|
return rest;
|
|
@@ -457,18 +478,25 @@
|
|
|
457
478
|
return {
|
|
458
479
|
layoutAutoResize: "container",
|
|
459
480
|
pageHorizontalMargin: 24,
|
|
460
|
-
pageVerticalMargin: 24
|
|
481
|
+
pageVerticalMargin: 24,
|
|
482
|
+
layoutLayerTransition: true
|
|
461
483
|
};
|
|
462
484
|
}
|
|
463
485
|
};
|
|
464
486
|
const layoutEnhancer = (next) => (options) => {
|
|
465
|
-
const {
|
|
487
|
+
const {
|
|
488
|
+
pageHorizontalMargin,
|
|
489
|
+
pageVerticalMargin,
|
|
490
|
+
layoutAutoResize,
|
|
491
|
+
layoutLayerTransition
|
|
492
|
+
} = options;
|
|
466
493
|
const reader = next(options);
|
|
467
494
|
const settingsManager = new SettingsManager$1(
|
|
468
495
|
{
|
|
469
496
|
pageHorizontalMargin,
|
|
470
497
|
pageVerticalMargin,
|
|
471
|
-
layoutAutoResize
|
|
498
|
+
layoutAutoResize,
|
|
499
|
+
layoutLayerTransition
|
|
472
500
|
},
|
|
473
501
|
reader.settings
|
|
474
502
|
);
|
|
@@ -532,7 +560,9 @@
|
|
|
532
560
|
reader.hookManager.register(`item.onDocumentCreated`, ({ layers }) => {
|
|
533
561
|
layers.forEach(({ element }) => {
|
|
534
562
|
element.style.opacity = `0`;
|
|
535
|
-
|
|
563
|
+
if (settingsManager.values.layoutLayerTransition) {
|
|
564
|
+
element.style.transition = `opacity 300ms`;
|
|
565
|
+
}
|
|
536
566
|
});
|
|
537
567
|
});
|
|
538
568
|
reader.hookManager.register(`item.onBeforeLayout`, ({ item }) => {
|
|
@@ -545,11 +575,6 @@
|
|
|
545
575
|
});
|
|
546
576
|
const revealItemOnReady$ = reader.spineItemsObserver.itemIsReady$.pipe(
|
|
547
577
|
operators.filter(({ isReady }) => isReady),
|
|
548
|
-
/**
|
|
549
|
-
* Make sure that even if the document was loaded instantly, the layout is applied first
|
|
550
|
-
* and therefore the transition played. eg: pdf are loaded before attached to the dom.
|
|
551
|
-
*/
|
|
552
|
-
operators.delay(1, rxjs.animationFrameScheduler),
|
|
553
578
|
operators.tap(({ item }) => {
|
|
554
579
|
item.renderer.layers.forEach(({ element }) => {
|
|
555
580
|
element.style.opacity = `1`;
|
|
@@ -585,7 +610,22 @@
|
|
|
585
610
|
}),
|
|
586
611
|
operators.takeUntil(reader.$.destroy$)
|
|
587
612
|
).subscribe();
|
|
588
|
-
|
|
613
|
+
const updateSpineItemClassName$ = reader.spineItemsObserver.itemIsReady$.pipe(
|
|
614
|
+
operators.tap(({ item, isReady }) => {
|
|
615
|
+
const className = `prose-spineItem-ready`;
|
|
616
|
+
if (isReady) {
|
|
617
|
+
item.containerElement.classList.add(className);
|
|
618
|
+
} else {
|
|
619
|
+
item.containerElement.classList.remove(className);
|
|
620
|
+
}
|
|
621
|
+
})
|
|
622
|
+
);
|
|
623
|
+
rxjs.merge(
|
|
624
|
+
updateSpineItemClassName$,
|
|
625
|
+
revealItemOnReady$,
|
|
626
|
+
movingSafePan$,
|
|
627
|
+
layoutOnContainerResize$
|
|
628
|
+
).pipe(operators.takeUntil(reader.$.destroy$)).subscribe();
|
|
589
629
|
return {
|
|
590
630
|
...reader,
|
|
591
631
|
destroy: () => {
|
|
@@ -1474,17 +1514,116 @@
|
|
|
1474
1514
|
return { paginationInfo$, getPaginationInfo: () => currentValue.value };
|
|
1475
1515
|
};
|
|
1476
1516
|
const NAMESPACE$6 = `paginationEnhancer`;
|
|
1517
|
+
const consolidate = (item, reader) => {
|
|
1518
|
+
var _a;
|
|
1519
|
+
let itemPageIndex = (_a = item.meta) == null ? void 0 : _a.itemPageIndex;
|
|
1520
|
+
const { itemIndex } = reader.cfi.parseCfi(item.cfi);
|
|
1521
|
+
const spineItem = reader.spineItemsManager.get(itemIndex);
|
|
1522
|
+
if (!spineItem) return rxjs.of({ ...item, meta: { ...item.meta, itemIndex } });
|
|
1523
|
+
if (spineItem.item.renditionLayout === `pre-paginated`) {
|
|
1524
|
+
itemPageIndex = 0;
|
|
1525
|
+
}
|
|
1526
|
+
return idle().pipe(
|
|
1527
|
+
rxjs.withLatestFrom(spineItem.isReady$),
|
|
1528
|
+
rxjs.map(([, isSpineItemReady]) => {
|
|
1529
|
+
var _a2, _b, _c;
|
|
1530
|
+
let range = void 0;
|
|
1531
|
+
const { node: startNode, offset: startOffset } = reader.cfi.resolveCfi({ cfi: item.cfi }) ?? {};
|
|
1532
|
+
if (spineItem.item.renditionLayout !== `pre-paginated` && startNode) {
|
|
1533
|
+
itemPageIndex = reader.spine.locator.spineItemLocator.getSpineItemPageIndexFromNode(
|
|
1534
|
+
startNode,
|
|
1535
|
+
startOffset ?? 0,
|
|
1536
|
+
spineItem
|
|
1537
|
+
) ?? itemPageIndex;
|
|
1538
|
+
}
|
|
1539
|
+
if (startNode && item.endCfi) {
|
|
1540
|
+
const { node: endNode, offset: endOffset } = reader.cfi.resolveCfi({ cfi: item.cfi }) ?? {};
|
|
1541
|
+
if (endNode && isSpineItemReady) {
|
|
1542
|
+
range = (_a2 = startNode == null ? void 0 : startNode.ownerDocument) == null ? void 0 : _a2.createRange();
|
|
1543
|
+
range == null ? void 0 : range.setStart(startNode, startOffset ?? 0);
|
|
1544
|
+
range == null ? void 0 : range.setEnd(endNode, endOffset ?? 0);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
let absolutePageIndex = (_b = item.meta) == null ? void 0 : _b.absolutePageIndex;
|
|
1548
|
+
if (itemPageIndex !== void 0) {
|
|
1549
|
+
absolutePageIndex = reader.spine.locator.getAbsolutePageIndexFromPageIndex({
|
|
1550
|
+
pageIndex: itemPageIndex,
|
|
1551
|
+
spineItemOrId: spineItem
|
|
1552
|
+
}) ?? ((_c = item.meta) == null ? void 0 : _c.absolutePageIndex);
|
|
1553
|
+
}
|
|
1554
|
+
return {
|
|
1555
|
+
...item,
|
|
1556
|
+
meta: {
|
|
1557
|
+
...item.meta,
|
|
1558
|
+
range,
|
|
1559
|
+
itemIndex,
|
|
1560
|
+
startNode,
|
|
1561
|
+
startOffset,
|
|
1562
|
+
absolutePageIndex,
|
|
1563
|
+
itemPageIndex
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
})
|
|
1567
|
+
);
|
|
1568
|
+
};
|
|
1569
|
+
const createLocator = (reader) => (resources) => {
|
|
1570
|
+
return deferIdle(() => {
|
|
1571
|
+
if (!resources.length)
|
|
1572
|
+
return rxjs.of({ isStale: false, data: resources });
|
|
1573
|
+
const StaleSymbol = Symbol("stale");
|
|
1574
|
+
const markStale$ = reader.layout$.pipe(
|
|
1575
|
+
rxjs.startWith(null),
|
|
1576
|
+
rxjs.map(() => StaleSymbol)
|
|
1577
|
+
);
|
|
1578
|
+
const consolidate$ = reader.layout$.pipe(
|
|
1579
|
+
rxjs.debounceTime(10),
|
|
1580
|
+
rxjs.startWith(null),
|
|
1581
|
+
rxjs.switchScan((acc$) => {
|
|
1582
|
+
return rxjs.forkJoin(
|
|
1583
|
+
acc$.map(
|
|
1584
|
+
(resource) => deferIdle(() => consolidate(resource, reader)).pipe(
|
|
1585
|
+
rxjs.map((value) => value)
|
|
1586
|
+
)
|
|
1587
|
+
)
|
|
1588
|
+
);
|
|
1589
|
+
}, resources)
|
|
1590
|
+
);
|
|
1591
|
+
const run$ = rxjs.merge(markStale$, consolidate$).pipe(
|
|
1592
|
+
rxjs.scan(
|
|
1593
|
+
(acc, value) => {
|
|
1594
|
+
if (value === StaleSymbol) {
|
|
1595
|
+
return {
|
|
1596
|
+
...acc,
|
|
1597
|
+
isStale: true
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
return {
|
|
1601
|
+
isStale: false,
|
|
1602
|
+
data: value
|
|
1603
|
+
};
|
|
1604
|
+
},
|
|
1605
|
+
{
|
|
1606
|
+
isStale: true,
|
|
1607
|
+
data: resources
|
|
1608
|
+
}
|
|
1609
|
+
)
|
|
1610
|
+
);
|
|
1611
|
+
return run$;
|
|
1612
|
+
});
|
|
1613
|
+
};
|
|
1477
1614
|
Report.namespace(NAMESPACE$6);
|
|
1478
1615
|
const paginationEnhancer = (next) => (options) => {
|
|
1479
1616
|
const reader = next(options);
|
|
1480
1617
|
const { paginationInfo$, getPaginationInfo } = trackPaginationInfo(reader);
|
|
1481
1618
|
paginationInfo$.pipe(rxjs.takeUntil(reader.$.destroy$)).subscribe();
|
|
1619
|
+
const locate = createLocator(reader);
|
|
1482
1620
|
return {
|
|
1483
1621
|
...reader,
|
|
1484
1622
|
pagination: {
|
|
1485
1623
|
...reader.pagination,
|
|
1486
1624
|
getState: () => getPaginationInfo(),
|
|
1487
|
-
state$: paginationInfo
|
|
1625
|
+
state$: paginationInfo$,
|
|
1626
|
+
locate
|
|
1488
1627
|
}
|
|
1489
1628
|
};
|
|
1490
1629
|
};
|
|
@@ -4382,19 +4521,6 @@
|
|
|
4382
4521
|
})
|
|
4383
4522
|
);
|
|
4384
4523
|
};
|
|
4385
|
-
const withPaginationInfo = () => (stream) => {
|
|
4386
|
-
return stream.pipe(
|
|
4387
|
-
rxjs.map(({ navigation, pagination, ...rest }) => {
|
|
4388
|
-
return {
|
|
4389
|
-
navigation: {
|
|
4390
|
-
...navigation,
|
|
4391
|
-
paginationBeginCfi: pagination.beginCfi
|
|
4392
|
-
},
|
|
4393
|
-
...rest
|
|
4394
|
-
};
|
|
4395
|
-
})
|
|
4396
|
-
);
|
|
4397
|
-
};
|
|
4398
4524
|
const withCfiPosition = ({ navigationResolver }) => (stream) => {
|
|
4399
4525
|
return stream.pipe(
|
|
4400
4526
|
rxjs.map((params) => {
|
|
@@ -4490,6 +4616,52 @@
|
|
|
4490
4616
|
})
|
|
4491
4617
|
);
|
|
4492
4618
|
};
|
|
4619
|
+
const withPaginationInfo = () => (stream) => {
|
|
4620
|
+
return stream.pipe(
|
|
4621
|
+
rxjs.map(({ navigation, pagination, ...rest }) => {
|
|
4622
|
+
return {
|
|
4623
|
+
navigation: {
|
|
4624
|
+
...navigation,
|
|
4625
|
+
paginationBeginCfi: pagination.beginCfi
|
|
4626
|
+
},
|
|
4627
|
+
...rest
|
|
4628
|
+
};
|
|
4629
|
+
})
|
|
4630
|
+
);
|
|
4631
|
+
};
|
|
4632
|
+
const consolidateWithPagination = (context, navigation$, spine) => context.bridgeEvent.pagination$.pipe(
|
|
4633
|
+
rxjs.withLatestFrom(navigation$),
|
|
4634
|
+
rxjs.filter(
|
|
4635
|
+
([pagination, navigation]) => pagination.navigationId === navigation.id
|
|
4636
|
+
),
|
|
4637
|
+
/**
|
|
4638
|
+
* We only register the pagination cfi IF the spine item is ready.
|
|
4639
|
+
* Otherwise we might save something incomplete and thus restore
|
|
4640
|
+
* the user to an invalid location.
|
|
4641
|
+
*/
|
|
4642
|
+
rxjs.switchMap(([pagination, navigation]) => {
|
|
4643
|
+
const spineItem = spine.spineItemsManager.get(navigation.spineItem);
|
|
4644
|
+
return ((spineItem == null ? void 0 : spineItem.isReady$.pipe(rxjs.first())) ?? rxjs.of(false)).pipe(
|
|
4645
|
+
rxjs.filter((isReady) => isReady),
|
|
4646
|
+
rxjs.map(() => ({
|
|
4647
|
+
pagination,
|
|
4648
|
+
navigation
|
|
4649
|
+
}))
|
|
4650
|
+
);
|
|
4651
|
+
}),
|
|
4652
|
+
withPaginationInfo(),
|
|
4653
|
+
rxjs.distinctUntilChanged(
|
|
4654
|
+
(prev, curr) => prev.navigation.paginationBeginCfi === curr.navigation.paginationBeginCfi
|
|
4655
|
+
),
|
|
4656
|
+
rxjs.map(
|
|
4657
|
+
({ navigation }) => ({
|
|
4658
|
+
...navigation,
|
|
4659
|
+
meta: {
|
|
4660
|
+
triggeredBy: "pagination"
|
|
4661
|
+
}
|
|
4662
|
+
})
|
|
4663
|
+
)
|
|
4664
|
+
);
|
|
4493
4665
|
const NAMESPACE$1 = `navigation/InternalNavigator`;
|
|
4494
4666
|
const report = Report.namespace(NAMESPACE$1);
|
|
4495
4667
|
class InternalNavigator extends DestroyableClass {
|
|
@@ -4613,7 +4785,12 @@
|
|
|
4613
4785
|
const navigationUpateFromLayout$ = layoutHasChanged$.pipe(
|
|
4614
4786
|
rxjs.switchMap(() => {
|
|
4615
4787
|
return rxjs.of(null).pipe(
|
|
4616
|
-
rxjs.switchMap(
|
|
4788
|
+
rxjs.switchMap(
|
|
4789
|
+
() => isUserLocked$.pipe(
|
|
4790
|
+
rxjs.filter((isLocked) => !isLocked),
|
|
4791
|
+
rxjs.first()
|
|
4792
|
+
)
|
|
4793
|
+
),
|
|
4617
4794
|
rxjs.map(
|
|
4618
4795
|
() => ({
|
|
4619
4796
|
...this.navigationSubject.getValue(),
|
|
@@ -4678,29 +4855,10 @@
|
|
|
4678
4855
|
rxjs.map(({ navigation }) => navigation),
|
|
4679
4856
|
rxjs.share()
|
|
4680
4857
|
);
|
|
4681
|
-
const navigationUpdateOnPaginationUpdate$ =
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
),
|
|
4686
|
-
rxjs.map(([pagination, navigation]) => ({
|
|
4687
|
-
pagination,
|
|
4688
|
-
navigation: {
|
|
4689
|
-
...navigation
|
|
4690
|
-
}
|
|
4691
|
-
})),
|
|
4692
|
-
withPaginationInfo(),
|
|
4693
|
-
rxjs.distinctUntilChanged(
|
|
4694
|
-
(prev, curr) => prev.navigation.paginationBeginCfi === curr.navigation.paginationBeginCfi
|
|
4695
|
-
),
|
|
4696
|
-
rxjs.map(
|
|
4697
|
-
({ navigation }) => ({
|
|
4698
|
-
...navigation,
|
|
4699
|
-
meta: {
|
|
4700
|
-
triggeredBy: "pagination"
|
|
4701
|
-
}
|
|
4702
|
-
})
|
|
4703
|
-
)
|
|
4858
|
+
const navigationUpdateOnPaginationUpdate$ = consolidateWithPagination(
|
|
4859
|
+
context,
|
|
4860
|
+
this.navigationSubject,
|
|
4861
|
+
spine
|
|
4704
4862
|
);
|
|
4705
4863
|
const navigationUpdate$ = rxjs.merge(
|
|
4706
4864
|
navigationRestored$,
|
|
@@ -5173,9 +5331,7 @@
|
|
|
5173
5331
|
})
|
|
5174
5332
|
);
|
|
5175
5333
|
const updateCfi$ = updatePagination$.pipe(
|
|
5176
|
-
|
|
5177
|
-
rxjs.filter((state) => state === "free"),
|
|
5178
|
-
rxjs.switchMap(() => rxjs.timer(500, rxjs.animationFrameScheduler)),
|
|
5334
|
+
waitForSwitch(this.context.bridgeEvent.viewportFree$),
|
|
5179
5335
|
rxjs.tap(() => {
|
|
5180
5336
|
const {
|
|
5181
5337
|
beginSpineItemIndex,
|
|
@@ -5205,14 +5361,9 @@
|
|
|
5205
5361
|
rxjs.merge(updatePagination$, updateCfi$).pipe(rxjs.takeUntil(this.destroy$)).subscribe();
|
|
5206
5362
|
}
|
|
5207
5363
|
}
|
|
5208
|
-
const generateCfiFromRange = ({
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
end,
|
|
5212
|
-
endNode
|
|
5213
|
-
}, item) => {
|
|
5214
|
-
const startCFI = generateCfi(startNode, start, item);
|
|
5215
|
-
const endCFI = generateCfi(endNode, end, item);
|
|
5364
|
+
const generateCfiFromRange = (range, item) => {
|
|
5365
|
+
const startCFI = generateCfi(range.startContainer, range.startOffset, item);
|
|
5366
|
+
const endCFI = generateCfi(range.endContainer, range.endOffset, item);
|
|
5216
5367
|
return { start: startCFI, end: endCFI };
|
|
5217
5368
|
};
|
|
5218
5369
|
const defaultGetResource = (item) => new URL(item.href);
|
|
@@ -5342,6 +5493,29 @@
|
|
|
5342
5493
|
unload() {
|
|
5343
5494
|
this.triggerSubject.next({ type: `unload` });
|
|
5344
5495
|
}
|
|
5496
|
+
renderHeadless() {
|
|
5497
|
+
const releaseSubject = new rxjs.Subject();
|
|
5498
|
+
return rxjs.defer(() => this.onRenderHeadless({ release: releaseSubject })).pipe(
|
|
5499
|
+
rxjs.endWith(void 0),
|
|
5500
|
+
rxjs.first(),
|
|
5501
|
+
rxjs.map((doc) => {
|
|
5502
|
+
if (!doc) return void 0;
|
|
5503
|
+
return {
|
|
5504
|
+
doc,
|
|
5505
|
+
release: () => {
|
|
5506
|
+
releaseSubject.next(void 0);
|
|
5507
|
+
}
|
|
5508
|
+
};
|
|
5509
|
+
}),
|
|
5510
|
+
rxjs.finalize(() => {
|
|
5511
|
+
releaseSubject.complete();
|
|
5512
|
+
}),
|
|
5513
|
+
rxjs.catchError((e) => {
|
|
5514
|
+
Report.error(e);
|
|
5515
|
+
return rxjs.of(void 0);
|
|
5516
|
+
})
|
|
5517
|
+
);
|
|
5518
|
+
}
|
|
5345
5519
|
destroy() {
|
|
5346
5520
|
super.destroy();
|
|
5347
5521
|
this.stateSubject.complete();
|
|
@@ -5366,6 +5540,9 @@
|
|
|
5366
5540
|
onLayout() {
|
|
5367
5541
|
return rxjs.of(void 0);
|
|
5368
5542
|
}
|
|
5543
|
+
onRenderHeadless() {
|
|
5544
|
+
return rxjs.EMPTY;
|
|
5545
|
+
}
|
|
5369
5546
|
}
|
|
5370
5547
|
class SpineItem extends DestroyableClass {
|
|
5371
5548
|
constructor(item, parentElement, context, settings, hookManager, index) {
|
|
@@ -5507,7 +5684,7 @@
|
|
|
5507
5684
|
operators.map(([event, loaded]) => !!(event.type === `end` && loaded)),
|
|
5508
5685
|
operators.startWith(false),
|
|
5509
5686
|
operators.distinctUntilChanged(),
|
|
5510
|
-
operators.shareReplay({ refCount: true })
|
|
5687
|
+
operators.shareReplay({ refCount: true, bufferSize: 1 })
|
|
5511
5688
|
);
|
|
5512
5689
|
this.needsLayout$ = rxjs.merge(this.unloaded$, this.loaded$);
|
|
5513
5690
|
rxjs.merge(this.layout$, this.isReady$).pipe(operators.takeUntil(this.destroy$)).subscribe();
|
|
@@ -6359,7 +6536,9 @@
|
|
|
6359
6536
|
}),
|
|
6360
6537
|
rxjs.share()
|
|
6361
6538
|
);
|
|
6362
|
-
this.info$ = this.layout$.pipe(
|
|
6539
|
+
this.info$ = this.layout$.pipe(
|
|
6540
|
+
rxjs.shareReplay({ refCount: true, bufferSize: 1 })
|
|
6541
|
+
);
|
|
6363
6542
|
rxjs.merge(this.layout$, this.info$).pipe(rxjs.takeUntil(this.destroy$)).subscribe();
|
|
6364
6543
|
}
|
|
6365
6544
|
layout() {
|
|
@@ -6971,6 +7150,9 @@
|
|
|
6971
7150
|
height
|
|
6972
7151
|
});
|
|
6973
7152
|
}
|
|
7153
|
+
onRenderHeadless() {
|
|
7154
|
+
return rxjs.EMPTY;
|
|
7155
|
+
}
|
|
6974
7156
|
}
|
|
6975
7157
|
const mediaEnhancer = (next) => (options) => {
|
|
6976
7158
|
const reader = next({
|
|
@@ -7209,6 +7391,7 @@
|
|
|
7209
7391
|
top: 0;
|
|
7210
7392
|
color: rgb(202, 202, 202);
|
|
7211
7393
|
background-color: white;
|
|
7394
|
+
z-index: 1;
|
|
7212
7395
|
`;
|
|
7213
7396
|
return loadingElement;
|
|
7214
7397
|
};
|
|
@@ -7277,11 +7460,15 @@
|
|
|
7277
7460
|
);
|
|
7278
7461
|
const updateEntriesVisibility$ = (entries) => reader.spineItemsObserver.itemIsReady$.pipe(
|
|
7279
7462
|
operators.tap(({ item, isReady }) => {
|
|
7280
|
-
var _a;
|
|
7463
|
+
var _a, _b;
|
|
7281
7464
|
(_a = entries[item.item.id]) == null ? void 0 : _a.style.setProperty(
|
|
7282
7465
|
`visibility`,
|
|
7283
7466
|
isReady ? `hidden` : `visible`
|
|
7284
7467
|
);
|
|
7468
|
+
(_b = entries[item.item.id]) == null ? void 0 : _b.style.setProperty(
|
|
7469
|
+
`z-index`,
|
|
7470
|
+
isReady ? `0` : `1`
|
|
7471
|
+
);
|
|
7285
7472
|
})
|
|
7286
7473
|
);
|
|
7287
7474
|
const loadingItems$ = reader.spineItemsManager.items$.pipe(
|
|
@@ -7997,8 +8184,6 @@
|
|
|
7997
8184
|
if ((frameElement == null ? void 0 : frameElement.contentDocument) && (frameElement == null ? void 0 : frameElement.contentWindow)) {
|
|
7998
8185
|
let contentWidth = pageWidth;
|
|
7999
8186
|
let contentHeight = pageHeight;
|
|
8000
|
-
frameElement == null ? void 0 : frameElement.style.setProperty(`visibility`, `visible`);
|
|
8001
|
-
frameElement == null ? void 0 : frameElement.style.setProperty(`opacity`, `1`);
|
|
8002
8187
|
if (viewportDimensions == null ? void 0 : viewportDimensions.hasViewport) {
|
|
8003
8188
|
upsertCSS(
|
|
8004
8189
|
frameElement,
|
|
@@ -8094,6 +8279,51 @@
|
|
|
8094
8279
|
latestContentHeightWhenLoaded: newLatestContentHeightWhenLoaded
|
|
8095
8280
|
};
|
|
8096
8281
|
};
|
|
8282
|
+
const loadMedias = ({
|
|
8283
|
+
settings,
|
|
8284
|
+
item,
|
|
8285
|
+
context
|
|
8286
|
+
}) => (stream) => stream.pipe(
|
|
8287
|
+
rxjs.switchMap((frameElement) => {
|
|
8288
|
+
var _a;
|
|
8289
|
+
const images = ((_a = frameElement.contentDocument) == null ? void 0 : _a.getElementsByTagName("img")) || [];
|
|
8290
|
+
const imageObservables = Array.from(images).map((img) => {
|
|
8291
|
+
var _a2;
|
|
8292
|
+
const originalSrc = img.getAttribute("src");
|
|
8293
|
+
const spineItemUriParentPath = shared.getParentPath(item.href);
|
|
8294
|
+
const foundItem = (_a2 = context.manifest) == null ? void 0 : _a2.items.find(({ href }) => {
|
|
8295
|
+
return `${spineItemUriParentPath}/${originalSrc}`.endsWith(
|
|
8296
|
+
`${href}`
|
|
8297
|
+
);
|
|
8298
|
+
});
|
|
8299
|
+
if (!foundItem) return rxjs.of(null);
|
|
8300
|
+
const resourceHandler = new ResourceHandler(foundItem, settings);
|
|
8301
|
+
return rxjs.from(resourceHandler.getResource()).pipe(
|
|
8302
|
+
rxjs.mergeMap(
|
|
8303
|
+
(resource) => resource instanceof Response ? rxjs.from(resource.blob()) : rxjs.of(void 0)
|
|
8304
|
+
),
|
|
8305
|
+
rxjs.tap((blob) => {
|
|
8306
|
+
if (blob) {
|
|
8307
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
8308
|
+
img.src = blobUrl;
|
|
8309
|
+
}
|
|
8310
|
+
})
|
|
8311
|
+
);
|
|
8312
|
+
});
|
|
8313
|
+
return rxjs.combineLatest(imageObservables).pipe(rxjs.map(() => frameElement));
|
|
8314
|
+
})
|
|
8315
|
+
);
|
|
8316
|
+
const unloadMedias = (frameElement) => {
|
|
8317
|
+
var _a;
|
|
8318
|
+
const images = Array.from(
|
|
8319
|
+
((_a = frameElement == null ? void 0 : frameElement.contentDocument) == null ? void 0 : _a.getElementsByTagName("img")) || []
|
|
8320
|
+
);
|
|
8321
|
+
images.forEach((img) => {
|
|
8322
|
+
if (img.src.startsWith("blob:")) {
|
|
8323
|
+
URL.revokeObjectURL(img.src);
|
|
8324
|
+
}
|
|
8325
|
+
});
|
|
8326
|
+
};
|
|
8097
8327
|
class HtmlRenderer extends DocumentRenderer {
|
|
8098
8328
|
constructor() {
|
|
8099
8329
|
super(...arguments);
|
|
@@ -8125,10 +8355,16 @@
|
|
|
8125
8355
|
this.containerElement.appendChild(frameElement2);
|
|
8126
8356
|
}),
|
|
8127
8357
|
waitForFrameLoad,
|
|
8358
|
+
loadMedias({
|
|
8359
|
+
context: this.context,
|
|
8360
|
+
item: this.item,
|
|
8361
|
+
settings: this.settings
|
|
8362
|
+
}),
|
|
8128
8363
|
waitForFrameReady
|
|
8129
8364
|
);
|
|
8130
8365
|
}
|
|
8131
8366
|
onUnload() {
|
|
8367
|
+
unloadMedias(this.getFrameElement());
|
|
8132
8368
|
this.layers.forEach((layer) => layer.element.remove());
|
|
8133
8369
|
this.layers = [];
|
|
8134
8370
|
return rxjs.EMPTY;
|
|
@@ -8172,6 +8408,34 @@
|
|
|
8172
8408
|
this.latestContentHeightWhenLoaded = latestContentHeightWhenLoaded;
|
|
8173
8409
|
return rxjs.of(rest);
|
|
8174
8410
|
}
|
|
8411
|
+
onRenderHeadless() {
|
|
8412
|
+
return rxjs.from(this.resourcesHandler.fetchResource()).pipe(
|
|
8413
|
+
rxjs.switchMap((resource) => {
|
|
8414
|
+
if (resource instanceof Response) {
|
|
8415
|
+
const contentType = resource.headers.get("content-type") ?? "";
|
|
8416
|
+
const parsableContentTypes = [
|
|
8417
|
+
`application/xhtml+xml`,
|
|
8418
|
+
`application/xml`,
|
|
8419
|
+
`text/html`,
|
|
8420
|
+
`text/xml`
|
|
8421
|
+
];
|
|
8422
|
+
if (parsableContentTypes.includes(contentType)) {
|
|
8423
|
+
return rxjs.from(resource.text()).pipe(
|
|
8424
|
+
rxjs.map((text) => {
|
|
8425
|
+
const domParser = new DOMParser();
|
|
8426
|
+
const doc = domParser.parseFromString(
|
|
8427
|
+
text,
|
|
8428
|
+
contentType
|
|
8429
|
+
);
|
|
8430
|
+
return doc;
|
|
8431
|
+
})
|
|
8432
|
+
);
|
|
8433
|
+
}
|
|
8434
|
+
}
|
|
8435
|
+
return rxjs.of(void 0);
|
|
8436
|
+
})
|
|
8437
|
+
);
|
|
8438
|
+
}
|
|
8175
8439
|
getFrameElement() {
|
|
8176
8440
|
var _a;
|
|
8177
8441
|
const frame = (_a = this.layers[0]) == null ? void 0 : _a.element;
|
|
@@ -8248,7 +8512,7 @@
|
|
|
8248
8512
|
}
|
|
8249
8513
|
return range;
|
|
8250
8514
|
};
|
|
8251
|
-
const
|
|
8515
|
+
const createOrderedRangeFromSelection = ({
|
|
8252
8516
|
selection,
|
|
8253
8517
|
spineItem
|
|
8254
8518
|
}) => {
|
|
@@ -8374,7 +8638,7 @@
|
|
|
8374
8638
|
selectionAfterPointerUp$,
|
|
8375
8639
|
lastSelectionOnPointerdown$,
|
|
8376
8640
|
getSelection: () => selectionSubject.getValue(),
|
|
8377
|
-
|
|
8641
|
+
createOrderedRangeFromSelection
|
|
8378
8642
|
},
|
|
8379
8643
|
destroy: () => {
|
|
8380
8644
|
selectionSubject.complete();
|
|
@@ -8437,10 +8701,15 @@
|
|
|
8437
8701
|
exports2.SettingsManager = SettingsManager;
|
|
8438
8702
|
exports2.SpineItem = SpineItem;
|
|
8439
8703
|
exports2.createReader = createReaderWithEnhancers;
|
|
8704
|
+
exports2.deferIdle = deferIdle;
|
|
8705
|
+
exports2.deferNextResult = deferNextResult;
|
|
8440
8706
|
exports2.getAttributeValueFromString = getAttributeValueFromString;
|
|
8441
8707
|
exports2.getFrameViewportInfo = getFrameViewportInfo;
|
|
8708
|
+
exports2.idle = idle;
|
|
8442
8709
|
exports2.injectCSS = injectCSS;
|
|
8443
8710
|
exports2.isHtmlElement = isHtmlElement;
|
|
8711
|
+
exports2.mapKeysTo = mapKeysTo;
|
|
8712
|
+
exports2.observeResize = observeResize;
|
|
8444
8713
|
exports2.removeCSS = removeCSS;
|
|
8445
8714
|
exports2.upsertCSS = upsertCSS;
|
|
8446
8715
|
exports2.waitForFrameLoad = waitForFrameLoad;
|