UNPKG

@pdftron/webviewer

Version:

[WebViewer](https://www.apryse.com/webviewer) is a powerful JavaScript Document SDK and UI Component Library that is a part of the [Apryse PDF SDK](https://www.apryse.com). It provides a slick, out-of-the-box responsive UI that interacts with the core lib

11 lines (10 loc) 4.72 kB
/** Notice * This file contains works from many authors under various (but compatible) licenses. Please see core.txt for more information. **/ (function(){(window.wpCoreControlsBundle=window.wpCoreControlsBundle||[]).push([[11],{692:function(wa,ua,e){e.r(ua);var ka=e(0),pa=e(1);e.n(pa);var na=e(2),ia=e(245);wa=e(50);var ca=e(146),ba=e(402),x=e(112),y=e(401);e=e(605);var r=window,b=function(){function f(a,w,aa){var z=-1===a.indexOf("?")?"?":"&";switch(w){case x.a.NEVER_CACHE:this.url="".concat(a+z,"_=").concat(Object(pa.uniqueId)());break;default:this.url=a}this.eg=aa;this.request=new XMLHttpRequest;this.request.open("GET",this.url,!0);this.request.setRequestHeader("X-Requested-With", "XMLHttpRequest");this.request.overrideMimeType?this.request.overrideMimeType("text/plain; charset=x-user-defined"):this.request.setRequestHeader("Accept-Charset","x-user-defined");this.status=y.a.NOT_STARTED}f.prototype.start=function(a,w){var aa=this,z=this,fa=this.request,ea;z.hI=0;a&&Object.keys(a).forEach(function(ma){aa.request.setRequestHeader(ma,a[ma])});w&&(this.request.withCredentials=w);this.ER=setInterval(function(){var ma=0===window.document.URL.indexOf("file:///");ma=200===fa.status|| ma&&0===fa.status;if(fa.readyState!==y.b.DONE||ma){try{fa.responseText}catch(ha){return}z.hI<fa.responseText.length&&(ea=z.nWa())&&z.trigger(f.Events.DATA,[ea]);0===fa.readyState&&(clearInterval(z.ER),z.trigger(f.Events.DONE))}else clearInterval(z.ER),z.trigger(f.Events.DONE,["Error received return status ".concat(fa.status)])},1E3);this.request.send(null);this.status=y.a.STARTED};f.prototype.nWa=function(){var a=this.request,w=a.responseText;if(0!==w.length)if(this.hI===w.length)clearInterval(this.ER), this.trigger(f.Events.DONE);else return w=Math.min(this.hI+3E6,w.length),a=r.afa(a,this.hI,!0,w),this.hI=w,a};f.prototype.abort=function(){clearInterval(this.ER);var a=this;this.request.onreadystatechange=function(){Object(na.j)("StreamingRequest aborted");a.status=y.a.ABORTED;return a.trigger(f.Events.ABORTED)};this.request.abort()};f.prototype.finish=function(){var a=this;this.request.onreadystatechange=function(){a.status=y.a.SUCCESS;return a.trigger(f.Events.DONE)};this.request.abort()};f.Events= {DONE:"done",DATA:"data",ABORTED:"aborted"};return f}();Object(wa.b)(b);var h;(function(f){f[f.LOCAL_HEADER=0]="LOCAL_HEADER";f[f.FILE=1]="FILE";f[f.CENTRAL_DIR=2]="CENTRAL_DIR"})(h||(h={}));var n=function(f){function a(){var w=f.call(this)||this;w.buffer="";w.state=h.LOCAL_HEADER;w.a5=4;w.Sr=null;w.zC=ia.c;w.cu={};return w}Object(ka.d)(a,f);a.prototype.PVa=function(w){var aa;for(w=this.buffer+w;w.length>=this.zC;)switch(this.state){case h.LOCAL_HEADER:this.Sr=aa=this.sWa(w.slice(0,this.zC));if(aa.tD!== ia.g)throw Error("Wrong signature in local header: ".concat(aa.tD));w=w.slice(this.zC);this.state=h.FILE;this.zC=aa.zW+aa.oy+aa.vG+this.a5;this.trigger(a.Events.HEADER,[aa]);break;case h.FILE:this.Sr.name=w.slice(0,this.Sr.oy);this.cu[this.Sr.name]=this.Sr;aa=this.zC-this.a5;var z=w.slice(this.Sr.oy+this.Sr.vG,aa);this.trigger(a.Events.FILE,[this.Sr.name,z,this.Sr.gX]);w=w.slice(aa);if(w.slice(0,this.a5)===ia.h)this.state=h.LOCAL_HEADER,this.zC=ia.c;else return this.state=h.CENTRAL_DIR,!0}this.buffer= w;return!1};a.Events={HEADER:"header",FILE:"file"};return a}(ba.a);Object(wa.b)(n);wa=function(f){function a(w,aa,z,fa,ea){z=f.call(this,w,z,fa)||this;z.url=w;z.stream=new b(w,aa);z.jf=new n;z.$ja=window.createPromiseCapability();z.Uka={};z.eg=ea;return z}Object(ka.d)(a,f);a.prototype.uJ=function(w){var aa=this;this.request([this.ao,this.pq,this.$n]);this.stream.addEventListener(b.Events.DATA,function(z){try{if(aa.jf.PVa(z))return aa.stream.finish()}catch(fa){throw aa.stream.abort(),aa.mx(fa),w(fa), fa;}});this.stream.addEventListener(b.Events.DONE,function(z){aa.eVa=!0;aa.$ja.resolve();z&&(aa.mx(z),w(z))});this.jf.addEventListener(n.Events.HEADER,Object(pa.bind)(this.Tka,this));this.jf.addEventListener(n.Events.FILE,Object(pa.bind)(this.KWa,this));return this.stream.start(this.eg,this.withCredentials)};a.prototype.Vea=function(w){var aa=this;this.$ja.promise.then(function(){w(Object.keys(aa.jf.cu))})};a.prototype.jv=function(){return!0};a.prototype.request=function(w){var aa=this;this.eVa&& w.forEach(function(z){aa.Uka[z]||aa.e4a(z)})};a.prototype.Tka=function(){};a.prototype.abort=function(){this.stream&&this.stream.abort()};a.prototype.e4a=function(w){this.trigger(ca.a.Events.PART_READY,[{Tb:w,error:"Requested part not found",Nm:!1,Zi:!1}])};a.prototype.KWa=function(w,aa,z){this.Uka[w]=!0;this.trigger(ca.a.Events.PART_READY,[{Tb:w,data:aa,Nm:!1,Zi:!1,error:null,Te:z}])};return a}(ca.a);Object(e.a)(wa);Object(e.b)(wa);ua["default"]=wa}}]);}).call(this || window)