diff --git a/tf-pdf.js b/tf-pdf.js new file mode 100644 index 0000000..3f21524 --- /dev/null +++ b/tf-pdf.js @@ -0,0 +1,2 @@ +!function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function r(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}let c,s;function a(t,e){return c||(c=document.createElement("a")),c.href=e,t===c.href}function l(t,e){t.appendChild(e)}function u(t,e,n){t.insertBefore(e,n||null)}function d(t){t.parentNode.removeChild(t)}function f(t){return document.createElement(t)}function p(t){return document.createTextNode(t)}function h(){return p(" ")}function g(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function m(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function $(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function b(t){const e={};for(const n of t)e[n.name]=n.value;return e}function v(t){s=t}function x(t){(function(){if(!s)throw new Error("Function called outside component initialization");return s})().$$.on_mount.push(t)}const w=[],y=[],_=[],k=[],E=Promise.resolve();let C=!1;function T(t){_.push(t)}const j=new Set;let L=0;function A(){const t=s;do{for(;L{const o=n.length?n[0]:e;return m.ctx&&u(m.ctx[t],m.ctx[t]=o)&&(!m.skip_bound&&m.bound[t]&&m.bound[t](o),$&&P(i,t)),e})):[],m.update(),$=!0,o(m.before_update),m.fragment=!!l&&l(m.ctx),c.target){if(c.hydrate){const t=function(t){return Array.from(t.childNodes)}(c.target);m.fragment&&m.fragment.l(t),t.forEach(d)}else m.fragment&&m.fragment.c();c.intro&&((b=i.$$.fragment)&&b.i&&(N.delete(b),b.i(x))),function(t,n,i,c){const{fragment:s,on_mount:a,on_destroy:l,after_update:u}=t.$$;s&&s.m(n,i),c||T((()=>{const n=a.map(e).filter(r);l?l.push(...n):o(n),t.$$.on_mount=[]})),u.forEach(T)}(i,c.target,c.anchor,c.customElement),A()}var b,x;v(g)}let O;function S(t){let e;return{c(){e=f("p"),e.textContent="loading ...",m(e,"class","loading")},m(t,n){u(t,e,n)},d(t){t&&d(e)}}}function q(t){let e,n,r,i,c,s,b,v,x,w,y,_,k,E,C,T,j,L,A,M,N,P;return{c(){e=f("div"),n=f("button"),r=f("img"),s=h(),b=f("p"),v=p("page "),x=p(t[3]),w=p(" from "),y=p(t[1]),_=h(),k=f("button"),E=f("img"),j=h(),L=f("button"),A=f("img"),a(r.src,i=R)||m(r,"src",i),m(r,"alt","previous page"),m(r,"title","previous page"),m(r,"width","24px"),n.disabled=c=t[4]||1===t[3],a(E.src,C=z)||m(E,"src",C),m(E,"alt","next page"),m(E,"title","next page"),m(E,"width","24px"),k.disabled=T=t[4]||t[1]===t[3],a(A.src,M=B)||m(A,"src",M),m(A,"alt","full page"),m(A,"title","full page"),m(A,"width","24px"),L.disabled=t[4],m(e,"class","control")},m(o,i){u(o,e,i),l(e,n),l(n,r),l(e,s),l(e,b),l(b,v),l(b,x),l(b,w),l(b,y),l(e,_),l(e,k),l(k,E),l(e,j),l(e,L),l(L,A),N||(P=[g(n,"click",t[7]),g(k,"click",t[8]),g(L,"click",t[9])],N=!0)},p(t,e){24&e&&c!==(c=t[4]||1===t[3])&&(n.disabled=c),8&e&&$(x,t[3]),2&e&&$(y,t[1]),26&e&&T!==(T=t[4]||t[1]===t[3])&&(k.disabled=T),16&e&&(L.disabled=t[4])},d(t){t&&d(e),N=!1,o(P)}}}function F(e){let n,o,r,i,c,s,a,p=e[4]&&S(),$=e[1]&&q(e);return{c(){p&&p.c(),n=h(),o=f("div"),$&&$.c(),r=h(),i=f("div"),this.c=t,m(i,"class","canvas_holder"),m(i,"style",e[5]),m(o,"class","pdf-viewer"),m(o,"style",c="--page-width: "+e[2]+"px")},m(t,c){p&&p.m(t,c),u(t,n,c),u(t,o,c),$&&$.m(o,null),l(o,r),l(o,i),e[11](i),s||(a=g(i,"scroll",e[6]),s=!0)},p(t,[e]){t[4]?p||(p=S(),p.c(),p.m(n.parentNode,n)):p&&(p.d(1),p=null),t[1]?$?$.p(t,e):($=q(t),$.c(),$.m(o,r)):$&&($.d(1),$=null),32&e&&m(i,"style",t[5]),4&e&&c!==(c="--page-width: "+t[2]+"px")&&m(o,"style",c)},i:t,o:t,d(t){p&&p.d(t),t&&d(n),t&&d(o),$&&$.d(),e[11](null),s=!1,a()}}}"function"==typeof HTMLElement&&(O=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){const{on_mount:t}=this.$$;this.$$.on_disconnect=t.map(e).filter(r);for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}disconnectedCallback(){o(this.$$.on_disconnect)}$destroy(){!function(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});const R="https://fonts.gstatic.com/s/i/materialiconsround/arrow_back/v13/24px.svg",z="https://fonts.gstatic.com/s/i/materialiconsround/arrow_forward/v13/24px.svg",B="https://fonts.gstatic.com/s/i/materialiconsround/fullscreen/v12/24px.svg";function D(t,e,n){let o,r,i,c,{url:s}=e,a=1,l=!1,u="";return x((()=>{function t(t){var e=t.getViewport({scale:1}),r=document.createElement("div");r.className="canvas-wrapper";var s=document.createElement("canvas"),a={canvasContext:s.getContext("2d"),viewport:e};i=s.height=e.height,n(2,c=s.width=e.width),n(5,u="--page-height: "+e.height+"px;--page-width: "+e.width+"px;"),r.appendChild(s),o.appendChild(r),t.render(a)}n(4,l=!0),pdfjsLib.disableWorker=!0,pdfjsLib.getDocument(s).promise.then((e=>{n(1,r=e.numPages),function(e){for(var o=1;o<=e.numPages;o++)e.getPage(o).then(t).finally((()=>{n(4,l=!1)}))}(e)}))})),t.$$set=t=>{"url"in t&&n(10,s=t.url)},[o,r,c,a,l,u,function(){n(3,a=Math.round(o.scrollTop/i+1))},function(){let t=(a-2)*i;o.scrollTo(0,t),n(3,a--,a)},function(){let t=a*i;o.scrollTo(0,t),n(3,a++,a)},function(){o.requestFullscreen()},s,function(t){y[t?"unshift":"push"]((()=>{o=t,n(0,o)}))}]}window.customElements.define("tf-pdf",class extends O{constructor(t){super(),this.shadowRoot.innerHTML="",H(this,{target:this.shadowRoot,props:b(this.attributes),customElement:!0},D,F,i,{url:10},null),t&&(t.target&&u(t.target,this,t.anchor),t.props&&(this.$set(t.props),A()))}static get observedAttributes(){return["url"]}get url(){return this.$$.ctx[10]}set url(t){this.$$set({url:t}),A()}})}(); +//# sourceMappingURL=bundle.js.map