@pdf-viewer/react 0.9.0-beta.3 → 0.9.0-beta.5
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,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { P as u, S as M, T as
|
|
2
|
+
import { useState as o } from "react";
|
|
3
|
+
import { P as u, S as M, T as R, a as C } from "../RPDefaultLayout-1a423868.js";
|
|
4
4
|
import { DarkModeProvider as L } from "../contexts/DarkModeContext.js";
|
|
5
5
|
import { ScrollMode as T, SelectionMode as V } from "../utils/types.js";
|
|
6
6
|
import { RotateProvider as b } from "../contexts/RotationContext.js";
|
|
@@ -18,42 +18,42 @@ import { FullScreenProvider as Z } from "../contexts/FullScreenContext.js";
|
|
|
18
18
|
import { FileInputProvider as j } from "../contexts/FileInputContext.js";
|
|
19
19
|
import { DropFileZoneProvider as A } from "../contexts/DropFileZoneContext.js";
|
|
20
20
|
import { LayoutContainerContext as N } from "../contexts/LayoutContainerContext.js";
|
|
21
|
-
const nr = (
|
|
21
|
+
const nr = (t) => {
|
|
22
22
|
const {
|
|
23
|
-
children:
|
|
24
|
-
darkMode:
|
|
25
|
-
onDarkModeChange:
|
|
26
|
-
initialRotate:
|
|
27
|
-
textLayer:
|
|
28
|
-
initialPage:
|
|
23
|
+
children: l,
|
|
24
|
+
darkMode: n = !1,
|
|
25
|
+
onDarkModeChange: d,
|
|
26
|
+
initialRotate: m = 0,
|
|
27
|
+
textLayer: a = !0,
|
|
28
|
+
initialPage: c = 1,
|
|
29
29
|
// initialViewMode = ViewMode.SINGLE_PAGE,
|
|
30
|
-
initialThumbnailsVisible:
|
|
30
|
+
initialThumbnailsVisible: f = !1,
|
|
31
31
|
initialSearch: h,
|
|
32
|
-
initialScale:
|
|
33
|
-
initialScrollMode:
|
|
34
|
-
mobileWidth:
|
|
35
|
-
} =
|
|
32
|
+
initialScale: P,
|
|
33
|
+
initialScrollMode: p = T.VERTICAL_SCROLLING,
|
|
34
|
+
mobileWidth: v
|
|
35
|
+
} = t, [i, S] = o(null), [e, s] = o(null);
|
|
36
36
|
return /* @__PURE__ */ r(
|
|
37
37
|
G,
|
|
38
38
|
{
|
|
39
|
-
initialScale:
|
|
40
|
-
initialPage:
|
|
41
|
-
initialScrollMode:
|
|
42
|
-
initialRotate:
|
|
43
|
-
children: /* @__PURE__ */ r(w, { mobileWidth:
|
|
39
|
+
initialScale: P,
|
|
40
|
+
initialPage: c,
|
|
41
|
+
initialScrollMode: p,
|
|
42
|
+
initialRotate: m,
|
|
43
|
+
children: /* @__PURE__ */ r(w, { mobileWidth: v, containerRef: i, children: /* @__PURE__ */ r(D, { children: /* @__PURE__ */ r(y, { children: /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(k, { children: /* @__PURE__ */ r(E, { initialSelectionMode: V.TEXT, children: /* @__PURE__ */ r(F, { children: /* @__PURE__ */ r(u, { children: /* @__PURE__ */ r(b, { children: /* @__PURE__ */ r(x, { textLayer: a, children: /* @__PURE__ */ r(I, { children: /* @__PURE__ */ r(
|
|
44
44
|
L,
|
|
45
45
|
{
|
|
46
|
-
darkMode:
|
|
47
|
-
onDarkModeChange:
|
|
46
|
+
darkMode: n,
|
|
47
|
+
onDarkModeChange: d,
|
|
48
48
|
children: /* @__PURE__ */ r(
|
|
49
49
|
N.Provider,
|
|
50
50
|
{
|
|
51
|
-
value: { container:
|
|
51
|
+
value: { container: i, contentRef: e, setContainer: S, setContentRef: s },
|
|
52
52
|
children: /* @__PURE__ */ r(M, { initialSearch: h, children: /* @__PURE__ */ r(
|
|
53
|
-
|
|
53
|
+
R,
|
|
54
54
|
{
|
|
55
|
-
initialThumbnailsVisible:
|
|
56
|
-
children: /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Z, { elementRef:
|
|
55
|
+
initialThumbnailsVisible: f,
|
|
56
|
+
children: /* @__PURE__ */ r(A, { children: /* @__PURE__ */ r(Z, { elementRef: e, children: /* @__PURE__ */ r(C, { children: /* @__PURE__ */ r(j, { children: l }) }) }) })
|
|
57
57
|
}
|
|
58
58
|
) })
|
|
59
59
|
}
|
|
@@ -1,62 +1,72 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as b, useState as v, useEffect as x, useContext as g } from "react";
|
|
3
|
+
const k = {
|
|
4
4
|
xs: 320,
|
|
5
5
|
sm: 640,
|
|
6
6
|
md: 768,
|
|
7
7
|
lg: 1024,
|
|
8
8
|
xl: 1280,
|
|
9
9
|
"2xl": 1536
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
}, p = b(void 0), S = ({
|
|
11
|
+
children: s,
|
|
12
|
+
containerRef: t,
|
|
13
|
+
mobileWidth: l = 768
|
|
14
|
+
}) => {
|
|
15
|
+
const [o, c] = v({
|
|
16
|
+
width: (t == null ? void 0 : t.clientWidth) || window.innerWidth,
|
|
17
|
+
height: (t == null ? void 0 : t.clientHeight) || window.innerHeight,
|
|
14
18
|
isMobile: !1,
|
|
15
19
|
currentBreakpoint: "xs",
|
|
16
20
|
orientation: "portrait"
|
|
17
|
-
}),
|
|
18
|
-
...
|
|
19
|
-
md:
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
for (let
|
|
23
|
-
if (e >= i
|
|
24
|
-
return i
|
|
21
|
+
}), n = {
|
|
22
|
+
...k,
|
|
23
|
+
md: l
|
|
24
|
+
}, w = () => o.width < n.md, u = (e) => {
|
|
25
|
+
const r = Object.entries(n);
|
|
26
|
+
for (let i = r.length - 1; i >= 0; i--)
|
|
27
|
+
if (e >= r[i][1])
|
|
28
|
+
return r[i][0];
|
|
25
29
|
return "xs";
|
|
26
|
-
},
|
|
30
|
+
}, a = () => {
|
|
27
31
|
const e = navigator.userAgent.toLowerCase();
|
|
28
|
-
return ["iphone", "ipod", "ipad", "android", "mobile", "phone", "tablet"].some((
|
|
32
|
+
return ["iphone", "ipod", "ipad", "android", "mobile", "phone", "tablet"].some((i) => e.includes(i));
|
|
29
33
|
};
|
|
30
|
-
|
|
34
|
+
x(() => {
|
|
35
|
+
if (!t)
|
|
36
|
+
return;
|
|
31
37
|
const e = () => {
|
|
32
|
-
const i =
|
|
33
|
-
|
|
38
|
+
const i = t.clientWidth, d = t.clientHeight;
|
|
39
|
+
c({
|
|
34
40
|
width: i,
|
|
35
|
-
height:
|
|
36
|
-
isMobile:
|
|
37
|
-
currentBreakpoint:
|
|
38
|
-
orientation:
|
|
41
|
+
height: d,
|
|
42
|
+
isMobile: a(),
|
|
43
|
+
currentBreakpoint: u(i),
|
|
44
|
+
orientation: d > i ? "portrait" : "landscape"
|
|
39
45
|
});
|
|
40
46
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
e();
|
|
48
|
+
const r = new ResizeObserver(e);
|
|
49
|
+
return r.observe(t), window.addEventListener("resize", e), () => {
|
|
50
|
+
r.disconnect(), window.removeEventListener("resize", e);
|
|
51
|
+
};
|
|
52
|
+
}, [t]);
|
|
53
|
+
const h = {
|
|
44
54
|
...o,
|
|
45
|
-
breakpoints:
|
|
46
|
-
isBreakpoint: (e) => o.width >=
|
|
55
|
+
breakpoints: n,
|
|
56
|
+
isBreakpoint: (e) => o.width >= n[e],
|
|
47
57
|
isMobileDevice: o.isMobile,
|
|
48
58
|
isPortrait: o.orientation === "portrait",
|
|
49
59
|
isLandscape: o.orientation === "landscape",
|
|
50
|
-
isSmallScreen:
|
|
60
|
+
isSmallScreen: w()
|
|
51
61
|
};
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
},
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
62
|
+
return /* @__PURE__ */ m(p.Provider, { value: h, children: s });
|
|
63
|
+
}, P = () => {
|
|
64
|
+
const s = g(p);
|
|
65
|
+
if (s === void 0)
|
|
56
66
|
throw new Error("useViewportContext must be used within a ViewportProvider");
|
|
57
|
-
return
|
|
67
|
+
return s;
|
|
58
68
|
};
|
|
59
69
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
S as ViewportProvider,
|
|
71
|
+
P as useViewportContext
|
|
62
72
|
};
|
|
@@ -22,6 +22,7 @@ interface ViewportContextType extends ViewportState {
|
|
|
22
22
|
interface ViewportProviderProps {
|
|
23
23
|
children: React.ReactNode;
|
|
24
24
|
mobileWidth?: number;
|
|
25
|
+
containerRef: HTMLElement | null;
|
|
25
26
|
}
|
|
26
27
|
export declare const ViewportProvider: React.FC<ViewportProviderProps>;
|
|
27
28
|
export declare const useViewportContext: () => ViewportContextType;
|
|
@@ -1,94 +1,102 @@
|
|
|
1
|
-
import { useState as g, useCallback as
|
|
1
|
+
import { useState as g, useCallback as E, useEffect as h } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const
|
|
3
|
+
const A = /* @__PURE__ */ new Date("2025-02-27T04:59:26.050Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
|
|
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}`,
|
|
7
7
|
exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
|
|
8
8
|
invalidSignature: "Invalid license key: Signature mismatch"
|
|
9
9
|
};
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
for (let e = 0; e <
|
|
13
|
-
n[e] =
|
|
10
|
+
function b(r) {
|
|
11
|
+
const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), i = atob(t), n = new Uint8Array(i.length);
|
|
12
|
+
for (let e = 0; e < i.length; e++)
|
|
13
|
+
n[e] = i.charCodeAt(e);
|
|
14
14
|
return n.buffer;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
for (let n = 0; n <
|
|
19
|
-
|
|
20
|
-
return
|
|
16
|
+
function S(r) {
|
|
17
|
+
const t = atob(r), i = new Uint8Array(t.length);
|
|
18
|
+
for (let n = 0; n < t.length; n++)
|
|
19
|
+
i[n] = t.charCodeAt(n);
|
|
20
|
+
return i.buffer;
|
|
21
21
|
}
|
|
22
|
-
async function I(r,
|
|
22
|
+
async function I(r, t = "SHA-256") {
|
|
23
23
|
try {
|
|
24
|
-
const { data:
|
|
24
|
+
const { data: i, signature: n } = JSON.parse(atob(r)), e = b(`-----BEGIN PUBLIC KEY-----
|
|
25
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
|
|
26
|
+
gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
|
|
27
|
+
HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
|
|
28
|
+
Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
|
|
29
|
+
vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
|
|
30
|
+
vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
|
|
31
|
+
kwIDAQAB
|
|
32
|
+
-----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
|
|
25
33
|
"spki",
|
|
26
34
|
// str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
|
|
27
35
|
e,
|
|
28
|
-
{ name: "RSA-PSS", hash:
|
|
36
|
+
{ name: "RSA-PSS", hash: t },
|
|
29
37
|
!0,
|
|
30
38
|
["verify"]
|
|
31
39
|
);
|
|
32
40
|
if (!await window.crypto.subtle.verify(
|
|
33
41
|
{ name: "RSA-PSS", saltLength: 32 },
|
|
34
42
|
a,
|
|
35
|
-
|
|
43
|
+
S(n),
|
|
36
44
|
// Convert signature to ArrayBuffer
|
|
37
|
-
new TextEncoder().encode(atob(
|
|
45
|
+
new TextEncoder().encode(atob(i))
|
|
38
46
|
))
|
|
39
47
|
throw new Error(o.invalidSignature);
|
|
40
|
-
return JSON.parse(atob(
|
|
48
|
+
return JSON.parse(atob(i));
|
|
41
49
|
} catch {
|
|
42
50
|
throw new Error(o.invalidLicense);
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
|
-
const L = (r,
|
|
53
|
+
const L = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), c = {
|
|
46
54
|
isValid: !1,
|
|
47
55
|
invalidatedMessage: o.invalidLicense,
|
|
48
56
|
type: void 0
|
|
49
|
-
},
|
|
50
|
-
const [
|
|
57
|
+
}, N = (r) => {
|
|
58
|
+
const [t, i] = g(c), n = E(async () => {
|
|
51
59
|
if (!r)
|
|
52
|
-
return
|
|
60
|
+
return i(c), c;
|
|
53
61
|
try {
|
|
54
62
|
const e = await I(r);
|
|
55
63
|
l.debug(">>> validatedLicense", e);
|
|
56
|
-
const { avu: a, exp: s, dmt: m, dm:
|
|
64
|
+
const { avu: a, exp: s, dmt: m, dm: p, t: v } = e;
|
|
57
65
|
if (!s)
|
|
58
66
|
throw new Error("License is missing expiration timestamp");
|
|
59
67
|
if (s > Number.MAX_SAFE_INTEGER / 1e3)
|
|
60
68
|
throw new Error("Invalid expiration timestamp: value too large");
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
69
|
+
const f = new Date(s * 1e3), w = (/* @__PURE__ */ new Date()).getTime();
|
|
70
|
+
if (f.getTime() < w)
|
|
63
71
|
throw new Error(o.expired);
|
|
64
72
|
if (!a)
|
|
65
73
|
throw new Error("License is missing available until version timestamp");
|
|
66
74
|
if (a > Number.MAX_SAFE_INTEGER / 1e3)
|
|
67
75
|
throw new Error("Invalid available until version timestamp: value too large");
|
|
68
76
|
const u = new Date(a * 1e3);
|
|
69
|
-
if (l.debug("availableUntilTimestamp", u), u.getTime() <
|
|
77
|
+
if (l.debug("availableUntilTimestamp", u), u.getTime() < A.getTime())
|
|
70
78
|
throw new Error(o.exceededVersion);
|
|
71
|
-
if (!L(m,
|
|
79
|
+
if (!L(m, p))
|
|
72
80
|
throw new Error(o.mismatchedDomain);
|
|
73
81
|
return {
|
|
74
82
|
isValid: !0,
|
|
75
|
-
type:
|
|
83
|
+
type: v,
|
|
76
84
|
invalidatedMessage: void 0
|
|
77
85
|
};
|
|
78
86
|
} catch (e) {
|
|
79
87
|
return l.warn(e.message), { ...c, invalidatedMessage: e.message };
|
|
80
88
|
}
|
|
81
89
|
}, [r]);
|
|
82
|
-
return
|
|
90
|
+
return h(() => {
|
|
83
91
|
n().then(({ isValid: e, type: a, invalidatedMessage: s }) => {
|
|
84
|
-
|
|
92
|
+
i({
|
|
85
93
|
isValid: e,
|
|
86
94
|
type: a,
|
|
87
95
|
invalidatedMessage: s
|
|
88
96
|
});
|
|
89
97
|
});
|
|
90
|
-
}, [n]),
|
|
98
|
+
}, [n]), t;
|
|
91
99
|
};
|
|
92
100
|
export {
|
|
93
|
-
|
|
101
|
+
N as useLicense
|
|
94
102
|
};
|