@react-pdf-kit/viewer 2.2.0 → 2.3.0-beta.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.
Files changed (54) hide show
  1. package/dist/{Combination-479e39c6.js → Combination-17ab8af1.js} +184 -187
  2. package/dist/RPSplitter-925c8ff7.js +72 -0
  3. package/dist/assets/style.css +1 -1
  4. package/dist/assets/style.js +4 -4
  5. package/dist/components/layout/RPDefaultLayout.js +3 -3
  6. package/dist/components/layout/RPLayout.js +3 -3
  7. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  8. package/dist/components/layout/sidebar/RPSplitter.js +1 -1
  9. package/dist/components/layout/toolbar/DocumentDialog.js +52 -53
  10. package/dist/components/layout/toolbar/DocumentProperties.js +2 -2
  11. package/dist/components/layout/toolbar/FileDownloadTool.js +2 -2
  12. package/dist/components/layout/toolbar/FileUploadTool.js +2 -2
  13. package/dist/components/layout/toolbar/FullScreenTool.js +2 -2
  14. package/dist/components/layout/toolbar/MenuItem.js +2 -2
  15. package/dist/components/layout/toolbar/MenuSeparator.js +2 -2
  16. package/dist/components/layout/toolbar/MostPageTool.js +2 -2
  17. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  18. package/dist/components/layout/toolbar/PrintTool.js +2 -2
  19. package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
  20. package/dist/components/layout/toolbar/RPMoreOptions.js +2 -2
  21. package/dist/components/layout/toolbar/RPToolbar.js +2 -2
  22. package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -2
  23. package/dist/components/layout/toolbar/RotateTool.js +2 -2
  24. package/dist/components/layout/toolbar/ScrollModeTool.js +2 -2
  25. package/dist/components/layout/toolbar/SearchTool.js +2 -2
  26. package/dist/components/layout/toolbar/SelectionModeTool.js +2 -2
  27. package/dist/components/layout/toolbar/ToolbarCustom.js +1 -1
  28. package/dist/components/layout/toolbar/ToolbarDefault.js +3 -3
  29. package/dist/components/layout/toolbar/ToolbarLayout.js +3 -3
  30. package/dist/components/layout/toolbar/ViewModeTool.js +2 -2
  31. package/dist/components/layout/toolbar/ZoomTool.js +2 -2
  32. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +1 -1
  33. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +3 -3
  34. package/dist/components/layout/toolbar/tools/FirstPageTool.js +3 -3
  35. package/dist/components/layout/toolbar/tools/LastPageTool.js +3 -3
  36. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +2 -2
  37. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +2 -2
  38. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  39. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
  40. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
  41. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  42. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +2 -2
  43. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
  44. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +2 -2
  45. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +2 -2
  46. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
  47. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
  48. package/dist/components/ui/DropDown.js +2 -2
  49. package/dist/index-0b2a9a20.js +11698 -0
  50. package/dist/{index-535ad364.js → index-11f3cd64.js} +1 -1
  51. package/dist/main.js +3 -3
  52. package/dist/utils/hooks/useLicense.js +97 -75
  53. package/package.json +3 -1
  54. package/dist/RPSplitter-f6acf13b.js +0 -71
@@ -3,7 +3,7 @@ import K from "react";
3
3
  import { c as re, a as k, g as pe, f as ye, P as L, b as g, d as ae, j as Te, i as _n } from "./index-113053cf.js";
4
4
  import { jsx as s } from "react/jsx-runtime";
5
5
  import { a as ge, u as me, D as Rn } from "./index-23911b43.js";
6
- import { h as In, u as En, F as Sn, R as bn, P as Pn } from "./Combination-479e39c6.js";
6
+ import { h as In, u as En, F as Sn, R as bn, P as Pn } from "./Combination-17ab8af1.js";
7
7
  import { c as xe, A as Dn, C as yn, a as Tn, R as xn } from "./index-d0f0aa9a.js";
8
8
  function Ae(e) {
9
9
  const o = e + "CollectionProvider", [n, t] = re(o), [r, c] = n(
package/dist/main.js CHANGED
@@ -139,11 +139,11 @@ import "./components/layout/toolbar/RPToolbarEnd.js";
139
139
  import "./components/layout/toolbar/FileUploadTool.js";
140
140
  import "./components/icons/FileUploadDefaultIcon.js";
141
141
  import "./components/layout/toolbar/MenuItem.js";
142
- import "./index-535ad364.js";
142
+ import "./index-11f3cd64.js";
143
143
  import "./index-113053cf.js";
144
144
  import "react-dom";
145
145
  import "./index-23911b43.js";
146
- import "./Combination-479e39c6.js";
146
+ import "./Combination-17ab8af1.js";
147
147
  import "./index-d0f0aa9a.js";
148
148
  import "./index-ada501c4.js";
149
149
  import "./components/layout/toolbar/DarkModeTool.js";
@@ -193,7 +193,7 @@ import "./utils/zoom.js";
193
193
  import "./components/ui/LoadingIndicator.js";
194
194
  import "./components/layout/sidebar/RPSidebar.js";
195
195
  import "./components/icons/Thumbnail.js";
196
- import "./RPSplitter-f6acf13b.js";
196
+ import "./RPSplitter-925c8ff7.js";
197
197
  import "./components/layout/sidebar/Thumbnails.js";
198
198
  import "./components/layout/sidebar/Thumbnail.js";
199
199
  import "./utils/hooks/useInfiniteScroll.js";
@@ -1,29 +1,8 @@
1
- import { useState as h, useCallback as E, useEffect as A } from "react";
2
- import { LicenseType as b } from "../types.js";
1
+ import { useState as E, useCallback as y, useEffect as b } from "react";
2
+ import { LicenseType as L } from "../types.js";
3
3
  import { appConsole as c } from "../appConsole.js";
4
4
  import "../../de_DE-a553b162.js";
5
- const y = /* @__PURE__ */ new Date("2026-03-25T12:17:37.740Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
6
- invalidLicense: `You are currently using without a valid license. ${d}`,
7
- mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
8
- expired: `Your license key has expired. ${d}`,
9
- exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
10
- invalidSignature: "Invalid license key: Signature mismatch"
11
- };
12
- function L(n) {
13
- const t = n.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), r = new Uint8Array(e.length);
14
- for (let i = 0; i < e.length; i++)
15
- r[i] = e.charCodeAt(i);
16
- return r.buffer;
17
- }
18
- function S(n) {
19
- const t = atob(n), e = new Uint8Array(t.length);
20
- for (let r = 0; r < t.length; r++)
21
- e[r] = t.charCodeAt(r);
22
- return e.buffer;
23
- }
24
- async function I(n, t = "SHA-256") {
25
- try {
26
- const { data: e, signature: r } = JSON.parse(atob(n)), i = L(`-----BEGIN PUBLIC KEY-----
5
+ const A = /* @__PURE__ */ new Date("2026-03-26T04:34:25.350Z"), w = `-----BEGIN PUBLIC KEY-----
27
6
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
28
7
  gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
29
8
  HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
@@ -31,88 +10,131 @@ Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
31
10
  vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
32
11
  vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
33
12
  kwIDAQAB
34
- -----END PUBLIC KEY-----`), s = await window.crypto.subtle.importKey(
35
- "spki",
36
- // str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
37
- i,
38
- { name: "RSA-PSS", hash: t },
39
- !0,
40
- ["verify"]
41
- ), a = await window.crypto.subtle.verify(
42
- { name: "RSA-PSS", saltLength: 32 },
43
- s,
44
- S(r),
45
- // Convert signature to ArrayBuffer
46
- new TextEncoder().encode(atob(e))
47
- );
48
- if (c.debug(">>> Verified license key validity", a), !a)
13
+ -----END PUBLIC KEY-----`, f = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
14
+ invalidLicense: `You are currently using without a valid license. ${f}`,
15
+ mismatchedDomain: `Your license key is not valid for the current domain / IP. ${f}`,
16
+ expired: `Your license key has expired. ${f}`,
17
+ exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
18
+ invalidSignature: "Invalid license key: Signature mismatch"
19
+ };
20
+ function S(a) {
21
+ const i = a.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(i), t = new Uint8Array(e.length);
22
+ for (let r = 0; r < e.length; r++)
23
+ t[r] = e.charCodeAt(r);
24
+ return t.buffer;
25
+ }
26
+ function I(a) {
27
+ const i = atob(a), e = new Uint8Array(i.length);
28
+ for (let t = 0; t < i.length; t++)
29
+ e[t] = i.charCodeAt(t);
30
+ return e.buffer;
31
+ }
32
+ async function T(a) {
33
+ try {
34
+ const i = await import("../../index-0b2a9a20.js").then((u) => u.i), e = (i == null ? void 0 : i.default) ?? i, t = e.pki.publicKeyFromPem(w), r = atob(a.data), n = e.util.decode64(a.signature), s = e.md.sha256.create();
35
+ s.update(r, "utf8");
36
+ const d = e.pss.create({
37
+ md: e.md.sha256.create(),
38
+ mgf: e.mgf.mgf1.create(e.md.sha256.create()),
39
+ saltLength: 32
40
+ });
41
+ return t.verify(s.digest().bytes(), n, d);
42
+ } catch (i) {
43
+ return c.debug("[License] node-forge verify failed:", i), !1;
44
+ }
45
+ }
46
+ async function B(a, i = "SHA-256") {
47
+ var e;
48
+ try {
49
+ const t = JSON.parse(atob(a));
50
+ let r = !1;
51
+ try {
52
+ if ((e = window.crypto) != null && e.subtle) {
53
+ const n = S(w), s = await window.crypto.subtle.importKey(
54
+ "spki",
55
+ n,
56
+ { name: "RSA-PSS", hash: i },
57
+ !0,
58
+ ["verify"]
59
+ );
60
+ r = await window.crypto.subtle.verify(
61
+ { name: "RSA-PSS", saltLength: 32 },
62
+ s,
63
+ I(t.signature),
64
+ new TextEncoder().encode(atob(t.data))
65
+ );
66
+ }
67
+ } catch (n) {
68
+ c.debug("[License] crypto.subtle verify failed, trying node-forge fallback:", n);
69
+ }
70
+ if (r || (r = await T(t)), !r)
49
71
  throw new Error(o.invalidSignature);
50
- return JSON.parse(atob(e));
51
- } catch {
52
- throw new Error(o.invalidLicense);
72
+ return JSON.parse(atob(t.data));
73
+ } catch (t) {
74
+ throw t instanceof Error && t.message === o.invalidSignature ? t : new Error(o.invalidLicense);
53
75
  }
54
76
  }
55
- const T = (n, t) => {
56
- switch (n) {
77
+ const N = (a, i) => {
78
+ switch (a) {
57
79
  case "specific":
58
- return t === window.location.host;
80
+ return i === window.location.host;
59
81
  case "wildcard":
60
- return t ? window.location.host.includes(t) : !1;
82
+ return i ? window.location.host.includes(i) : !1;
61
83
  }
62
- }, u = {
84
+ }, m = {
63
85
  isValid: !0,
64
86
  invalidatedMessage: o.invalidLicense,
65
87
  type: void 0
66
- }, V = (n) => {
67
- const [t, e] = h(u), r = E(async () => {
68
- if (e((l) => ({ ...l, validating: !0 })), !n)
69
- throw e({ ...u, validating: !1 }), new Error(o.invalidLicense);
70
- let i;
88
+ }, V = (a) => {
89
+ const [i, e] = E(m), t = y(async () => {
90
+ if (e((l) => ({ ...l, validating: !0 })), !a)
91
+ throw e({ ...m, validating: !1 }), new Error(o.invalidLicense);
92
+ let r;
71
93
  try {
72
- i = await I(n);
94
+ r = await B(a);
73
95
  } catch (l) {
74
96
  throw c.warn(l.message), new Error(l.message);
75
97
  }
76
- c.debug(">>> validatedLicense", i);
77
- const { avu: s, exp: a, dmt: v, dm: w, t: f } = i;
78
- if (!a)
98
+ c.debug(">>> validatedLicense", r);
99
+ const { avu: n, exp: s, dmt: d, dm: u, t: g } = r;
100
+ if (!s)
79
101
  throw new Error("License is missing expiration timestamp");
80
- if (a > Number.MAX_SAFE_INTEGER / 1e3)
102
+ if (s > Number.MAX_SAFE_INTEGER / 1e3)
81
103
  throw new Error("Invalid expiration timestamp: value too large");
82
- const p = new Date(a * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
83
- if (p.getTime() < g)
104
+ const v = new Date(s * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
105
+ if (v.getTime() < h)
84
106
  throw new Error(o.expired);
85
- if (!s)
107
+ if (!n)
86
108
  throw new Error("License is missing available until version timestamp");
87
- if (s > Number.MAX_SAFE_INTEGER / 1e3)
109
+ if (n > Number.MAX_SAFE_INTEGER / 1e3)
88
110
  throw new Error("Invalid available until version timestamp: value too large");
89
- const m = new Date(s * 1e3);
90
- if (c.debug("availableUntilTimestamp", m), m.getTime() < y.getTime())
111
+ const p = new Date(n * 1e3);
112
+ if (c.debug("availableUntilTimestamp", p), p.getTime() < A.getTime())
91
113
  throw new Error(o.exceededVersion);
92
- if (f !== b.Custom && !T(v, w))
114
+ if (g !== L.Custom && !N(d, u))
93
115
  throw new Error(o.mismatchedDomain);
94
116
  return {
95
117
  isValid: !0,
96
- type: f,
118
+ type: g,
97
119
  invalidatedMessage: void 0
98
120
  };
99
- }, [n]);
100
- return A(() => {
101
- r().then(({ isValid: i, type: s, invalidatedMessage: a }) => {
121
+ }, [a]);
122
+ return b(() => {
123
+ t().then(({ isValid: r, type: n, invalidatedMessage: s }) => {
102
124
  e({
103
- isValid: i,
104
- type: s,
105
- invalidatedMessage: a,
125
+ isValid: r,
126
+ type: n,
127
+ invalidatedMessage: s,
106
128
  validating: !1
107
129
  });
108
- }).catch((i) => {
130
+ }).catch((r) => {
109
131
  e({
110
- ...u,
132
+ ...m,
111
133
  isValid: !1,
112
134
  validating: !1
113
- }), c.warn(i.message);
135
+ }), c.warn(r.message);
114
136
  });
115
- }, [r]), t;
137
+ }, [t]), i;
116
138
  };
117
139
  export {
118
140
  V as useLicense
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.2.0",
3
+ "version": "2.3.0-beta.1",
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": [
@@ -40,6 +40,7 @@
40
40
  "@radix-ui/react-checkbox": "^1.3.3",
41
41
  "@radix-ui/react-popover": "^1.1.15",
42
42
  "@radix-ui/react-tooltip": "^1.2.8",
43
+ "node-forge": "^1.3.3",
43
44
  "pdfjs-dist": "5.4.530",
44
45
  "react-virtualized-auto-sizer": "^1.0.24",
45
46
  "react-window": "^1.8.10"
@@ -50,6 +51,7 @@
50
51
  "@radix-ui/react-dropdown-menu": "^2.1.2",
51
52
  "@rollup/plugin-commonjs": "^28.0.1",
52
53
  "@tanstack/eslint-plugin-query": "^5.60.1",
54
+ "@types/node-forge": "^1.3.14",
53
55
  "@types/react": "^18.2.14",
54
56
  "@types/react-dom": "^18.2.6",
55
57
  "@types/react-window": "^1.8.8",
@@ -1,71 +0,0 @@
1
- import { jsx as N } from "react/jsx-runtime";
2
- import { useRef as _, useState as T, useCallback as w, useEffect as f } from "react";
3
- import { THUMBNAIL_MIN_WIDTH as v } from "./utils/constants.js";
4
- import { useLayoutContainer as A } from "./contexts/LayoutContainerContext.js";
5
- const P = {
6
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_ppg43_1",
7
- "rp-sidebar-content": "_rp-sidebar-content_ppg43_1",
8
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_ppg43_17",
9
- "rp-thumbnails-wrapper-dragging": "_rp-thumbnails-wrapper-dragging_ppg43_24",
10
- "rp-thumbnails-wrapper-hidden": "_rp-thumbnails-wrapper-hidden_ppg43_28"
11
- }, L = {
12
- "rp-thumbnail-dragger": "_rp-thumbnail-dragger_17ndw_2",
13
- "rp-thumbnail-dragger-dragging": "_rp-thumbnail-dragger-dragging_17ndw_12"
14
- }, R = {
15
- "rp-thumbnail-dragger": "_rp-thumbnail-dragger_8o6id_1",
16
- "rp-thumbnail-dragger-dragging": "_rp-thumbnail-dragger-dragging_8o6id_14"
17
- }, W = (p) => {
18
- p.preventDefault(), p.stopPropagation();
19
- }, k = (p) => {
20
- const { onWidthChange: e, thumbnailRef: S, leftSidebarRef: x, isRPLayout: y } = p, n = _(null), E = _(0), o = _(null), [a, B] = T(v), { container: m } = A(), I = w((t) => {
21
- var c, u, l, s, d, g, M, D;
22
- W(t);
23
- const r = ((u = (c = n.current) == null ? void 0 : c.getBoundingClientRect()) == null ? void 0 : u.left) ?? 0, i = ((s = (l = S.current) == null ? void 0 : l.getBoundingClientRect()) == null ? void 0 : s.width) ?? 0;
24
- o.current = { x: r, y: 0 }, E.current = i, (d = n.current) == null || d.classList.add(L["rp-thumbnail-dragger-dragging"]), (g = n.current) == null || g.classList.add(R["rp-thumbnail-dragger-dragging"]), (D = (M = n.current) == null ? void 0 : M.closest('[data-rp="thumbnailSidebar"]')) == null || D.classList.add(
25
- P["rp-thumbnails-wrapper"],
26
- P["rp-thumbnails-wrapper-dragging"]
27
- );
28
- }, []), h = w((t) => {
29
- var r, i;
30
- W(t), o.current = null, (r = n.current) == null || r.classList.remove(L["rp-thumbnail-dragger-dragging"]), (i = n.current) == null || i.classList.remove(R["rp-thumbnail-dragger-dragging"]);
31
- }, []), b = w(
32
- (t) => {
33
- if (!o.current)
34
- return;
35
- const r = t.clientX - o.current.x, i = Math.max(
36
- v,
37
- Math.min(E.current + r, a)
38
- );
39
- e == null || e(i), W(t);
40
- },
41
- [e, a]
42
- );
43
- return f(() => {
44
- if (!m)
45
- return;
46
- const t = new ResizeObserver(([r]) => {
47
- var s, d, g;
48
- const i = ((s = n.current) == null ? void 0 : s.offsetWidth) ?? 0, c = ((g = (d = x.current) == null ? void 0 : d.getBoundingClientRect()) == null ? void 0 : g.width) ?? 0, u = r.contentRect.width / 2, l = i + c;
49
- B(u - l);
50
- });
51
- return t.observe(m), () => {
52
- t.disconnect();
53
- };
54
- }, [m, x]), f(() => {
55
- var r;
56
- (((r = S.current) == null ? void 0 : r.clientWidth) ?? v) > a && (e == null || e(a));
57
- }, [a, e]), f(() => (window.addEventListener("pointermove", b), window.addEventListener("pointerup", h), () => {
58
- window.removeEventListener("pointermove", b), window.removeEventListener("pointerup", h);
59
- }), [b, h]), /* @__PURE__ */ N(
60
- "div",
61
- {
62
- ref: n,
63
- className: y ? R["rp-thumbnail-dragger"] : L["rp-thumbnail-dragger"],
64
- onPointerDown: I
65
- }
66
- );
67
- };
68
- export {
69
- k as R,
70
- P as c
71
- };