@pdf-viewer/react 1.8.0-rc.1 → 1.8.0-rc.2
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,60 +1,71 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { LicenseType as
|
|
4
|
-
import { useDimensionPagesContext as
|
|
5
|
-
import { usePagesRotateContext as
|
|
6
|
-
import { useLicenseContext as
|
|
7
|
-
import { useZoomContext as
|
|
8
|
-
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as
|
|
9
|
-
const
|
|
10
|
-
const [
|
|
11
|
-
(e,
|
|
12
|
-
|
|
13
|
-
const
|
|
1
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as L, useState as g, useCallback as l, useContext as h, useRef as w, useMemo as R } from "react";
|
|
3
|
+
import { LicenseType as A } from "../utils/types.js";
|
|
4
|
+
import { useDimensionPagesContext as y } from "./DimensionPagesContext.js";
|
|
5
|
+
import { usePagesRotateContext as O } from "./PagesRotateContext.js";
|
|
6
|
+
import { useLicenseContext as S } from "./LicenseContext.js";
|
|
7
|
+
import { useZoomContext as T } from "./ZoomContext.js";
|
|
8
|
+
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as u } from "../utils/const.js";
|
|
9
|
+
const d = L(void 0), k = ({ children: i }) => {
|
|
10
|
+
const [m, o] = g({}), { widths: t, heights: c } = y(), { pageRotate: a } = O(), { zoomLevel: f } = T(), x = l(
|
|
11
|
+
(e, r) => {
|
|
12
|
+
o((n) => {
|
|
13
|
+
const s = { width: t[e], height: c[e] };
|
|
14
14
|
return {
|
|
15
|
-
...
|
|
16
|
-
[e]:
|
|
15
|
+
...n,
|
|
16
|
+
[e]: r(n[e], s, a[e], f)
|
|
17
17
|
};
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
|
-
[
|
|
21
|
-
),
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
return delete
|
|
20
|
+
[t, c, f, a]
|
|
21
|
+
), p = l((e) => {
|
|
22
|
+
o((r) => {
|
|
23
|
+
const n = { ...r };
|
|
24
|
+
return delete n[e], n;
|
|
25
25
|
});
|
|
26
|
-
}, []), C =
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
return
|
|
26
|
+
}, []), C = l((e, r) => {
|
|
27
|
+
o((n) => {
|
|
28
|
+
const s = { ...n };
|
|
29
|
+
return s[e] = s[e].filter((_, P) => P !== r), s;
|
|
30
30
|
});
|
|
31
31
|
}, []);
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
|
|
32
|
+
return /* @__PURE__ */ v(
|
|
33
|
+
d.Provider,
|
|
34
34
|
{
|
|
35
|
-
value: { updateElement:
|
|
36
|
-
children:
|
|
35
|
+
value: { updateElement: x, clearElements: p, removeElement: C, elementList: m },
|
|
36
|
+
children: i
|
|
37
37
|
}
|
|
38
38
|
);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
}, E = () => {
|
|
40
|
+
}, U = () => {
|
|
41
|
+
const i = h(d), { type: m, validating: o } = S(), t = w(0), c = R(() => {
|
|
42
|
+
if (o !== !1)
|
|
43
|
+
return {
|
|
44
|
+
updateElement: E,
|
|
45
|
+
clearElements: E,
|
|
46
|
+
removeElement: E,
|
|
47
|
+
elementList: {}
|
|
48
|
+
};
|
|
49
|
+
if (m !== A.Organization)
|
|
50
|
+
return {
|
|
51
|
+
updateElement: () => {
|
|
52
|
+
t.current === 0 && (console.error(u), t.current++);
|
|
53
|
+
},
|
|
54
|
+
clearElements: () => {
|
|
55
|
+
t.current === 0 && (console.error(u), t.current++);
|
|
56
|
+
},
|
|
57
|
+
removeElement: () => {
|
|
58
|
+
t.current === 0 && (console.error(u), t.current++);
|
|
59
|
+
},
|
|
60
|
+
elementList: {}
|
|
61
|
+
};
|
|
62
|
+
}, [m, o]);
|
|
63
|
+
if (!i)
|
|
42
64
|
throw new Error("useElementPageContext must be used within a ElementPageProvider");
|
|
43
|
-
return
|
|
44
|
-
updateElement: () => {
|
|
45
|
-
console.error(l);
|
|
46
|
-
},
|
|
47
|
-
clearElements: () => {
|
|
48
|
-
console.error(l);
|
|
49
|
-
},
|
|
50
|
-
removeElement: () => {
|
|
51
|
-
console.error(l);
|
|
52
|
-
},
|
|
53
|
-
elementList: {}
|
|
54
|
-
} : r;
|
|
65
|
+
return c || i;
|
|
55
66
|
};
|
|
56
67
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
d as ElementPageContext,
|
|
69
|
+
k as ElementPageProvider,
|
|
70
|
+
U as useElementPageContext
|
|
60
71
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { appConsole as
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2025-07-
|
|
4
|
-
invalidLicense: `You are currently using without a valid license. ${
|
|
5
|
-
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${
|
|
6
|
-
expired: `Your license key has expired. ${
|
|
1
|
+
import { useState as E, useCallback as h, useEffect as A } from "react";
|
|
2
|
+
import { appConsole as l } from "../appConsole.js";
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-07-23T12:35:19.160Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
|
|
4
|
+
invalidLicense: `You are currently using without a valid license. ${d}`,
|
|
5
|
+
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
|
|
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
|
};
|
|
@@ -50,41 +50,41 @@ kwIDAQAB
|
|
|
50
50
|
throw new Error(s.invalidLicense);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t),
|
|
53
|
+
const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), u = {
|
|
54
54
|
isValid: !0,
|
|
55
55
|
invalidatedMessage: s.invalidLicense,
|
|
56
56
|
type: void 0
|
|
57
57
|
}, x = (r) => {
|
|
58
|
-
const [t, e] =
|
|
59
|
-
if (!r)
|
|
60
|
-
throw e(
|
|
58
|
+
const [t, e] = E(u), n = h(async () => {
|
|
59
|
+
if (e((c) => ({ ...c, validating: !0 })), !r)
|
|
60
|
+
throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
|
|
61
61
|
let i;
|
|
62
62
|
try {
|
|
63
63
|
i = await I(r);
|
|
64
|
-
} catch (
|
|
65
|
-
throw
|
|
64
|
+
} catch (c) {
|
|
65
|
+
throw l.warn(c.message), new Error(c.message);
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
const { avu: a, exp: o, dmt:
|
|
67
|
+
l.debug(">>> validatedLicense", i);
|
|
68
|
+
const { avu: a, exp: o, dmt: m, dm: w, t: f } = i;
|
|
69
69
|
if (!o)
|
|
70
70
|
throw new Error("License is missing expiration timestamp");
|
|
71
71
|
if (o > Number.MAX_SAFE_INTEGER / 1e3)
|
|
72
72
|
throw new Error("Invalid expiration timestamp: value too large");
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
73
|
+
const p = new Date(o * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
|
|
74
|
+
if (p.getTime() < g)
|
|
75
75
|
throw new Error(s.expired);
|
|
76
76
|
if (!a)
|
|
77
77
|
throw new Error("License is missing available until version timestamp");
|
|
78
78
|
if (a > Number.MAX_SAFE_INTEGER / 1e3)
|
|
79
79
|
throw new Error("Invalid available until version timestamp: value too large");
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
80
|
+
const v = new Date(a * 1e3);
|
|
81
|
+
if (l.debug("availableUntilTimestamp", v), v.getTime() < b.getTime())
|
|
82
82
|
throw new Error(s.exceededVersion);
|
|
83
|
-
if (!y(
|
|
83
|
+
if (!y(m, w))
|
|
84
84
|
throw new Error(s.mismatchedDomain);
|
|
85
85
|
return {
|
|
86
86
|
isValid: !0,
|
|
87
|
-
type:
|
|
87
|
+
type: f,
|
|
88
88
|
invalidatedMessage: void 0
|
|
89
89
|
};
|
|
90
90
|
}, [r]);
|
|
@@ -93,13 +93,15 @@ const y = (r, t) => r === "specific" ? t === window.location.host : window.locat
|
|
|
93
93
|
e({
|
|
94
94
|
isValid: i,
|
|
95
95
|
type: a,
|
|
96
|
-
invalidatedMessage: o
|
|
96
|
+
invalidatedMessage: o,
|
|
97
|
+
validating: !1
|
|
97
98
|
});
|
|
98
99
|
}).catch((i) => {
|
|
99
100
|
e({
|
|
100
|
-
...
|
|
101
|
-
isValid: !1
|
|
102
|
-
|
|
101
|
+
...u,
|
|
102
|
+
isValid: !1,
|
|
103
|
+
validating: !1
|
|
104
|
+
}), l.warn(i.message);
|
|
103
105
|
});
|
|
104
106
|
}, [n]), t;
|
|
105
107
|
};
|
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
import { usePagesRotateContext as
|
|
3
|
-
import { useLicenseContext as
|
|
4
|
-
import { LicenseType as
|
|
5
|
-
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as
|
|
6
|
-
const
|
|
7
|
-
const { setSinglePageRotate: n } =
|
|
8
|
-
(
|
|
1
|
+
import { useRef as u, useCallback as f } from "react";
|
|
2
|
+
import { usePagesRotateContext as m } from "../../contexts/PagesRotateContext.js";
|
|
3
|
+
import { useLicenseContext as l } from "../../contexts/LicenseContext.js";
|
|
4
|
+
import { LicenseType as p } from "../types.js";
|
|
5
|
+
import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as R } from "../const.js";
|
|
6
|
+
const C = () => {
|
|
7
|
+
const { setSinglePageRotate: n } = m(), { type: i, validating: a } = l(), r = u(0), c = f(
|
|
8
|
+
(s, t) => {
|
|
9
9
|
n((e) => {
|
|
10
|
-
const o = typeof t == "function" ? t(e[
|
|
10
|
+
const o = typeof t == "function" ? t(e[s] || 0) : t;
|
|
11
11
|
return o % 90 !== 0 ? (console.warn("rotationDegree must be a multiple of 90 got", o), e) : {
|
|
12
12
|
...e,
|
|
13
|
-
[
|
|
13
|
+
[s]: o
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
},
|
|
17
17
|
[n]
|
|
18
18
|
);
|
|
19
|
-
return
|
|
19
|
+
return a !== !1 ? {
|
|
20
20
|
rotate: () => {
|
|
21
|
-
console.error(u);
|
|
22
21
|
}
|
|
23
|
-
} :
|
|
22
|
+
} : i !== p.Organization ? {
|
|
23
|
+
rotate: () => {
|
|
24
|
+
r.current === 0 && (console.error(R), r.current++);
|
|
25
|
+
}
|
|
26
|
+
} : { rotate: c };
|
|
24
27
|
};
|
|
25
28
|
export {
|
|
26
|
-
|
|
29
|
+
C as usePageRotateContext
|
|
27
30
|
};
|
package/package.json
CHANGED