@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 s, useEffect as S } from "react";
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 f } from "../utils/constants.js";
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 g = P({
11
+ const h = P({
12
12
  zoomLevel: 100,
13
13
  currentZoom: 1,
14
14
  setZoomLevel: () => {
15
15
  }
16
16
  }), T = () => {
17
- const n = L(g);
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: c } = D(), { contentRef: o } = G(), { viewMode: h } = H(), p = s(() => i / 100, [i]), t = s(() => {
25
- let e = c.get(u);
26
- return e || (e = c.get(1)), e == null ? void 0 : e.page.getViewport({ scale: 1, rotation: l });
27
- }, [c, u, l]), m = s(() => {
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 * f, x = ((t == null ? void 0 : t.height) || 0) + 2 * f, Z = (o == null ? void 0 : o.clientWidth) || 0, v = (o == null ? void 0 : o.clientHeight) || 0;
31
- return E(r, Z, v, e, x, h);
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 d = s(() => ({
36
+ const x = c(() => ({
37
37
  zoomLevel: i,
38
- currentZoom: p,
38
+ currentZoom: f,
39
39
  setZoomLevel: a
40
- }), [p, i]);
41
- return /* @__PURE__ */ C(g.Provider, { value: d, children: n });
40
+ }), [f, i]);
41
+ return /* @__PURE__ */ C(h.Provider, { value: x, children: n });
42
42
  };
43
43
  export {
44
- g as ZoomContext,
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 e, ViewMode as c } from "./types.js";
3
- const Z = (o, t, m, r, a, u) => {
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 e.ACTUAL:
8
- return 100;
9
- case e.PAGE_FIT:
10
- let n = 0;
11
- const l = u === c.DUAL_PAGE ? 2 * r : r;
12
- return n = Math.min(
13
- (t - s) / l,
14
- m / a
15
- ), Math.floor(n * 100);
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
- Z as getZoomLevel
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-26T08:41:06.647Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
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}`,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "The PDF Viewer component for React and Next.js",
5
- "version": "1.6.0",
5
+ "version": "1.6.1-rc.1",
6
6
  "keywords": [
7
7
  "component",
8
8
  "frontend",