pdfjs-viewer-element 1.0.3 → 2.0.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/README.md +11 -11
- package/dist/pdfjs-viewer-element.js +1 -1
- package/dist/pdfjs-viewer-element.umd.cjs +2 -2
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A web component for [PDF.js viewer](https://mozilla.github.io/pdf.js/web/viewer.html). See [demo](https://alekswebnet.github.io/pdfjs-viewer-element/index.html).
|
|
4
4
|
|
|
5
|
-
⚠️ `pdfjs-viewer-element` uses PDF.js [prebuilt](https://github.com/mozilla/pdf.js/releases/download/
|
|
5
|
+
⚠️ `pdfjs-viewer-element` uses PDF.js [prebuilt](https://github.com/mozilla/pdf.js/releases/download/v3.4.120/pdfjs-3.4.120-dist.zip), that includes the generic build of PDF.js and the viewer. To use the package you should **extract the prebuilt** files into some directory of your project. You may specify the path to this directory with `viewerPath` property (by default is '/pdfjs-3.4.120-dist').
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
```
|
|
@@ -16,21 +16,21 @@ yarn add pdfjs-viewer-element
|
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
Extract the PDF.js prebuilt. See demo [example](https://github.com/alekswebnet/pdfjs-viewer-element/tree/master/public).
|
|
20
21
|
|
|
21
22
|
```javascript
|
|
22
23
|
import 'pdfjs-viewer-element'
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
Extract the PDF.js prebuilt. See [example](https://github.com/alekswebnet/pdfjs-viewer-element/tree/master/public).
|
|
26
|
-
|
|
27
|
-
Use the element inside your template:
|
|
28
|
-
|
|
29
26
|
```javascript
|
|
30
|
-
<pdfjs-viewer-element
|
|
31
|
-
src="/pdfjs-2.15.349-dist/web/compressed.tracemonkey-pldi-09.pdf"
|
|
32
|
-
height="100vh">
|
|
33
|
-
</pdfjs-viewer-element>
|
|
27
|
+
<pdfjs-viewer-element src="/compressed.tracemonkey-pldi-09.pdf"></pdfjs-viewer-element>
|
|
34
28
|
```
|
|
29
|
+
|
|
30
|
+
## Properties
|
|
31
|
+
|
|
32
|
+
`src` - path to pdf file.
|
|
33
|
+
|
|
34
|
+
`viewerPath` - path to viewer prebuilt directory (by default is '/pdfjs-3.4.120-dist').
|
|
35
35
|
## License
|
|
36
|
-
[MIT](http://opensource.org/licenses/MIT)
|
|
36
|
+
[MIT](http://opensource.org/licenses/MIT)
|
|
@@ -598,7 +598,7 @@ var xt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, q = (n, t,
|
|
|
598
598
|
};
|
|
599
599
|
let x = class extends b {
|
|
600
600
|
constructor() {
|
|
601
|
-
super(...arguments), this.src = "", this.height = "
|
|
601
|
+
super(...arguments), this.src = "", this.height = "100%";
|
|
602
602
|
}
|
|
603
603
|
render() {
|
|
604
604
|
return ft`
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
\f\r](?:([^\\s"'>=/]+)([
|
|
15
15
|
\f\r]*=[
|
|
16
16
|
\f\r]*(?:[^
|
|
17
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),st=/'/g,nt=/"/g,rt=/^(?:script|style|textarea|title)$/i,_t=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),ft=_t(1),E=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),ot=new WeakMap,mt=(n,t,e)=>{var i,s;const o=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let r=o._$litPart$;if(r===void 0){const d=(s=e==null?void 0:e.renderBefore)!==null&&s!==void 0?s:null;o._$litPart$=r=new
|
|
17
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),st=/'/g,nt=/"/g,rt=/^(?:script|style|textarea|title)$/i,_t=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),ft=_t(1),E=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),ot=new WeakMap,mt=(n,t,e)=>{var i,s;const o=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let r=o._$litPart$;if(r===void 0){const d=(s=e==null?void 0:e.renderBefore)!==null&&s!==void 0?s:null;o._$litPart$=r=new x(t.insertBefore(w(),d),d,void 0,e!=null?e:{})}return r._$AI(n),r},S=g.createTreeWalker(g,129,null,!1),At=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",r=P;for(let l=0;l<e;l++){const h=n[l];let v,a,c=-1,$=0;for(;$<h.length&&(r.lastIndex=$,a=r.exec(h),a!==null);)$=r.lastIndex,r===P?a[1]==="!--"?r=et:a[1]!==void 0?r=it:a[2]!==void 0?(rt.test(a[2])&&(s=RegExp("</"+a[2],"g")),r=m):a[3]!==void 0&&(r=m):r===m?a[0]===">"?(r=s!=null?s:P,c=-1):a[1]===void 0?c=-2:(c=r.lastIndex-a[2].length,v=a[1],r=a[3]===void 0?m:a[3]==='"'?nt:st):r===nt||r===st?r=m:r===et||r===it?r=P:(r=m,s=void 0);const M=r===m&&n[l+1].startsWith("/>")?" ":"";o+=r===P?h+$t:c>=0?(i.push(v),h.slice(0,c)+"$lit$"+h.slice(c)+f+M):h+f+(c===-2?(i.push(void 0),l):M)}const d=o+(n[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return[X!==void 0?X.createHTML(d):d,i]};class U{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,r=0;const d=t.length-1,l=this.parts,[h,v]=At(t,e);if(this.el=U.createElement(h,i),S.currentNode=this.el.content,e===2){const a=this.el.content,c=a.firstChild;c.remove(),a.append(...c.childNodes)}for(;(s=S.nextNode())!==null&&l.length<d;){if(s.nodeType===1){if(s.hasAttributes()){const a=[];for(const c of s.getAttributeNames())if(c.endsWith("$lit$")||c.startsWith(f)){const $=v[r++];if(a.push(c),$!==void 0){const M=s.getAttribute($.toLowerCase()+"$lit$").split(f),R=/([.?@])?(.*)/.exec($);l.push({type:1,index:o,name:R[2],strings:M,ctor:R[1]==="."?gt:R[1]==="?"?St:R[1]==="@"?bt:N})}else l.push({type:6,index:o})}for(const c of a)s.removeAttribute(c)}if(rt.test(s.tagName)){const a=s.textContent.split(f),c=a.length-1;if(c>0){s.textContent=y?y.emptyScript:"";for(let $=0;$<c;$++)s.append(a[$],w()),S.nextNode(),l.push({type:2,index:++o});s.append(a[c],w())}}}else if(s.nodeType===8)if(s.data===Y)l.push({type:2,index:o});else{let a=-1;for(;(a=s.data.indexOf(f,a+1))!==-1;)l.push({type:7,index:o}),a+=f.length-1}o++}}static createElement(t,e){const i=g.createElement("template");return i.innerHTML=t,i}}function b(n,t,e=n,i){var s,o,r,d;if(t===E)return t;let l=i!==void 0?(s=e._$Cl)===null||s===void 0?void 0:s[i]:e._$Cu;const h=C(t)?void 0:t._$litDirective$;return(l==null?void 0:l.constructor)!==h&&((o=l==null?void 0:l._$AO)===null||o===void 0||o.call(l,!1),h===void 0?l=void 0:(l=new h(n),l._$AT(n,e,i)),i!==void 0?((r=(d=e)._$Cl)!==null&&r!==void 0?r:d._$Cl=[])[i]=l:e._$Cu=l),l!==void 0&&(t=b(n,l._$AS(n,t.values),l,i)),t}class yt{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:s}=this._$AD,o=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:g).importNode(i,!0);S.currentNode=o;let r=S.nextNode(),d=0,l=0,h=s[0];for(;h!==void 0;){if(d===h.index){let v;h.type===2?v=new x(r,r.nextSibling,this,t):h.type===1?v=new h.ctor(r,h.name,h.strings,this,t):h.type===6&&(v=new wt(r,this,t)),this.v.push(v),h=s[++l]}d!==(h==null?void 0:h.index)&&(r=S.nextNode(),d++)}return o}m(t){let e=0;for(const i of this.v)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class x{constructor(t,e,i,s){var o;this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$C_=(o=s==null?void 0:s.isConnected)===null||o===void 0||o}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$C_}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=b(this,t,e),C(t)?t===u||t==null||t===""?(this._$AH!==u&&this._$AR(),this._$AH=u):t!==this._$AH&&t!==E&&this.$(t):t._$litType$!==void 0?this.T(t):t.nodeType!==void 0?this.k(t):vt(t)?this.O(t):this.$(t)}S(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}$(t){this._$AH!==u&&C(this._$AH)?this._$AA.nextSibling.data=t:this.k(g.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:s}=t,o=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=U.createElement(s.h,this.options)),s);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===o)this._$AH.m(i);else{const r=new yt(o,this),d=r.p(this.options);r.m(i),this.k(d),this._$AH=r}}_$AC(t){let e=ot.get(t.strings);return e===void 0&&ot.set(t.strings,e=new U(t)),e}O(t){tt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new x(this.S(w()),this.S(w()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$C_=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class N{constructor(t,e,i,s,o){this.type=1,this._$AH=u,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=b(this,t,e,0),r=!C(t)||t!==this._$AH&&t!==E,r&&(this._$AH=t);else{const d=t;let l,h;for(t=o[0],l=0;l<o.length-1;l++)h=b(this,d[i+l],e,l),h===E&&(h=this._$AH[l]),r||(r=!C(h)||h!==this._$AH[l]),h===u?t=u:t!==u&&(t+=(h!=null?h:"")+o[l+1]),this._$AH[l]=h}r&&!s&&this.P(t)}P(t){t===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}}class gt extends N{constructor(){super(...arguments),this.type=3}P(t){this.element[this.name]=t===u?void 0:t}}const Et=y?y.emptyScript:"";class St extends N{constructor(){super(...arguments),this.type=4}P(t){t&&t!==u?this.element.setAttribute(this.name,Et):this.element.removeAttribute(this.name)}}class bt extends N{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){var i;if((t=(i=b(this,t,e,0))!==null&&i!==void 0?i:u)===E)return;const s=this._$AH,o=t===u&&s!==u||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==u&&(s===u||o);o&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class wt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){b(this,t)}}const lt=T.litHtmlPolyfillSupport;lt==null||lt(U,x),((V=T.litHtmlVersions)!==null&&V!==void 0?V:T.litHtmlVersions=[]).push("2.3.0");/**
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2017 Google LLC
|
|
20
20
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2021 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
33
|
-
*/var W;((W=window.HTMLSlotElement)===null||W===void 0?void 0:W.prototype.assignedElements)!=null;var
|
|
33
|
+
*/var W;((W=window.HTMLSlotElement)===null||W===void 0?void 0:W.prototype.assignedElements)!=null;var Ut=Object.defineProperty,xt=Object.getOwnPropertyDescriptor,q=(n,t,e,i)=>{for(var s=i>1?void 0:i?xt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&Ut(t,e,s),s};p.PdfjsViewerElement=class extends H{constructor(){super(...arguments),this.src="",this.height="100%"}render(){return ft`
|
|
34
34
|
<iframe
|
|
35
35
|
frameborder="0"
|
|
36
36
|
width="100%"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfjs-viewer-element",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Oleksandr Shevchuk",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"dependencies": {},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^18.7.1",
|
|
44
|
-
"lit": "^2.3.0",
|
|
45
44
|
"typescript": "^4.6.4",
|
|
46
45
|
"vite": "^3.0.6"
|
|
47
46
|
}
|