@react-pdf-kit/viewer 2.4.0-beta.4 → 2.4.0-beta.5

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.
@@ -2,3 +2,4 @@ import { NormalizedKeyword } from './types';
2
2
  export declare const EMPTY_KEYWORD_REGEXP: NormalizedKeyword;
3
3
  export declare const ORGANIZATION_ALLOWED_FEATURES_MESSAGE = "This feature is only available for the Organization license";
4
4
  export declare const INVALID_OR_CORRUPTED_PDF_MESSAGE = "Invalid or corrupted PDF file.";
5
+ export declare const BROWSER_NOT_SUPPORTED_MESSAGE = "React PDF Kit is unable to render on this browser.";
@@ -2,8 +2,9 @@ const e = {
2
2
  keyword: "",
3
3
  regExp: new RegExp(" "),
4
4
  wholeWords: !1
5
- }, E = "This feature is only available for the Organization license", o = "Invalid or corrupted PDF file.";
5
+ }, E = "This feature is only available for the Organization license", o = "Invalid or corrupted PDF file.", r = "React PDF Kit is unable to render on this browser.";
6
6
  export {
7
+ r as BROWSER_NOT_SUPPORTED_MESSAGE,
7
8
  e as EMPTY_KEYWORD_REGEXP,
8
9
  o as INVALID_OR_CORRUPTED_PDF_MESSAGE,
9
10
  E as ORGANIZATION_ALLOWED_FEATURES_MESSAGE
@@ -2,7 +2,7 @@ import { useState as E, useCallback as y, useEffect as b } from "react";
2
2
  import { LicenseType as L } from "../types.js";
3
3
  import { appConsole as c } from "../appConsole.js";
4
4
  import "../../de_DE-8145915f.js";
5
- const A = /* @__PURE__ */ new Date("2026-04-16T08:12:46.089Z"), w = `-----BEGIN PUBLIC KEY-----
5
+ const A = /* @__PURE__ */ new Date("2026-04-17T07:06:06.167Z"), w = `-----BEGIN PUBLIC KEY-----
6
6
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
7
7
  gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
8
8
  HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
@@ -1,48 +1,52 @@
1
- import { useState as d, useRef as j, useEffect as C } from "react";
2
- import * as A from "pdfjs-dist";
3
- import { ErrorType as T } from "../types.js";
4
- import { getThumbnailViewport as z } from "../getThumbnailViewport.js";
5
- import { useConfigContext as G } from "../../contexts/ConfigContext.js";
6
- import { useDocumentPasswordContext as B } from "../../contexts/DocumentPasswordContext.js";
7
- import { INVALID_OR_CORRUPTED_PDF_MESSAGE as H } from "../const.js";
1
+ import { useState as u, useRef as B, useEffect as T } from "react";
2
+ import * as k from "pdfjs-dist";
3
+ import { ErrorType as b } from "../types.js";
4
+ import { getThumbnailViewport as G } from "../getThumbnailViewport.js";
5
+ import { useConfigContext as j } from "../../contexts/ConfigContext.js";
6
+ import { useDocumentPasswordContext as z } from "../../contexts/DocumentPasswordContext.js";
7
+ import { INVALID_OR_CORRUPTED_PDF_MESSAGE as W, BROWSER_NOT_SUPPORTED_MESSAGE as H } from "../const.js";
8
8
  import "../../de_DE-8145915f.js";
9
9
  import "react/jsx-runtime";
10
10
  import "../appConsole.js";
11
- function F(i) {
12
- const t = new Error(H);
13
- return t.cause = i, t;
11
+ function x(n) {
12
+ const o = new Error(W);
13
+ return o.cause = n, o;
14
14
  }
15
- const ee = (i, t, L = {}) => {
16
- const [a, P] = d(), { workerUrlAdded: S, wasmUrl: c } = G(), [N, V] = d(/* @__PURE__ */ new Map()), u = j(), [g, p] = d(0), [w, y] = d(!1), [h, l] = d(), { password: f, passwordError: q, setPasswordError: E, passwordRequired: R, setPasswordRequired: D } = B(), { onLoadError: o, onLoaded: I, onLoadProgress: v, disableAutoFetch: U, disableStream: k, rangeChunkSize: x } = L;
17
- return C(() => {
18
- v && v(g);
19
- }, [g, v]), C(() => {
20
- if (!S || !i)
15
+ function J(n) {
16
+ const o = new Error(H);
17
+ return o.cause = n, o;
18
+ }
19
+ const te = (n, o, F = {}) => {
20
+ const [a, c] = u(), { workerUrlAdded: C, wasmUrl: P } = j(), [h, N] = u(/* @__PURE__ */ new Map()), d = B(), [p, g] = u(0), [w, U] = u(!1), [L, l] = u(), { password: f, passwordError: q, setPasswordError: E, passwordRequired: R, setPasswordRequired: D } = z(), { onLoadError: t, onLoaded: _, onLoadProgress: O, disableAutoFetch: V, disableStream: y, rangeChunkSize: A } = F;
21
+ return T(() => {
22
+ O && O(p);
23
+ }, [p, O]), T(() => {
24
+ if (!C || !n)
21
25
  return;
22
- p(0), l(void 0), u.current = Date.now();
23
- const n = u.current, _ = {
24
- url: i,
25
- cMapPacked: (t == null ? void 0 : t.isCompressed) ?? !0,
26
- ...(t == null ? void 0 : t.url) && { cMapUrl: t.url },
26
+ g(0), l(void 0), d.current = Date.now();
27
+ const i = d.current, S = {
28
+ url: n,
29
+ cMapPacked: (o == null ? void 0 : o.isCompressed) ?? !0,
30
+ ...(o == null ? void 0 : o.url) && { cMapUrl: o.url },
27
31
  ...f && { password: f },
28
- ...U !== void 0 && { disableAutoFetch: U },
29
- ...k !== void 0 && { disableStream: k },
30
- ...x !== void 0 && { rangeChunkSize: x },
31
- ...c && { wasmUrl: c },
32
- verbosity: A.VerbosityLevel.ERRORS
32
+ ...V !== void 0 && { disableAutoFetch: V },
33
+ ...y !== void 0 && { disableStream: y },
34
+ ...A !== void 0 && { rangeChunkSize: A },
35
+ ...P && { wasmUrl: P },
36
+ verbosity: k.VerbosityLevel.ERRORS
33
37
  };
34
38
  try {
35
- const r = A.getDocument(_);
39
+ const r = k.getDocument(S);
36
40
  r.onProgress = (e) => {
37
- if (n === u.current) {
38
- const { loaded: O, total: m } = e, b = m ? Math.min(100, Math.round(O / m * 100)) : 0;
39
- p(b);
41
+ if (i === d.current) {
42
+ const { loaded: I, total: m } = e, v = m ? Math.min(100, Math.round(I / m * 100)) : 0;
43
+ g(v);
40
44
  }
41
- }, y(!0), P(void 0);
42
- const s = r.promise.then((e) => (n === u.current && (P(e), p(100)), I && I(e), D(!1), E(""), e)).catch((e) => {
43
- e instanceof Error && e.name === "PasswordException" ? (D(!0), E(e.message || "Password required")) : e instanceof Error && e.name === "InvalidPDFException" && f ? (D(!0), E("Incorrect password")) : e instanceof Error && e.name === "InvalidPDFException" ? (l(T.INVALID_OR_CORRUPTED_PDF), o == null || o(F(e))) : o && o(e);
45
+ }, U(!0), c(void 0);
46
+ const s = r.promise.then((e) => (i === d.current && (c(e), g(100)), _ && _(e), D(!1), E(""), e)).catch((e) => {
47
+ e instanceof Error && e.name === "PasswordException" ? (D(!0), E(e.message || "Password required")) : e instanceof Error && e.name === "InvalidPDFException" && f ? (D(!0), E("Incorrect password")) : e instanceof Error && e.name === "InvalidPDFException" ? (l(b.INVALID_OR_CORRUPTED_PDF), t == null || t(x(e))) : t && t(e);
44
48
  }).finally(() => {
45
- y(!1);
49
+ U(!1);
46
50
  });
47
51
  return () => {
48
52
  s.finally(() => {
@@ -50,44 +54,44 @@ const ee = (i, t, L = {}) => {
50
54
  });
51
55
  };
52
56
  } catch (r) {
53
- l(T.NOT_SUPPORTED), o && o(r);
57
+ l(b.NOT_SUPPORTED), t == null || t(J(r));
54
58
  }
55
- }, [i, S, c, f, o, I]), C(() => {
59
+ }, [n, C, P, f, t, _]), T(() => {
56
60
  if (R)
57
61
  return;
58
- const n = /* @__PURE__ */ new Map();
62
+ const i = /* @__PURE__ */ new Map();
59
63
  if (!a || w) {
60
- V(n);
64
+ N(i);
61
65
  return;
62
66
  }
63
- const _ = a.numPages, r = [];
64
- for (let s = 1; s <= _; s++) {
67
+ const S = a.numPages, r = [];
68
+ for (let s = 1; s <= S; s++) {
65
69
  const e = a.getPage(s);
66
70
  r.push(e);
67
71
  }
68
72
  Promise.all(r).then((s) => {
69
73
  s.map((e) => {
70
- const { thumbnailViewport: O, scale: m } = z(e), b = e.getViewport();
71
- n.set(e.pageNumber, {
74
+ const { thumbnailViewport: I, scale: m } = G(e), v = e.getViewport();
75
+ i.set(e.pageNumber, {
72
76
  page: e,
73
- thumbnailViewport: O,
77
+ thumbnailViewport: I,
74
78
  thumbnailScale: m,
75
- defaultRotation: b.rotation
79
+ defaultRotation: v.rotation
76
80
  });
77
- }), V(n);
81
+ }), N(i);
78
82
  }).catch((s) => {
79
- P(void 0), l(T.INVALID_OR_CORRUPTED_PDF), o == null || o(F(s));
83
+ c(void 0), l(b.INVALID_OR_CORRUPTED_PDF), t == null || t(x(s));
80
84
  });
81
- }, [a, w, R, o]), {
85
+ }, [a, w, R, t]), {
82
86
  pdf: a,
83
- pages: N,
87
+ pages: h,
84
88
  loading: w,
85
- error: h,
86
- loadingProgress: g,
89
+ error: L,
90
+ loadingProgress: p,
87
91
  passwordRequired: R,
88
92
  passwordError: q
89
93
  };
90
94
  };
91
95
  export {
92
- ee as useLoadPdf
96
+ te as useLoadPdf
93
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.4.0-beta.4",
3
+ "version": "2.4.0-beta.5",
4
4
  "private": false,
5
5
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
6
6
  "keywords": [