@react-pdf-kit/viewer 2.5.0-beta.3 → 2.5.0-rc.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,5 +1,5 @@
1
1
  import { jsx as $ } from "react/jsx-runtime";
2
- import { createContext as j, useState as B, useRef as P, useEffect as x, useCallback as c, useContext as y, useMemo as k } from "react";
2
+ import { createContext as j, useState as B, useRef as P, useEffect as L, useCallback as s, useContext as y, useMemo as k } from "react";
3
3
  import { LicenseType as V } from "../utils/types.js";
4
4
  import { usePagesRotateContext as Z } from "./PagesRotateContext.js";
5
5
  import { useLicenseContext as z } from "./LicenseContext.js";
@@ -37,34 +37,34 @@ import "./LayoutContainerContext.js";
37
37
  import "../utils/hooks/useDebounce.js";
38
38
  import "../utils/getScrollDistance.js";
39
39
  import "../utils/calculatePage.js";
40
- const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), L = j(
40
+ const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), R = j(
41
41
  void 0
42
42
  ), Dt = ({ children: i }) => {
43
- const [a, u] = B({}), { pageRotate: r } = Z(), { thumbnailPages: m, addToPage: h, thumbnailLength: f } = J(), { scrollBehavior: R } = K(), { totalPages: w } = Q(), v = P(null), S = P(m), A = P(f), [l, C] = B(null);
44
- x(() => {
45
- S.current = m;
46
- }, [m]), x(() => {
43
+ const [a, u] = B({}), { pageRotate: r } = Z(), { thumbnailPages: c, addToPage: h, thumbnailLength: f } = J(), { scrollBehavior: v } = K(), { totalPages: w } = Q(), S = P(null), C = P(c), A = P(f), [l, x] = B(null);
44
+ L(() => {
45
+ C.current = c;
46
+ }, [c]), L(() => {
47
47
  A.current = f;
48
48
  }, [f]);
49
- const H = c((e) => {
50
- v.current = e;
51
- }, []), d = c(
49
+ const H = s((e) => {
50
+ S.current = e;
51
+ }, []), d = s(
52
52
  (e) => {
53
53
  const n = e + Y;
54
54
  return w ? Math.min(n, w) : e;
55
55
  },
56
56
  [w]
57
- ), _ = c(
57
+ ), _ = s(
58
58
  (e) => {
59
59
  const n = d(e);
60
- return !S.current[e] || A.current < n ? (h(n), !1) : !0;
60
+ return !C.current[e] || A.current < n ? (h(n), !1) : !0;
61
61
  },
62
62
  [h, d]
63
- ), G = c(
63
+ ), G = s(
64
64
  (e, n) => {
65
65
  u((o) => {
66
- var s;
67
- const t = (s = m[e]) == null ? void 0 : s.viewport, p = {
66
+ var m;
67
+ const t = (m = C.current[e]) == null ? void 0 : m.viewport, p = {
68
68
  width: t ? t.width : 0,
69
69
  height: t ? t.height : 0
70
70
  };
@@ -74,47 +74,47 @@ const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), L =
74
74
  };
75
75
  });
76
76
  },
77
- [m, r]
78
- ), O = c((e) => {
77
+ [r]
78
+ ), O = s((e) => {
79
79
  u((n) => {
80
80
  const o = { ...n };
81
81
  return delete o[e], o;
82
82
  });
83
- }, []), U = c((e, n) => {
83
+ }, []), U = s((e, n) => {
84
84
  u((o) => {
85
85
  const t = { ...o };
86
- return t[e] ? (t[e] = t[e].filter((p, s) => s !== n), t) : o;
86
+ return t[e] ? (t[e] = t[e].filter((p, m) => m !== n), t) : o;
87
87
  });
88
- }, []), T = c(
88
+ }, []), T = s(
89
89
  (e, n, o) => {
90
90
  var F;
91
- const t = v.current;
91
+ const t = S.current;
92
92
  if (!t)
93
93
  return !1;
94
94
  const p = t.querySelector(
95
95
  `[data-rp="thumbnail-${e}-customElement"]`
96
- ), s = (F = p == null ? void 0 : p.children) == null ? void 0 : F[n];
97
- if (!s)
96
+ ), m = (F = p == null ? void 0 : p.children) == null ? void 0 : F[n];
97
+ if (!m)
98
98
  return !1;
99
- const D = s.closest(`[id="page-${e}"]`) ?? s, M = t.getBoundingClientRect(), g = D.getBoundingClientRect(), N = t.scrollTop + (g.top - M.top) - (t.clientHeight - g.height) / 2, q = t.scrollLeft + (g.left - M.left) - (t.clientWidth - g.width) / 2;
99
+ const D = m.closest(`[id="page-${e}"]`) ?? m, M = t.getBoundingClientRect(), g = D.getBoundingClientRect(), N = t.scrollTop + (g.top - M.top) - (t.clientHeight - g.height) / 2, q = t.scrollLeft + (g.left - M.left) - (t.clientWidth - g.width) / 2;
100
100
  return t.scrollTo({
101
101
  top: I(N, t.scrollHeight - t.clientHeight),
102
102
  left: I(q, t.scrollWidth - t.clientWidth),
103
- behavior: (o == null ? void 0 : o.behavior) ?? R
103
+ behavior: (o == null ? void 0 : o.behavior) ?? v
104
104
  }), !0;
105
105
  },
106
- [R]
107
- ), W = c(
106
+ [v]
107
+ ), W = s(
108
108
  (e, n, o) => {
109
- T(e, n, o) || (_(e), C({ page: e, index: n, config: o, attempt: 0 }));
109
+ T(e, n, o) || (_(e), x({ page: e, index: n, config: o, attempt: 0 }));
110
110
  },
111
111
  [_, T]
112
112
  );
113
- return x(() => {
113
+ return L(() => {
114
114
  if (!l)
115
115
  return;
116
116
  const e = d(l.page);
117
- if (!m[l.page] || f < e) {
117
+ if (!c[l.page] || f < e) {
118
118
  h(e);
119
119
  return;
120
120
  }
@@ -124,10 +124,10 @@ const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), L =
124
124
  l.index,
125
125
  l.config
126
126
  )) {
127
- C(null);
127
+ x(null);
128
128
  return;
129
129
  }
130
- l.attempt < X && C((t) => !t || t.page !== l.page || t.index !== l.index ? t : { ...t, attempt: t.attempt + 1 });
130
+ l.attempt < X && x((t) => !t || t.page !== l.page || t.index !== l.index ? t : { ...t, attempt: t.attempt + 1 });
131
131
  });
132
132
  return () => {
133
133
  window.cancelAnimationFrame(n);
@@ -138,9 +138,9 @@ const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), L =
138
138
  l,
139
139
  T,
140
140
  f,
141
- m
141
+ c
142
142
  ]), /* @__PURE__ */ $(
143
- L.Provider,
143
+ R.Provider,
144
144
  {
145
145
  value: {
146
146
  updateElement: G,
@@ -155,10 +155,10 @@ const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), L =
155
155
  );
156
156
  }, E = () => {
157
157
  }, Nt = () => {
158
- const i = y(L);
158
+ const i = y(R);
159
159
  return (i == null ? void 0 : i.setThumbnailContainer) ?? E;
160
160
  }, qt = () => {
161
- const i = y(L), { type: a, validating: u } = z(), r = P(0), m = k(() => {
161
+ const i = y(R), { type: a, validating: u } = z(), r = P(0), c = k(() => {
162
162
  if (u !== !1)
163
163
  return {
164
164
  updateElement: E,
@@ -186,10 +186,10 @@ const X = 5, Y = 10, I = (i, a) => Math.min(Math.max(i, 0), Math.max(a, 0)), L =
186
186
  }, [a, u]);
187
187
  if (!i)
188
188
  throw new Error("useElementThumbnailContext must be used within a ElementThumbnailProvider");
189
- return m || i;
189
+ return c || i;
190
190
  };
191
191
  export {
192
- L as ElementThumbnailContext,
192
+ R as ElementThumbnailContext,
193
193
  Dt as ElementThumbnailProvider,
194
194
  qt as useElementThumbnailContext,
195
195
  Nt as useThumbnailContainerRegister
@@ -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-05-06T03:41:32.991Z"), w = `-----BEGIN PUBLIC KEY-----
5
+ const A = /* @__PURE__ */ new Date("2026-05-06T12:44:45.520Z"), v = `-----BEGIN PUBLIC KEY-----
6
6
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
7
7
  gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
8
8
  HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
@@ -10,7 +10,7 @@ Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
10
10
  vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
11
11
  vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
12
12
  kwIDAQAB
13
- -----END PUBLIC KEY-----`, f = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
13
+ -----END PUBLIC KEY-----`, f = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", o = {
14
14
  invalidLicense: `You are currently using without a valid license. ${f}`,
15
15
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${f}`,
16
16
  expired: `Your license key has expired. ${f}`,
@@ -31,7 +31,7 @@ function I(a) {
31
31
  }
32
32
  async function T(a) {
33
33
  try {
34
- const i = await import("../../index-e04c91b1.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();
34
+ const i = await import("../../index-e04c91b1.js").then((u) => u.i), e = (i == null ? void 0 : i.default) ?? i, t = e.pki.publicKeyFromPem(v), r = atob(a.data), n = e.util.decode64(a.signature), s = e.md.sha256.create();
35
35
  s.update(r, "utf8");
36
36
  const d = e.pss.create({
37
37
  md: e.md.sha256.create(),
@@ -50,7 +50,7 @@ async function B(a, i = "SHA-256") {
50
50
  let r = !1;
51
51
  try {
52
52
  if ((e = window.crypto) != null && e.subtle) {
53
- const n = S(w), s = await window.crypto.subtle.importKey(
53
+ const n = S(v), s = await window.crypto.subtle.importKey(
54
54
  "spki",
55
55
  n,
56
56
  { name: "RSA-PSS", hash: i },
@@ -96,26 +96,26 @@ const N = (a, i) => {
96
96
  throw c.warn(l.message), new Error(l.message);
97
97
  }
98
98
  c.debug(">>> validatedLicense", r);
99
- const { avu: n, exp: s, dmt: d, dm: u, t: g } = r;
99
+ const { avu: n, exp: s, dmt: d, dm: u, t: p } = r;
100
100
  if (!s)
101
101
  throw new Error("License is missing expiration timestamp");
102
102
  if (s > Number.MAX_SAFE_INTEGER / 1e3)
103
103
  throw new Error("Invalid expiration timestamp: value too large");
104
- const v = new Date(s * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
105
- if (v.getTime() < h)
104
+ const w = new Date(s * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
105
+ if (w.getTime() < h)
106
106
  throw new Error(o.expired);
107
107
  if (!n)
108
108
  throw new Error("License is missing available until version timestamp");
109
109
  if (n > Number.MAX_SAFE_INTEGER / 1e3)
110
110
  throw new Error("Invalid available until version timestamp: value too large");
111
- const p = new Date(n * 1e3);
112
- if (c.debug("availableUntilTimestamp", p), p.getTime() < A.getTime())
111
+ const g = new Date(n * 1e3);
112
+ if (c.debug("availableUntilTimestamp", g), g.getTime() < A.getTime())
113
113
  throw new Error(o.exceededVersion);
114
- if (g !== L.Custom && !N(d, u))
114
+ if (p !== L.Custom && !N(d, u))
115
115
  throw new Error(o.mismatchedDomain);
116
116
  return {
117
117
  isValid: !0,
118
- type: g,
118
+ type: p,
119
119
  invalidatedMessage: void 0
120
120
  };
121
121
  }, [a]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "2.5.0-beta.3",
3
+ "version": "2.5.0-rc.0",
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": [