libpdfviewer/app/src/main/assets/pdf.js

22 lines
216 KiB
JavaScript
Raw Normal View History

/**
* @licstart The following is the entire license notice for the
* Javascript code in this page
*
2021-11-21 23:30:18 +01:00
* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* Javascript code in this page
*/
2021-11-21 23:30:18 +01:00
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=t():e["pdfjs-dist/build/pdf"]=e.pdfjsLib=t()}(this,(function(){return(()=>{"use strict";var __webpack_modules__=[,(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});t.addLinkAttributes=function addLinkAttributes(e,{url:t,target:r,rel:n,enabled:o=!0}={}){(0,s.assert)(t&&"string"==typeof t,'addLinkAttributes: A valid "url" parameter must provided.');const l=(0,s.removeNullCharacters)(t);if(o)e.href=e.title=l;else{e.href="";e.title=`Disabled: ${l}`;e.onclick=()=>!1}let c="";switch(r){case i.NONE:break;case i.SELF:c="_self";break;case i.BLANK:c="_blank";break;case i.PARENT:c="_parent";break;case i.TOP:c="_top"}e.target=c;e.rel="string"==typeof n?n:a};t.deprecated=function deprecated(e){console.log("Deprecated API usage: "+e)};t.getFilenameFromUrl=function getFilenameFromUrl(e){const t=e.indexOf("#"),r=e.indexOf("?"),s=Math.min(t>0?t:e.length,r>0?r:e.length);return e.substring(e.lastIndexOf("/",s)+1,s)};t.getPdfFilenameFromUrl=function getPdfFilenameFromUrl(e,t="document.pdf"){if("string"!=typeof e)return t;if(isDataScheme(e)){(0,s.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return t}const r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let a=r.exec(n[1])||r.exec(n[2])||r.exec(n[3]);if(a){a=a[0];if(a.includes("%"))try{a=r.exec(decodeURIComponent(a))[0]}catch(e){}}return a||t};t.getXfaPageViewport=function getXfaPageViewport(e,{scale:t=1,rotation:r=0}){const{width:s,height:n}=e.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new PageViewport({viewBox:a,scale:t,rotation:r})};t.isDataScheme=isDataScheme;t.isPdfFile=function isPdfFile(e){return"string"==typeof e&&/\.pdf$/i.test(e)};t.isValidFetchUrl=isValidFetchUrl;t.loadScript=function loadScript(e,t=!1){return new Promise(((r,s)=>{const n=document.createElement("script");n.src=e;n.onload=function(e){t&&n.remove();r(e)};n.onerror=function(){s(new Error(`Cannot load script at: ${n.src}`))};(document.head||document.documentElement).appendChild(n)}))};t.StatTimer=t.RenderingCancelledException=t.PDFDateString=t.PageViewport=t.LinkTarget=t.DOMSVGFactory=t.DOMStandardFontDataFactory=t.DOMCMapReaderFactory=t.DOMCanvasFactory=t.DEFAULT_LINK_REL=void 0;var s=r(2),n=r(5);const a="noopener noreferrer nofollow";t.DEFAULT_LINK_REL=a;class DOMCanvasFactory extends n.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super();this._document=e}_createCanvas(e,t){const r=this._document.createElement("canvas");r.width=e;r.height=t;return r}}t.DOMCanvasFactory=DOMCanvasFactory;async function fetchData(e,t=!1){if(isValidFetchUrl(e,document.baseURI)){const r=await fetch(e);if(!r.ok)throw new Error(r.statusText);return t?new Uint8Array(await r.arrayBuffer()):(0,s.stringToBytes)(await r.text())}return new Promise(((r,n)=>{const a=new XMLHttpRequest;a.open("GET",e,!0);t&&(a.responseType="arraybuffer");a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(200===a.status||0===a.status){let e;t&&a.response?e=new Uint8Array(a.response):!t&&a.responseText&&(e=(0,s.stringToBytes)(a.responseText));if(e){r(e);return}}n(new Error(a.statusText))}};a.send(null)}))}class DOMCMapReaderFactory extends n.BaseCMapReaderFactory{_fetchData(e,t){return fetchData(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=DOMCMapReaderFactory;class DOMStandardFontDataFactory extends n.BaseStandardFontDataFactory{_fetchData(e){return fetchData(e,!0)}}t.DOMStandardFontDataFactory=DOMStandardFontDataFactory;class DOMSVGFactory extends n.BaseSVGFactory{_createSVG(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}}t.DOMSVGFactory=DOMSVGFactory;class PageViewport{constructor({viewBox:e,scale:t,rotation:r,offsetX:s=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=e;this.scale=t;this.rotation=r;this.offsetX=s;this.of