@react-pdf-kit/viewer 2.9.1 → 2.9.2-rc.0
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.
- package/dist/CanvasLayer-C3gb8EXu.js +116 -0
- package/dist/RPPages-BZwgKgfJ.js +717 -0
- package/dist/components/RPPages.js +1 -1
- package/dist/components/page/CanvasLayer.js +1 -1
- package/dist/components/page/RPPage.js +48 -56
- package/dist/contexts/RenderQueueProvider.js +27 -27
- package/dist/contexts/ZoomContext.js +89 -83
- package/dist/main.js +1 -1
- package/dist/types/utils/documentLayout.d.ts +1 -1
- package/dist/utils/documentLayout.js +44 -44
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/usePresentPage.js +9 -5
- package/package.json +1 -1
- package/dist/CanvasLayer-CJqCJ30J.js +0 -111
- package/dist/RPPages-cyO0Tn21.js +0 -690
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { useDocumentContext as e } from "./contexts/RPDocumentContext.js";
|
|
2
|
+
import { useInitialStateContext as t } from "./contexts/InitialStateContext.js";
|
|
3
|
+
import { useZoomContext as n } from "./contexts/ZoomContext.js";
|
|
4
|
+
import { usePagesRotateContext as r } from "./contexts/PagesRotateContext.js";
|
|
5
|
+
import { useRenderQueue as i } from "./contexts/RenderQueueProvider.js";
|
|
6
|
+
import { useRenderedPagesCache as a } from "./contexts/RenderedPagesCache.js";
|
|
7
|
+
import { useCallback as o, useEffect as s, useLayoutEffect as c, useRef as l } from "react";
|
|
8
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
9
|
+
import './assets/CanvasLayer.css';//#region lib/components/page/RPPage.module.css
|
|
10
|
+
var d = {
|
|
11
|
+
"rp-page-wrapper": "_rp-page-wrapper_1iuev_1",
|
|
12
|
+
"rp-page": "_rp-page_1iuev_1",
|
|
13
|
+
"rp-canvas-layer": "_rp-canvas-layer_1iuev_17",
|
|
14
|
+
"rp-loader-wrapper": "_rp-loader-wrapper_1iuev_40"
|
|
15
|
+
}, f = 3, p = (p) => {
|
|
16
|
+
let { pageNumber: m, onLoaded: h, onLoading: g } = p, _ = l(null), v = l(null), y = l(null), { pages: b } = e(), { pageRotate: x } = r(), { currentZoom: S, targetZoom: C, isZooming: w } = n(), { interactiveForm: T } = t(), { hasRenderedPage: E, markRenderedPage: D } = a(), O = i(), k = l(`page-${m}`), A = l(0), j = l(""), M = l(null), N = l(0), P = l(!1), F = b.get(m), I = F ? x[m] ?? F.defaultRotation ?? 0 : 0, L = l(null), R = o((e, t = !1) => {
|
|
17
|
+
e && (e.width = 0, e.height = 0, t && e.parentNode && e.parentNode.removeChild(e));
|
|
18
|
+
}, []), z = o((e = v.current) => {
|
|
19
|
+
if (!e) return;
|
|
20
|
+
let t = N.current, n = t ? (C || S || t || 1) / t : 1;
|
|
21
|
+
e.style.setProperty("--rp-canvas-scale-ratio", String(n));
|
|
22
|
+
}, [S, C]), B = o(() => {
|
|
23
|
+
let e = document.createElement("canvas");
|
|
24
|
+
return e.dataset.rp = `page-${m}-canvas`, e.style.opacity = "0", e.style.position = "absolute", e.style.inset = "0", z(e), e;
|
|
25
|
+
}, [m, z]), V = o(() => {
|
|
26
|
+
O.removeQueue(k.current), M.current &&= (M.current.cancel(), null);
|
|
27
|
+
}, [O]), H = o(() => {
|
|
28
|
+
y.current && !y.current.parentNode && (R(y.current), y.current = null);
|
|
29
|
+
}, [R]), U = o((e) => {
|
|
30
|
+
if (!P.current) return R(e), !1;
|
|
31
|
+
let t = _.current;
|
|
32
|
+
if (!t) return R(e), !1;
|
|
33
|
+
let n = v.current;
|
|
34
|
+
return n?.parentNode ? n.replaceWith(e) : t.appendChild(e), e.style.opacity = "1", v.current = e, R(n), !0;
|
|
35
|
+
}, [R]);
|
|
36
|
+
return s(() => (P.current = !0, () => {
|
|
37
|
+
P.current = !1, V(), R(y.current), R(v.current), y.current = null, v.current = null;
|
|
38
|
+
}), [V, R]), s(() => {
|
|
39
|
+
z();
|
|
40
|
+
}, [z]), s(() => {
|
|
41
|
+
k.current = `page-${m}`, j.current = "", L.current = null, N.current = 0, R(y.current, !0), R(v.current, !0), y.current = null, v.current = null;
|
|
42
|
+
}, [R, m]), s(() => {
|
|
43
|
+
w && (V(), H());
|
|
44
|
+
}, [
|
|
45
|
+
V,
|
|
46
|
+
H,
|
|
47
|
+
w
|
|
48
|
+
]), c(() => {
|
|
49
|
+
let e = v.current, t = L.current;
|
|
50
|
+
if (!e || t === null || t === I || e.width === 0 || e.height === 0) return;
|
|
51
|
+
let n = _.current;
|
|
52
|
+
if (!n) return;
|
|
53
|
+
let r = e.offsetWidth || parseFloat(e.style.width) || 0, i = e.offsetHeight || parseFloat(e.style.height) || 0, a = I - t;
|
|
54
|
+
e.style.inset = "auto", e.style.left = `${(n.clientWidth - r) / 2}px`, e.style.top = `${(n.clientHeight - i) / 2}px`, e.style.transform = `rotate(${a}deg) scale(var(--rp-canvas-scale-ratio, 1))`, e.style.transformOrigin = "center";
|
|
55
|
+
}, [I]), s(() => {
|
|
56
|
+
if (!F || S === 0 || w || !_.current) return;
|
|
57
|
+
let e = `${m}:${S}:${I}:${T ? "forms" : "static"}`;
|
|
58
|
+
if (j.current === e) return;
|
|
59
|
+
let t = v.current, n = !!t && t.width > 0 && t.height > 0, r = A.current + 1;
|
|
60
|
+
A.current = r, V(), H(), g && !n && g({
|
|
61
|
+
renderKey: e,
|
|
62
|
+
hasRenderedBefore: E(e)
|
|
63
|
+
});
|
|
64
|
+
let i = B();
|
|
65
|
+
return y.current = i, O.enqueue(k.current, {
|
|
66
|
+
page: F.page,
|
|
67
|
+
canvasElem: i,
|
|
68
|
+
options: {
|
|
69
|
+
scale: S,
|
|
70
|
+
rotate: I,
|
|
71
|
+
renderForms: !0,
|
|
72
|
+
interactiveForm: T
|
|
73
|
+
},
|
|
74
|
+
onLoaded: () => {
|
|
75
|
+
if (A.current !== r || y.current !== i) {
|
|
76
|
+
R(i);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (N.current = S, z(i), !U(i)) {
|
|
80
|
+
y.current = null;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
y.current = null, j.current = e, L.current = I, D(e), M.current = null, h?.();
|
|
84
|
+
},
|
|
85
|
+
onRenderTask: (e) => {
|
|
86
|
+
A.current === r && (M.current = e);
|
|
87
|
+
}
|
|
88
|
+
}, f), () => {
|
|
89
|
+
V(), y.current === i && (R(i), y.current = null);
|
|
90
|
+
};
|
|
91
|
+
}, [
|
|
92
|
+
V,
|
|
93
|
+
R,
|
|
94
|
+
H,
|
|
95
|
+
B,
|
|
96
|
+
S,
|
|
97
|
+
E,
|
|
98
|
+
T,
|
|
99
|
+
w,
|
|
100
|
+
D,
|
|
101
|
+
h,
|
|
102
|
+
g,
|
|
103
|
+
F,
|
|
104
|
+
m,
|
|
105
|
+
O,
|
|
106
|
+
I,
|
|
107
|
+
U,
|
|
108
|
+
z
|
|
109
|
+
]), /* @__PURE__ */ u("div", {
|
|
110
|
+
className: d["rp-canvas-layer"],
|
|
111
|
+
"data-rp": `page-${m}-canvasLayer`,
|
|
112
|
+
ref: _
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { d as n, p as t };
|