@readium/navigator 2.0.0-beta.3 → 2.0.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/index.js +13 -9
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3560,15 +3560,19 @@ function Ri(i) {
|
|
|
3560
3560
|
return i.clientHeight - e - A;
|
|
3561
3561
|
}
|
|
3562
3562
|
function xe(i) {
|
|
3563
|
-
const t = i
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
const e =
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3563
|
+
const t = pA(i);
|
|
3564
|
+
if (!t)
|
|
3565
|
+
return !1;
|
|
3566
|
+
const e = i.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
3567
|
+
for (const a of e)
|
|
3568
|
+
a.remove();
|
|
3569
|
+
const A = e.length, n = i.document.scrollingElement.scrollWidth, r = i.visualViewport.width, s = Math.round(n / r * t) % t, o = t === 1 || s === 0 ? 0 : t - s;
|
|
3570
|
+
if (o > 0)
|
|
3571
|
+
for (let a = 0; a < o; a++) {
|
|
3572
|
+
const h = i.document.createElement("div");
|
|
3573
|
+
h.setAttribute("id", `readium-virtual-page-${a}`), h.dataset.readium = "true", CSS.supports("break-before", "column") ? h.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (h.style.breakInside = "avoid-column"), h.style.height = Ri(i.document.documentElement) + "px"), h.innerHTML = "​", i.document.body.appendChild(h);
|
|
3571
3574
|
}
|
|
3575
|
+
return A !== o;
|
|
3572
3576
|
}
|
|
3573
3577
|
function Qi(i) {
|
|
3574
3578
|
return i < 0.5 ? 2 * i * i : -1 + (4 - 2 * i) * i;
|
|
@@ -4112,7 +4116,7 @@ const yA = class qt extends Dt {
|
|
|
4112
4116
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
4113
4117
|
value: {
|
|
4114
4118
|
name: "readium-ts-toolkit",
|
|
4115
|
-
version: "2.0.0-beta.
|
|
4119
|
+
version: "2.0.0-beta.2",
|
|
4116
4120
|
hasFeature: (n, r = "") => {
|
|
4117
4121
|
switch (n) {
|
|
4118
4122
|
case "dom-manipulation":
|
package/dist/index.umd.cjs
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
html, body {
|
|
39
39
|
touch-action: manipulation;
|
|
40
40
|
user-select: ${this.protected?"none":"auto"};
|
|
41
|
-
}`}mount(t,e){const A=t.document.createElement("style");return A.dataset.readium="true",A.id=Ze,A.textContent=this.buildStyles(),t.document.head.appendChild(A),e.register("protect",me.moduleName,(n,r)=>{this.protected=!0,A.textContent=this.buildStyles(),r(!0)}),e.register("unprotect",me.moduleName,(n,r)=>{this.protected=!1,A.textContent=this.buildStyles(),r(!0)}),e.log("Snapper Mounted"),!0}unmount(t,e){var A;return(A=t.document.getElementById(Ze))==null||A.remove(),e.log("Snapper Unmounted"),!0}};Ke.moduleName="snapper";let qe=Ke;function it(i){return i.document.body.dir.toLowerCase()==="rtl"}function _e(i){return parseInt(i.getComputedStyle(i.document.documentElement).getPropertyValue("column-count"))}function vi(i){const t=getComputedStyle(i),e=parseFloat(t.paddingTop||"0"),A=parseFloat(t.paddingBottom||"0");return i.clientHeight-e-A}function $e(i){const t=i.document.querySelectorAll("div[id^='readium-virtual-page']");for(const
|
|
41
|
+
}`}mount(t,e){const A=t.document.createElement("style");return A.dataset.readium="true",A.id=Ze,A.textContent=this.buildStyles(),t.document.head.appendChild(A),e.register("protect",me.moduleName,(n,r)=>{this.protected=!0,A.textContent=this.buildStyles(),r(!0)}),e.register("unprotect",me.moduleName,(n,r)=>{this.protected=!1,A.textContent=this.buildStyles(),r(!0)}),e.log("Snapper Mounted"),!0}unmount(t,e){var A;return(A=t.document.getElementById(Ze))==null||A.remove(),e.log("Snapper Unmounted"),!0}};Ke.moduleName="snapper";let qe=Ke;function it(i){return i.document.body.dir.toLowerCase()==="rtl"}function _e(i){return parseInt(i.getComputedStyle(i.document.documentElement).getPropertyValue("column-count"))}function vi(i){const t=getComputedStyle(i),e=parseFloat(t.paddingTop||"0"),A=parseFloat(t.paddingBottom||"0");return i.clientHeight-e-A}function $e(i){const t=_e(i);if(!t)return!1;const e=i.document.querySelectorAll("div[id^='readium-virtual-page']");for(const a of e)a.remove();const A=e.length,n=i.document.scrollingElement.scrollWidth,r=i.visualViewport.width,s=Math.round(n/r*t)%t,o=t===1||s===0?0:t-s;if(o>0)for(let a=0;a<o;a++){const h=i.document.createElement("div");h.setAttribute("id",`readium-virtual-page-${a}`),h.dataset.readium="true",CSS.supports("break-before","column")?h.style.breakBefore="column":(CSS.supports("break-inside","avoid-column")&&(h.style.breakInside="avoid-column"),h.style.height=vi(i.document.documentElement)+"px"),h.innerHTML="​",i.document.body.appendChild(h)}return A!==o}function Gi(i){return i<.5?2*i*i:-1+(4-2*i)*i}function T(i){const t=i.getSelection();t&&t.removeAllRanges()}const Hi=["a","audio","button","canvas","details","input","label","option","select","submit","textarea","video"];function tA(i){var t;return Hi.indexOf(i.nodeName.toLowerCase())!==-1||i.hasAttribute("contenteditable")&&((t=i.getAttribute("contenteditable"))==null?void 0:t.toLowerCase())!=="false"?i:i.parentElement?tA(i.parentElement):null}function eA(i,t){const e=AA(i,i.document.body,t),A=i._readium_cssSelectorGenerator.getCssSelector(e,{selectors:["tag","id","class","nthchild","nthoftype","attribute"]});return new _({href:"#",type:"application/xhtml+xml",locations:new S({otherLocations:new Map([["cssSelector",A]])}),text:new at({highlight:e.textContent||void 0})})}function AA(i,t,e){for(var A=0;A<t.children.length;A++){const n=t.children[A];if(!Wi(n)&&ki(i,n,e))return Ji(i,n)?n:AA(i,n,e)}return t}function ki(i,t,e){if(t===document.body||t===document.documentElement)return!0;if(!document||!document.documentElement||!document.body)return!1;const A=t.getBoundingClientRect();return e?A.bottom>0&&A.top<i.innerHeight:A.right>0&&A.left<i.innerWidth}function Ji(i,t){const e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=i.innerHeight&&e.right<=i.innerWidth}function Wi(i){const t=getComputedStyle(i);if(t){const e=t.getPropertyValue("display");if(e!="block"&&e!="list-item"||t.getPropertyValue("opacity")==="0")return!0}return!1}const iA="readium-column-snapper-style",Li=200,nA=class P extends qe{constructor(){super(...arguments),this.shakeTimeout=0,this.snappingCancelled=!1,this.alreadyScrollLeft=0,this.overscroll=0,this.cachedScrollWidth=0,this.touchState=0,this.startingX=void 0,this.endingX=void 0,this.onTouchStarter=this.onTouchStart.bind(this),this.onTouchEnder=this.onTouchEnd.bind(this),this.onWidthChanger=this.onWidthChange.bind(this),this.onTouchMover=this.onTouchMove.bind(this)}doc(){return this.wnd.document.scrollingElement}scrollOffset(){return this.doc().scrollLeft>0?this.doc().scrollLeft:this.alreadyScrollLeft}snapOffset(t){const e=t+(it(this.wnd)?-1:1);return e-e%this.wnd.innerWidth}reportProgress(){this.comms.send("progress",{progress:this.wnd.scrollX/this.cachedScrollWidth,reference:this.wnd.innerWidth/this.doc().scrollWidth})}shake(){if(this.overscroll!==0||this.shakeTimeout!==0)return;const t=this.doc();t.classList.add(it(this.wnd)?"readium-bounce-l":"readium-bounce-r");const e=this.scrollOffset();this.shakeTimeout=this.wnd.setTimeout(()=>{t.classList.remove("readium-bounce-l"),t.classList.remove("readium-bounce-r"),this.shakeTimeout=0,this.doc().scrollLeft=e},150)}takeOverSnap(){var t;this.snappingCancelled=!0,this.clearTouches();const e=this.doc();this.overscroll=((t=e.style.transform)==null?void 0:t.length)>12?parseFloat(e.style.transform.slice(12).split("px")[0]):0}snapCurrentOffset(t=!1,e=!1){const A=this.wnd.scrollX>0?this.wnd.scrollX:this.alreadyScrollLeft,n=this.doc(),r=this.dragOffset(),s=_e(this.wnd),o=Math.min(Math.max(0,A),this.cachedScrollWidth),a=it(this.wnd)?-1:1,h=a*(this.wnd.innerWidth/3)*(a*r>0?2:1),l=this.snapOffset(o+h);if(t&&l!==this.scrollOffset()){this.snappingCancelled=!1;const c=(B,w,f,U)=>f>U?w:B+(w-B)*Gi(f/U),g=Li*s;let m;const M=B=>{if(this.snappingCancelled)return;m||(m=B);const w=B-m,f=c(this.overscroll,0,w,g),U=c(A,l,w,g);n.scrollLeft=U,this.overscroll!==0&&(n.style.transform=`translate3d(${-f}px, 0px, 0px)`),w<g?this.wnd.requestAnimationFrame(M):(this.clearTouches(),n.style.removeProperty("transform"),n.scrollLeft=l,e||this.reportProgress())};this.wnd.requestAnimationFrame(M)}else n.style.removeProperty("transform"),this.wnd.requestAnimationFrame(()=>{n.scrollLeft=l,this.clearTouches(),e||this.reportProgress()})}dragOffset(){return(this.startingX??0)-(this.endingX??0)}clearTouches(){this.startingX=void 0,this.endingX=void 0,this.overscroll=0}onTouchStart(t){switch(t.stopPropagation(),this.takeOverSnap(),t.touches.length){case 1:break;case 2:this.onTouchEnd(t);return;default:{this.onTouchEnd(t),this.comms.send("tap_more",t.touches.length);return}}this.startingX=t.touches[0].clientX,this.alreadyScrollLeft=this.doc().scrollLeft,this.touchState=1}onTouchEnd(t){if(this.touchState===2){const e=this.dragOffset(),A=this.scrollOffset();this.cachedScrollWidth<=this.wnd.innerWidth?(this.reportProgress(),e>5&&this.comms.send("no_more",void 0),e<-5&&this.comms.send("no_less",void 0)):A<5&&e<5?(this.alreadyScrollLeft=0,this.comms.send("no_less",void 0)):this.cachedScrollWidth-A-this.wnd.innerWidth<5&&e>5&&(this.alreadyScrollLeft=this.cachedScrollWidth,this.comms.send("no_more",void 0)),this.snapCurrentOffset(!0),this.comms.send("swipe",e)}this.touchState=0}onWidthChange(){this.cachedScrollWidth=this.doc().scrollWidth,this.comms.ready&&this.snapCurrentOffset()}onTouchMove(t){if(this.touchState===0)return;this.touchState===1&&(this.touchState=2,T(this.wnd)),this.endingX=t.touches[0].clientX;const e=this.dragOffset(),A=this.alreadyScrollLeft+e;A<0?(this.overscroll=A,this.doc().style.transform=`translate3d(${-this.overscroll}px, 0px, 0px)`):A+this.wnd.innerWidth>this.cachedScrollWidth?(this.overscroll=A,this.doc().style.transform=`translate3d(${-A}px, 0px, 0px)`):(this.overscroll=0,this.doc().style.removeProperty("transform"),this.doc().scrollLeft=this.alreadyScrollLeft+e)}mount(t,e){if(this.wnd=t,this.comms=e,!super.mount(t,e))return!1;t.navigator.epubReadingSystem.layoutStyle="paginated";const A=t.document.createElement("style");A.dataset.readium="true",A.id=iA,A.textContent=`
|
|
42
42
|
@keyframes readium-bounce-l-animation {
|
|
43
43
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
44
44
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
body::-webkit-scrollbar {
|
|
81
81
|
display: none; /* for Chrome, Safari, and Opera */
|
|
82
82
|
}
|
|
83
|
-
`,t.document.head.appendChild(A),this.resizeObserver=new ResizeObserver(()=>{this.comms.ready&&this.handleScroll()}),this.resizeObserver.observe(t.document.body),t.addEventListener("scroll",this.handleScroll,{passive:!0}),e.register("go_progression",L.moduleName,(n,r)=>{const s=n;if(s<0||s>1){e.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*s,this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_id",L.moduleName,(n,r)=>{const s=t.document.getElementById(n);if(!s){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const o=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:o,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_text",L.moduleName,(n,r)=>{let s;Array.isArray(n)&&(n.length>1&&(s=n[1]),n=n[0]);const o=at.deserialize(n),a=ne(this.wnd.document,new _({href:t.location.href,type:"text/html",text:o,locations:s?new S({otherLocations:new Map([["cssSelector",s]])}):void 0}));if(!a){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const h=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:h,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_start",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("go_end",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("unfocus",L.moduleName,(n,r)=>{T(this.wnd),r(!0)}),e.register(["go_next","go_prev"],L.moduleName,(n,r)=>r(!1)),e.register("focus",L.moduleName,(n,r)=>{const s=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("first_visible_locator",L.moduleName,(n,r)=>{const s=eA(t,!0);this.comms.send("first_visible_locator",s.serialize()),r(!0)}),e.log("ScrollSnapper Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&t.removeEventListener("scroll",this.handleScroll),(A=t.document.getElementById(rA))==null||A.remove(),e.log("ScrollSnapper Unmounted"),!0}};sA.moduleName="scroll_snapper";let Xi=sA;class oA extends St{constructor(){super(...arguments),this.pointerMoved=!1,this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onContextMenu=this.onContext.bind(this),this.onClicker=this.onClick.bind(this)}onPointUp(t){var e,A,n,r,s;const o=this.wnd.getSelection();if(o&&((e=o.toString())==null?void 0:e.length)>0){const h=(A=o.getRangeAt(0))==null?void 0:A.getClientRects();if(!h||h.length===0)return;const l=h[0],c={text:o.toString(),x:l.x,y:l.y,width:l.width,height:l.height,targetFrameSrc:(r=(n=this.wnd)==null?void 0:n.location)==null?void 0:r.href};this.comms.send("text_selected",c)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!(o!=null&&o.isCollapsed)||!t.isPrimary)return;const a=this.wnd.devicePixelRatio;t.preventDefault(),this.comms.send(t.pointerType==="touch"?"tap":"click",{defaultPrevented:t.defaultPrevented,x:t.clientX*a,y:t.clientY*a,targetFrameSrc:this.wnd.location.href,targetElement:t.target.outerHTML,interactiveElement:(s=tA(t.target))==null?void 0:s.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)}),this.pointerMoved=!1}onPointMove(t){if(t.movementY!==void 0&&t.movementX!==void 0){(Math.abs(t.movementX)>1||Math.abs(t.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onContext(t){this.onPointUp(t),this.pointerMoved=!1}onClick(t){if(t.preventDefault(),!t.isTrusted){const e=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:t.clientX,clientY:t.clientY});Object.defineProperty(e,"target",{writable:!1,value:t.target}),Object.defineProperty(e,"defaultPrevented",{writable:!1,value:t.defaultPrevented}),this.onPointUp(e)}}mount(t,e){return this.wnd=t,this.comms=e,t.document.addEventListener("pointerdown",this.onPointerDown),t.document.addEventListener("pointerup",this.onPointerUp),t.document.addEventListener("contextmenu",this.onContextMenu),t.document.addEventListener("pointermove",this.onPointerMove),t.document.addEventListener("click",this.onClicker),e.log("Peripherals Mounted"),!0}unmount(t,e){return t.document.removeEventListener("pointerdown",this.onPointerDown),t.document.removeEventListener("pointerup",this.onPointerUp),t.document.removeEventListener("contextmenu",this.onContextMenu),t.document.removeEventListener("pointermove",this.onPointerMove),t.document.removeEventListener("click",this.onClicker),e.log("Peripherals Unmounted"),!0}}oA.moduleName="peripherals";const aA=class Me extends St{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(t){var e;(e=this.comms)==null||e.send("error",{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno})}unblock(t){var e;for(t._readium_blockEvents=!1;((e=t._readium_blockedEvents)==null?void 0:e.length)>0;){const A=t._readium_blockedEvents.shift();switch(A[0]){case 0:Reflect.apply(A[1],A[2],A[3]);break;case 1:const n=A[1],r=A[2];t.removeEventListener(n.type,t._readium_eventBlocker,!0);const s=new Event(n.type,{bubbles:n.bubbles,cancelable:n.cancelable});r?r.dispatchEvent(s):t.dispatchEvent(s);break}}}onMediaPlayEvent(){var t;this.mediaPlayingCount++,(t=this.comms)==null||t.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){var t;this.mediaPlayingCount>0&&this.mediaPlayingCount--,(t=this.comms)==null||t.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(t){const e=t.document.querySelectorAll("audio,video");for(let A=0;A<e.length;A++)e[A].pause()}mount(t,e){this.comms=e,t.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(t.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.0.0-beta.
|
|
83
|
+
`,t.document.head.appendChild(A),this.resizeObserver=new ResizeObserver(()=>{this.comms.ready&&this.handleScroll()}),this.resizeObserver.observe(t.document.body),t.addEventListener("scroll",this.handleScroll,{passive:!0}),e.register("go_progression",L.moduleName,(n,r)=>{const s=n;if(s<0||s>1){e.send("error",{message:"go_progression must be given a position from 0.0 to 1.0"}),r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=this.doc().offsetHeight*s,this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_id",L.moduleName,(n,r)=>{const s=t.document.getElementById(n);if(!s){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=s.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const o=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:o,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_text",L.moduleName,(n,r)=>{let s;Array.isArray(n)&&(n.length>1&&(s=n[1]),n=n[0]);const o=at.deserialize(n),a=ne(this.wnd.document,new _({href:t.location.href,type:"text/html",text:o,locations:s?new S({otherLocations:new Map([["cssSelector",s]])}):void 0}));if(!a){r(!1);return}this.wnd.requestAnimationFrame(()=>{this.doc().scrollTop=a.getBoundingClientRect().top+t.scrollY-t.innerHeight/2;const h=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:h,reference:this.wnd.innerHeight/this.doc().scrollHeight}),T(this.wnd),r(!0)})}),e.register("go_start",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("go_end",L.moduleName,(n,r)=>{if(this.doc().scrollTop===0)return r(!1);this.doc().scrollTop=0,this.reportProgress({progress:0,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("unfocus",L.moduleName,(n,r)=>{T(this.wnd),r(!0)}),e.register(["go_next","go_prev"],L.moduleName,(n,r)=>r(!1)),e.register("focus",L.moduleName,(n,r)=>{const s=this.doc().scrollTop/this.doc().offsetHeight;this.reportProgress({progress:s,reference:this.wnd.innerHeight/this.doc().scrollHeight}),r(!0)}),e.register("first_visible_locator",L.moduleName,(n,r)=>{const s=eA(t,!0);this.comms.send("first_visible_locator",s.serialize()),r(!0)}),e.log("ScrollSnapper Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(L.moduleName),this.resizeObserver.disconnect(),this.handleScroll&&t.removeEventListener("scroll",this.handleScroll),(A=t.document.getElementById(rA))==null||A.remove(),e.log("ScrollSnapper Unmounted"),!0}};sA.moduleName="scroll_snapper";let Xi=sA;class oA extends St{constructor(){super(...arguments),this.pointerMoved=!1,this.onPointerUp=this.onPointUp.bind(this),this.onPointerMove=this.onPointMove.bind(this),this.onPointerDown=this.onPointDown.bind(this),this.onContextMenu=this.onContext.bind(this),this.onClicker=this.onClick.bind(this)}onPointUp(t){var e,A,n,r,s;const o=this.wnd.getSelection();if(o&&((e=o.toString())==null?void 0:e.length)>0){const h=(A=o.getRangeAt(0))==null?void 0:A.getClientRects();if(!h||h.length===0)return;const l=h[0],c={text:o.toString(),x:l.x,y:l.y,width:l.width,height:l.height,targetFrameSrc:(r=(n=this.wnd)==null?void 0:n.location)==null?void 0:r.href};this.comms.send("text_selected",c)}if(this.pointerMoved){this.pointerMoved=!1;return}if(!(o!=null&&o.isCollapsed)||!t.isPrimary)return;const a=this.wnd.devicePixelRatio;t.preventDefault(),this.comms.send(t.pointerType==="touch"?"tap":"click",{defaultPrevented:t.defaultPrevented,x:t.clientX*a,y:t.clientY*a,targetFrameSrc:this.wnd.location.href,targetElement:t.target.outerHTML,interactiveElement:(s=tA(t.target))==null?void 0:s.outerHTML,cssSelector:this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)}),this.pointerMoved=!1}onPointMove(t){if(t.movementY!==void 0&&t.movementX!==void 0){(Math.abs(t.movementX)>1||Math.abs(t.movementY)>1)&&(this.pointerMoved=!0);return}this.pointerMoved=!0}onPointDown(){this.pointerMoved=!1}onContext(t){this.onPointUp(t),this.pointerMoved=!1}onClick(t){if(t.preventDefault(),!t.isTrusted){const e=new PointerEvent("pointerup",{isPrimary:!0,pointerType:"mouse",clientX:t.clientX,clientY:t.clientY});Object.defineProperty(e,"target",{writable:!1,value:t.target}),Object.defineProperty(e,"defaultPrevented",{writable:!1,value:t.defaultPrevented}),this.onPointUp(e)}}mount(t,e){return this.wnd=t,this.comms=e,t.document.addEventListener("pointerdown",this.onPointerDown),t.document.addEventListener("pointerup",this.onPointerUp),t.document.addEventListener("contextmenu",this.onContextMenu),t.document.addEventListener("pointermove",this.onPointerMove),t.document.addEventListener("click",this.onClicker),e.log("Peripherals Mounted"),!0}unmount(t,e){return t.document.removeEventListener("pointerdown",this.onPointerDown),t.document.removeEventListener("pointerup",this.onPointerUp),t.document.removeEventListener("contextmenu",this.onContextMenu),t.document.removeEventListener("pointermove",this.onPointerMove),t.document.removeEventListener("click",this.onClicker),e.log("Peripherals Unmounted"),!0}}oA.moduleName="peripherals";const aA=class Me extends St{constructor(){super(...arguments),this.mediaPlayingCount=0,this.allAnimations=new Set}wndOnErr(t){var e;(e=this.comms)==null||e.send("error",{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno})}unblock(t){var e;for(t._readium_blockEvents=!1;((e=t._readium_blockedEvents)==null?void 0:e.length)>0;){const A=t._readium_blockedEvents.shift();switch(A[0]){case 0:Reflect.apply(A[1],A[2],A[3]);break;case 1:const n=A[1],r=A[2];t.removeEventListener(n.type,t._readium_eventBlocker,!0);const s=new Event(n.type,{bubbles:n.bubbles,cancelable:n.cancelable});r?r.dispatchEvent(s):t.dispatchEvent(s);break}}}onMediaPlayEvent(){var t;this.mediaPlayingCount++,(t=this.comms)==null||t.send("media_play",this.mediaPlayingCount)}onMediaPauseEvent(){var t;this.mediaPlayingCount>0&&this.mediaPlayingCount--,(t=this.comms)==null||t.send("media_pause",this.mediaPlayingCount)}pauseAllMedia(t){const e=t.document.querySelectorAll("audio,video");for(let A=0;A<e.length;A++)e[A].pause()}mount(t,e){this.comms=e,t.addEventListener("error",this.wndOnErr,!1),Reflect.defineProperty(t.navigator,"epubReadingSystem",{value:{name:"readium-ts-toolkit",version:"2.0.0-beta.2",hasFeature:(n,r="")=>{switch(n){case"dom-manipulation":return!0;case"layout-changes":return!0;case"touch-events":return!0;case"mouse-events":return!0;case"keyboard-events":return!0;case"spine-scripting":return!0;case"embedded-web-content":return!0;default:return!1}}},writable:!1}),"getAnimations"in t.document&&t.document.getAnimations().forEach(n=>{n.cancel(),this.allAnimations.add(n)}),e.register("activate",Me.moduleName,(n,r)=>{this.allAnimations.forEach(s=>{s.cancel(),s.play()}),r(!0)}),e.register("unfocus",Me.moduleName,(n,r)=>{this.pauseAllMedia(t),this.allAnimations.forEach(s=>s.pause()),r(!0)});const A=t.document.querySelectorAll("audio,video");for(let n=0;n<A.length;n++){const r=A[n];r.addEventListener("play",this.onMediaPlayEvent,{passive:!0}),r.addEventListener("pause",this.onMediaPauseEvent,{passive:!0})}return e.log("Setup Mounted"),!0}unmount(t,e){return t.removeEventListener("error",this.wndOnErr),t.removeEventListener("play",this.onMediaPlayEvent),t.removeEventListener("pause",this.onMediaPauseEvent),this.allAnimations.forEach(A=>A.cancel()),this.allAnimations.clear(),e.log("Setup Unmounted"),!0}};aA.moduleName="setup";let hA=aA;const lA="readium-viewport",cA=class nt extends hA{onViewportWidthChanged(t){const e=t.target;Vt(e,"--RS__viewportWidth",`${e.innerWidth}px`)}mount(t,e){if(!super.mount(t,e))return!1;const A=t.document.createElement("meta");return A.dataset.readium="true",A.setAttribute("name","viewport"),A.setAttribute("id",lA),A.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"),t.document.head.appendChild(A),t.addEventListener("orientationchange",this.onViewportWidthChanged),t.addEventListener("resize",this.onViewportWidthChanged),this.onViewportWidthChanged({target:t}),e.register("get_properties",nt.moduleName,(n,r)=>{We(t),r(!0)}),e.register("update_properties",nt.moduleName,(n,r)=>{n["--RS__viewportWidth"]=`${t.innerWidth}px`,xi(t,n),r(!0)}),e.register("set_property",nt.moduleName,(n,r)=>{const s=n;Vt(t,s[0],s[1]),r(!0)}),e.register("remove_property",nt.moduleName,(n,r)=>{re(t,n),r(!0)}),e.register("activate",nt.moduleName,(n,r)=>{this.unblock(t),r(!0)}),e.log("ReflowableSetup Mounted"),!0}unmount(t,e){var A;return e.unregisterAll(nt.moduleName),(A=t.document.head.querySelector(`#${lA}`))==null||A.remove(),t.removeEventListener("orientationchange",this.onViewportWidthChanged),e.log("ReflowableSetup Unmounted"),super.unmount(t,e)}};cA.moduleName="reflowable_setup";let Zi=cA;const gA="readium-fixed-style",dA=class et extends hA{mount(t,e){if(!super.mount(t,e))return!1;t.navigator.epubReadingSystem.layoutStyle="paginated";const A=t.document.createElement("style");return A.id=gA,A.dataset.readium="true",A.textContent=`
|
|
84
84
|
html, body {
|
|
85
85
|
text-size-adjust: none;
|
|
86
86
|
-ms-text-size-adjust: none;
|