@pdf-viewer/react 1.14.0-rc.0 → 1.15.0-beta.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.
@@ -1,17 +1,17 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
- import { useMemo as P, useEffect as h } from "react";
3
- import { DocumentProvider as v } from "../contexts/RPDocumentContext.js";
4
- import { DocumentPasswordProvider as u } from "../contexts/DocumentPasswordContext.js";
5
- import { RPController as S } from "./RPController.js";
6
- import { LoaderProvider as C } from "../contexts/LoaderContext.js";
7
- import { ToolComponentProvider as g } from "../contexts/ToolComponentContext.js";
8
- import { IconToolProvider as L } from "../contexts/IconToolContext.js";
9
- import { OtherToolProvider as T } from "../contexts/OtherToolContext.js";
10
- import { useFlickerSelectText as b } from "../utils/hooks/useFlickerSelectText.js";
11
- import { EventCallbackProvider as j } from "../contexts/EventCallbackContext.js";
12
- import { combinedCSS as w } from "../assets/style.js";
13
- import { injectGlobalCSS as x } from "../libInjectCss.js";
14
- import { injectPrintCSS as y } from "../utils/injectPrintCSS.js";
2
+ import { useMemo as v, useEffect as S } from "react";
3
+ import { DocumentProvider as C } from "../contexts/RPDocumentContext.js";
4
+ import { DocumentPasswordProvider as g } from "../contexts/DocumentPasswordContext.js";
5
+ import { RPController as b } from "./RPController.js";
6
+ import { LoaderProvider as L } from "../contexts/LoaderContext.js";
7
+ import { ToolComponentProvider as T } from "../contexts/ToolComponentContext.js";
8
+ import { IconToolProvider as j } from "../contexts/IconToolContext.js";
9
+ import { OtherToolProvider as k } from "../contexts/OtherToolContext.js";
10
+ import { useFlickerSelectText as w } from "../utils/hooks/useFlickerSelectText.js";
11
+ import { EventCallbackProvider as x } from "../contexts/EventCallbackContext.js";
12
+ import { combinedCSS as y } from "../assets/style.js";
13
+ import { injectGlobalCSS as D } from "../libInjectCss.js";
14
+ import { injectPrintCSS as E } from "../utils/injectPrintCSS.js";
15
15
  import "../utils/hooks/useLoadPdf.js";
16
16
  import "pdfjs-dist";
17
17
  import "../utils/types.js";
@@ -139,7 +139,7 @@ import "../utils/zoom.js";
139
139
  import "./icons/SearchIcon.js";
140
140
  import "./icons/ClearIcon.js";
141
141
  import "../utils/hooks/useWatermark.js";
142
- const ct = (i) => {
142
+ const at = (i) => {
143
143
  const {
144
144
  children: m,
145
145
  src: o,
@@ -148,26 +148,32 @@ const ct = (i) => {
148
148
  onLoadError: n,
149
149
  loaderImage: c,
150
150
  onLoadProgress: d,
151
- onPageChange: l,
152
- onRotate: a,
153
- onScroll: f,
154
- ...s
155
- } = i, t = P(() => typeof o == "string" ? o : `${Date.now()}`, [o]);
156
- return b(), h(() => {
157
- x(w, "rp-viewer-styles"), y();
158
- }, []), /* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(
159
- v,
151
+ disableAutoFetch: l,
152
+ disableStream: a,
153
+ rangeChunkSize: s,
154
+ onPageChange: f,
155
+ onRotate: P,
156
+ onScroll: h,
157
+ ...u
158
+ } = i, t = v(() => typeof o == "string" ? o : `${Date.now()}`, [o]);
159
+ return w(), S(() => {
160
+ D(y, "rp-viewer-styles"), E();
161
+ }, []), /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(
162
+ C,
160
163
  {
161
164
  src: o,
162
165
  characterMap: p,
163
166
  onLoaded: e,
164
167
  onLoadError: n,
165
168
  onLoadProgress: d,
166
- children: /* @__PURE__ */ r(j, { onPageChange: l, onRotate: a, onScroll: f, children: /* @__PURE__ */ r(S, { ...s, children: /* @__PURE__ */ r(C, { loaderImage: c, children: /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(L, { children: /* @__PURE__ */ r(T, { children: m }) }) }) }, t) }, t) })
169
+ disableAutoFetch: l,
170
+ disableStream: a,
171
+ rangeChunkSize: s,
172
+ children: /* @__PURE__ */ r(x, { onPageChange: f, onRotate: P, onScroll: h, children: /* @__PURE__ */ r(b, { ...u, children: /* @__PURE__ */ r(L, { loaderImage: c, children: /* @__PURE__ */ r(T, { children: /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(k, { children: m }) }) }) }, t) }, t) })
167
173
  },
168
174
  t
169
175
  ) });
170
176
  };
171
177
  export {
172
- ct as RPProvider
178
+ at as RPProvider
173
179
  };
@@ -1,8 +1,8 @@
1
- import { jsx as h } from "react/jsx-runtime";
2
- import { createContext as v, useState as l, useEffect as S, useMemo as D, useContext as F } from "react";
3
- import { useLoadPdf as M } from "../utils/hooks/useLoadPdf.js";
4
- import { usePdfProperties as j } from "../utils/hooks/usePdfProperties.js";
5
- import { appConsole as k } from "../utils/appConsole.js";
1
+ import { jsx as F } from "react/jsx-runtime";
2
+ import { createContext as M, useState as l, useEffect as j, useMemo as k, useContext as w } from "react";
3
+ import { useLoadPdf as E } from "../utils/hooks/useLoadPdf.js";
4
+ import { usePdfProperties as L } from "../utils/hooks/usePdfProperties.js";
5
+ import { appConsole as R } from "../utils/appConsole.js";
6
6
  import "pdfjs-dist";
7
7
  import "../utils/types.js";
8
8
  import "../th_TH-d627cd51.js";
@@ -11,7 +11,7 @@ import "./ConfigContext.js";
11
11
  import "./DocumentPasswordContext.js";
12
12
  import "../utils/convertPdfDate.js";
13
13
  import "../utils/formatFileSize.js";
14
- const u = v({
14
+ const u = M({
15
15
  pdf: void 0,
16
16
  pages: /* @__PURE__ */ new Map(),
17
17
  setPdfSrc: () => {
@@ -21,23 +21,31 @@ const u = v({
21
21
  loading: !1,
22
22
  loaderProgress: 0,
23
23
  error: void 0
24
- }), J = ({
24
+ }), Q = ({
25
25
  children: t,
26
26
  src: e,
27
27
  characterMap: c,
28
28
  onLoadError: P,
29
29
  onLoaded: g,
30
- onLoadProgress: x
30
+ onLoadProgress: x,
31
+ disableAutoFetch: C,
32
+ disableStream: h,
33
+ rangeChunkSize: v,
34
+ loaderImage: S
31
35
  }) => {
32
- const [o, n] = l(e), [i, s] = l(), { pdf: r, pages: p, loading: m, loadingProgress: d, error: f } = M(o, c, {
36
+ const [o, n] = l(e), [i, s] = l(), { pdf: r, pages: p, loading: m, loadingProgress: d, error: f } = E(o, c, {
33
37
  onLoadError: P,
34
38
  onLoaded: g,
35
- onLoadProgress: x
36
- }), a = j(o, r, i);
37
- S(() => {
39
+ onLoadProgress: x,
40
+ disableAutoFetch: C,
41
+ disableStream: h,
42
+ rangeChunkSize: v,
43
+ loaderImage: S
44
+ }), a = L(o, r, i);
45
+ j(() => {
38
46
  s(e == null ? void 0 : e.split("/").pop()), n(e);
39
47
  }, [e]);
40
- const C = D(() => ({
48
+ const D = k(() => ({
41
49
  pdf: r,
42
50
  pages: p,
43
51
  pdfSrc: o,
@@ -49,13 +57,13 @@ const u = v({
49
57
  loaderProgress: d,
50
58
  error: f
51
59
  }), [r, p, o, a, m, d, f]);
52
- return /* @__PURE__ */ h(u.Provider, { value: C, children: o ? t : null });
53
- }, K = () => {
54
- const t = F(u);
55
- return t.pdfSrc || k.error("Please use this hooks inside children component of RPDocument"), t;
60
+ return /* @__PURE__ */ F(u.Provider, { value: D, children: o ? t : null });
61
+ }, T = () => {
62
+ const t = w(u);
63
+ return t.pdfSrc || R.error("Please use this hooks inside children component of RPDocument"), t;
56
64
  };
57
65
  export {
58
- J as DocumentProvider,
66
+ Q as DocumentProvider,
59
67
  u as default,
60
- K as useDocumentContext
68
+ T as useDocumentContext
61
69
  };
@@ -641,6 +641,9 @@ export interface LoadPDFOptions {
641
641
  onLoaded?: (pdfDocument: PDFDocumentProxy) => void;
642
642
  onLoadProgress?: (progress: number) => void;
643
643
  loaderImage?: LoaderImage;
644
+ disableAutoFetch?: boolean;
645
+ disableStream?: boolean;
646
+ rangeChunkSize?: number;
644
647
  }
645
648
  export interface ScrollPosition {
646
649
  left: number;
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-12-09T09:10:54.668Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-12-12T03:35:49.089Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,
@@ -1,39 +1,42 @@
1
- import { useState as a, useRef as O, useEffect as T } from "react";
2
- import * as C from "pdfjs-dist";
3
- import { ErrorType as U } from "../types.js";
4
- import { getThumbnailViewport as h } from "../getThumbnailViewport.js";
5
- import { useConfigContext as j } from "../../contexts/ConfigContext.js";
6
- import { useDocumentPasswordContext as A } from "../../contexts/DocumentPasswordContext.js";
1
+ import { useState as d, useRef as A, useEffect as k } from "react";
2
+ import * as I from "pdfjs-dist";
3
+ import { ErrorType as F } from "../types.js";
4
+ import { getThumbnailViewport as j } from "../getThumbnailViewport.js";
5
+ import { useConfigContext as z } from "../../contexts/ConfigContext.js";
6
+ import { useDocumentPasswordContext as _ } from "../../contexts/DocumentPasswordContext.js";
7
7
  import "../../th_TH-d627cd51.js";
8
8
  import "react/jsx-runtime";
9
9
  import "../appConsole.js";
10
- const Q = (l, s, I = {}) => {
11
- const [n, S] = a(), { workerUrlAdded: k } = j(), [q, x] = a(/* @__PURE__ */ new Map()), d = O(), [m, P] = a(0), [g, V] = a(!1), [v, D] = a(), { password: u, passwordError: N, setPasswordError: c, passwordRequired: p, setPasswordRequired: w } = A(), { onLoadError: i, onLoaded: E, onLoadProgress: R } = I;
12
- return T(() => {
13
- R && R(m);
14
- }, [m, R]), T(() => {
15
- if (!k || !l)
10
+ const Y = (m, s, h = {}) => {
11
+ const [n, q] = d(), { workerUrlAdded: v } = z(), [D, S] = d(/* @__PURE__ */ new Map()), a = A(), [f, g] = d(0), [P, T] = d(!1), [N, O] = d(), { password: u, passwordError: U, setPasswordError: c, passwordRequired: p, setPasswordRequired: w } = _(), { onLoadError: i, onLoaded: E, onLoadProgress: b, disableAutoFetch: x, disableStream: C, rangeChunkSize: V } = h;
12
+ return k(() => {
13
+ b && b(f);
14
+ }, [f, b]), k(() => {
15
+ if (!v || !m)
16
16
  return;
17
- P(0), d.current = Date.now();
18
- const r = d.current, b = {
19
- url: l,
17
+ g(0), a.current = Date.now();
18
+ const r = a.current, R = {
19
+ url: m,
20
20
  cMapPacked: (s == null ? void 0 : s.isCompressed) ?? !0,
21
21
  ...(s == null ? void 0 : s.url) && { cMapUrl: s.url },
22
22
  ...u && { password: u },
23
- verbosity: C.VerbosityLevel.ERRORS
23
+ ...x !== void 0 && { disableAutoFetch: x },
24
+ ...C !== void 0 && { disableStream: C },
25
+ ...V !== void 0 && { rangeChunkSize: V },
26
+ verbosity: I.VerbosityLevel.ERRORS
24
27
  };
25
28
  try {
26
- const e = C.getDocument(b);
29
+ const e = I.getDocument(R);
27
30
  e.onProgress = (o) => {
28
- if (r === d.current) {
29
- const { loaded: y, total: f } = o, L = f ? Math.min(100, Math.round(y / f * 100)) : 0;
30
- P(L);
31
+ if (r === a.current) {
32
+ const { loaded: y, total: l } = o, L = l ? Math.min(100, Math.round(y / l * 100)) : 0;
33
+ g(L);
31
34
  }
32
- }, V(!0);
33
- const t = e.promise.then((o) => (r === d.current && (S(o), P(100)), E && E(o), w(!1), c(""), o)).catch((o) => {
35
+ }, T(!0);
36
+ const t = e.promise.then((o) => (r === a.current && (q(o), g(100)), E && E(o), w(!1), c(""), o)).catch((o) => {
34
37
  o instanceof Error && o.name === "PasswordException" ? (w(!0), c(o.message || "Password required")) : o instanceof Error && o.name === "InvalidPDFException" && u ? (w(!0), c("Incorrect password")) : i && i(o);
35
38
  }).finally(() => {
36
- V(!1);
39
+ T(!1);
37
40
  });
38
41
  return () => {
39
42
  t.finally(() => {
@@ -41,42 +44,42 @@ const Q = (l, s, I = {}) => {
41
44
  });
42
45
  };
43
46
  } catch (e) {
44
- D(U.NOT_SUPPORTED), i && i(e);
47
+ O(F.NOT_SUPPORTED), i && i(e);
45
48
  }
46
- }, [l, k, u, i, E]), T(() => {
49
+ }, [m, v, u, i, E]), k(() => {
47
50
  if (p)
48
51
  return;
49
52
  const r = /* @__PURE__ */ new Map();
50
- if (!n || g) {
51
- x(r);
53
+ if (!n || P) {
54
+ S(r);
52
55
  return;
53
56
  }
54
- const b = n.numPages, e = [];
55
- for (let t = 1; t <= b; t++) {
57
+ const R = n.numPages, e = [];
58
+ for (let t = 1; t <= R; t++) {
56
59
  const o = n.getPage(t);
57
60
  e.push(o);
58
61
  }
59
62
  Promise.all(e).then((t) => {
60
63
  t.map((o) => {
61
- const { thumbnailViewport: y, scale: f } = h(o), L = o.getViewport();
64
+ const { thumbnailViewport: y, scale: l } = j(o), L = o.getViewport();
62
65
  r.set(o.pageNumber, {
63
66
  page: o,
64
67
  thumbnailViewport: y,
65
- thumbnailScale: f,
68
+ thumbnailScale: l,
66
69
  defaultRotation: L.rotation
67
70
  });
68
- }), x(r);
71
+ }), S(r);
69
72
  });
70
- }, [n, g, p]), {
73
+ }, [n, P, p]), {
71
74
  pdf: n,
72
- pages: q,
73
- loading: g,
74
- error: v,
75
- loadingProgress: m,
75
+ pages: D,
76
+ loading: P,
77
+ error: N,
78
+ loadingProgress: f,
76
79
  passwordRequired: p,
77
- passwordError: N
80
+ passwordError: U
78
81
  };
79
82
  };
80
83
  export {
81
- Q as useLoadPdf
84
+ Y as useLoadPdf
82
85
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
5
- "version": "1.14.0-rc.0",
5
+ "version": "1.15.0-beta.0",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",