@pdf-viewer/react 1.6.0 → 1.6.1-rc.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.
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { jsx as C } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as P, useContext as L, useState as y, useMemo as
|
|
2
|
+
import { createContext as P, useContext as L, useState as y, useMemo as c, useEffect as S } from "react";
|
|
3
3
|
import { ZoomLevel as V } from "../utils/types.js";
|
|
4
4
|
import { appConsole as b } from "../utils/appConsole.js";
|
|
5
5
|
import { useInitialStateContext as A } from "./InitialStateContext.js";
|
|
6
6
|
import { useDocumentContext as D } from "./RPDocumentContext.js";
|
|
7
|
-
import { PAGE_PADDING as
|
|
7
|
+
import { PAGE_PADDING as p } from "../utils/constants.js";
|
|
8
8
|
import { getZoomLevel as E } from "../utils/getZoomLevel.js";
|
|
9
9
|
import { useLayoutContainer as G } from "./LayoutContainerContext.js";
|
|
10
10
|
import { useViewModeContext as H } from "./ViewModeContext.js";
|
|
11
|
-
const
|
|
11
|
+
const h = P({
|
|
12
12
|
zoomLevel: 100,
|
|
13
13
|
currentZoom: 1,
|
|
14
14
|
setZoomLevel: () => {
|
|
15
15
|
}
|
|
16
16
|
}), T = () => {
|
|
17
|
-
const n = L(
|
|
17
|
+
const n = L(h);
|
|
18
18
|
return typeof n.currentZoom != "number" && b.warn("Please use this hooks inside children component of RPProvider"), n;
|
|
19
19
|
}, q = ({ children: n }) => {
|
|
20
20
|
const {
|
|
21
21
|
initialScale: r = V.PAGE_FIT,
|
|
22
22
|
initialPage: u = 1,
|
|
23
23
|
initialRotation: l = 0
|
|
24
|
-
} = A(), [i, a] = y(typeof r == "number" ? r : 100), { pages:
|
|
25
|
-
let e =
|
|
26
|
-
return e || (e =
|
|
27
|
-
}, [
|
|
24
|
+
} = A(), [i, a] = y(typeof r == "number" ? r : 100), { pages: s } = D(), { pagesRef: o } = G(), { viewMode: d } = H(), f = c(() => i / 100, [i]), t = c(() => {
|
|
25
|
+
let e = s.get(u);
|
|
26
|
+
return e || (e = s.get(1)), e == null ? void 0 : e.page.getViewport({ scale: 1, rotation: l });
|
|
27
|
+
}, [s, u, l]), m = c(() => {
|
|
28
28
|
if (!t)
|
|
29
29
|
return 0;
|
|
30
|
-
const e = ((t == null ? void 0 : t.width) || 0) + 2 *
|
|
31
|
-
return E(r,
|
|
30
|
+
const e = ((t == null ? void 0 : t.width) || 0) + 2 * p, Z = ((t == null ? void 0 : t.height) || 0) + 2 * p, g = (o == null ? void 0 : o.clientWidth) || 0, v = (o == null ? void 0 : o.clientHeight) || 0;
|
|
31
|
+
return E(r, g, v, e, Z, d);
|
|
32
32
|
}, [t, r, o]);
|
|
33
33
|
S(() => {
|
|
34
34
|
typeof m == "number" && m && a(m);
|
|
35
35
|
}, [m]);
|
|
36
|
-
const
|
|
36
|
+
const x = c(() => ({
|
|
37
37
|
zoomLevel: i,
|
|
38
|
-
currentZoom:
|
|
38
|
+
currentZoom: f,
|
|
39
39
|
setZoomLevel: a
|
|
40
|
-
}), [
|
|
41
|
-
return /* @__PURE__ */ C(
|
|
40
|
+
}), [f, i]);
|
|
41
|
+
return /* @__PURE__ */ C(h.Provider, { value: x, children: n });
|
|
42
42
|
};
|
|
43
43
|
export {
|
|
44
|
-
|
|
44
|
+
h as ZoomContext,
|
|
45
45
|
q as ZoomProvider,
|
|
46
46
|
T as useZoomContext
|
|
47
47
|
};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { SCROLL_BAR_WIDTH as s } from "./constants.js";
|
|
2
|
-
import { ZoomLevel as
|
|
3
|
-
const
|
|
1
|
+
import { SCROLL_BAR_WIDTH as s, PAGE_PADDING as f } from "./constants.js";
|
|
2
|
+
import { ZoomLevel as t, ViewMode as u } from "./types.js";
|
|
3
|
+
const l = (o, e, n, r, m, a) => {
|
|
4
4
|
if (typeof o == "number")
|
|
5
5
|
return o;
|
|
6
6
|
switch (o) {
|
|
7
|
-
case
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
case e.PAGE_WIDTH:
|
|
17
|
-
return Math.floor(t / r * 100);
|
|
7
|
+
case t.PAGE_FIT:
|
|
8
|
+
const A = a === u.DUAL_PAGE ? 2 * r : r, c = Math.min(
|
|
9
|
+
(e - s) / A,
|
|
10
|
+
(n - f) / m
|
|
11
|
+
);
|
|
12
|
+
return Math.floor(c * 100);
|
|
13
|
+
case t.PAGE_WIDTH:
|
|
14
|
+
return Math.floor(e / r * 100);
|
|
15
|
+
case t.ACTUAL:
|
|
18
16
|
default:
|
|
19
17
|
return 100;
|
|
20
18
|
}
|
|
21
19
|
};
|
|
22
20
|
export {
|
|
23
|
-
|
|
21
|
+
l as getZoomLevel
|
|
24
22
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as g, useCallback as h, useEffect as A } from "react";
|
|
2
2
|
import { appConsole as c } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2025-05-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-05-27T03:30:08.159Z"), l = "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. ${l}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
|
|
6
6
|
expired: `Your license key has expired. ${l}`,
|