@prose-reader/enhancer-pdf 1.306.0 → 1.307.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1215 -76
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +16 -6
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.cjs
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("rxjs"),require("pdfjs-dist"),require("@prose-reader/core")):typeof define==`function`&&define.amd?define([`exports`,`rxjs`,`pdfjs-dist`,`@prose-reader/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`prose-reader-enhancer-pdf`]={},e.rxjs,e.pdfjs_dist,e._prose_reader_core))})(this,function(e,t,n,r){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=s(t),c=0,u=i.length,d;c<u;c++)d=i[c],!l.call(e,d)&&d!==n&&a(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=o(t,d))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:i(c(e)),d(t||!e||!e.__esModule?a(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);function f(e){let t=[];if(e.length===0)return``;if(typeof e[0]!=`string`)throw TypeError(`Url must be a string. Received ${e[0]}`);e[0].match(/^[^/:]+:\/*$/)&&e.length>1&&(e[0]=e.shift()+e[0]),e[0].match(/^file:\/\/\//)?e[0]=e[0].replace(/^([^/:]+):\/*/,`$1:///`):e[0]=e[0].replace(/^([^/:]+):\/*/,`$1://`);for(let n=0;n<e.length;n++){let r=e[n];if(typeof r!=`string`)throw TypeError(`Url must be a string. Received ${r}`);r!==``&&(n>0&&(r=r.replace(/^[/]+/,``)),r=n<e.length-1?r.replace(/[/]+$/,``):r.replace(/[/]+$/,`/`),t.push(r))}let n=t.join(`/`);n=n.replace(/\/(\?|&|#[^!])/g,`$1`);let r=n.split(`?`);return n=r.shift()+(r.length>0?`?`:``)+r.join(`&`),n}function p(...e){return f(Array.from(Array.isArray(e[0])?e[0]:e))}var m=()=>{if(!(typeof window>`u`))return window};function h(){let e=m()?.__PROSE_READER_DEBUG;return e===!0||e===`true`}var g=(e,t)=>typeof e==`boolean`?{enabled:e,options:t}:{enabled:e?.enabled,options:e??t},_=e=>e.at(-1)?.color,v=e=>{if(!e.length)return;if(!e.some(e=>e.color))return[e.map(e=>e.label).join(` `)];let t=``,n=[];for(let r of e)t+=`%c${t?` ${r.label}`:r.label}`,n.push(r.color?`color: ${r.color}`:``);return[t,...n]},y=(e=[],t=h())=>{let n=t,r={enable:e=>{a(e)},namespace:(t,r,i)=>{let a=g(r,i),o=a.options?.color??_(e);return y([...e,{label:`[${t}]`,color:o}],a.enabled??n)},isEnabled:()=>n,debug:()=>{},info:()=>{},log:()=>{},groupCollapsed:()=>{},groupEnd:()=>{},getGroupArgs:t=>{let n=v(e);if(!n)return[t];let[r,...i]=n;return[`${r} ${t}`,...i]},warn:()=>{},error:()=>{}},i=t=>{if(!t){r.debug=()=>{},r.info=()=>{},r.log=()=>{},r.groupCollapsed=()=>{},r.groupEnd=()=>{},r.warn=()=>{},r.error=()=>{};return}let n=v(e)??[];r.debug=Function.prototype.bind.call(console.debug,console,...n),r.info=Function.prototype.bind.call(console.info,console,...n),r.log=Function.prototype.bind.call(console.log,console,...n),r.groupCollapsed=Function.prototype.bind.call(console.groupCollapsed,console),r.groupEnd=Function.prototype.bind.call(console.groupEnd,console),r.warn=Function.prototype.bind.call(console.warn,console,...n),r.error=Function.prototype.bind.call(console.error,console,...n)},a=e=>{n!==e&&(n=e,i(n))};return i(n),r},b=y(),x=({records:e,...t})=>{let n=new Map;for(let t of e)n.has(t.uri)||n.set(t.uri,t);return{...t,records:e,recordsByUri:n}};b.namespace(`@prose-reader/streamer`,!1,{color:`#ffae42`});var S=e=>({blob:e,arrayBuffer:()=>e().then(e=>e.arrayBuffer())}),C=u((e=>{(function(e){e.parser=function(e,t){return new n(e,t)},e.SAXParser=n,e.SAXStream=u,e.createStream=c,e.MAX_BUFFER_LENGTH=64*1024;var t=[`comment`,`sgmlDecl`,`textNode`,`tagName`,`doctype`,`procInstName`,`procInstBody`,`entity`,`attribName`,`attribValue`,`cdata`,`script`];e.EVENTS=[`text`,`processinginstruction`,`sgmldeclaration`,`doctype`,`comment`,`opentagstart`,`attribute`,`opentag`,`closetag`,`opencdata`,`cdata`,`closecdata`,`error`,`end`,`ready`,`script`,`opennamespace`,`closenamespace`];function n(t,r){if(!(this instanceof n))return new n(t,r);var a=this;i(a),a.q=a.c=``,a.bufferCheckPosition=e.MAX_BUFFER_LENGTH,a.encoding=null,a.opt=r||{},a.opt.lowercase=a.opt.lowercase||a.opt.lowercasetags,a.looseCase=a.opt.lowercase?`toLowerCase`:`toUpperCase`,a.opt.maxEntityCount=a.opt.maxEntityCount||512,a.opt.maxEntityDepth=a.opt.maxEntityDepth||4,a.entityCount=a.entityDepth=0,a.tags=[],a.closed=a.closedRoot=a.sawRoot=!1,a.tag=a.error=null,a.strict=!!t,a.noscript=!!(t||a.opt.noscript),a.state=T.BEGIN,a.strictEntities=a.opt.strictEntities,a.ENTITIES=a.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),a.attribList=[],a.opt.xmlns&&(a.ns=Object.create(h)),a.opt.unquotedAttributeValues===void 0&&(a.opt.unquotedAttributeValues=!t),a.trackPosition=a.opt.position!==!1,a.trackPosition&&(a.position=a.line=a.column=0),D(a,`onready`)}Object.create||(Object.create=function(e){function t(){}return t.prototype=e,new t}),Object.keys||(Object.keys=function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t});function r(n){for(var r=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,a=0,o=t.length;a<o;a++){var s=n[t[a]].length;if(s>r)switch(t[a]){case`textNode`:N(n);break;case`cdata`:M(n,`oncdata`,n.cdata),n.cdata=``;break;case`script`:M(n,`onscript`,n.script),n.script=``;break;default:F(n,`Max buffer length exceeded: `+t[a])}i=Math.max(i,s)}n.bufferCheckPosition=e.MAX_BUFFER_LENGTH-i+n.position}function i(e){for(var n=0,r=t.length;n<r;n++)e[t[n]]=``}function a(e){N(e),e.cdata!==``&&(M(e,`oncdata`,e.cdata),e.cdata=``),e.script!==``&&(M(e,`onscript`,e.script),e.script=``)}n.prototype={end:function(){I(this)},write:K,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=require("node:stream").Stream}catch{o=function(){}}o||=function(){};var s=e.EVENTS.filter(function(e){return e!==`error`&&e!==`end`});function c(e,t){return new u(e,t)}function l(e,t){if(e.length>=2){if(e[0]===255&&e[1]===254)return`utf-16le`;if(e[0]===254&&e[1]===255)return`utf-16be`}return e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191?`utf8`:e.length>=4?e[0]===60&&e[1]===0&&e[2]===63&&e[3]===0?`utf-16le`:e[0]===0&&e[1]===60&&e[2]===0&&e[3]===63?`utf-16be`:`utf8`:t?`utf8`:null}function u(e,t){if(!(this instanceof u))return new u(e,t);o.apply(this),this._parser=new n(e,t),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit(`end`)},this._parser.onerror=function(e){r.emit(`error`,e),r._parser.error=null},this._decoder=null,this._decoderBuffer=null,s.forEach(function(e){Object.defineProperty(r,`on`+e,{get:function(){return r._parser[`on`+e]},set:function(t){if(!t)return r.removeAllListeners(e),r._parser[`on`+e]=t,t;r.on(e,t)},enumerable:!0,configurable:!1})})}u.prototype=Object.create(o.prototype,{constructor:{value:u}}),u.prototype._decodeBuffer=function(e,t){if(this._decoderBuffer&&=(e=Buffer.concat([this._decoderBuffer,e]),null),!this._decoder){var n=l(e,t);if(!n)return this._decoderBuffer=e,``;this._parser.encoding=n,this._decoder=new TextDecoder(n)}return this._decoder.decode(e,{stream:!t})},u.prototype.write=function(e){if(typeof Buffer==`function`&&typeof Buffer.isBuffer==`function`&&Buffer.isBuffer(e))e=this._decodeBuffer(e,!1);else if(this._decoderBuffer){var t=this._decodeBuffer(Buffer.alloc(0),!0);t&&(this._parser.write(t),this.emit(`data`,t))}return this._parser.write(e.toString()),this.emit(`data`,e),!0},u.prototype.end=function(e){if(e&&e.length&&this.write(e),this._decoderBuffer){var t=this._decodeBuffer(Buffer.alloc(0),!0);t&&(this._parser.write(t),this.emit(`data`,t))}else if(this._decoder){var n=this._decoder.decode();n&&(this._parser.write(n),this.emit(`data`,n))}return this._parser.end(),!0},u.prototype.on=function(e,t){var n=this;return!n._parser[`on`+e]&&s.indexOf(e)!==-1&&(n._parser[`on`+e]=function(){var t=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),n.emit.apply(n,t)}),o.prototype.on.call(n,e,t)};var d=`[CDATA[`,f=`DOCTYPE`,p=`http://www.w3.org/XML/1998/namespace`,m=`http://www.w3.org/2000/xmlns/`,h={xml:p,xmlns:m},g=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,_=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,v=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,y=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function b(e){return e===` `||e===`
|
|
2
|
+
`||e===`\r`||e===` `}function x(e){return e===`"`||e===`'`}function S(e){return e===`>`||b(e)}function C(e,t){return e.test(t)}function w(e,t){return!C(e,t)}var T=0;for(var E in e.STATE={BEGIN:T++,BEGIN_WHITESPACE:T++,TEXT:T++,TEXT_ENTITY:T++,OPEN_WAKA:T++,SGML_DECL:T++,SGML_DECL_QUOTED:T++,DOCTYPE:T++,DOCTYPE_QUOTED:T++,DOCTYPE_DTD:T++,DOCTYPE_DTD_QUOTED:T++,COMMENT_STARTING:T++,COMMENT:T++,COMMENT_ENDING:T++,COMMENT_ENDED:T++,CDATA:T++,CDATA_ENDING:T++,CDATA_ENDING_2:T++,PROC_INST:T++,PROC_INST_BODY:T++,PROC_INST_ENDING:T++,OPEN_TAG:T++,OPEN_TAG_SLASH:T++,ATTRIB:T++,ATTRIB_NAME:T++,ATTRIB_NAME_SAW_WHITE:T++,ATTRIB_VALUE:T++,ATTRIB_VALUE_QUOTED:T++,ATTRIB_VALUE_CLOSED:T++,ATTRIB_VALUE_UNQUOTED:T++,ATTRIB_VALUE_ENTITY_Q:T++,ATTRIB_VALUE_ENTITY_U:T++,CLOSE_TAG:T++,CLOSE_TAG_SAW_WHITE:T++,SCRIPT:T++,SCRIPT_ENDING:T++},e.XML_ENTITIES={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`},e.ENTITIES={amp:`&`,gt:`>`,lt:`<`,quot:`"`,apos:`'`,AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(t){var n=e.ENTITIES[t],r=typeof n==`number`?String.fromCharCode(n):n;e.ENTITIES[t]=r}),e.STATE)e.STATE[e.STATE[E]]=E;T=e.STATE;function D(e,t,n){e[t]&&e[t](n)}function O(e){var t=e&&e.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);return t?t[2]:null}function k(e){return e?e.toLowerCase().replace(/[^a-z0-9]/g,``):null}function A(e,t){let n=k(e),r=k(t);return!n||!r?!0:r===`utf16`?n===`utf16le`||n===`utf16be`:n===r}function j(e,t){if(!(!e.strict||!e.encoding||!t||t.name!==`xml`)){var n=O(t.body);n&&!A(e.encoding,n)&&L(e,`XML declaration encoding `+n+` does not match detected stream encoding `+e.encoding.toUpperCase())}}function M(e,t,n){e.textNode&&N(e),D(e,t,n)}function N(e){e.textNode=P(e.opt,e.textNode),e.textNode&&D(e,`ontext`,e.textNode),e.textNode=``}function P(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g,` `)),t}function F(e,t){return N(e),e.trackPosition&&(t+=`
|
|
3
|
+
Line: `+e.line+`
|
|
4
|
+
Column: `+e.column+`
|
|
5
|
+
Char: `+e.c),t=Error(t),e.error=t,D(e,`onerror`,t),e}function I(e){return e.sawRoot&&!e.closedRoot&&L(e,`Unclosed root tag`),e.state!==T.BEGIN&&e.state!==T.BEGIN_WHITESPACE&&e.state!==T.TEXT&&F(e,`Unexpected end`),N(e),e.c=``,e.closed=!0,D(e,`onend`),n.call(e,e.strict,e.opt),e}function L(e,t){if(typeof e!=`object`||!(e instanceof n))throw Error(`bad call to strictFail`);e.strict&&F(e,t)}function R(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,n=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(n.ns=t.ns),e.attribList.length=0,M(e,`onopentagstart`,n)}function z(e,t){var n=e.indexOf(`:`)<0?[``,e]:e.split(`:`),r=n[0],i=n[1];return t&&e===`xmlns`&&(r=`xmlns`,i=``),{prefix:r,local:i}}function B(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),e.attribList.indexOf(e.attribName)!==-1||e.tag.attributes.hasOwnProperty(e.attribName)){e.attribName=e.attribValue=``;return}if(e.opt.xmlns){var t=z(e.attribName,!0),n=t.prefix,r=t.local;if(n===`xmlns`)if(r===`xml`&&e.attribValue!==p)L(e,`xml: prefix must be bound to `+p+`
|
|
6
|
+
Actual: `+e.attribValue);else if(r===`xmlns`&&e.attribValue!==m)L(e,`xmlns: prefix must be bound to `+m+`
|
|
7
|
+
Actual: `+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.ns&&(i.ns=Object.create(a.ns)),i.ns[r]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,M(e,`onattribute`,{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=``}function V(e,t){if(e.opt.xmlns){var n=e.tag,r=z(e.tagName);n.prefix=r.prefix,n.local=r.local,n.uri=n.ns[r.prefix]||``,n.prefix&&!n.uri&&(L(e,`Unbound namespace prefix: `+JSON.stringify(e.tagName)),n.uri=r.prefix);var i=e.tags[e.tags.length-1]||e;n.ns&&i.ns!==n.ns&&Object.keys(n.ns).forEach(function(t){M(e,`onopennamespace`,{prefix:t,uri:n.ns[t]})});for(var a=0,o=e.attribList.length;a<o;a++){var s=e.attribList[a],c=s[0],l=s[1],u=z(c,!0),d=u.prefix,f=u.local,p=d===``?``:n.ns[d]||``,m={name:c,value:l,prefix:d,local:f,uri:p};d&&d!==`xmlns`&&!p&&(L(e,`Unbound namespace prefix: `+JSON.stringify(d)),m.uri=d),e.tag.attributes[c]=m,M(e,`onattribute`,m)}e.attribList.length=0}e.tag.isSelfClosing=!!t,e.sawRoot=!0,e.tags.push(e.tag),M(e,`onopentag`,e.tag),t||(!e.noscript&&e.tagName.toLowerCase()===`script`?e.state=T.SCRIPT:e.state=T.TEXT,e.tag=null,e.tagName=``),e.attribName=e.attribValue=``,e.attribList.length=0}function H(e){if(!e.tagName){L(e,`Weird empty close tag.`),e.textNode+=`</>`,e.state=T.TEXT;return}if(e.script){if(e.tagName!==`script`){e.script+=`</`+e.tagName+`>`,e.tagName=``,e.state=T.SCRIPT;return}M(e,`onscript`,e.script),e.script=``}var t=e.tags.length,n=e.tagName;e.strict||(n=n[e.looseCase]());for(var r=n;t--&&e.tags[t].name!==r;)L(e,`Unexpected close tag`);if(t<0){L(e,`Unmatched closing tag: `+e.tagName),e.textNode+=`</`+e.tagName+`>`,e.state=T.TEXT;return}e.tagName=n;for(var i=e.tags.length;i-- >t;){var a=e.tag=e.tags.pop();e.tagName=e.tag.name,M(e,`onclosetag`,e.tagName);var o={};for(var s in a.ns)o[s]=a.ns[s];var c=e.tags[e.tags.length-1]||e;e.opt.xmlns&&a.ns!==c.ns&&Object.keys(a.ns).forEach(function(t){var n=a.ns[t];M(e,`onclosenamespace`,{prefix:t,uri:n})})}t===0&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName=``,e.attribList.length=0,e.state=T.TEXT}function U(e){var t=e.entity,n=t.toLowerCase(),r,i=``;return e.ENTITIES[t]?e.ENTITIES[t]:e.ENTITIES[n]?e.ENTITIES[n]:(t=n,t.charAt(0)===`#`&&(t.charAt(1)===`x`?(t=t.slice(2),r=parseInt(t,16),i=r.toString(16)):(t=t.slice(1),r=parseInt(t,10),i=r.toString(10))),t=t.replace(/^0+/,``),isNaN(r)||i.toLowerCase()!==t||r<0||r>1114111?(L(e,`Invalid character entity`),`&`+e.entity+`;`):String.fromCodePoint(r))}function W(e,t){t===`<`?(e.state=T.OPEN_WAKA,e.startTagPosition=e.position):b(t)||(L(e,`Non-whitespace before first tag.`),e.textNode=t,e.state=T.TEXT)}function G(e,t){var n=``;return t<e.length&&(n=e.charAt(t)),n}function K(t){var n=this;if(this.error)throw this.error;if(n.closed)return F(n,`Cannot write after close. Assign an onready handler.`);if(t===null)return I(n);typeof t==`object`&&(t=t.toString());for(var i=0,a=``;a=G(t,i++),n.c=a,a;)switch(n.trackPosition&&(n.position++,a===`
|
|
8
|
+
`?(n.line++,n.column=0):n.column++),n.state){case T.BEGIN:if(n.state=T.BEGIN_WHITESPACE,a===``)continue;W(n,a);continue;case T.BEGIN_WHITESPACE:W(n,a);continue;case T.TEXT:if(n.sawRoot&&!n.closedRoot){for(var o=i-1;a&&a!==`<`&&a!==`&`;)a=G(t,i++),a&&n.trackPosition&&(n.position++,a===`
|
|
9
|
+
`?(n.line++,n.column=0):n.column++);n.textNode+=t.substring(o,i-1)}a===`<`&&!(n.sawRoot&&n.closedRoot&&!n.strict)?(n.state=T.OPEN_WAKA,n.startTagPosition=n.position):(!b(a)&&(!n.sawRoot||n.closedRoot)&&L(n,`Text data outside of root node.`),a===`&`?n.state=T.TEXT_ENTITY:n.textNode+=a);continue;case T.SCRIPT:a===`<`?n.state=T.SCRIPT_ENDING:n.script+=a;continue;case T.SCRIPT_ENDING:a===`/`?n.state=T.CLOSE_TAG:(n.script+=`<`+a,n.state=T.SCRIPT);continue;case T.OPEN_WAKA:if(a===`!`)n.state=T.SGML_DECL,n.sgmlDecl=``;else if(!b(a))if(C(g,a))n.state=T.OPEN_TAG,n.tagName=a;else if(a===`/`)n.state=T.CLOSE_TAG,n.tagName=``;else if(a===`?`)n.state=T.PROC_INST,n.procInstName=n.procInstBody=``;else{if(L(n,`Unencoded <`),n.startTagPosition+1<n.position){var s=n.position-n.startTagPosition;a=Array(s).join(` `)+a}n.textNode+=`<`+a,n.state=T.TEXT}continue;case T.SGML_DECL:if(n.sgmlDecl+a===`--`){n.state=T.COMMENT,n.comment=``,n.sgmlDecl=``;continue}n.doctype&&n.doctype!==!0&&n.sgmlDecl?(n.state=T.DOCTYPE_DTD,n.doctype+=`<!`+n.sgmlDecl+a,n.sgmlDecl=``):(n.sgmlDecl+a).toUpperCase()===d?(M(n,`onopencdata`),n.state=T.CDATA,n.sgmlDecl=``,n.cdata=``):(n.sgmlDecl+a).toUpperCase()===f?(n.state=T.DOCTYPE,(n.doctype||n.sawRoot)&&L(n,`Inappropriately located doctype declaration`),n.doctype=``,n.sgmlDecl=``):a===`>`?(M(n,`onsgmldeclaration`,n.sgmlDecl),n.sgmlDecl=``,n.state=T.TEXT):(x(a)&&(n.state=T.SGML_DECL_QUOTED),n.sgmlDecl+=a);continue;case T.SGML_DECL_QUOTED:a===n.q&&(n.state=T.SGML_DECL,n.q=``),n.sgmlDecl+=a;continue;case T.DOCTYPE:a===`>`?(n.state=T.TEXT,M(n,`ondoctype`,n.doctype),n.doctype=!0):(n.doctype+=a,a===`[`?n.state=T.DOCTYPE_DTD:x(a)&&(n.state=T.DOCTYPE_QUOTED,n.q=a));continue;case T.DOCTYPE_QUOTED:n.doctype+=a,a===n.q&&(n.q=``,n.state=T.DOCTYPE);continue;case T.DOCTYPE_DTD:a===`]`?(n.doctype+=a,n.state=T.DOCTYPE):a===`<`?(n.state=T.OPEN_WAKA,n.startTagPosition=n.position):x(a)?(n.doctype+=a,n.state=T.DOCTYPE_DTD_QUOTED,n.q=a):n.doctype+=a;continue;case T.DOCTYPE_DTD_QUOTED:n.doctype+=a,a===n.q&&(n.state=T.DOCTYPE_DTD,n.q=``);continue;case T.COMMENT:a===`-`?n.state=T.COMMENT_ENDING:n.comment+=a;continue;case T.COMMENT_ENDING:a===`-`?(n.state=T.COMMENT_ENDED,n.comment=P(n.opt,n.comment),n.comment&&M(n,`oncomment`,n.comment),n.comment=``):(n.comment+=`-`+a,n.state=T.COMMENT);continue;case T.COMMENT_ENDED:a===`>`?n.doctype&&n.doctype!==!0?n.state=T.DOCTYPE_DTD:n.state=T.TEXT:(L(n,`Malformed comment`),n.comment+=`--`+a,n.state=T.COMMENT);continue;case T.CDATA:for(var o=i-1;a&&a!==`]`;)a=G(t,i++),a&&n.trackPosition&&(n.position++,a===`
|
|
10
|
+
`?(n.line++,n.column=0):n.column++);n.cdata+=t.substring(o,i-1),a===`]`&&(n.state=T.CDATA_ENDING);continue;case T.CDATA_ENDING:a===`]`?n.state=T.CDATA_ENDING_2:(n.cdata+=`]`+a,n.state=T.CDATA);continue;case T.CDATA_ENDING_2:a===`>`?(n.cdata&&M(n,`oncdata`,n.cdata),M(n,`onclosecdata`),n.cdata=``,n.state=T.TEXT):a===`]`?n.cdata+=`]`:(n.cdata+=`]]`+a,n.state=T.CDATA);continue;case T.PROC_INST:a===`?`?n.state=T.PROC_INST_ENDING:b(a)?n.state=T.PROC_INST_BODY:n.procInstName+=a;continue;case T.PROC_INST_BODY:if(!n.procInstBody&&b(a))continue;a===`?`?n.state=T.PROC_INST_ENDING:n.procInstBody+=a;continue;case T.PROC_INST_ENDING:if(a===`>`){let e={name:n.procInstName,body:n.procInstBody};j(n,e),M(n,`onprocessinginstruction`,e),n.procInstName=n.procInstBody=``,n.state=T.TEXT}else n.procInstBody+=`?`+a,n.state=T.PROC_INST_BODY;continue;case T.OPEN_TAG:C(_,a)?n.tagName+=a:(R(n),a===`>`?V(n):a===`/`?n.state=T.OPEN_TAG_SLASH:(b(a)||L(n,`Invalid character in tag name`),n.state=T.ATTRIB));continue;case T.OPEN_TAG_SLASH:a===`>`?(V(n,!0),H(n)):(L(n,`Forward-slash in opening tag not followed by >`),n.state=T.ATTRIB);continue;case T.ATTRIB:if(b(a))continue;a===`>`?V(n):a===`/`?n.state=T.OPEN_TAG_SLASH:C(g,a)?(n.attribName=a,n.attribValue=``,n.state=T.ATTRIB_NAME):L(n,`Invalid attribute name`);continue;case T.ATTRIB_NAME:a===`=`?n.state=T.ATTRIB_VALUE:a===`>`?(L(n,`Attribute without value`),n.attribValue=n.attribName,B(n),V(n)):b(a)?n.state=T.ATTRIB_NAME_SAW_WHITE:C(_,a)?n.attribName+=a:L(n,`Invalid attribute name`);continue;case T.ATTRIB_NAME_SAW_WHITE:if(a===`=`)n.state=T.ATTRIB_VALUE;else if(b(a))continue;else L(n,`Attribute without value`),n.tag.attributes[n.attribName]=``,n.attribValue=``,M(n,`onattribute`,{name:n.attribName,value:``}),n.attribName=``,a===`>`?V(n):C(g,a)?(n.attribName=a,n.state=T.ATTRIB_NAME):(L(n,`Invalid attribute name`),n.state=T.ATTRIB);continue;case T.ATTRIB_VALUE:if(b(a))continue;x(a)?(n.q=a,n.state=T.ATTRIB_VALUE_QUOTED):(n.opt.unquotedAttributeValues||F(n,`Unquoted attribute value`),n.state=T.ATTRIB_VALUE_UNQUOTED,n.attribValue=a);continue;case T.ATTRIB_VALUE_QUOTED:if(a!==n.q){a===`&`?n.state=T.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=a;continue}B(n),n.q=``,n.state=T.ATTRIB_VALUE_CLOSED;continue;case T.ATTRIB_VALUE_CLOSED:b(a)?n.state=T.ATTRIB:a===`>`?V(n):a===`/`?n.state=T.OPEN_TAG_SLASH:C(g,a)?(L(n,`No whitespace between attributes`),n.attribName=a,n.attribValue=``,n.state=T.ATTRIB_NAME):L(n,`Invalid attribute name`);continue;case T.ATTRIB_VALUE_UNQUOTED:if(!S(a)){a===`&`?n.state=T.ATTRIB_VALUE_ENTITY_U:n.attribValue+=a;continue}B(n),a===`>`?V(n):n.state=T.ATTRIB;continue;case T.CLOSE_TAG:if(n.tagName)a===`>`?H(n):C(_,a)?n.tagName+=a:n.script?(n.script+=`</`+n.tagName+a,n.tagName=``,n.state=T.SCRIPT):(b(a)||L(n,`Invalid tagname in closing tag`),n.state=T.CLOSE_TAG_SAW_WHITE);else{if(b(a))continue;w(g,a)?n.script?(n.script+=`</`+a,n.state=T.SCRIPT):L(n,`Invalid tagname in closing tag.`):n.tagName=a}continue;case T.CLOSE_TAG_SAW_WHITE:if(b(a))continue;a===`>`?H(n):L(n,`Invalid characters in closing tag`);continue;case T.TEXT_ENTITY:case T.ATTRIB_VALUE_ENTITY_Q:case T.ATTRIB_VALUE_ENTITY_U:var c,l;switch(n.state){case T.TEXT_ENTITY:c=T.TEXT,l=`textNode`;break;case T.ATTRIB_VALUE_ENTITY_Q:c=T.ATTRIB_VALUE_QUOTED,l=`attribValue`;break;case T.ATTRIB_VALUE_ENTITY_U:c=T.ATTRIB_VALUE_UNQUOTED,l=`attribValue`;break}if(a===`;`){var u=U(n);n.opt.unparsedEntities&&!Object.values(e.XML_ENTITIES).includes(u)?((n.entityCount+=1)>n.opt.maxEntityCount&&F(n,`Parsed entity count exceeds max entity count`),(n.entityDepth+=1)>n.opt.maxEntityDepth&&F(n,`Parsed entity depth exceeds max entity depth`),n.entity=``,n.state=c,n.write(u),--n.entityDepth):(n[l]+=u,n.entity=``,n.state=c)}else C(n.entity.length?y:v,a)?n.entity+=a:(L(n,`Invalid character in entity name`),n[l]+=`&`+n.entity+a,n.entity=``,n.state=c);continue;default:throw Error(n,`Unknown state: `+n.state)}return n.position>=n.bufferCheckPosition&&r(n),n}String.fromCodePoint||(function(){var e=String.fromCharCode,t=Math.floor,n=function(){var n=16384,r=[],i,a,o=-1,s=arguments.length;if(!s)return``;for(var c=``;++o<s;){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||t(l)!==l)throw RangeError(`Invalid code point: `+l);l<=65535?r.push(l):(l-=65536,i=(l>>10)+55296,a=l%1024+56320,r.push(i,a)),(o+1===s||r.length>n)&&(c+=e.apply(null,r),r.length=0)}return c};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n})()})(e===void 0?e.sax={}:e)})),w=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.XmlDocument=e.XmlElement=e.XmlCommentNode=e.XmlCDataNode=e.XmlTextNode=void 0;var n=t(C()),r=class{constructor(e){this.text=e,this.type=`text`}toString(e){return u(l(this.text),e)}toStringWithIndent(e,t){return e+this.toString(t)}};e.XmlTextNode=r;var i=class{constructor(e){this.cdata=e,this.type=`cdata`}toString(e){return`<![CDATA[${u(this.cdata,e)}]]>`}toStringWithIndent(e,t){return e+this.toString(t)}};e.XmlCDataNode=i;var a=class{constructor(e){this.comment=e,this.type=`comment`}toString(e){return`<!--${u(l(this.comment),e)}-->`}toStringWithIndent(e,t){return e+this.toString(t)}};e.XmlCommentNode=a;var o=class e{constructor(e,t){if(this.type=`element`,!t&&s.length){var n=s[s.length-1];`parser`in n&&(t=n.parser)}this.name=e.name,this.attr=e.attributes,this.val=``,this.children=[],this.firstChild=null,this.lastChild=null,this.line=t?t.line:null,this.column=t?t.column:null,this.position=t?t.position:null,this.startTagPosition=t?t.startTagPosition:null}_addChild(e){this.children.push(e),this.firstChild||=e,this.lastChild=e}_opentag(t){let n=new e(t);this._addChild(n),s.unshift(n)}_closetag(){s.shift()}_text(e){this.val+=e,this._addChild(new r(e))}_cdata(e){this.val+=e,this._addChild(new i(e))}_comment(e){this._addChild(new a(e))}_error(e){throw e}eachChild(e,t){for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n];if(r.type===`element`&&e.call(t,r,n,this.children)===!1)return}}childNamed(e){for(let t=0,n=this.children.length;t<n;t++){let n=this.children[t];if(n.type===`element`&&n.name===e)return n}}childrenNamed(e){let t=[];for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n];r.type===`element`&&r.name===e&&t.push(r)}return t}childWithAttribute(e,t){for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n];if(r.type===`element`&&(t!==void 0&&r.attr[e]===t||t===void 0&&r.attr[e]))return r}}descendantsNamed(e){let t=[];for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n];if(r.type===`element`){let n=r;n.name===e&&t.push(n),t.push(...n.descendantsNamed(e))}}return t}descendantWithPath(e){let t=this,n=e.split(`.`);for(let e=0,r=n.length;e<r;e++)if(t&&t.type===`element`)t=t.childNamed(n[e]);else return;return t}valueWithPath(e){let t=e.split(`@`),n=this.descendantWithPath(t[0]);if(n)return t.length>1?n.attr[t[1]]:n.val}toString(e){return this.toStringWithIndent(``,e)}toStringWithIndent(e,t){let n=`${e}<${this.name}`,r=t?.compressed?``:`
|
|
11
|
+
`;for(let e in this.attr)Object.prototype.hasOwnProperty.call(this.attr,e)&&(n+=` ${e}="${l(this.attr[e])}"`);if(this.children.length===1&&this.children[0].type!==`element`)n+=`>${this.children[0].toString(t)}</${this.name}>`;else if(this.children.length){n+=`>${r}`;let i=e+(t?.compressed?``:` `);for(let e=0,a=this.children.length;e<a;e++)n+=`${this.children[e].toStringWithIndent(i,t)}${r}`;n+=`${e}</${this.name}>`}else t?.html?[`area`,`base`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`menuitem`,`meta`,`param`,`source`,`track`,`wbr`].includes(this.name)?n+=`/>`:n+=`></${this.name}>`:n+=`/>`;return n}};e.XmlElement=o,e.XmlDocument=class extends o{constructor(e){if(super({name:``,attributes:{}}),e=e.toString().trim(),!e)throw Error(`No XML to parse!`);this.doctype=``,this.parser=n.default.parser(!0),c(this.parser),s=[this];try{this.parser.write(e)}finally{delete this.parser}}_opentag(e){this.name===``?(this.name=e.name,this.attr=e.attributes):super._opentag(e)}_doctype(e){this.doctype+=e}};var s=[];function c(e){e.onopentag=e=>s[0]?._opentag(e),e.onclosetag=()=>s[0]?._closetag(),e.ontext=e=>s[0]?._text(e),e.oncdata=e=>s[0]?._cdata(e),e.oncomment=e=>s[0]?._comment(e),e.ondoctype=e=>{let t=s[0];t._doctype&&t._doctype(e)},e.onerror=e=>s[0]?._error(e)}function l(e){return e.toString().replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/'/g,`'`).replace(/"/g,`"`)}function u(e,t){let n=e;return t?.trimmed&&e.length>25&&(n=n.substring(0,25).trim()+`…`),t?.preserveWhitespace||(n=n.trim()),n}}))(),T=`com.apple.ibooks.display-options.xml`,E=`ComicInfo.xml`;new Set([`Pages`,`ComicInfo`]),new Set([8,12,13,14]),E.toLowerCase(),T.toLowerCase(),E.toLowerCase();var D=e=>e?e.children.map(e=>e instanceof w.XmlTextNode?e.text:e instanceof w.XmlElement?D(e):``).join(``).trim():``,O=(e,{basePath:t,baseUrl:n})=>{let r={contents:[],path:``,href:``,title:``},i=e.childNamed(`span`)||e.childNamed(`a`);r.title=(i?.attr.title||i?.val.trim()||D(i))??``;let a=i?.name;a!==`a`&&(i=e.descendantWithPath(`${a}.a`),i&&(a=i.name.toLowerCase())),a===`a`&&i?.attr.href&&(r.path=p(t,i.attr.href),r.href=p(n,t,i.attr.href));let o=e.childNamed(`ol`);if(o){let e=o.childrenNamed(`li`);e&&e.length>0&&(r.contents=e.map(e=>O(e,{basePath:t,baseUrl:n})))}return r},k=(e,{opfBasePath:t,baseUrl:n,prefix:r})=>{let i=e?.childNamed(`${r}content`)?.attr.src||``,a={title:e?.descendantWithPath(`${r}navLabel.${r}text`)?.val||``,path:p(t,i),href:p(n,t,i),contents:[]},o=e.childrenNamed(`${r}navPoint`);return o&&o.length>0&&(a.contents=o.map(e=>k(e,{opfBasePath:t,baseUrl:n,prefix:r}))),a},A=Symbol(`pdfjs`),j=e=>`_symbol`in e&&e._symbol===A,M=async(e,t)=>{let r=await n.getDocument(await e.arrayBuffer()).promise,i=Array.from({length:r.numPages}),a=i.map((e,t)=>({id:`page-${t}`,resourcePath:`${t}.pdf`})),o=`
|
|
2
12
|
<?xml version="1.0" encoding="UTF-8"?><package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="bookid">
|
|
3
13
|
<metadata>
|
|
4
14
|
<meta property="rendition:layout">pre-paginated</meta>
|
|
@@ -12,17 +22,17 @@
|
|
|
12
22
|
`)}
|
|
13
23
|
</spine>
|
|
14
24
|
</package>
|
|
15
|
-
`;return{filename:
|
|
25
|
+
`;return{...x({filename:t,encodingFormat:`application/pdf`,records:[{dir:!1,basename:`content.opf`,uri:`content.opf`,size:0,...S(async()=>new Blob([o]))},...i.map((e,t)=>({dir:!1,basename:`${t}.pdf`,uri:`${t}.pdf`,size:0,...S(async()=>{throw Error(`Unable to get blob from pdf`)})}))],close:()=>r.cleanup()}),proxyDocument:r,_symbol:A}},N=`html{touch-action:none}body{width:100%;height:100%;margin:0;padding:0;overflow:hidden}`,P=(e,t,n)=>{if(!e)return;let{height:i,width:a}=n.pageSize;(0,r.setStylePropertyIfChanged)(e.style,`width`,`${a}px`),(0,r.setStylePropertyIfChanged)(e.style,`height`,`${i}px`),t===`right`?(0,r.setStylePropertyIfChanged)(e.style,`justify-content`,`flex-start`):t===`left`?(0,r.setStylePropertyIfChanged)(e.style,`justify-content`,`flex-end`):(0,r.setStylePropertyIfChanged)(e.style,`justify-content`,`center`)},F=(e,t,n)=>{let i=window.devicePixelRatio||1,{height:a,width:o}=n.pageSize,{width:s,height:c}=e.getViewport({scale:1}),l=Math.max(o/s,a/c),u=e.getViewport({scale:l}),d=u.width/u.height,f=o/a,p=d>f?o:a*d,m=d>f?o/d:a;(0,r.setPropertyIfChanged)(t,`width`,Math.floor(u.width*i)),(0,r.setPropertyIfChanged)(t,`height`,Math.floor(u.height*i)),(0,r.setStylePropertyIfChanged)(t.style,`width`,`${Math.floor(p)}px`),(0,r.setStylePropertyIfChanged)(t.style,`height`,`${Math.floor(m)}px`)},I=`:root {
|
|
16
26
|
--scale-factor: 1;
|
|
17
27
|
--user-unit: 1;
|
|
18
28
|
--total-scale-factor: calc(var(--scale-factor) * var(--user-unit));
|
|
19
29
|
--scale-round-x: 1px;
|
|
20
30
|
--scale-round-y: 1px;
|
|
21
|
-
}`,
|
|
31
|
+
}`,L=class extends r.DocumentRenderer{pdfViewerStyle;pageProxy;renderTask;textLayer;constructor(e,t){super(t),this.pdfViewerStyle=e}getCanvas(){let e=this.documentContainer?.children[0];if(e instanceof HTMLCanvasElement)return e}getFrameElement(){let e=this.documentContainer?.children[1]?.children[0];if(e instanceof HTMLIFrameElement)return e}getPageProxy(){return this.pageProxy?(0,t.of)(this.pageProxy):(0,t.from)(this.resourcesHandler.fetchResource()).pipe((0,t.switchMap)(e=>`custom`in e?(this.pageProxy=e.data,(0,t.of)(this.pageProxy)):t.EMPTY))}onUnload(){return this.detach(),this.renderTask&&this.renderTask.cancel(),this.textLayer?.cancel(),this.pageProxy?.cleanup(),t.EMPTY}onCreateDocument(){let e=document.createElement(`iframe`);e.style.cssText=`
|
|
22
32
|
overflow: hidden;
|
|
23
33
|
height: 100%;
|
|
24
34
|
width: 100%;
|
|
25
|
-
`,e.setAttribute(`tabIndex`,`0`),e.setAttribute(`frameBorder`,`0`),e.setAttribute(`src`,`about:blank`);let
|
|
35
|
+
`,e.setAttribute(`tabIndex`,`0`),e.setAttribute(`frameBorder`,`0`),e.setAttribute(`src`,`about:blank`);let n=this.containerElement.ownerDocument.createElement(`div`);n.style.cssText=`
|
|
26
36
|
mix-blend-mode: multiply;
|
|
27
37
|
-webkit-transform: translateZ(0);
|
|
28
38
|
transform: translateZ(0);
|
|
@@ -30,9 +40,9 @@
|
|
|
30
40
|
height: 100%;
|
|
31
41
|
width: 100%;
|
|
32
42
|
top: 0;
|
|
33
|
-
`;let r=this.containerElement.ownerDocument.createElement(`canvas`);
|
|
43
|
+
`;let r=this.containerElement.ownerDocument.createElement(`canvas`);n.appendChild(e);let i=this.containerElement.ownerDocument.createElement(`div`);return i.style.cssText=`
|
|
34
44
|
display: flex;
|
|
35
45
|
align-items: center;
|
|
36
46
|
justify-content: center;
|
|
37
|
-
`,i.appendChild(r),i.appendChild(
|
|
47
|
+
`,i.appendChild(r),i.appendChild(n),this.setDocumentContainer(i),(0,t.of)(i)}onLoadDocument(){return this.getPageProxy().pipe((0,t.switchMap)(()=>{let e=this.getFrameElement(),i=this.pageProxy;return!e||!i?t.EMPTY:(0,t.of)(e).pipe((0,r.waitForSwitch)(this.context.bridgeEvent.viewportFree$),(0,t.tap)(()=>{this.attach()}),r.waitForFrameLoad,(0,t.switchMap)(()=>{(0,r.injectCSSToFrame)(e,`pdfjs-viewer-style`,this.pdfViewerStyle),(0,r.injectCSSToFrame)(e,`enhancer-pdf-style`,N),(0,r.upsertCSSToFrame)(e,`pdf-scale-scale`,I);let i=e.contentDocument?.body;return!i||!this.pageProxy?t.EMPTY:((0,r.setAttributeIfChanged)(i,`class`,`textLayer`),this.textLayer=new n.TextLayer({container:i,textContentSource:this.pageProxy.streamTextContent(),viewport:this.pageProxy.getViewport({scale:1})}),(0,t.from)(this.textLayer.render()))}),r.waitForFrameReady)}))}onLayout({spreadPosition:e}){let i=this.getFrameElement(),a=this.getCanvas();if(!i||!a)return(0,t.of)(void 0);let{height:o,width:s}=this.viewport.pageSize;P(this.documentContainer,e,this.viewport);let c=a.getContext(`2d`),l=window.devicePixelRatio||1;if(!this.pageProxy||!c)return(0,t.of)(void 0);this.renderTask&&=(this.renderTask.cancel(),void 0),F(this.pageProxy,a,this.viewport);let{width:u,height:d}=this.pageProxy.getViewport({scale:1}),f=Math.max(s/u,o/d),p=this.pageProxy.getViewport({scale:f}),m=l===1?null:[l,0,0,l,0,0];return this.renderTask=this.pageProxy.render({...m&&{transform:m},canvasContext:c,viewport:p,canvas:a}),(0,t.from)(this.renderTask.promise).pipe((0,t.switchMap)(()=>{this.renderTask=void 0;let e=i?.contentDocument,n=this.pageProxy;if(!e||!i||!n||!this.textLayer)throw Error(`Unable to update text layer due to missing elements`);let o=e.body,s=a.clientWidth/u;return(0,r.setStylePropertyIfChanged)(o.style,`top`,`${a.offsetTop}px`),(0,r.setStylePropertyIfChanged)(o.style,`left`,`${a.offsetLeft}px`),(0,r.setStylePropertyIfChanged)(o.style,`height`,a.style.height),(0,r.setStylePropertyIfChanged)(o.style,`width`,a.style.width),(0,r.setStylePropertyIfChanged)(e.documentElement.style,`--scale-factor`,`${s}`),this.textLayer.update({viewport:p}),(0,t.of)(void 0)}),(0,t.catchError)(e=>(e instanceof n.RenderingCancelledException||console.error(e),(0,t.of)(void 0))))}onRenderHeadless(){return this.getPageProxy().pipe((0,t.switchMap)(e=>{let r=document.implementation.createHTMLDocument(),i=r.body;return(0,t.from)(new n.TextLayer({container:i,textContentSource:e.streamTextContent(),viewport:e.getViewport({scale:1})}).render()).pipe((0,t.map)(()=>r))}))}getDocumentFrame(){return this.getFrameElement()}};e.createArchiveFromPdf=M,e.isPdfJsArchive=j,e.pdfEnhancer=e=>n=>e({...n,getRenderer(e){let t=n.getRenderer?.(e);return!t&&e.href.endsWith(`.pdf`)?e=>new L(n.pdf.pdfjsViewerInlineCss,e):t},getResource:e=>n.pdf.getArchiveForItem(e).pipe((0,t.mergeMap)(n=>{if(!n)return(0,t.of)(void 0);if(!j(n))return console.warn(`You provided an invalid pdf archive`),(0,t.of)(void 0);let r=n.records.findIndex(t=>e.href.endsWith(t.uri))-1;return(0,t.from)(n.proxyDocument.getPage(r+1)).pipe((0,t.map)(e=>({custom:!0,data:e})))}))})});
|
|
38
48
|
//# sourceMappingURL=index.umd.cjs.map
|