pdfjs-viewer-element 2.7.0 → 2.7.1

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 CHANGED
@@ -10,7 +10,7 @@ Supported in all [major browsers](https://caniuse.com/custom-elementsv1), and wo
10
10
  See [demo pages](https://github.com/alekswebnet/pdfjs-viewer-element/tree/master/demo) for various usecases.
11
11
  See [live examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo) of usage with frameworks.
12
12
 
13
- # Features
13
+ ## Features
14
14
 
15
15
  - Simple PDF.js viewer integration to any web application
16
16
  - PDF.js viewer options and parameters support, access to the viewer application instance
@@ -18,7 +18,7 @@ See [live examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo) of
18
18
 
19
19
  ## How it works
20
20
 
21
- **⚠️ This is an important part, please read this firstly !!!**
21
+ **⚠️ This is an important part, please read this FIRST !!!**
22
22
 
23
23
  **You should download and place the PDF.js prebuilt files in the project.**
24
24
 
@@ -179,7 +179,9 @@ const viewerApp = await viewer.initialize()
179
179
  viewerApp.open({ data: pdfData })
180
180
  ```
181
181
 
182
- ## Server configuration
182
+ ## Known issues
183
+
184
+ ### The `.mjs` files support
183
185
 
184
186
  Since v4 PDF.js requires `.mjs` files support, make sure your server has it.
185
187
 
@@ -204,6 +206,13 @@ server {
204
206
  }
205
207
  ```
206
208
 
209
+ ### Problem with range requests / streaming
210
+
211
+ Sometimes a PDF file fails to load when working with range requests / streaming.
212
+ If you encounter this issue, you can try disabling the broken functionality of PDF.js:
213
+
214
+ `disable-range="true"`
215
+
207
216
 
208
217
  ## License
209
218
  [MIT](http://opensource.org/licenses/MIT)
@@ -9,8 +9,7 @@ const y = (p, t) => new Promise((o) => {
9
9
  class x extends HTMLElement {
10
10
  constructor() {
11
11
  super(), this.onIframeReady = function(s, r = 25, e = {}) {
12
- if (e = { ...T, ...e }, !Number.isFinite(r))
13
- throw new TypeError("Expected `wait` to be a finite number");
12
+ if (e = { ...T, ...e }, !Number.isFinite(r)) throw new TypeError("Expected `wait` to be a finite number");
14
13
  let i, n, a, l, h = [];
15
14
  const f = (c, m) => (a = async function(d, u, w) {
16
15
  return await d.apply(u, w);
@@ -26,8 +25,7 @@ class x extends HTMLElement {
26
25
  clearTimeout(n), n = setTimeout(() => {
27
26
  n = null;
28
27
  const u = e.leading ? i : f(this, c);
29
- for (const w of h)
30
- w(u);
28
+ for (const w of h) w(u);
31
29
  h = [];
32
30
  }, r), d ? (i = f(this, c), m(i)) : h.push(m);
33
31
  });
@@ -36,17 +34,14 @@ class x extends HTMLElement {
36
34
  await y("iframe", this.shadowRoot), s();
37
35
  }, 0, { leading: !0 }), this.setViewerExtraStyles = (s, r = "extra") => {
38
36
  var i, n, a, l, h;
39
- if (!s)
40
- return void ((n = (i = this.iframe.contentDocument) == null ? void 0 : i.head.querySelector(`style[${r}]`)) == null ? void 0 : n.remove());
41
- if (((l = (a = this.iframe.contentDocument) == null ? void 0 : a.head.querySelector(`style[${r}]`)) == null ? void 0 : l.innerHTML) === s)
42
- return;
37
+ if (!s) return void ((n = (i = this.iframe.contentDocument) == null ? void 0 : i.head.querySelector(`style[${r}]`)) == null ? void 0 : n.remove());
38
+ if (((l = (a = this.iframe.contentDocument) == null ? void 0 : a.head.querySelector(`style[${r}]`)) == null ? void 0 : l.innerHTML) === s) return;
43
39
  const e = document.createElement("style");
44
40
  e.innerHTML = s, e.setAttribute(r, ""), (h = this.iframe.contentDocument) == null || h.head.appendChild(e);
45
41
  }, this.injectExtraStylesLinks = (s) => {
46
42
  s && s.replace(/'|]|\[/g, "").split(",").map((r) => r.trim()).forEach((r) => {
47
43
  var n, a;
48
- if ((n = this.iframe.contentDocument) == null ? void 0 : n.head.querySelector(`link[href="${r}"]`))
49
- return;
44
+ if ((n = this.iframe.contentDocument) == null ? void 0 : n.head.querySelector(`link[href="${r}"]`)) return;
50
45
  const i = document.createElement("link");
51
46
  i.rel = "stylesheet", i.href = r, (a = this.iframe.contentDocument) == null || a.head.appendChild(i);
52
47
  });
@@ -114,8 +109,7 @@ ${g ? "&nameddest=" + g : ""}`;
114
109
  `)[1].split(`
115
110
  }`)[0]);
116
111
  this.setViewerExtraStyles(n.join(""), "theme");
117
- } else
118
- (r = (s = this.iframe.contentDocument) == null ? void 0 : s.head.querySelector("style[theme]")) == null || r.remove();
112
+ } else (r = (s = this.iframe.contentDocument) == null ? void 0 : s.head.querySelector("style[theme]")) == null || r.remove();
119
113
  }
120
114
  }
121
115
  window.customElements.get("pdfjs-viewer-element") || (window.PdfjsViewerElement = x, window.customElements.define("pdfjs-viewer-element", x));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdfjs-viewer-element",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Oleksandr Shevchuk",
@@ -34,13 +34,13 @@
34
34
  "devDependencies": {
35
35
  "@awlsn/pdfjs-full": "^4.2.392",
36
36
  "@rollup/plugin-terser": "^0.4.4",
37
- "@types/node": "^18.19.31",
38
- "@vitest/browser": "^1.5.0",
39
- "jsdom": "^22.1.0",
40
- "typescript": "^4.9.5",
41
- "vite": "^5.2.9",
42
- "vitest": "^1.5.0",
43
- "webdriverio": "^8.36.1"
37
+ "@types/node": "^22.13.5",
38
+ "@vitest/browser": "^3.0.7",
39
+ "jsdom": "^26.0.0",
40
+ "typescript": "^5.7.3",
41
+ "vite": "^6.2.0",
42
+ "vitest": "^3.0.7",
43
+ "webdriverio": "^9.10.1"
44
44
  },
45
45
  "dependencies": {
46
46
  "perfect-debounce": "^1.0.0"
@@ -18,7 +18,7 @@ export declare class PdfjsViewerElement extends HTMLElement {
18
18
  private setCssTheme;
19
19
  private setViewerExtraStyles;
20
20
  private injectExtraStylesLinks;
21
- initialize: () => Promise<PdfjsViewerElementIframeWindow['PDFViewerApplication']>;
21
+ initialize: () => Promise<PdfjsViewerElementIframeWindow["PDFViewerApplication"]>;
22
22
  }
23
23
  declare global {
24
24
  interface Window {