@internetarchive/bookreader 5.0.0-116 → 5.0.0-117
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/BookReader/BookReader.css +44 -18
- package/BookReader/BookReader.js +1 -1
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +74 -74
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +2 -2
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.experiments.js +1 -1
- package/BookReader/plugins/plugin.experiments.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js +1 -1
- package/BookReader/plugins/plugin.resume.js +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +22 -2
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +23 -3
- package/BookReader/plugins/plugin.translate.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/README.md +3 -1
- package/package.json +33 -29
- package/src/BookReader.js +16 -0
- package/src/css/_TextSelection.scss +51 -18
- package/src/plugins/plugin.chapters.js +8 -4
- package/src/plugins/plugin.iframe.js +36 -37
- package/src/plugins/plugin.text_selection.js +36 -11
- package/src/plugins/search/plugin.search.js +2 -8
- package/src/plugins/tts/plugin.tts.js +3 -8
- package/src/util/TextSelectionManager.js +53 -8
- package/src/util/dom.js +88 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[479],{6098:function(t,e,r){var n=r(9504),o=2147483647,a=/[^\0-\u007E]/,i=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",u=RangeError,l=n(i.exec),h=Math.floor,c=String.fromCharCode,f=n("".charCodeAt),p=n([].join),d=n([].push),m=n("".replace),g=n("".split),v=n("".toLowerCase),y=function(t){return t+22+75*(t<26)},b=function(t,e,r){var n=0;for(t=r?h(t/700):t>>1,t+=h(t/e);t>455;)t=h(t/35),n+=36;return h(n+36*t/(t+38))},w=function(t){var e=[];t=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=f(t,r++);if(o>=55296&&o<=56319&&r<n){var a=f(t,r++);56320==(64512&a)?d(e,((1023&o)<<10)+(1023&a)+65536):(d(e,o),r--)}else d(e,o)}return e}(t);var r,n,a=t.length,i=128,l=0,m=72;for(r=0;r<t.length;r++)(n=t[r])<128&&d(e,c(n));var g=e.length,v=g;for(g&&d(e,"-");v<a;){var w=o;for(r=0;r<t.length;r++)(n=t[r])>=i&&n<w&&(w=n);var P=v+1;if(w-i>h((o-l)/P))throw new u(s);for(l+=(w-i)*P,i=w,r=0;r<t.length;r++){if((n=t[r])<i&&++l>o)throw new u(s);if(n===i){for(var S=l,k=36;;){var R=k<=m?1:k>=m+26?26:k-m;if(S<R)break;var U=S-R,B=36-R;d(e,c(y(R+U%B))),S=h(U/B),k+=36}d(e,c(y(S))),m=b(l,P,v===g),l=0,v++}}l++,i++}return p(e,"")};t.exports=function(t){var e,r,n=[],o=g(m(v(t),i,"."),".");for(e=0;e<o.length;e++)r=o[e],d(n,l(a,r)?"xn--"+w(r):r);return p(n,".")}},706:function(t,e,r){var n=r(350).PROPER,o=r(9039),a=r(7452);t.exports=function(t){return o(function(){return!!a[t]()||"
"!=="
"[t]()||n&&a[t].name!==t})}},3921:function(t,e,r){var n=r(6518),o=r(2652),a=r(4659);n({target:"Object",stat:!0},{fromEntries:function(t){var e={};return o(t,function(t,r){a(e,t,r)},{AS_ENTRIES:!0}),e}})},2762:function(t,e,r){var n=r(6518),o=r(3802).trim;n({target:"String",proto:!0,forced:r(706)("trim")},{trim:function(){return o(this)}})},5806:function(t,e,r){r(7764);var n,o=r(6518),a=r(3724),i=r(7416),s=r(4576),u=r(6080),l=r(9504),h=r(6840),c=r(2106),f=r(679),p=r(9297),d=r(4213),m=r(7916),g=r(7680),v=r(8183).codeAt,y=r(6098),b=r(655),w=r(687),P=r(2812),S=r(8406),k=r(1181),R=k.set,U=k.getterFor("URL"),B=S.URLSearchParams,H=S.getState,L=s.URL,O=s.TypeError,j=s.encodeURIComponent,q=s.parseInt,I=Math.floor,T=Math.pow,A=l("".charAt),F=l(/./.exec),_=l([].join),C=l(1.1.toString),E=l([].pop),M=l([].push),x=l("".replace),z=l([].shift),$=l("".split),N=l("".slice),D=l("".toLowerCase),J=l([].unshift),W="Invalid scheme",Q="Invalid host",G="Invalid port",K=/[a-z]/i,V=/[\d+\-.a-z]/i,X=/\d/,Y=/^0x/i,Z=/^[0-7]+$/,tt=/^\d+$/,et=/^[\da-f]+$/i,rt=/[\0\t\n\r #%/:<>?@[\\\]^|]/,nt=/[\0\t\n\r #/:<>?@[\\\]^|]/,ot=/^[\u0000-\u0020]+/,at=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,it=/[\t\n\r]/g,st=function(t){var e,r,n,o;if("number"==typeof t){for(e=[],r=0;r<4;r++)J(e,t%256),t=I(t/256);return _(e,".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,r=1,n=null,o=0,a=0;a<8;a++)0!==t[a]?(o>r&&(e=n,r=o),n=null,o=0):(null===n&&(n=a),++o);return o>r?n:e}(t),r=0;r<8;r++)o&&0===t[r]||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=C(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},ut={},lt=d({},ut,{" ":1,'"':1,"#":1,"<":1,">":1}),ht=d({},lt,{"'":1}),ct=d({},ut,{" ":1,'"':1,"<":1,">":1,"`":1}),ft=d({},ct,{"#":1,"?":1,"{":1,"}":1,"^":1}),pt=d({},ft,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),dt=function(t,e){var r=v(t,0);return r>=32&&r<127&&!p(e,t)?t:"'"===t&&p(e,t)?"%27":j(t)},mt={ftp:21,file:null,http:80,https:443,ws:80,wss:443},gt=function(t,e){var r;return 2===t.length&&F(K,A(t,0))&&(":"===(r=A(t,1))||!e&&"|"===r)},vt=function(t){var e;return t.length>1&>(N(t,0,2))&&(2===t.length||"/"===(e=A(t,2))||"\\"===e||"?"===e||"#"===e)},yt=function(t){return"."===t||"%2e"===D(t)},bt=function(t){return".."===(t=D(t))||"%2e."===t||".%2e"===t||"%2e%2e"===t},wt={},Pt={},St={},kt={},Rt={},Ut={},Bt={},Ht={},Lt={},Ot={},jt={},qt={},It={},Tt={},At={},Ft={},_t={},Ct={},Et={},Mt={},xt={},zt=function(t,e,r){var n,o,a,i=b(t);if(e){if(o=this.parse(i))throw new O(o);this.searchParams=null}else{if(void 0!==r&&(n=new zt(r,!0)),o=this.parse(i,null,n))throw new O(o);(a=H(new B)).bindURL(this),this.searchParams=a}};zt.prototype={type:"URL",parse:function(t,e,r){var o,a,i,s,u=this,l=e||wt,h=0,c="",f=!1,d=!1,v=!1;for(t=b(t),e||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,t=x(t,ot,""),t=x(t,at,"$1")),t=x(t,it,""),o=m(t);h<=o.length;){switch(a=o[h],l){case wt:if(!a||!F(K,a)){if(e)return W;l=St;continue}c+=D(a),l=Pt;break;case Pt:if(a&&F(V,a))c+=D(a);else{if(":"!==a){if(e)return W;c="",l=St,h=0;continue}if(e&&(u.isSpecial()!==p(mt,c)||"file"===c&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&""===u.host))return;if(u.scheme=c,e)return void(u.isSpecial()&&mt[u.scheme]===u.port&&(u.port=null));c="","file"===u.scheme?l=Tt:u.isSpecial()&&r&&r.scheme===u.scheme?l=kt:u.isSpecial()?l=Ht:"/"===o[h+1]?(l=Rt,h++):(u.cannotBeABaseURL=!0,M(u.path,""),l=Et)}break;case St:if(!r||r.cannotBeABaseURL&&"#"!==a)return W;if(r.cannotBeABaseURL&&"#"===a){u.scheme=r.scheme,u.path=g(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,l=xt;break}l="file"===r.scheme?Tt:Ut;continue;case kt:if("/"!==a||"/"!==o[h+1]){l=Ut;continue}l=Lt,h++;break;case Rt:if("/"===a){l=Ot;break}l=Ct;continue;case Ut:if(u.scheme=r.scheme,a===n)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query;else if("/"===a||"\\"===a&&u.isSpecial())l=Bt;else if("?"===a)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query="",l=Mt;else{if("#"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.path.length&&u.path.length--,l=Ct;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt}break;case Bt:if(!u.isSpecial()||"/"!==a&&"\\"!==a){if("/"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,l=Ct;continue}l=Ot}else l=Lt;break;case Ht:if(l=Lt,"/"!==a||"/"!==o[h+1])continue;h++;break;case Lt:if("/"!==a&&"\\"!==a){l=Ot;continue}break;case Ot:if("@"===a){f&&(c="%40"+c),f=!0,i=m(c);for(var y=0;y<i.length;y++){var w=i[y];if(":"!==w||v){var P=dt(w,pt);v?u.password+=P:u.username+=P}else v=!0}c=""}else if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(f&&""===c)return"Invalid authority";h-=m(c).length+1,c="",l=jt}else c+=a;break;case jt:case qt:if(e&&"file"===u.scheme){l=Ft;continue}if(":"!==a||d){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(u.isSpecial()&&""===c)return Q;if(e&&""===c&&(u.includesCredentials()||null!==u.port))return;if(s=u.parseHost(c))return s;if(c="",l=_t,e)return;continue}"["===a?d=!0:"]"===a&&(d=!1),c+=a}else{if(""===c)return Q;if(e===qt)return;if(s=u.parseHost(c))return s;c="",l=It}break;case It:if(!F(X,a)){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()||e){if(""!==c){var S=q(c,10);if(S>65535)return G;u.port=u.isSpecial()&&S===mt[u.scheme]?null:S,c=""}if(e)return;l=_t;continue}return G}c+=a;break;case Tt:if(u.scheme="file",u.host="","/"===a||"\\"===a)l=At;else{if(!r||"file"!==r.scheme){l=Ct;continue}switch(a){case n:u.host=r.host,u.path=g(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=g(r.path),u.query="",l=Mt;break;case"#":u.host=r.host,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt;break;default:u.host=r.host,vt(_(g(o,h),""))||(u.path=g(r.path),u.shortenPath()),l=Ct;continue}}break;case At:if("/"===a||"\\"===a){l=Ft;break}r&&"file"===r.scheme&&(u.host=r.host,!vt(_(g(o,h),""))&>(r.path[0],!0)&&M(u.path,r.path[0])),l=Ct;continue;case Ft:if(a===n||"/"===a||"\\"===a||"?"===a||"#"===a){if(!e&>(c))l=Ct;else if(""===c){if(u.host="",e)return;l=_t}else{if(s=u.parseHost(c))return s;if("localhost"===u.host&&(u.host=""),e)return;c="",l=_t}continue}c+=a;break;case _t:if(u.isSpecial()){if(l=Ct,"/"!==a&&"\\"!==a)continue}else if(e||"?"!==a)if(e||"#"!==a){if(a!==n&&(l=Ct,"/"!==a))continue}else u.fragment="",l=xt;else u.query="",l=Mt;break;case Ct:if(a===n||"/"===a||"\\"===a&&u.isSpecial()||!e&&("?"===a||"#"===a)){if(bt(c)?(u.shortenPath(),"/"===a||"\\"===a&&u.isSpecial()||M(u.path,"")):yt(c)?"/"===a||"\\"===a&&u.isSpecial()||M(u.path,""):("file"===u.scheme&&!u.path.length&>(c)&&(null!==u.host&&""!==u.host&&(u.host=""),c=A(c,0)+":"),M(u.path,c)),c="","file"===u.scheme&&(a===n||"?"===a||"#"===a))for(;u.path.length>1&&""===u.path[0];)z(u.path);"?"===a?(u.query="",l=Mt):"#"===a&&(u.fragment="",l=xt)}else c+=dt(a,ft);break;case Et:"?"===a?(u.query="",l=Mt):"#"===a?(u.fragment="",l=xt):a!==n&&(u.path[0]+=dt(a,ut));break;case Mt:e||"#"!==a?a!==n&&(u.query+=dt(a,u.isSpecial()?ht:lt)):(u.fragment="",l=xt);break;case xt:a!==n&&(u.fragment+=dt(a,ct))}h++}},parseHost:function(t){var e,r,n;if("["===A(t,0)){if("]"!==A(t,t.length-1))return Q;if(e=function(t){var e,r,n,o,a,i,s,u=[0,0,0,0,0,0,0,0],l=0,h=null,c=0,f=function(){return A(t,c)};if(":"===f()){if(":"!==A(t,1))return;c+=2,h=++l}for(;f();){if(8===l)return;if(":"!==f()){for(e=r=0;r<4&&F(et,f());)e=16*e+q(f(),16),c++,r++;if("."===f()){if(0===r)return;if(c-=r,l>6)return;for(n=0;f();){if(o=null,n>0){if(!("."===f()&&n<4))return;c++}if(!F(X,f()))return;for(;F(X,f());){if(a=q(f(),10),null===o)o=a;else{if(0===o)return;o=10*o+a}if(o>255)return;c++}u[l]=256*u[l]+o,2!==++n&&4!==n||l++}if(4!==n)return;break}if(":"===f()){if(c++,!f())return}else if(f())return;u[l++]=e}else{if(null!==h)return;c++,h=++l}}if(null!==h)for(i=l-h,l=7;0!==l&&i>0;)s=u[l],u[l--]=u[h+i-1],u[h+--i]=s;else if(8!==l)return;return u}(N(t,1,-1)),!e)return Q;this.host=e}else if(this.isSpecial()){if(t=y(t),F(rt,t))return Q;if(function(t){var e,r,n=$(t,".");if(""===n[n.length-1]){if(1===n.length)return!1;n.length--}return e=n[n.length-1],!!F(tt,e)||!!F(Y,e)&&(""===(r=N(e,2))||!!F(et,r))}(t)){if(e=function(t){var e,r,n,o,a,i,s,u=$(t,".");if(u.length&&""===u[u.length-1]&&u.length--,(e=u.length)>4)return null;for(r=[],n=0;n<e;n++){if(""===(o=u[n]))return null;if(a=10,o.length>1&&"0"===A(o,0)&&(a=F(Y,o)?16:8,o=N(o,8===a?1:2)),""===o)i=0;else{if(!F(10===a?tt:8===a?Z:et,o))return null;i=q(o,a)}M(r,i)}for(n=0;n<e;n++)if(i=r[n],n===e-1){if(i>=T(256,5-e))return null}else if(i>255)return null;for(s=E(r),n=0;n<r.length;n++)s+=r[n]*T(256,3-n);return s}(t),null===e)return Q;this.host=e}else this.host=t}else{if(F(nt,t))return Q;for(e="",r=m(t),n=0;n<r.length;n++)e+=dt(r[n],ut);this.host=e}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return p(mt,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;!e||"file"===this.scheme&&1===e&>(t[0],!0)||t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,a=t.port,i=t.path,s=t.query,u=t.fragment,l=e+":";return null!==o?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=st(o),null!==a&&(l+=":"+a)):"file"===e&&(l+="//"),null===o&&!t.cannotBeABaseURL&&i.length>1&&""===i[0]&&(l+="/."),l+=t.cannotBeABaseURL?i[0]:i.length?"/"+_(i,"/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new O(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if("blob"===t)try{return new $t(this.path[0]).origin}catch(t){return"null"}return"file"!==t&&this.isSpecial()?t+"://"+st(this.host)+(null!==e?":"+e:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(b(t)+":",wt)},getUsername:function(){return this.username},setUsername:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=dt(e[r],pt)}},getPassword:function(){return this.password},setPassword:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=dt(e[r],pt)}},getHost:function(){var t=this.host,e=this.port;return null===t?"":null===e?st(t):st(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,jt)},getHostname:function(){var t=this.host;return null===t?"":st(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,qt)},getPort:function(){var t=this.port;return null===t?"":b(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""===(t=b(t))?this.port=null:this.parse(t,It))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+_(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,_t))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""===(t=b(t))?this.query=null:("?"===A(t,0)&&(t=N(t,1)),this.query="",this.parse(t,Mt)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!==(t=b(t))?("#"===A(t,0)&&(t=N(t,1)),this.fragment="",this.parse(t,xt)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var $t=function(t){var e=f(this,Nt),r=P(arguments.length,1)>1?arguments[1]:void 0,n=R(e,new zt(t,!1,r));a||(e.href=n.serialize(),e.origin=n.getOrigin(),e.protocol=n.getProtocol(),e.username=n.getUsername(),e.password=n.getPassword(),e.host=n.getHost(),e.hostname=n.getHostname(),e.port=n.getPort(),e.pathname=n.getPathname(),e.search=n.getSearch(),e.searchParams=n.getSearchParams(),e.hash=n.getHash())},Nt=$t.prototype,Dt=function(t,e){return{get:function(){return U(this)[t]()},set:e&&function(t){return U(this)[e](t)},configurable:!0,enumerable:!0}};if(a&&(c(Nt,"href",Dt("serialize","setHref")),c(Nt,"origin",Dt("getOrigin")),c(Nt,"protocol",Dt("getProtocol","setProtocol")),c(Nt,"username",Dt("getUsername","setUsername")),c(Nt,"password",Dt("getPassword","setPassword")),c(Nt,"host",Dt("getHost","setHost")),c(Nt,"hostname",Dt("getHostname","setHostname")),c(Nt,"port",Dt("getPort","setPort")),c(Nt,"pathname",Dt("getPathname","setPathname")),c(Nt,"search",Dt("getSearch","setSearch")),c(Nt,"searchParams",Dt("getSearchParams")),c(Nt,"hash",Dt("getHash","setHash"))),h(Nt,"toJSON",function(){return U(this).serialize()},{enumerable:!0}),h(Nt,"toString",function(){return U(this).serialize()},{enumerable:!0}),L){var Jt=L.createObjectURL,Wt=L.revokeObjectURL;Jt&&h($t,"createObjectURL",u(Jt,L)),Wt&&h($t,"revokeObjectURL",u(Wt,L))}w($t,"URL"),o({global:!0,constructor:!0,forced:!i,sham:!a},{URL:$t})},3296:function(t,e,r){r(5806)},7208:function(t,e,r){var n=r(6518),o=r(9565);n({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return o(URL.prototype.toString,this)}})},5857:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r(2675),r(9463),r(2259),r(5700),r(8706),r(3792),r(2712),r(9572),r(8130),r(3851),r(875),r(6099),r(825),r(888),r(7495),r(7764),r(5440),r(2953),r(8408),r(2008),r(113),r(3418),r(8598),r(2062),r(4782),r(2010),r(5506),r(3921),r(9432),r(8781),r(1761),r(5746),r(2762),r(3500),r(3296),r(7208);var s,u=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.bookReaderOptions=e,this.urlSchema=[{name:"page",position:"path",default:"n0"},{name:"mode",position:"path",default:"2up"},{name:"search",position:"path",deprecated_for:"q"},{name:"q",position:"query_param"},{name:"sort",position:"query_param"},{name:"view",position:"query_param"},{name:"admin",position:"query_param"},{name:"focus",position:"query_param",readOnly:!0}],this.urlState={},this.urlMode=this.bookReaderOptions.urlMode||"hash",this.urlHistoryBasePath=this.bookReaderOptions.urlHistoryBasePath||"/",this.urlLocationPollId=null,this.oldLocationHash=null,this.oldUserHash=null},e=[{key:"urlStateToUrlString",value:function(t){var e=this,r=new URLSearchParams,n={};Object.keys(t).forEach(function(o){var a,i,s,u,l,h=e.urlSchema.find(function(t){return t.name===o});null!==(a=h)&&void 0!==a&&a.deprecated_for&&(h=e.urlSchema.find(function(t){return t.name===h.deprecated_for})),null!==(i=h)&&void 0!==i&&i.readOnly||("path"==(null===(s=h)||void 0===s?void 0:s.position)?n[null===(u=h)||void 0===u?void 0:u.name]=t[o]:r.append((null===(l=h)||void 0===l?void 0:l.name)||o,t[o]))});var o=this.urlSchema.filter(function(t){return"path"==t.position}).map(function(t){return n[t.name]?"".concat(t.name,"/").concat(encodeURIComponent(n[t.name])):""}).join("/"),a="".concat(o.replace(/\/+/g,"/").replace(/\/+$/,"")),i="".concat(a,"?").concat(r.toString());return r.toString()?i:"".concat(a)}},{key:"urlStringToUrlState",value:function(t){var e={},r=new URL(t,"http://example.com"),n=Object.fromEntries(r.searchParams.entries()),a=r.pathname.match(/[^\\/]+\/[^\\/]+/g),i=a?Object.fromEntries(a.map(function(t){return t.split("/")})):{},s=function(t,e){return Object.keys(t).some(function(t){return t==e})};return this.urlSchema.filter(function(t){return"path"==t.position}).forEach(function(t){var r=s(i,t.name),n=s(t,"deprecated_for")&&r;if(r||n){var o=n?t.deprecated_for:t.name;e[o]=decodeURIComponent(i[t.name])}}),Object.entries(n).forEach(function(t){var r=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,s=[],u=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=r[0],a=r[1];e[n]=a}),e}},{key:"setUrlParam",value:function(t,e){this.urlState[t]=e,this.pushToAddressBar()}},{key:"removeUrlParam",value:function(t){delete this.urlState[t],this.pushToAddressBar()}},{key:"getUrlParam",value:function(t){return this.urlState[t]}},{key:"pushToAddressBar",value:function(){var t=this.urlStateToUrlString(this.urlState),e="/"!==t?t:"";if("history"==this.urlMode)if(window.history&&window.history.replaceState){var r="".concat(this.urlHistoryBasePath).concat(e).trim().replace(/(\/+)/g,"/");try{window.history.replaceState({},null,r)}catch(t){this.urlMode="hash"}}else this.options.urlMode="hash";"hash"==this.urlMode&&window.location.replace("#"+e),this.oldLocationHash=t}},{key:"listenForHashChanges",value:function(){var t=this;this.oldLocationHash=this.getHash(),this.urlLocationPollId&&(clearInterval(this.urlLocationPollId),this.urlLocationPollId=null),this.urlLocationPollId=setInterval(function(){var e=t.getHash();e!=t.oldLocationHash&&(t.urlState=t.urlStringToUrlState(e))},500)}},{key:"pullFromAddressBar",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,e="history"===this.urlMode?t.pathname.substr(this.urlHistoryBasePath.length)+t.search:t.hash.substr(1);this.urlState=this.urlStringToUrlState(e)}},{key:"getHash",value:function(){return window.location.hash.slice(1)}}],e&&a(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=d(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},p.apply(null,arguments)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}r(1669).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view","text"],urlTrackIndex0:!1}),BookReader.prototype.setup=(s=BookReader.prototype.setup,function(t){s.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var e=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,function(){var t=e.options,r=t.updateWindowTitle,n=t.urlMode;r&&(document.title=e.shortTitle(e.bookTitle,50)),"hash"===n&&e.urlStartLocationPolling()}),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollId),this.locationPollId=null),this.locationPollId=setInterval(function(){var e=t.urlReadFragment();if(e!=t.oldLocationHash&&e!=t.oldUserHash){var r,n=t.paramsFromFragment(e),o=function(){return t.updateFromParams(n)};t.trigger(BookReader.eventNames.stop),t.animating?(null===(r=t.plugins.autoplay)||void 0===r||r.stop(),t.animationFinishedCallback=o):o(),t.oldUserHash=e}},500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),e=this.options,r=e.urlTrackIndex0,n=e.urlTrackedParams;r||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var o=n.reduce(function(e,r){return r in t&&(e[r]=t[r]),e},{}),a=this.fragmentFromParams(o,this.options.urlMode),i=""===a?"":"/".concat(a),s=this.urlReadFragment(),u=this.getLocationSearch(),l=this.queryStringFromParams(o,u,this.options.urlMode);if(s!==a||u!==l){if("history"===this.options.urlMode)if(window.history&&window.history.replaceState){var h=this.options.urlHistoryBasePath.replace(/\/+$/,""),c="".concat(h).concat(i).concat(l);try{window.history.replaceState({},null,c),this.oldLocationHash=a+l}catch(t){this.options.urlMode="hash"}}else this.options.urlMode="hash";if("hash"===this.options.urlMode){var f=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+a+f),this.oldLocationHash=a+f}}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var e=new URLSearchParams(t);return e.has("q")?"?".concat(new URLSearchParams({q:e.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,e=t.urlMode,r=t.urlHistoryBasePath;return"history"===e?window.location.pathname.substr(r.length):this.urlPlugin.getHash()},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)};var g=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,f()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(t,BookReader),e=t,r=[{key:"init",value:function(){var e,r,n,o=this;this.options.enableUrlPlugin&&(this.urlPlugin=new u(this.options),this.on(BookReader.eventNames.PostInit,function(){"hash"===o.options.urlMode&&o.urlPlugin.listenForHashChanges()})),(e=t,r=this,"function"==typeof(n=p(d(1&3?e.prototype:e),"init",r))?function(t){return n.apply(r,t)}:n)([])}}],r&&h(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();window.BookReader=g}},function(t){t(t.s=5857)}]);
|
|
1
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[479],{6098:function(t,e,r){var n=r(9504),o=2147483647,a=/[^\0-\u007E]/,i=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",u=RangeError,l=n(i.exec),h=Math.floor,c=String.fromCharCode,f=n("".charCodeAt),p=n([].join),d=n([].push),m=n("".replace),g=n("".split),v=n("".toLowerCase),y=function(t){return t+22+75*(t<26)},b=function(t,e,r){var n=0;for(t=r?h(t/700):t>>1,t+=h(t/e);t>455;)t=h(t/35),n+=36;return h(n+36*t/(t+38))},w=function(t){var e=[];t=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=f(t,r++);if(o>=55296&&o<=56319&&r<n){var a=f(t,r++);56320==(64512&a)?d(e,((1023&o)<<10)+(1023&a)+65536):(d(e,o),r--)}else d(e,o)}return e}(t);var r,n,a=t.length,i=128,l=0,m=72;for(r=0;r<t.length;r++)(n=t[r])<128&&d(e,c(n));var g=e.length,v=g;for(g&&d(e,"-");v<a;){var w=o;for(r=0;r<t.length;r++)(n=t[r])>=i&&n<w&&(w=n);var P=v+1;if(w-i>h((o-l)/P))throw new u(s);for(l+=(w-i)*P,i=w,r=0;r<t.length;r++){if((n=t[r])<i&&++l>o)throw new u(s);if(n===i){for(var S=l,k=36;;){var R=k<=m?1:k>=m+26?26:k-m;if(S<R)break;var U=S-R,B=36-R;d(e,c(y(R+U%B))),S=h(U/B),k+=36}d(e,c(y(S))),m=b(l,P,v===g),l=0,v++}}l++,i++}return p(e,"")};t.exports=function(t){var e,r,n=[],o=g(m(v(t),i,"."),".");for(e=0;e<o.length;e++)r=o[e],d(n,l(a,r)?"xn--"+w(r):r);return p(n,".")}},706:function(t,e,r){var n=r(350).PROPER,o=r(9039),a=r(7452);t.exports=function(t){return o(function(){return!!a[t]()||"
"!=="
"[t]()||n&&a[t].name!==t})}},3921:function(t,e,r){var n=r(6518),o=r(2652),a=r(4659);n({target:"Object",stat:!0},{fromEntries:function(t){var e={};return o(t,function(t,r){a(e,t,r)},{AS_ENTRIES:!0}),e}})},2762:function(t,e,r){var n=r(6518),o=r(3802).trim;n({target:"String",proto:!0,forced:r(706)("trim")},{trim:function(){return o(this)}})},5806:function(t,e,r){r(7764);var n,o=r(6518),a=r(3724),i=r(7416),s=r(4576),u=r(6080),l=r(9504),h=r(6840),c=r(2106),f=r(679),p=r(9297),d=r(4213),m=r(7916),g=r(7680),v=r(8183).codeAt,y=r(6098),b=r(655),w=r(687),P=r(2812),S=r(8406),k=r(1181),R=k.set,U=k.getterFor("URL"),B=S.URLSearchParams,H=S.getState,L=s.URL,O=s.TypeError,j=s.encodeURIComponent,q=s.parseInt,I=Math.floor,T=Math.pow,A=l("".charAt),F=l(/./.exec),_=l([].join),C=l(1.1.toString),E=l([].pop),M=l([].push),x=l("".replace),z=l([].shift),$=l("".split),N=l("".slice),D=l("".toLowerCase),J=l([].unshift),W="Invalid scheme",Q="Invalid host",G="Invalid port",K=/[a-z]/i,V=/[\d+\-.a-z]/i,X=/\d/,Y=/^0x/i,Z=/^[0-7]+$/,tt=/^\d+$/,et=/^[\da-f]+$/i,rt=/[\0\t\n\r #%/:<>?@[\\\]^|]/,nt=/[\0\t\n\r #/:<>?@[\\\]^|]/,ot=/^[\u0000-\u0020]+/,at=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,it=/[\t\n\r]/g,st=function(t){var e,r,n,o;if("number"==typeof t){for(e=[],r=0;r<4;r++)J(e,t%256),t=I(t/256);return _(e,".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,r=1,n=null,o=0,a=0;a<8;a++)0!==t[a]?(o>r&&(e=n,r=o),n=null,o=0):(null===n&&(n=a),++o);return o>r?n:e}(t),r=0;r<8;r++)o&&0===t[r]||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=C(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},ut={},lt=d({},ut,{" ":1,'"':1,"#":1,"<":1,">":1}),ht=d({},lt,{"'":1}),ct=d({},ut,{" ":1,'"':1,"<":1,">":1,"`":1}),ft=d({},ct,{"#":1,"?":1,"{":1,"}":1,"^":1}),pt=d({},ft,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),dt=function(t,e){var r=v(t,0);return r>=32&&r<127&&!p(e,t)?t:"'"===t&&p(e,t)?"%27":j(t)},mt={ftp:21,file:null,http:80,https:443,ws:80,wss:443},gt=function(t,e){var r;return 2===t.length&&F(K,A(t,0))&&(":"===(r=A(t,1))||!e&&"|"===r)},vt=function(t){var e;return t.length>1&>(N(t,0,2))&&(2===t.length||"/"===(e=A(t,2))||"\\"===e||"?"===e||"#"===e)},yt=function(t){return"."===t||"%2e"===D(t)},bt=function(t){return".."===(t=D(t))||"%2e."===t||".%2e"===t||"%2e%2e"===t},wt={},Pt={},St={},kt={},Rt={},Ut={},Bt={},Ht={},Lt={},Ot={},jt={},qt={},It={},Tt={},At={},Ft={},_t={},Ct={},Et={},Mt={},xt={},zt=function(t,e,r){var n,o,a,i=b(t);if(e){if(o=this.parse(i))throw new O(o);this.searchParams=null}else{if(void 0!==r&&(n=new zt(r,!0)),o=this.parse(i,null,n))throw new O(o);(a=H(new B)).bindURL(this),this.searchParams=a}};zt.prototype={type:"URL",parse:function(t,e,r){var o,a,i,s,u=this,l=e||wt,h=0,c="",f=!1,d=!1,v=!1;for(t=b(t),e||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,t=x(t,ot,""),t=x(t,at,"$1")),t=x(t,it,""),o=m(t);h<=o.length;){switch(a=o[h],l){case wt:if(!a||!F(K,a)){if(e)return W;l=St;continue}c+=D(a),l=Pt;break;case Pt:if(a&&F(V,a))c+=D(a);else{if(":"!==a){if(e)return W;c="",l=St,h=0;continue}if(e&&(u.isSpecial()!==p(mt,c)||"file"===c&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&""===u.host))return;if(u.scheme=c,e)return void(u.isSpecial()&&mt[u.scheme]===u.port&&(u.port=null));c="","file"===u.scheme?l=Tt:u.isSpecial()&&r&&r.scheme===u.scheme?l=kt:u.isSpecial()?l=Ht:"/"===o[h+1]?(l=Rt,h++):(u.cannotBeABaseURL=!0,M(u.path,""),l=Et)}break;case St:if(!r||r.cannotBeABaseURL&&"#"!==a)return W;if(r.cannotBeABaseURL&&"#"===a){u.scheme=r.scheme,u.path=g(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,l=xt;break}l="file"===r.scheme?Tt:Ut;continue;case kt:if("/"!==a||"/"!==o[h+1]){l=Ut;continue}l=Lt,h++;break;case Rt:if("/"===a){l=Ot;break}l=Ct;continue;case Ut:if(u.scheme=r.scheme,a===n)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query;else if("/"===a||"\\"===a&&u.isSpecial())l=Bt;else if("?"===a)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query="",l=Mt;else{if("#"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.path.length&&u.path.length--,l=Ct;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt}break;case Bt:if(!u.isSpecial()||"/"!==a&&"\\"!==a){if("/"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,l=Ct;continue}l=Ot}else l=Lt;break;case Ht:if(l=Lt,"/"!==a||"/"!==o[h+1])continue;h++;break;case Lt:if("/"!==a&&"\\"!==a){l=Ot;continue}break;case Ot:if("@"===a){f&&(c="%40"+c),f=!0,i=m(c);for(var y=0;y<i.length;y++){var w=i[y];if(":"!==w||v){var P=dt(w,pt);v?u.password+=P:u.username+=P}else v=!0}c=""}else if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(f&&""===c)return"Invalid authority";h-=m(c).length+1,c="",l=jt}else c+=a;break;case jt:case qt:if(e&&"file"===u.scheme){l=Ft;continue}if(":"!==a||d){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(u.isSpecial()&&""===c)return Q;if(e&&""===c&&(u.includesCredentials()||null!==u.port))return;if(s=u.parseHost(c))return s;if(c="",l=_t,e)return;continue}"["===a?d=!0:"]"===a&&(d=!1),c+=a}else{if(""===c)return Q;if(e===qt)return;if(s=u.parseHost(c))return s;c="",l=It}break;case It:if(!F(X,a)){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()||e){if(""!==c){var S=q(c,10);if(S>65535)return G;u.port=u.isSpecial()&&S===mt[u.scheme]?null:S,c=""}if(e)return;l=_t;continue}return G}c+=a;break;case Tt:if(u.scheme="file",u.host="","/"===a||"\\"===a)l=At;else{if(!r||"file"!==r.scheme){l=Ct;continue}switch(a){case n:u.host=r.host,u.path=g(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=g(r.path),u.query="",l=Mt;break;case"#":u.host=r.host,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt;break;default:u.host=r.host,vt(_(g(o,h),""))||(u.path=g(r.path),u.shortenPath()),l=Ct;continue}}break;case At:if("/"===a||"\\"===a){l=Ft;break}r&&"file"===r.scheme&&(u.host=r.host,!vt(_(g(o,h),""))&>(r.path[0],!0)&&M(u.path,r.path[0])),l=Ct;continue;case Ft:if(a===n||"/"===a||"\\"===a||"?"===a||"#"===a){if(!e&>(c))l=Ct;else if(""===c){if(u.host="",e)return;l=_t}else{if(s=u.parseHost(c))return s;if("localhost"===u.host&&(u.host=""),e)return;c="",l=_t}continue}c+=a;break;case _t:if(u.isSpecial()){if(l=Ct,"/"!==a&&"\\"!==a)continue}else if(e||"?"!==a)if(e||"#"!==a){if(a!==n&&(l=Ct,"/"!==a))continue}else u.fragment="",l=xt;else u.query="",l=Mt;break;case Ct:if(a===n||"/"===a||"\\"===a&&u.isSpecial()||!e&&("?"===a||"#"===a)){if(bt(c)?(u.shortenPath(),"/"===a||"\\"===a&&u.isSpecial()||M(u.path,"")):yt(c)?"/"===a||"\\"===a&&u.isSpecial()||M(u.path,""):("file"===u.scheme&&!u.path.length&>(c)&&(null!==u.host&&""!==u.host&&(u.host=""),c=A(c,0)+":"),M(u.path,c)),c="","file"===u.scheme&&(a===n||"?"===a||"#"===a))for(;u.path.length>1&&""===u.path[0];)z(u.path);"?"===a?(u.query="",l=Mt):"#"===a&&(u.fragment="",l=xt)}else c+=dt(a,ft);break;case Et:"?"===a?(u.query="",l=Mt):"#"===a?(u.fragment="",l=xt):a!==n&&(u.path[0]+=dt(a,ut));break;case Mt:e||"#"!==a?a!==n&&(u.query+=dt(a,u.isSpecial()?ht:lt)):(u.fragment="",l=xt);break;case xt:a!==n&&(u.fragment+=dt(a,ct))}h++}},parseHost:function(t){var e,r,n;if("["===A(t,0)){if("]"!==A(t,t.length-1))return Q;if(e=function(t){var e,r,n,o,a,i,s,u=[0,0,0,0,0,0,0,0],l=0,h=null,c=0,f=function(){return A(t,c)};if(":"===f()){if(":"!==A(t,1))return;c+=2,h=++l}for(;f();){if(8===l)return;if(":"!==f()){for(e=r=0;r<4&&F(et,f());)e=16*e+q(f(),16),c++,r++;if("."===f()){if(0===r)return;if(c-=r,l>6)return;for(n=0;f();){if(o=null,n>0){if(!("."===f()&&n<4))return;c++}if(!F(X,f()))return;for(;F(X,f());){if(a=q(f(),10),null===o)o=a;else{if(0===o)return;o=10*o+a}if(o>255)return;c++}u[l]=256*u[l]+o,2!==++n&&4!==n||l++}if(4!==n)return;break}if(":"===f()){if(c++,!f())return}else if(f())return;u[l++]=e}else{if(null!==h)return;c++,h=++l}}if(null!==h)for(i=l-h,l=7;0!==l&&i>0;)s=u[l],u[l--]=u[h+i-1],u[h+--i]=s;else if(8!==l)return;return u}(N(t,1,-1)),!e)return Q;this.host=e}else if(this.isSpecial()){if(t=y(t),F(rt,t))return Q;if(function(t){var e,r,n=$(t,".");if(""===n[n.length-1]){if(1===n.length)return!1;n.length--}return e=n[n.length-1],!!F(tt,e)||!!F(Y,e)&&(""===(r=N(e,2))||!!F(et,r))}(t)){if(e=function(t){var e,r,n,o,a,i,s,u=$(t,".");if(u.length&&""===u[u.length-1]&&u.length--,(e=u.length)>4)return null;for(r=[],n=0;n<e;n++){if(""===(o=u[n]))return null;if(a=10,o.length>1&&"0"===A(o,0)&&(a=F(Y,o)?16:8,o=N(o,8===a?1:2)),""===o)i=0;else{if(!F(10===a?tt:8===a?Z:et,o))return null;i=q(o,a)}M(r,i)}for(n=0;n<e;n++)if(i=r[n],n===e-1){if(i>=T(256,5-e))return null}else if(i>255)return null;for(s=E(r),n=0;n<r.length;n++)s+=r[n]*T(256,3-n);return s}(t),null===e)return Q;this.host=e}else this.host=t}else{if(F(nt,t))return Q;for(e="",r=m(t),n=0;n<r.length;n++)e+=dt(r[n],ut);this.host=e}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return p(mt,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;!e||"file"===this.scheme&&1===e&>(t[0],!0)||t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,a=t.port,i=t.path,s=t.query,u=t.fragment,l=e+":";return null!==o?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=st(o),null!==a&&(l+=":"+a)):"file"===e&&(l+="//"),null===o&&!t.cannotBeABaseURL&&i.length>1&&""===i[0]&&(l+="/."),l+=t.cannotBeABaseURL?i[0]:i.length?"/"+_(i,"/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new O(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if("blob"===t)try{return new $t(this.path[0]).origin}catch(t){return"null"}return"file"!==t&&this.isSpecial()?t+"://"+st(this.host)+(null!==e?":"+e:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(b(t)+":",wt)},getUsername:function(){return this.username},setUsername:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=dt(e[r],pt)}},getPassword:function(){return this.password},setPassword:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=dt(e[r],pt)}},getHost:function(){var t=this.host,e=this.port;return null===t?"":null===e?st(t):st(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,jt)},getHostname:function(){var t=this.host;return null===t?"":st(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,qt)},getPort:function(){var t=this.port;return null===t?"":b(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""===(t=b(t))?this.port=null:this.parse(t,It))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+_(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,_t))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""===(t=b(t))?this.query=null:("?"===A(t,0)&&(t=N(t,1)),this.query="",this.parse(t,Mt)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!==(t=b(t))?("#"===A(t,0)&&(t=N(t,1)),this.fragment="",this.parse(t,xt)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var $t=function(t){var e=f(this,Nt),r=P(arguments.length,1)>1?arguments[1]:void 0,n=R(e,new zt(t,!1,r));a||(e.href=n.serialize(),e.origin=n.getOrigin(),e.protocol=n.getProtocol(),e.username=n.getUsername(),e.password=n.getPassword(),e.host=n.getHost(),e.hostname=n.getHostname(),e.port=n.getPort(),e.pathname=n.getPathname(),e.search=n.getSearch(),e.searchParams=n.getSearchParams(),e.hash=n.getHash())},Nt=$t.prototype,Dt=function(t,e){return{get:function(){return U(this)[t]()},set:e&&function(t){return U(this)[e](t)},configurable:!0,enumerable:!0}};if(a&&(c(Nt,"href",Dt("serialize","setHref")),c(Nt,"origin",Dt("getOrigin")),c(Nt,"protocol",Dt("getProtocol","setProtocol")),c(Nt,"username",Dt("getUsername","setUsername")),c(Nt,"password",Dt("getPassword","setPassword")),c(Nt,"host",Dt("getHost","setHost")),c(Nt,"hostname",Dt("getHostname","setHostname")),c(Nt,"port",Dt("getPort","setPort")),c(Nt,"pathname",Dt("getPathname","setPathname")),c(Nt,"search",Dt("getSearch","setSearch")),c(Nt,"searchParams",Dt("getSearchParams")),c(Nt,"hash",Dt("getHash","setHash"))),h(Nt,"toJSON",function(){return U(this).serialize()},{enumerable:!0}),h(Nt,"toString",function(){return U(this).serialize()},{enumerable:!0}),L){var Jt=L.createObjectURL,Wt=L.revokeObjectURL;Jt&&h($t,"createObjectURL",u(Jt,L)),Wt&&h($t,"revokeObjectURL",u(Wt,L))}w($t,"URL"),o({global:!0,constructor:!0,forced:!i,sham:!a},{URL:$t})},3296:function(t,e,r){r(5806)},7208:function(t,e,r){var n=r(6518),o=r(9565);n({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return o(URL.prototype.toString,this)}})},5857:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r(2675),r(9463),r(2259),r(5700),r(8706),r(3792),r(2712),r(9572),r(2892),r(3851),r(875),r(6099),r(825),r(888),r(7495),r(7764),r(5440),r(2953),r(8408),r(2008),r(113),r(3418),r(8598),r(2062),r(4782),r(2010),r(5506),r(3921),r(9432),r(8781),r(1761),r(5746),r(2762),r(3500),r(3296),r(7208);var s,u=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.bookReaderOptions=e,this.urlSchema=[{name:"page",position:"path",default:"n0"},{name:"mode",position:"path",default:"2up"},{name:"search",position:"path",deprecated_for:"q"},{name:"q",position:"query_param"},{name:"sort",position:"query_param"},{name:"view",position:"query_param"},{name:"admin",position:"query_param"},{name:"focus",position:"query_param",readOnly:!0}],this.urlState={},this.urlMode=this.bookReaderOptions.urlMode||"hash",this.urlHistoryBasePath=this.bookReaderOptions.urlHistoryBasePath||"/",this.urlLocationPollId=null,this.oldLocationHash=null,this.oldUserHash=null},e=[{key:"urlStateToUrlString",value:function(t){var e=this,r=new URLSearchParams,n={};Object.keys(t).forEach(function(o){var a,i,s,u,l,h=e.urlSchema.find(function(t){return t.name===o});null!==(a=h)&&void 0!==a&&a.deprecated_for&&(h=e.urlSchema.find(function(t){return t.name===h.deprecated_for})),null!==(i=h)&&void 0!==i&&i.readOnly||("path"==(null===(s=h)||void 0===s?void 0:s.position)?n[null===(u=h)||void 0===u?void 0:u.name]=t[o]:r.append((null===(l=h)||void 0===l?void 0:l.name)||o,t[o]))});var o=this.urlSchema.filter(function(t){return"path"==t.position}).map(function(t){return n[t.name]?"".concat(t.name,"/").concat(encodeURIComponent(n[t.name])):""}).join("/"),a="".concat(o.replace(/\/+/g,"/").replace(/\/+$/,"")),i="".concat(a,"?").concat(r.toString());return r.toString()?i:"".concat(a)}},{key:"urlStringToUrlState",value:function(t){var e={},r=new URL(t,"http://example.com"),n=Object.fromEntries(r.searchParams.entries()),a=r.pathname.match(/[^\\/]+\/[^\\/]+/g),i=a?Object.fromEntries(a.map(function(t){return t.split("/")})):{},s=function(t,e){return Object.keys(t).some(function(t){return t==e})};return this.urlSchema.filter(function(t){return"path"==t.position}).forEach(function(t){var r=s(i,t.name),n=s(t,"deprecated_for")&&r;if(r||n){var o=n?t.deprecated_for:t.name;e[o]=decodeURIComponent(i[t.name])}}),Object.entries(n).forEach(function(t){var r=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,s=[],u=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=r[0],a=r[1];e[n]=a}),e}},{key:"setUrlParam",value:function(t,e){this.urlState[t]=e,this.pushToAddressBar()}},{key:"removeUrlParam",value:function(t){delete this.urlState[t],this.pushToAddressBar()}},{key:"getUrlParam",value:function(t){return this.urlState[t]}},{key:"pushToAddressBar",value:function(){var t=this.urlStateToUrlString(this.urlState),e="/"!==t?t:"";if("history"==this.urlMode)if(window.history&&window.history.replaceState){var r="".concat(this.urlHistoryBasePath).concat(e).trim().replace(/(\/+)/g,"/");try{window.history.replaceState({},null,r)}catch(t){this.urlMode="hash"}}else this.options.urlMode="hash";"hash"==this.urlMode&&window.location.replace("#"+e),this.oldLocationHash=t}},{key:"listenForHashChanges",value:function(){var t=this;this.oldLocationHash=this.getHash(),this.urlLocationPollId&&(clearInterval(this.urlLocationPollId),this.urlLocationPollId=null),this.urlLocationPollId=setInterval(function(){var e=t.getHash();e!=t.oldLocationHash&&(t.urlState=t.urlStringToUrlState(e))},500)}},{key:"pullFromAddressBar",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,e="history"===this.urlMode?t.pathname.substr(this.urlHistoryBasePath.length)+t.search:t.hash.substr(1);this.urlState=this.urlStringToUrlState(e)}},{key:"getHash",value:function(){return window.location.hash.slice(1)}}],e&&a(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=d(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},p.apply(null,arguments)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}r(1669).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view","text"],urlTrackIndex0:!1}),BookReader.prototype.setup=(s=BookReader.prototype.setup,function(t){s.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var e=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,function(){var t=e.options,r=t.updateWindowTitle,n=t.urlMode;r&&(document.title=e.shortTitle(e.bookTitle,50)),"hash"===n&&e.urlStartLocationPolling()}),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollId),this.locationPollId=null),this.locationPollId=setInterval(function(){var e=t.urlReadFragment();if(e!=t.oldLocationHash&&e!=t.oldUserHash){var r,n=t.paramsFromFragment(e),o=function(){return t.updateFromParams(n)};t.trigger(BookReader.eventNames.stop),t.animating?(null===(r=t.plugins.autoplay)||void 0===r||r.stop(),t.animationFinishedCallback=o):o(),t.oldUserHash=e}},500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),e=this.options,r=e.urlTrackIndex0,n=e.urlTrackedParams;r||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var o=n.reduce(function(e,r){return r in t&&(e[r]=t[r]),e},{}),a=this.fragmentFromParams(o,this.options.urlMode),i=""===a?"":"/".concat(a),s=this.urlReadFragment(),u=this.getLocationSearch(),l=this.queryStringFromParams(o,u,this.options.urlMode);if(s!==a||u!==l){if("history"===this.options.urlMode)if(window.history&&window.history.replaceState){var h=this.options.urlHistoryBasePath.replace(/\/+$/,""),c="".concat(h).concat(i).concat(l);try{window.history.replaceState({},null,c),this.oldLocationHash=a+l}catch(t){this.options.urlMode="hash"}}else this.options.urlMode="hash";if("hash"===this.options.urlMode){var f=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+a+f),this.oldLocationHash=a+f}}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var e=new URLSearchParams(t);return e.has("q")?"?".concat(new URLSearchParams({q:e.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,e=t.urlMode,r=t.urlHistoryBasePath;return"history"===e?window.location.pathname.substr(r.length):this.urlPlugin.getHash()},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)};var g=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,f()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(t,BookReader),e=t,r=[{key:"init",value:function(){var e,r,n,o=this;this.options.enableUrlPlugin&&(this.urlPlugin=new u(this.options),this.on(BookReader.eventNames.PostInit,function(){"hash"===o.options.urlMode&&o.urlPlugin.listenForHashChanges()})),(e=t,r=this,"function"==typeof(n=p(d(1&3?e.prototype:e),"init",r))?function(t){return n.apply(r,t)}:n)([])}}],r&&h(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();window.BookReader=g}},function(t){t(t.s=5857)}]);
|
|
2
2
|
//# sourceMappingURL=plugin.url.js.map
|
package/README.md
CHANGED
|
@@ -167,7 +167,9 @@ To version bump the repo and prepare a release, run `npm version major|minor|pat
|
|
|
167
167
|
We release BookReader [in-repo as tags](https://github.com/internetarchive/bookreader/releases) & also as a node module [@internetarchive/bookreader](https://www.npmjs.com/package/@internetarchive/bookreader)
|
|
168
168
|
|
|
169
169
|
## Tests
|
|
170
|
-
|
|
170
|
+
|
|
171
|
+
When contributing code, please
|
|
172
|
+
include unit tests and/or update tests accordingly. [Current code coverage can be tracked here](https://app.codecov.io/gh/internetarchive/bookreader).
|
|
171
173
|
|
|
172
174
|
### End to end tests
|
|
173
175
|
We also have end to end tests using [Testcafe](https://devexpress.github.io/testcafe/documentation/getting-started/). We write tests for the repo itself and also for our use on archive.org. You can read about them in [here](./tests/e2e/README.md). These are relatively easy to do, and a fantastic way of getting introduced to the wonders of BookReader. Check the project board for open tickets to work on. And if you don't see a test for something you spotted, feel free to make an issue.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/bookreader",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-117",
|
|
4
4
|
"description": "The Internet Archive BookReader.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -32,22 +32,23 @@
|
|
|
32
32
|
"private": false,
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@internetarchive/bergamot-translator": "^0.4.9-ia.1",
|
|
35
|
-
"@internetarchive/ia-activity-indicator": "1.0.0",
|
|
36
|
-
"@internetarchive/ia-item-navigator": "2.2.3",
|
|
37
|
-
"@internetarchive/icon-bookmark": "1.4.1",
|
|
38
|
-
"@internetarchive/icon-close": "1.4.1",
|
|
39
|
-
"@internetarchive/icon-dl": "1.4.1",
|
|
40
|
-
"@internetarchive/icon-edit-pencil": "1.4.1",
|
|
41
|
-
"@internetarchive/icon-
|
|
42
|
-
"@internetarchive/icon-
|
|
43
|
-
"@internetarchive/icon-magnify-
|
|
44
|
-
"@internetarchive/icon-
|
|
45
|
-
"@internetarchive/icon-
|
|
46
|
-
"@internetarchive/icon-
|
|
47
|
-
"@internetarchive/icon-
|
|
48
|
-
"@internetarchive/
|
|
49
|
-
"@internetarchive/
|
|
50
|
-
"
|
|
35
|
+
"@internetarchive/ia-activity-indicator": "^1.0.0",
|
|
36
|
+
"@internetarchive/ia-item-navigator": "^2.2.3",
|
|
37
|
+
"@internetarchive/icon-bookmark": "^1.4.1",
|
|
38
|
+
"@internetarchive/icon-close": "^1.4.1",
|
|
39
|
+
"@internetarchive/icon-dl": "^1.4.1",
|
|
40
|
+
"@internetarchive/icon-edit-pencil": "^1.4.1",
|
|
41
|
+
"@internetarchive/icon-ellipses": "^1.4.1",
|
|
42
|
+
"@internetarchive/icon-ia-logo": "^1.4.1",
|
|
43
|
+
"@internetarchive/icon-magnify-minus": "^1.4.1",
|
|
44
|
+
"@internetarchive/icon-magnify-plus": "^1.4.1",
|
|
45
|
+
"@internetarchive/icon-search": "^1.4.1",
|
|
46
|
+
"@internetarchive/icon-share": "^1.4.1",
|
|
47
|
+
"@internetarchive/icon-toc": "^1.4.1",
|
|
48
|
+
"@internetarchive/icon-visual-adjustment": "^1.4.1",
|
|
49
|
+
"@internetarchive/modal-manager": "^2.0.6",
|
|
50
|
+
"@internetarchive/shared-resize-observer": "^0.2.0",
|
|
51
|
+
"interactjs": "1.10.18",
|
|
51
52
|
"iso-language-codes": "2.0.0",
|
|
52
53
|
"jquery": "3.6.1",
|
|
53
54
|
"jquery-colorbox": "1.6.4",
|
|
@@ -67,27 +68,29 @@
|
|
|
67
68
|
"@iiif/presentation-3": "2.2.3",
|
|
68
69
|
"@open-wc/testing-helpers": "3.0.1",
|
|
69
70
|
"@types/jest": "30.0.0",
|
|
70
|
-
"@webcomponents/webcomponentsjs": "
|
|
71
|
+
"@webcomponents/webcomponentsjs": "2.6.0",
|
|
71
72
|
"babel-loader": "10.1.1",
|
|
72
73
|
"concurrently": "10.0.3",
|
|
73
74
|
"core-js": "3.49.0",
|
|
74
75
|
"cpx2": "9.0.0",
|
|
76
|
+
"css-loader": "7.1.4",
|
|
75
77
|
"eslint": "7.32.0",
|
|
76
|
-
"eslint-plugin-no-jquery": "
|
|
78
|
+
"eslint-plugin-no-jquery": "2.7.0",
|
|
77
79
|
"eslint-plugin-testcafe": "0.2.1",
|
|
78
80
|
"http-server": "14.1.1",
|
|
79
|
-
"hypothesis": "
|
|
81
|
+
"hypothesis": "1.1627.0",
|
|
80
82
|
"jest": "30.4.2",
|
|
81
83
|
"jest-environment-jsdom": "30.4.1",
|
|
82
84
|
"live-server": "1.2.2",
|
|
83
85
|
"regenerator-runtime": "0.14.1",
|
|
84
|
-
"sass": "1.
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
86
|
+
"sass": "1.101.5",
|
|
87
|
+
"sass-loader": "17.0.0",
|
|
88
|
+
"sinon": "22.1.0",
|
|
89
|
+
"svgo": "4.0.2",
|
|
90
|
+
"testcafe": "3.7.6",
|
|
88
91
|
"testcafe-browser-provider-browserstack": "1.15.2",
|
|
89
|
-
"webpack": "5.
|
|
90
|
-
"webpack-cli": "7.
|
|
92
|
+
"webpack": "5.108.4",
|
|
93
|
+
"webpack-cli": "7.2.1"
|
|
91
94
|
},
|
|
92
95
|
"jest": {
|
|
93
96
|
"testEnvironment": "jsdom",
|
|
@@ -95,7 +98,8 @@
|
|
|
95
98
|
"node_modules/(?!(sinon|lit-html|lit-element|lit|@lit|@lit-labs|@internetarchive|@open-wc)/)"
|
|
96
99
|
],
|
|
97
100
|
"moduleNameMapper": {
|
|
98
|
-
"
|
|
101
|
+
"@/(.*)$": "<rootDir>/$1",
|
|
102
|
+
"\\.scss$": "<rootDir>/tests/jest/styleMock.js"
|
|
99
103
|
},
|
|
100
104
|
"setupFiles": [
|
|
101
105
|
"./src/jquery-wrapper.js",
|
|
@@ -135,7 +139,7 @@
|
|
|
135
139
|
"update:test-deps": "npm i @babel/eslint-parser@latest @open-wc/testing-helpers@latest @types/jest@latest eslint@7 eslint-plugin-no-jquery@latest eslint-plugin-testcafe@latest jest@latest jest-environment-jsdom@latest sinon@latest testcafe@latest",
|
|
136
140
|
"update:test-deps:test": "npm run lint && npm run test && npm run test:e2e",
|
|
137
141
|
"DOCS:update:build-deps": "These can cause strange changes, so do an npm run build + check file size (git diff --stat), and check the site is as expected",
|
|
138
|
-
"update:build-deps": "npm i @babel/core@latest @babel/preset-env@latest @babel/plugin-proposal-class-properties@latest @babel/plugin-proposal-decorators@latest babel-loader@latest core-js@latest regenerator-runtime@latest sass@latest svgo@latest webpack@latest webpack-cli@latest",
|
|
142
|
+
"update:build-deps": "npm i @babel/core@latest @babel/preset-env@latest @babel/plugin-proposal-class-properties@latest @babel/plugin-proposal-decorators@latest babel-loader@latest core-js@latest css-loader@latest regenerator-runtime@latest sass@latest sass-loader@latest svgo@latest webpack@latest webpack-cli@latest",
|
|
139
143
|
"update:build-deps:test": "npm run build",
|
|
140
144
|
"DOCS:update:dev-deps": "Packages used for development",
|
|
141
145
|
"update:dev-deps": "npm i @iiif/presentation-2@latest @iiif/presentation-3@latest concurrently@latest cpx2@latest http-server@latest hypothesis@latest live-server@latest testcafe-browser-provider-browserstack@latest",
|
|
@@ -143,6 +147,6 @@
|
|
|
143
147
|
"update:runtime-deps": "npm i @webcomponents/webcomponentsjs@latest interactjs@latest iso-language-codes@latest jquery@latest jquery-colorbox@latest jquery-ui@latest jquery-ui-touch-punch@latest jquery.browser@latest lit@latest soundmanager2@latest",
|
|
144
148
|
"update:runtime-deps:test": "npm run build",
|
|
145
149
|
"DOCS:update:ia-deps": "Packages by @internetarchive",
|
|
146
|
-
"update:ia-deps": "npm i @internetarchive/bergamot-translator@latest @internetarchive/ia-activity-indicator@latest @internetarchive/ia-item-navigator@latest @internetarchive/icon-bookmark@latest @internetarchive/icon-close@latest @internetarchive/icon-dl@latest @internetarchive/icon-edit-pencil@latest @internetarchive/icon-ia-logo@latest @internetarchive/icon-magnify-minus@latest @internetarchive/icon-magnify-plus@latest @internetarchive/icon-search@latest @internetarchive/icon-share@latest @internetarchive/icon-toc@latest @internetarchive/icon-visual-adjustment@latest @internetarchive/modal-manager@latest @internetarchive/shared-resize-observer@latest"
|
|
150
|
+
"update:ia-deps": "npm i @internetarchive/bergamot-translator@latest @internetarchive/ia-activity-indicator@latest @internetarchive/ia-item-navigator@latest @internetarchive/icon-bookmark@latest @internetarchive/icon-close@latest @internetarchive/icon-dl@latest @internetarchive/icon-edit-pencil@latest @internetarchive/icon-ellipses@latest @internetarchive/icon-ia-logo@latest @internetarchive/icon-magnify-minus@latest @internetarchive/icon-magnify-plus@latest @internetarchive/icon-search@latest @internetarchive/icon-share@latest @internetarchive/icon-toc@latest @internetarchive/icon-visual-adjustment@latest @internetarchive/modal-manager@latest @internetarchive/shared-resize-observer@latest"
|
|
147
151
|
}
|
|
148
152
|
}
|
package/src/BookReader.js
CHANGED
|
@@ -26,6 +26,7 @@ import 'jquery-ui-touch-punch';
|
|
|
26
26
|
|
|
27
27
|
import PACKAGE_JSON from '../package.json';
|
|
28
28
|
import * as utils from './BookReader/utils.js';
|
|
29
|
+
import { singleScrollIntoView } from './util/dom.js';
|
|
29
30
|
import { exposeOverrideable } from './BookReader/utils/classes.js';
|
|
30
31
|
import { Navbar } from './BookReader/Navbar/Navbar.js';
|
|
31
32
|
import { DEFAULT_OPTIONS, OptionsParseError } from './BookReader/options.js';
|
|
@@ -111,6 +112,8 @@ BookReader.PLUGINS = {
|
|
|
111
112
|
chapters: null,
|
|
112
113
|
/** @type {typeof import('./plugins/plugin.experiments.js').ExperimentsPlugin | null}*/
|
|
113
114
|
experiments: null,
|
|
115
|
+
/** @type {typeof import('./plugins/plugin.iframe.js').IframePlugin | null}*/
|
|
116
|
+
iframe: null,
|
|
114
117
|
/** @type {typeof import('./plugins/plugin.resume.js').ResumePlugin | null}*/
|
|
115
118
|
resume: null,
|
|
116
119
|
/** @type {typeof import('./plugins/search/plugin.search.js').SearchPlugin | null}*/
|
|
@@ -181,6 +184,7 @@ BookReader.prototype.setup = function(options) {
|
|
|
181
184
|
autoplay: BookReader.PLUGINS.autoplay ? new BookReader.PLUGINS.autoplay(this) : null,
|
|
182
185
|
chapters: BookReader.PLUGINS.chapters ? new BookReader.PLUGINS.chapters(this) : null,
|
|
183
186
|
experiments: BookReader.PLUGINS.experiments ? new BookReader.PLUGINS.experiments(this) : null,
|
|
187
|
+
iframe: BookReader.PLUGINS.iframe ? new BookReader.PLUGINS.iframe(this) : null,
|
|
184
188
|
search: BookReader.PLUGINS.search ? new BookReader.PLUGINS.search(this) : null,
|
|
185
189
|
resume: BookReader.PLUGINS.resume ? new BookReader.PLUGINS.resume(this) : null,
|
|
186
190
|
textSelection: BookReader.PLUGINS.textSelection ? new BookReader.PLUGINS.textSelection(this) : null,
|
|
@@ -1031,6 +1035,18 @@ BookReader.prototype.resizeBRcontainer = function(animate) {
|
|
|
1031
1035
|
}
|
|
1032
1036
|
};
|
|
1033
1037
|
|
|
1038
|
+
/**
|
|
1039
|
+
* Scrolls the given element into view within the active mode's scroll container.
|
|
1040
|
+
* @param {Element} el
|
|
1041
|
+
* @param {object} [options]
|
|
1042
|
+
* @param {'auto' | 'smooth'} [options.behavior]
|
|
1043
|
+
* @param {'start' | 'center' | 'end' | 'nearest'} [options.block]
|
|
1044
|
+
* @param {'start' | 'center' | 'end' | 'nearest'} [options.inline]
|
|
1045
|
+
*/
|
|
1046
|
+
BookReader.prototype.scrollIntoView = function(el, options) {
|
|
1047
|
+
singleScrollIntoView(el, { ...options, scrollContainer: this.activeMode.scrollContainer });
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1034
1050
|
BookReader.prototype.centerPageView = function() {
|
|
1035
1051
|
const scrollWidth = this.refs.$brContainer.prop('scrollWidth');
|
|
1036
1052
|
const clientWidth = this.refs.$brContainer.prop('clientWidth');
|
|
@@ -145,16 +145,29 @@
|
|
|
145
145
|
display: none;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
|
|
149
|
+
$select-menu-radius: 25px;
|
|
150
|
+
$select-menu-extended-radius: 10px;
|
|
148
151
|
.br-select-menu__root {
|
|
149
152
|
display: none;
|
|
150
|
-
border-radius: 20px;
|
|
151
|
-
background-color: #333;
|
|
152
153
|
color: white;
|
|
153
154
|
color-scheme: dark;
|
|
154
155
|
padding: 2px;
|
|
155
156
|
overflow: hidden;
|
|
156
157
|
opacity: 1;
|
|
157
|
-
transition:
|
|
158
|
+
transition: opacity 0.2s;
|
|
159
|
+
gap: 5px;
|
|
160
|
+
|
|
161
|
+
&[open] {
|
|
162
|
+
display: flex;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&[showextended] {
|
|
166
|
+
display: block;
|
|
167
|
+
gap: 0px;
|
|
168
|
+
background-color: #333;
|
|
169
|
+
border-radius: $select-menu-extended-radius;
|
|
170
|
+
}
|
|
158
171
|
|
|
159
172
|
@starting-style {
|
|
160
173
|
opacity: 0;
|
|
@@ -164,13 +177,6 @@
|
|
|
164
177
|
opacity: 0;
|
|
165
178
|
pointer-events: none;
|
|
166
179
|
}
|
|
167
|
-
.br-select-menu__root:hover {
|
|
168
|
-
border-radius: 8px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.br-select-menu__root:hover .br-select-menu__option {
|
|
172
|
-
border-radius: 6px;
|
|
173
|
-
}
|
|
174
180
|
|
|
175
181
|
.br-select-menu__option {
|
|
176
182
|
--iconWidth: 15px;
|
|
@@ -179,18 +185,40 @@
|
|
|
179
185
|
background: transparent;
|
|
180
186
|
display: flex;
|
|
181
187
|
align-items: center;
|
|
182
|
-
border-radius:
|
|
188
|
+
border-radius: $select-menu-radius;
|
|
183
189
|
font-family: inherit;
|
|
184
190
|
color: inherit;
|
|
185
191
|
border: 0;
|
|
186
|
-
transition: background-color 0.2s, border-radius 0.2s;
|
|
187
192
|
cursor: pointer;
|
|
188
193
|
text-wrap: nowrap;
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
background-color: #333;
|
|
195
|
+
position: relative;
|
|
191
196
|
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
@media (pointer: coarse) and (hover: none) {
|
|
198
|
+
padding: 4px 8px;
|
|
199
|
+
#br-select-more & {
|
|
200
|
+
padding: 4px;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&:hover:after {
|
|
205
|
+
position: absolute;
|
|
206
|
+
left: 2px;
|
|
207
|
+
right: 2px;
|
|
208
|
+
top: 2px;
|
|
209
|
+
bottom: 2px;
|
|
210
|
+
content: "";
|
|
211
|
+
pointer-events: none;
|
|
212
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
213
|
+
border-radius: calc($select-menu-radius - 2px);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.br-select-menu__root[showextended] & {
|
|
217
|
+
width:100%;
|
|
218
|
+
&:hover:after {
|
|
219
|
+
border-radius: calc($select-menu-extended-radius - 2px);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
194
222
|
}
|
|
195
223
|
|
|
196
224
|
.br-select-menu__icon {
|
|
@@ -198,24 +226,29 @@
|
|
|
198
226
|
flex-shrink: 0;
|
|
199
227
|
width: 17px;
|
|
200
228
|
height: 17px;
|
|
229
|
+
padding: 2px;
|
|
201
230
|
}
|
|
202
231
|
|
|
203
232
|
.br-select-menu__label {
|
|
204
233
|
margin-left: 4px;
|
|
205
234
|
font-size: 12px;
|
|
235
|
+
margin-right: 4px;
|
|
206
236
|
}
|
|
207
237
|
|
|
208
238
|
@media (hover: hover) {
|
|
239
|
+
.br-select-menu__option {
|
|
240
|
+
padding: 4px;
|
|
241
|
+
}
|
|
209
242
|
.br-select-menu__label {
|
|
210
243
|
width: 0px;
|
|
211
|
-
margin
|
|
244
|
+
margin: 0;
|
|
212
245
|
opacity: 0;
|
|
213
246
|
interpolate-size: allow-keywords;
|
|
214
247
|
transition: width 0.2s;
|
|
215
248
|
}
|
|
216
249
|
.br-select-menu__root:hover .br-select-menu__label {
|
|
217
250
|
width: auto;
|
|
218
|
-
margin
|
|
251
|
+
margin: 0 4px;
|
|
219
252
|
opacity: 1;
|
|
220
253
|
}
|
|
221
254
|
}
|
|
@@ -7,6 +7,7 @@ import '@internetarchive/icon-toc/icon-toc.js';
|
|
|
7
7
|
import { BookReaderPlugin } from "../BookReaderPlugin.js";
|
|
8
8
|
import { applyVariables } from "../util/strings.js";
|
|
9
9
|
import { promisifyEvent } from "../BookReader/utils.js";
|
|
10
|
+
import { singleScrollIntoView } from "../util/dom.js";
|
|
10
11
|
/** @typedef {import('@/src/BookReader/BookModel.js').PageIndex} PageIndex */
|
|
11
12
|
/** @typedef {import('@/src/BookReader/BookModel.js').PageString} PageString */
|
|
12
13
|
/** @typedef {import('@/src/BookReader/BookModel.js').LeafNum} LeafNum */
|
|
@@ -323,10 +324,13 @@ export class BRChaptersPanel extends LitElement {
|
|
|
323
324
|
|
|
324
325
|
updated(changedProperties) {
|
|
325
326
|
if (changedProperties.has('currentChapter')) {
|
|
326
|
-
this.shadowRoot.querySelector('li.current')
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
const currentEl = this.shadowRoot.querySelector('li.current');
|
|
328
|
+
if (currentEl) {
|
|
329
|
+
singleScrollIntoView(currentEl, {
|
|
330
|
+
block: 'nearest',
|
|
331
|
+
behavior: 'smooth',
|
|
332
|
+
});
|
|
333
|
+
}
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
336
|
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* parent web page
|
|
5
|
-
*/
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { EVENTS } from '../BookReader/events.js';
|
|
3
|
+
import { BookReaderPlugin } from '../BookReaderPlugin.js';
|
|
6
4
|
|
|
7
5
|
const MESSAGE_TYPE_FRAGMENT_CHANGE = 'bookReaderFragmentChange';
|
|
8
6
|
|
|
9
|
-
BookReader.prototype.init = (function (super_) {
|
|
10
|
-
return function () {
|
|
11
|
-
super_.call(this);
|
|
12
|
-
_attachEventListeners(this);
|
|
13
|
-
};
|
|
14
|
-
})(BookReader.prototype.init);
|
|
15
|
-
|
|
16
7
|
/**
|
|
17
|
-
*
|
|
18
|
-
* Using window.postMessage() and event listeners, the
|
|
19
|
-
* parent window when pages change, and the parent
|
|
20
|
-
* explicitly request a page change by sending its own
|
|
21
|
-
*
|
|
22
|
-
* @param {BookReader} br
|
|
23
|
-
* @param {Window?} [parent]
|
|
8
|
+
* Plugin for two-way communication between a BookReader in an IFrame and the
|
|
9
|
+
* parent web page. Using window.postMessage() and event listeners, the
|
|
10
|
+
* plugin notifies the parent window when pages change, and the parent
|
|
11
|
+
* window can also explicitly request a page change by sending its own
|
|
12
|
+
* message.
|
|
24
13
|
*/
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return;
|
|
14
|
+
export class IframePlugin extends BookReaderPlugin {
|
|
15
|
+
options = {
|
|
16
|
+
enabled: true,
|
|
29
17
|
}
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
parent
|
|
35
|
-
{ type: MESSAGE_TYPE_FRAGMENT_CHANGE, fragment },
|
|
36
|
-
'*',
|
|
37
|
-
);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
window.addEventListener('message', event => {
|
|
41
|
-
// Not a recognized message type, abort
|
|
42
|
-
if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
|
|
19
|
+
/** @override */
|
|
20
|
+
init() {
|
|
21
|
+
// Not enabled, or not embedded, abort
|
|
22
|
+
if (!this.options.enabled || !window.parent) {
|
|
43
23
|
return;
|
|
44
24
|
}
|
|
45
25
|
|
|
46
|
-
br.
|
|
47
|
-
|
|
26
|
+
this.br.bind(EVENTS.fragmentChange, () => {
|
|
27
|
+
const fragment = this.br.fragmentFromParams(this.br.paramsFromCurrent());
|
|
28
|
+
|
|
29
|
+
window.parent.postMessage(
|
|
30
|
+
{ type: MESSAGE_TYPE_FRAGMENT_CHANGE, fragment },
|
|
31
|
+
'*',
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
window.addEventListener('message', event => {
|
|
36
|
+
// Not a recognized message type, abort
|
|
37
|
+
if (!event.data || event.data.type !== MESSAGE_TYPE_FRAGMENT_CHANGE) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.br.updateFromParams(this.br.paramsFromFragment(event.data.fragment));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
48
44
|
}
|
|
45
|
+
|
|
46
|
+
const BookReader = /** @type {typeof import('../BookReader').default} */(window.BookReader);
|
|
47
|
+
BookReader?.registerPlugin('iframe', IframePlugin);
|