@pdf-viewer/react 0.9.0-beta.1 → 0.9.0-beta.2

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 (52) hide show
  1. package/dist/{RPDefaultLayout-6a828c29.js → RPDefaultLayout-3d9595ed.js} +16 -17
  2. package/dist/components/RPController.js +1 -1
  3. package/dist/components/RPPages.js +1 -1
  4. package/dist/components/RPProvider.js +1 -1
  5. package/dist/components/layout/RPDefaultLayout.js +1 -1
  6. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  7. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  8. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  9. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  10. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  11. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  12. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  13. package/dist/components/layout/toolbar/MostPageTool.js +2 -2
  14. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  15. package/dist/components/layout/toolbar/Paginate.js +1 -1
  16. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  17. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  18. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  19. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  20. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  21. package/dist/components/layout/toolbar/SearchTool.js +1 -1
  22. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  23. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  24. package/dist/components/layout/toolbar/ZoomTool.js +2 -2
  25. package/dist/components/page/AnnotationLayer.js +1 -1
  26. package/dist/components/page/CanvasLayer.js +1 -1
  27. package/dist/components/page/DualPage.js +1 -1
  28. package/dist/components/page/RPPage.js +1 -1
  29. package/dist/components/page/SinglePage.js +1 -1
  30. package/dist/components/page/TextLayer.js +1 -1
  31. package/dist/components/ui/Checkbox.js +1 -1
  32. package/dist/components/ui/DropDown.js +1 -1
  33. package/dist/components/ui/LoadingIndicator.js +1 -1
  34. package/dist/components/ui/RPTooltip.js +1793 -532
  35. package/dist/contexts/PaginationContext.js +1 -1
  36. package/dist/contexts/PrintContext.js +1 -1
  37. package/dist/contexts/SearchContext.js +1 -1
  38. package/dist/contexts/ThumbnailsContext.js +1 -1
  39. package/dist/index-3459164c.js +3609 -0
  40. package/dist/{index-71898eb9.js → index-743c36f0.js} +30 -30
  41. package/dist/main.js +1 -1
  42. package/dist/utils/hooks/useFileDownload.js +1 -1
  43. package/dist/utils/hooks/useLicense.js +31 -39
  44. package/dist/utils/hooks/usePaginate.js +1 -1
  45. package/dist/utils/hooks/usePrint.js +1 -1
  46. package/dist/utils/hooks/useScrollToPage.js +1 -1
  47. package/dist/utils/hooks/useSearch.js +1 -1
  48. package/dist/utils/hooks/useThumbnail.js +1 -1
  49. package/dist/utils/hooks/useVirtualReactWindow.js +1 -1
  50. package/package.json +2 -4
  51. package/dist/floating-ui.react-dom-e6d5fe8f.js +0 -1327
  52. package/dist/index-316854c1.js +0 -2299
@@ -78,37 +78,13 @@ function y(e) {
78
78
  return (r = n.current) == null ? void 0 : r.call(n, ...t);
79
79
  }, []);
80
80
  }
81
- var g = globalThis != null && globalThis.document ? i.useLayoutEffect : () => {
82
- };
83
- function $(e) {
84
- const [n, t] = i.useState(void 0);
85
- return g(() => {
86
- if (e) {
87
- t({ width: e.offsetWidth, height: e.offsetHeight });
88
- const r = new ResizeObserver((u) => {
89
- if (!Array.isArray(u) || !u.length)
90
- return;
91
- const s = u[0];
92
- let o, c;
93
- if ("borderBoxSize" in s) {
94
- const a = s.borderBoxSize, f = Array.isArray(a) ? a[0] : a;
95
- o = f.inlineSize, c = f.blockSize;
96
- } else
97
- o = e.offsetWidth, c = e.offsetHeight;
98
- t({ width: o, height: c });
99
- });
100
- return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
101
- } else
102
- t(void 0);
103
- }, [e]), n;
104
- }
105
- function _({
81
+ function $({
106
82
  prop: e,
107
83
  defaultProp: n,
108
84
  onChange: t = () => {
109
85
  }
110
86
  }) {
111
- const [r, u] = p({ defaultProp: n, onChange: t }), s = e !== void 0, o = s ? e : r, c = y(t), a = i.useCallback(
87
+ const [r, u] = g({ defaultProp: n, onChange: t }), s = e !== void 0, o = s ? e : r, c = y(t), a = i.useCallback(
112
88
  (f) => {
113
89
  if (s) {
114
90
  const d = typeof f == "function" ? f(e) : f;
@@ -120,7 +96,7 @@ function _({
120
96
  );
121
97
  return [o, a];
122
98
  }
123
- function p({
99
+ function g({
124
100
  defaultProp: e,
125
101
  onChange: n
126
102
  }) {
@@ -129,11 +105,35 @@ function p({
129
105
  u.current !== r && (s(r), u.current = r);
130
106
  }, [r, u, s]), t;
131
107
  }
108
+ var p = globalThis != null && globalThis.document ? i.useLayoutEffect : () => {
109
+ };
110
+ function _(e) {
111
+ const [n, t] = i.useState(void 0);
112
+ return p(() => {
113
+ if (e) {
114
+ t({ width: e.offsetWidth, height: e.offsetHeight });
115
+ const r = new ResizeObserver((u) => {
116
+ if (!Array.isArray(u) || !u.length)
117
+ return;
118
+ const s = u[0];
119
+ let o, c;
120
+ if ("borderBoxSize" in s) {
121
+ const a = s.borderBoxSize, f = Array.isArray(a) ? a[0] : a;
122
+ o = f.inlineSize, c = f.blockSize;
123
+ } else
124
+ o = e.offsetWidth, c = e.offsetHeight;
125
+ t({ width: o, height: c });
126
+ });
127
+ return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
128
+ } else
129
+ t(void 0);
130
+ }, [e]), n;
131
+ }
132
132
  export {
133
- g as a,
133
+ $ as a,
134
134
  _ as b,
135
135
  E as c,
136
- $ as d,
136
+ y as d,
137
137
  m as e,
138
- y as u
138
+ p as u
139
139
  };
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RPProvider as t } from "./components/RPProvider.js";
2
- import { b as x, R as n, c as s, u as p, d as f, e as m } from "./RPDefaultLayout-6a828c29.js";
2
+ import { b as x, R as n, c as s, u as p, d as f, e as m } from "./RPDefaultLayout-3d9595ed.js";
3
3
  import { RPConfig as a } from "./components/RPConfig.js";
4
4
  import { RPController as C } from "./components/RPController.js";
5
5
  import { RPTheme as l } from "./components/RPTheme.js";
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../contexts/RPDocumentContext.js";
3
3
  import "react";
4
- import { c as v } from "../../RPDefaultLayout-6a828c29.js";
4
+ import { c as v } from "../../RPDefaultLayout-3d9595ed.js";
5
5
  import "../../contexts/DarkModeContext.js";
6
6
  import "../../contexts/RotationContext.js";
7
7
  import "../../contexts/LayerContext.js";
@@ -1,102 +1,94 @@
1
- import { useState as g, useCallback as E, useEffect as h } from "react";
1
+ import { useState as g, useCallback as h, useEffect as v } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const A = /* @__PURE__ */ new Date("2025-02-26T04:15:46.379Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
3
+ const b = /* @__PURE__ */ new Date("2025-02-26T09:00:59.002Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
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}`,
7
7
  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.",
8
8
  invalidSignature: "Invalid license key: Signature mismatch"
9
9
  };
10
- function b(r) {
11
- const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), i = atob(t), n = new Uint8Array(i.length);
12
- for (let e = 0; e < i.length; e++)
13
- n[e] = i.charCodeAt(e);
10
+ function y(r) {
11
+ const i = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), t = atob(i), n = new Uint8Array(t.length);
12
+ for (let e = 0; e < t.length; e++)
13
+ n[e] = t.charCodeAt(e);
14
14
  return n.buffer;
15
15
  }
16
- function S(r) {
17
- const t = atob(r), i = new Uint8Array(t.length);
18
- for (let n = 0; n < t.length; n++)
19
- i[n] = t.charCodeAt(n);
20
- return i.buffer;
16
+ function A(r) {
17
+ const i = atob(r), t = new Uint8Array(i.length);
18
+ for (let n = 0; n < i.length; n++)
19
+ t[n] = i.charCodeAt(n);
20
+ return t.buffer;
21
21
  }
22
- async function I(r, t = "SHA-256") {
22
+ async function I(r, i = "SHA-256") {
23
23
  try {
24
- const { data: i, signature: n } = JSON.parse(atob(r)), e = b(`-----BEGIN PUBLIC KEY-----
25
- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
26
- gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
27
- HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
28
- Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
29
- vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
30
- vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
31
- kwIDAQAB
32
- -----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
24
+ const { data: t, signature: n } = JSON.parse(atob(r)), e = y("-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyrIi83Zr5AKaWO6zbZmXqv3McVhtnPOnWCiFgf5xeaglLzEwMiXo3gALaPoBp5Q0WPOSBE9GTqwOyQUgpDNSBuQ0cjOzQdFM3GPnKSqQThZJfjUmD9egMZDmfhcpFGPybUoicoIEFQOdX2vMFUfn6yjRsyvbK6UPTombYl785V8dXNnnIHa4tQC1JSaSe/bhG3e/6kbQCy9VJ23242q9WJpx9c2sZ+bmyI0r9Zx0PfqcDJzDfKn45v96EtxGhV16OZhqkbj4ljiJ/mfqfCkxybkm9nvxz0hAwcEftQaxl/0cZ1RxtsRcL+V3msLsmGcs9nPqAuXecbfg9QVCi/+miwIDAQAB-----END PUBLIC KEY-----"), a = await window.crypto.subtle.importKey(
33
25
  "spki",
34
26
  // str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
35
27
  e,
36
- { name: "RSA-PSS", hash: t },
28
+ { name: "RSA-PSS", hash: i },
37
29
  !0,
38
30
  ["verify"]
39
31
  );
40
32
  if (!await window.crypto.subtle.verify(
41
33
  { name: "RSA-PSS", saltLength: 32 },
42
34
  a,
43
- S(n),
35
+ A(n),
44
36
  // Convert signature to ArrayBuffer
45
- new TextEncoder().encode(atob(i))
37
+ new TextEncoder().encode(atob(t))
46
38
  ))
47
39
  throw new Error(o.invalidSignature);
48
- return JSON.parse(atob(i));
40
+ return JSON.parse(atob(t));
49
41
  } catch {
50
42
  throw new Error(o.invalidLicense);
51
43
  }
52
44
  }
53
- const L = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), c = {
45
+ const L = (r, i) => r === "specific" ? i === window.location.host : window.location.host.includes(i), c = {
54
46
  isValid: !1,
55
47
  invalidatedMessage: o.invalidLicense,
56
48
  type: void 0
57
- }, N = (r) => {
58
- const [t, i] = g(c), n = E(async () => {
49
+ }, T = (r) => {
50
+ const [i, t] = g(c), n = h(async () => {
59
51
  if (!r)
60
- return i(c), c;
52
+ return t(c), c;
61
53
  try {
62
54
  const e = await I(r);
63
55
  l.debug(">>> validatedLicense", e);
64
- const { avu: a, exp: s, dmt: m, dm: p, t: v } = e;
56
+ const { avu: a, exp: s, dmt: m, dm: f, t: w } = e;
65
57
  if (!s)
66
58
  throw new Error("License is missing expiration timestamp");
67
59
  if (s > Number.MAX_SAFE_INTEGER / 1e3)
68
60
  throw new Error("Invalid expiration timestamp: value too large");
69
- const f = new Date(s * 1e3), w = (/* @__PURE__ */ new Date()).getTime();
70
- if (f.getTime() < w)
61
+ const p = new Date(s * 1e3), E = (/* @__PURE__ */ new Date()).getTime();
62
+ if (p.getTime() < E)
71
63
  throw new Error(o.expired);
72
64
  if (!a)
73
65
  throw new Error("License is missing available until version timestamp");
74
66
  if (a > Number.MAX_SAFE_INTEGER / 1e3)
75
67
  throw new Error("Invalid available until version timestamp: value too large");
76
68
  const u = new Date(a * 1e3);
77
- if (l.debug("availableUntilTimestamp", u), u.getTime() < A.getTime())
69
+ if (l.debug("availableUntilTimestamp", u), u.getTime() < b.getTime())
78
70
  throw new Error(o.exceededVersion);
79
- if (!L(m, p))
71
+ if (!L(m, f))
80
72
  throw new Error(o.mismatchedDomain);
81
73
  return {
82
74
  isValid: !0,
83
- type: v,
75
+ type: w,
84
76
  invalidatedMessage: void 0
85
77
  };
86
78
  } catch (e) {
87
79
  return l.warn(e.message), { ...c, invalidatedMessage: e.message };
88
80
  }
89
81
  }, [r]);
90
- return h(() => {
82
+ return v(() => {
91
83
  n().then(({ isValid: e, type: a, invalidatedMessage: s }) => {
92
- i({
84
+ t({
93
85
  isValid: e,
94
86
  type: a,
95
87
  invalidatedMessage: s
96
88
  });
97
89
  });
98
- }, [n]), t;
90
+ }, [n]), i;
99
91
  };
100
92
  export {
101
- N as useLicense
93
+ T as useLicense
102
94
  };
@@ -1,5 +1,5 @@
1
1
  import "react";
2
- import { g as z } from "../../RPDefaultLayout-6a828c29.js";
2
+ import { g as z } from "../../RPDefaultLayout-3d9595ed.js";
3
3
  import "../../contexts/ScrollStateContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
@@ -1,7 +1,7 @@
1
1
  import "react";
2
2
  import "react/jsx-runtime";
3
3
  import "../../contexts/RPDocumentContext.js";
4
- import { i as z } from "../../RPDefaultLayout-6a828c29.js";
4
+ import { i as z } from "../../RPDefaultLayout-3d9595ed.js";
5
5
  import "../../contexts/DarkModeContext.js";
6
6
  import "../../contexts/RotationContext.js";
7
7
  import "../../contexts/LayerContext.js";
@@ -2,7 +2,7 @@ import "react";
2
2
  import "../../contexts/ScrollModeContext.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
- import { f as y } from "../../RPDefaultLayout-6a828c29.js";
5
+ import { f as y } from "../../RPDefaultLayout-3d9595ed.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../types.js";
8
8
  import "../../contexts/RotationContext.js";
@@ -8,7 +8,7 @@ import "./usePageDimension.js";
8
8
  import "../../contexts/RPDocumentContext.js";
9
9
  import "../../contexts/ZoomContext.js";
10
10
  import "react/jsx-runtime";
11
- import { n as C } from "../../RPDefaultLayout-6a828c29.js";
11
+ import { n as C } from "../../RPDefaultLayout-3d9595ed.js";
12
12
  import "../../contexts/DarkModeContext.js";
13
13
  import "../../contexts/RotationContext.js";
14
14
  import "../../contexts/LayerContext.js";
@@ -2,7 +2,7 @@ import "react";
2
2
  import "../renderPage.js";
3
3
  import "react/jsx-runtime";
4
4
  import "../../contexts/RPDocumentContext.js";
5
- import { k as A } from "../../RPDefaultLayout-6a828c29.js";
5
+ import { k as A } from "../../RPDefaultLayout-3d9595ed.js";
6
6
  import "../../contexts/DarkModeContext.js";
7
7
  import "../../contexts/RotationContext.js";
8
8
  import "../../contexts/LayerContext.js";
@@ -3,7 +3,7 @@ import "../types.js";
3
3
  import "../../contexts/ScrollModeContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "../../contexts/RPDocumentContext.js";
6
- import { r as y } from "../../RPDefaultLayout-6a828c29.js";
6
+ import { r as y } from "../../RPDefaultLayout-3d9595ed.js";
7
7
  import "../../contexts/DarkModeContext.js";
8
8
  import "../../contexts/RotationContext.js";
9
9
  import "../../contexts/LayerContext.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
- "version": "0.9.0-beta.1",
4
+ "version": "0.9.0-beta.2",
5
5
  "keywords": [
6
6
  "component",
7
7
  "frontend",
@@ -42,9 +42,7 @@
42
42
  "prepare": "husky"
43
43
  },
44
44
  "peerDependencies": {
45
- "pdfjs-dist": "4.7.76",
46
- "react": "^18.2.0",
47
- "react-dom": "^18.2.0"
45
+ "pdfjs-dist": "4.7.76"
48
46
  },
49
47
  "dependencies": {
50
48
  "@radix-ui/react-checkbox": "^1.1.3",