@react-pdf-kit/viewer 2.5.0-beta.3 → 2.5.0-beta.4

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:41:09.996Z"), w = `-----BEGIN PUBLIC KEY-----
6
6
  MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
7
7
  gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
8
8
  HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
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-beta.4",
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": [