@pdf-viewer/react 1.9.1-rc.6 → 1.9.1-rc.7
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,75 +1,79 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { ZoomLevel as
|
|
4
|
-
import { appConsole as
|
|
5
|
-
import { useInitialStateContext as
|
|
6
|
-
import { useDocumentContext as
|
|
7
|
-
import { PAGE_PADDING as
|
|
8
|
-
import { getZoomLevel as
|
|
9
|
-
import { useLayoutContainer as
|
|
10
|
-
import { useViewModeContext as
|
|
11
|
-
import { useRotationContext as
|
|
12
|
-
import { useGlobalCurrentPage as
|
|
13
|
-
|
|
1
|
+
import { jsx as N } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as S, useContext as E, useState as u, useRef as G, useEffect as a, useCallback as Z, useMemo as x } from "react";
|
|
3
|
+
import { ZoomLevel as A } from "../utils/types.js";
|
|
4
|
+
import { appConsole as I } from "../utils/appConsole.js";
|
|
5
|
+
import { useInitialStateContext as M } from "./InitialStateContext.js";
|
|
6
|
+
import { useDocumentContext as O } from "./RPDocumentContext.js";
|
|
7
|
+
import { PAGE_PADDING as R } from "../utils/constants.js";
|
|
8
|
+
import { getZoomLevel as J } from "../utils/getZoomLevel.js";
|
|
9
|
+
import { useLayoutContainer as _ } from "./LayoutContainerContext.js";
|
|
10
|
+
import { useViewModeContext as j } from "./ViewModeContext.js";
|
|
11
|
+
import { useRotationContext as F } from "./RotationContext.js";
|
|
12
|
+
import { useGlobalCurrentPage as T } from "./GlobalCurrentPage.js";
|
|
13
|
+
import { useDebounce as k } from "../utils/hooks/useDebounce.js";
|
|
14
|
+
const C = S({
|
|
14
15
|
zoomLevel: 100,
|
|
15
16
|
currentZoom: 1,
|
|
16
17
|
setZoomLevel: () => {
|
|
17
18
|
}
|
|
18
|
-
}),
|
|
19
|
-
const
|
|
20
|
-
return typeof
|
|
21
|
-
},
|
|
22
|
-
const { initialScale:
|
|
19
|
+
}), se = () => {
|
|
20
|
+
const c = E(C);
|
|
21
|
+
return typeof c.currentZoom != "number" && I.warn("Please use this hooks inside children component of RPProvider"), c;
|
|
22
|
+
}, ce = ({ children: c }) => {
|
|
23
|
+
const { initialScale: L = A.PAGE_FIT } = M(), [r, f] = u(L), { pages: l } = O(), { pagesRef: o } = _(), { viewMode: p } = j(), [b, D] = u({
|
|
24
|
+
width: (o == null ? void 0 : o.clientWidth) || 0,
|
|
25
|
+
height: (o == null ? void 0 : o.clientHeight) || 0
|
|
26
|
+
}), h = k(b, 100), { rotate: g } = F(), [n, W] = u(null), d = G(null), { currentPage: v } = T(), [w, V] = u(v);
|
|
23
27
|
a(() => {
|
|
24
|
-
let e = l.get(
|
|
28
|
+
let e = l.get(w);
|
|
25
29
|
e || (e = l.get(1));
|
|
26
30
|
const t = e == null ? void 0 : e.page.getViewport({
|
|
27
31
|
scale: 1,
|
|
28
32
|
rotation: e.defaultRotation + g
|
|
29
33
|
});
|
|
30
|
-
t && JSON.stringify(t) !== JSON.stringify(d.current) && (d.current = t,
|
|
31
|
-
}, [l, g,
|
|
32
|
-
const
|
|
34
|
+
t && JSON.stringify(t) !== JSON.stringify(d.current) && (d.current = t, W(t));
|
|
35
|
+
}, [l, g, w]);
|
|
36
|
+
const P = Z(() => {
|
|
33
37
|
if (!n)
|
|
34
38
|
return null;
|
|
35
|
-
const e = ((n == null ? void 0 : n.width) || 0) + 2 *
|
|
39
|
+
const e = ((n == null ? void 0 : n.width) || 0) + 2 * R, t = (n == null ? void 0 : n.height) || 0, s = (o == null ? void 0 : o.clientWidth) || 0, i = (o == null ? void 0 : o.clientHeight) || 0;
|
|
36
40
|
return { pageWidth: e, pageHeight: t, clientWidth: s, clientHeight: i };
|
|
37
|
-
}, [n]),
|
|
38
|
-
const e =
|
|
39
|
-
if (!
|
|
41
|
+
}, [n]), m = x(() => {
|
|
42
|
+
const e = P();
|
|
43
|
+
if (!h.width || !h.height || !e)
|
|
40
44
|
return 0;
|
|
41
45
|
if (typeof r == "number")
|
|
42
46
|
return r / 100;
|
|
43
|
-
const { clientWidth: t, clientHeight: s, pageWidth: i, pageHeight:
|
|
44
|
-
return
|
|
45
|
-
}, [r,
|
|
47
|
+
const { clientWidth: t, clientHeight: s, pageWidth: i, pageHeight: y } = e;
|
|
48
|
+
return J(r, t, s, i, y, p) / 100;
|
|
49
|
+
}, [r, h, P, p]);
|
|
46
50
|
a(() => {
|
|
47
|
-
|
|
51
|
+
V(v);
|
|
48
52
|
}, [r]), a(() => {
|
|
49
53
|
const e = (s) => {
|
|
50
54
|
s.forEach((i) => {
|
|
51
|
-
|
|
55
|
+
D({ width: i.contentRect.width, height: i.contentRect.height });
|
|
52
56
|
});
|
|
53
57
|
}, t = new ResizeObserver(e);
|
|
54
58
|
return o && t.observe(o), () => {
|
|
55
59
|
t.disconnect();
|
|
56
60
|
};
|
|
57
61
|
}, [o]);
|
|
58
|
-
const
|
|
62
|
+
const z = Z(
|
|
59
63
|
(e) => {
|
|
60
64
|
let t = 0;
|
|
61
|
-
typeof e == "function" ? t = e(
|
|
65
|
+
typeof e == "function" ? t = e(m * 100) : t = e, t && f(t);
|
|
62
66
|
},
|
|
63
|
-
[f,
|
|
64
|
-
),
|
|
67
|
+
[f, m]
|
|
68
|
+
), H = x(() => ({
|
|
65
69
|
zoomLevel: r,
|
|
66
|
-
currentZoom:
|
|
67
|
-
setZoomLevel:
|
|
68
|
-
}), [
|
|
69
|
-
return /* @__PURE__ */
|
|
70
|
+
currentZoom: m,
|
|
71
|
+
setZoomLevel: z
|
|
72
|
+
}), [m, r]);
|
|
73
|
+
return /* @__PURE__ */ N(C.Provider, { value: H, children: c });
|
|
70
74
|
};
|
|
71
75
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
C as ZoomContext,
|
|
77
|
+
ce as ZoomProvider,
|
|
78
|
+
se as useZoomContext
|
|
75
79
|
};
|
|
@@ -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-10-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-10-02T08:22:17.235Z"), 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}`,
|
package/package.json
CHANGED