@pdf-viewer/react 1.5.0-beta.2 → 1.5.0-beta.3

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.
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as c } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-04-30T02:45:44.208Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
3
+ const b = /* @__PURE__ */ new Date("2025-04-30T06:01:15.055Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
4
4
  invalidLicense: `You are currently using without a valid license. ${l}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
6
6
  expired: `Your license key has expired. ${l}`,
@@ -1,36 +1,38 @@
1
- import { useState as l, useRef as E, useEffect as k } from "react";
2
- import * as I from "pdfjs-dist";
3
- import { getThumbnailViewport as N } from "../getThumbnailViewport.js";
4
- import { useConfigContext as S } from "../../contexts/ConfigContext.js";
5
- const A = (d, e, L = {}) => {
6
- const [r, y] = l(), { workerUrlAdded: p } = S(), [C, w] = l(/* @__PURE__ */ new Map()), i = E(), [T, m] = l(0), [f, b] = l(!1), { onLoadError: g, onLoaded: a } = L;
7
- return k(() => {
8
- if (!p || !d)
1
+ import { useState as u, useRef as x, useEffect as L } from "react";
2
+ import * as p from "pdfjs-dist";
3
+ import { getThumbnailViewport as E } from "../getThumbnailViewport.js";
4
+ import { useConfigContext as I } from "../../contexts/ConfigContext.js";
5
+ const V = (d, e, y = {}) => {
6
+ const [r, C] = u(), { workerUrlAdded: w } = I(), [T, b] = u(/* @__PURE__ */ new Map()), i = x(), [j, f] = u(0), [g, k] = u(!1), { onLoadError: m, onLoaded: a } = y;
7
+ return L(() => {
8
+ if (!w || !d)
9
9
  return;
10
10
  i.current = Date.now();
11
11
  const t = i.current, P = {
12
12
  url: d,
13
13
  cMapPacked: (e == null ? void 0 : e.isCompressed) ?? !0,
14
14
  ...(e == null ? void 0 : e.url) && { cMapUrl: e.url }
15
- }, n = I.getDocument(P);
15
+ };
16
+ console.log("currently pdfjs version", p.version, p);
17
+ const n = p.getDocument(P);
16
18
  n.onProgress = (o) => {
17
19
  if (t === i.current) {
18
- const { loaded: c, total: u } = o, x = u ? Math.min(100, Math.round(c / u * 100)) : 0;
19
- m(x);
20
+ const { loaded: c, total: l } = o, v = l ? Math.min(100, Math.round(c / l * 100)) : 0;
21
+ f(v);
20
22
  }
21
- }, b(!0), m(0);
22
- const s = n.promise.then((o) => (t === i.current && (y(o), m(100)), a && a(o), o)).catch((o) => {
23
- g && g(o);
24
- }).finally(() => b(!1));
23
+ }, k(!0), f(0);
24
+ const s = n.promise.then((o) => (t === i.current && (C(o), f(100)), a && a(o), o)).catch((o) => {
25
+ m && m(o);
26
+ }).finally(() => k(!1));
25
27
  return () => {
26
28
  s.finally(() => {
27
29
  n.destroy();
28
30
  });
29
31
  };
30
- }, [d, p, g, a]), k(() => {
32
+ }, [d, w, m, a]), L(() => {
31
33
  const t = /* @__PURE__ */ new Map();
32
- if (!r || f) {
33
- w(t);
34
+ if (!r || g) {
35
+ b(t);
34
36
  return;
35
37
  }
36
38
  const P = r.numPages, n = [];
@@ -40,17 +42,17 @@ const A = (d, e, L = {}) => {
40
42
  }
41
43
  Promise.all(n).then((s) => {
42
44
  s.map((o) => {
43
- const { thumbnailViewport: c, scale: u } = N(o);
44
- t.set(o.pageNumber, { page: o, thumbnailViewport: c, thumbnailScale: u });
45
- }), w(t);
45
+ const { thumbnailViewport: c, scale: l } = E(o);
46
+ t.set(o.pageNumber, { page: o, thumbnailViewport: c, thumbnailScale: l });
47
+ }), b(t);
46
48
  });
47
- }, [r, f]), {
49
+ }, [r, g]), {
48
50
  pdf: r,
49
- pages: C,
50
- loading: f,
51
- loadingProgress: T
51
+ pages: T,
52
+ loading: g,
53
+ loadingProgress: j
52
54
  };
53
55
  };
54
56
  export {
55
- A as useLoadPdf
57
+ V as useLoadPdf
56
58
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "The PDF Viewer component for React and Next.js",
5
- "version": "1.5.0-beta.2",
5
+ "version": "1.5.0-beta.3",
6
6
  "keywords": [
7
7
  "component",
8
8
  "frontend",