@react-pdf-kit/viewer 2.8.0-beta.7 → 2.8.0-beta.8
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/README.md +44 -30
- package/dist/{AnnotationLayer-Dl6VxRzL.js → AnnotationLayer-CyOYh0Tw.js} +1 -1
- package/dist/CanvasLayer-CJqCJ30J.js +111 -0
- package/dist/PaginationContext-DIzsZhFd.js +194 -0
- package/dist/RPPages-BQw330_L.js +655 -0
- package/dist/{Thumbnail-BVjnCNxv.js → Thumbnail-C6zkvwcs.js} +1 -1
- package/dist/{Thumbnails-CrKLESh3.js → Thumbnails-DKG6I7pb.js} +2 -2
- package/dist/assets/RPPages.css +1 -1
- package/dist/assets/style.js +1 -1
- package/dist/components/RPController.js +39 -39
- package/dist/components/RPPages.js +1 -1
- package/dist/components/RPProvider.js +1 -1
- package/dist/components/layout/LayoutContainer.js +6 -6
- package/dist/components/layout/LayoutWrapper.js +5 -5
- package/dist/components/layout/RPDefaultLayout.js +1 -1
- package/dist/components/layout/RPLayout.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/ScrollModeTool.js +4 -4
- package/dist/components/layout/toolbar/ToolbarCustom.js +1 -1
- package/dist/components/layout/toolbar/ToolbarDefault.js +1 -1
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +5 -5
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +1 -1
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/DualPageWithCover.js +1 -1
- package/dist/components/page/RPPage.js +18 -18
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextHighlightLayer.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/ui/PasswordModal.js +1 -1
- package/dist/contexts/ElementPageContext.js +46 -39
- package/dist/contexts/ElementThumbnailContext.js +1 -1
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +19 -17
- package/dist/contexts/RenderedPagesCache.js +32 -13
- package/dist/contexts/VirtualScrollContext.js +10 -13
- package/dist/{de_DE-C1OrwQKj.js → de_DE-x4Z-jQrz.js} +12 -0
- package/dist/{main-CdlJS0xf.js → main-7sMXtgRg.js} +1 -1
- package/dist/main.js +3 -3
- package/dist/style-CJtyyrJx.js +5 -0
- package/dist/types/components/page/CanvasLayer.d.ts +4 -1
- package/dist/types/contexts/RenderedPagesCache.d.ts +3 -0
- package/dist/types/contexts/VirtualScrollContext.d.ts +0 -3
- package/dist/types/locales/de_DE.json.d.ts +2 -0
- package/dist/types/locales/en_US.json.d.ts +2 -0
- package/dist/types/locales/it_IT.json.d.ts +2 -0
- package/dist/types/locales/pt_PT.json.d.ts +2 -0
- package/dist/types/locales/th_TH.json.d.ts +2 -0
- package/dist/types/locales/zh_CN.json.d.ts +2 -0
- package/dist/types/utils/const.d.ts +3 -0
- package/dist/types/utils/constants.d.ts +1 -0
- package/dist/types/utils/documentLayout.d.ts +60 -0
- package/dist/types/utils/hooks/usePresentPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +4 -1
- package/dist/utils/const.js +2 -2
- package/dist/utils/constants.js +2 -2
- package/dist/utils/documentLayout.js +141 -0
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +73 -63
- package/dist/utils/hooks/useLocalization.js +1 -1
- package/dist/utils/hooks/usePaginate.js +1 -1
- package/dist/utils/hooks/usePinch.js +56 -49
- package/dist/utils/hooks/usePresentPage.js +31 -59
- package/dist/utils/hooks/useScrollToPage.js +1 -1
- package/dist/utils/hooks/useSearch.js +66 -67
- package/dist/utils/types.js +2 -2
- package/package.json +1 -1
- package/dist/CanvasLayer-cRwL_IIT.js +0 -105
- package/dist/PaginationContext-B3qzCYJu.js +0 -235
- package/dist/RPPages-5yXo7yhq.js +0 -1307
- package/dist/contexts/VirtualGridContext.js +0 -18
- package/dist/style-CWQAmimK.js +0 -5
- package/dist/types/contexts/VirtualGridContext.d.ts +0 -9
- package/dist/types/utils/calculatePage.d.ts +0 -12
- package/dist/types/utils/hooks/useVirtualReactWindow.d.ts +0 -17
- package/dist/utils/calculatePage.js +0 -30
- package/dist/utils/hooks/useVirtualReactWindow.js +0 -86
- /package/dist/{PasswordModal-BW_C2ULg.js → PasswordModal-S0leMhEd.js} +0 -0
- /package/dist/{RPLayout.module-DCbTHUuG.js → RPLayout.module-BH5r8dDc.js} +0 -0
- /package/dist/{TextHighlightLayer-BSVgBxR3.js → TextHighlightLayer-3vIZbRyL.js} +0 -0
- /package/dist/{TextLayer-BdoXGj0Z.js → TextLayer-D-V9kogG.js} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ScrollMode, ViewMode } from './types';
|
|
2
|
+
export type DocumentPagePlacement = {
|
|
3
|
+
pageNumber: number;
|
|
4
|
+
rowIndex: number;
|
|
5
|
+
left: number;
|
|
6
|
+
top: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
export type DocumentRow = {
|
|
11
|
+
index: number;
|
|
12
|
+
top: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
pageNumbers: number[];
|
|
16
|
+
};
|
|
17
|
+
export type VisibleDocumentRow = DocumentRow & {
|
|
18
|
+
pages: DocumentPagePlacement[];
|
|
19
|
+
};
|
|
20
|
+
export type DocumentLayout = {
|
|
21
|
+
rows: DocumentRow[];
|
|
22
|
+
pages: DocumentPagePlacement[];
|
|
23
|
+
documentWidth: number;
|
|
24
|
+
documentHeight: number;
|
|
25
|
+
offsetLeft: number;
|
|
26
|
+
offsetTop: number;
|
|
27
|
+
scrollWidth: number;
|
|
28
|
+
scrollHeight: number;
|
|
29
|
+
viewportWidth: number;
|
|
30
|
+
viewportHeight: number;
|
|
31
|
+
scrollMode: ScrollMode;
|
|
32
|
+
viewMode: ViewMode;
|
|
33
|
+
};
|
|
34
|
+
export type PageDimensions = {
|
|
35
|
+
widths: number[];
|
|
36
|
+
heights: number[];
|
|
37
|
+
};
|
|
38
|
+
type BuildDocumentLayoutOptions = {
|
|
39
|
+
pageDimensions: PageDimensions;
|
|
40
|
+
viewportWidth: number;
|
|
41
|
+
viewportHeight: number;
|
|
42
|
+
scrollMode: ScrollMode;
|
|
43
|
+
viewMode: ViewMode;
|
|
44
|
+
focusedPage?: number;
|
|
45
|
+
};
|
|
46
|
+
export declare const getPageGroupForPage: (pageNumber: number, viewMode: ViewMode, totalPages: number) => number[];
|
|
47
|
+
export declare const buildDocumentLayout: (options: BuildDocumentLayoutOptions) => DocumentLayout;
|
|
48
|
+
export declare const getPagePlacement: (layout: DocumentLayout, pageNumber: number) => DocumentPagePlacement | null;
|
|
49
|
+
export declare const getPageContentOffset: (pageBoxWidth: number, pageBoxHeight: number, pageWidth: number, pageHeight: number) => {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
export declare const getPageFromDocumentPoint: (layout: DocumentLayout, documentX: number, documentY: number) => DocumentPagePlacement | null;
|
|
54
|
+
export declare const getVisibleRows: (layout: DocumentLayout, scrollTop: number, scrollLeft: number, viewportWidth: number, viewportHeight: number, overscan?: number) => VisibleDocumentRow[];
|
|
55
|
+
export declare const getRowsByIndexes: (layout: DocumentLayout, rowIndexes: number[], pageNumbers?: number[]) => VisibleDocumentRow[];
|
|
56
|
+
export declare const getScrollTargetForPage: (layout: DocumentLayout, pageNumber: number) => {
|
|
57
|
+
left: number;
|
|
58
|
+
top: number;
|
|
59
|
+
} | null;
|
|
60
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const usePresentPage: (
|
|
1
|
+
import { DocumentLayout } from '../documentLayout';
|
|
2
|
+
export declare const usePresentPage: (element?: HTMLElement, layout?: DocumentLayout) => void;
|
|
@@ -47,7 +47,8 @@ export declare enum AnnotationType {
|
|
|
47
47
|
}
|
|
48
48
|
export declare enum ErrorType {
|
|
49
49
|
NOT_SUPPORTED = "not-supported",
|
|
50
|
-
INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf"
|
|
50
|
+
INVALID_OR_CORRUPTED_PDF = "invalid-or-corrupted-pdf",
|
|
51
|
+
WASM_URL_REQUIRED = "wasm-url-required"
|
|
51
52
|
}
|
|
52
53
|
export interface AnnotationEventPayload {
|
|
53
54
|
type: AnnotationType;
|
|
@@ -128,6 +129,8 @@ export type Localization = {
|
|
|
128
129
|
pageScrollingTooltip?: string;
|
|
129
130
|
verticalScrollingLabel?: string;
|
|
130
131
|
verticalScrollingTooltip?: string;
|
|
132
|
+
horizontalScrollingLabel?: string;
|
|
133
|
+
horizontalScrollingTooltip?: string;
|
|
131
134
|
horizontalLabel?: string;
|
|
132
135
|
horizontalTooltip?: string;
|
|
133
136
|
singlePageLabel?: string;
|
package/dist/utils/const.js
CHANGED
|
@@ -3,6 +3,6 @@ var e = {
|
|
|
3
3
|
keyword: "",
|
|
4
4
|
regExp: /* @__PURE__ */ RegExp(" "),
|
|
5
5
|
wholeWords: !1
|
|
6
|
-
}, t = "This feature is only available for the Organization license",
|
|
6
|
+
}, t = "https://www.react-pdf-kit.dev/docs", n = "This feature is only available for the Organization license", r = "Invalid or corrupted PDF file.", i = "React PDF Kit is unable to render on this browser.", a = "This PDF uses JPEG 2000 images and requires pdf.js WASM assets. Please set wasmUrl in RPConfig.", o = `${a} Learn more: ${t}/components/rp-config`;
|
|
7
7
|
//#endregion
|
|
8
|
-
export {
|
|
8
|
+
export { i as BROWSER_NOT_SUPPORTED_MESSAGE, t as DOCS_URL, e as EMPTY_KEYWORD_REGEXP, r as INVALID_OR_CORRUPTED_PDF_MESSAGE, n as ORGANIZATION_ALLOWED_FEATURES_MESSAGE, o as WASM_URL_REQUIRED_CONSOLE_MESSAGE, a as WASM_URL_REQUIRED_MESSAGE };
|
package/dist/utils/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region lib/utils/constants.ts
|
|
2
|
-
var e = 4, t = 200, n = 20, r = 25, i = 1e3, a = 25, o =
|
|
2
|
+
var e = 4, t = 200, n = 20, r = 25, i = 1e3, a = 25, o = 2, s = 400, c = 1e3, l = 32767, u = 33554432, d = 16777216, f = 5242880, p = 200;
|
|
3
3
|
//#endregion
|
|
4
|
-
export {
|
|
4
|
+
export { p as CANVAS_AREA_CAP_FACTOR, f as IOS_MAX_CANVAS_PIXELS, l as MAX_CANVAS_DIM, u as MAX_CANVAS_PIXELS, i as MAX_ZOOM_SCALE, r as MIN_ZOOM_SCALE, e as PAGE_PADDING, d as SAFARI_MAX_CANVAS_PIXELS, n as SCROLL_BAR_WIDTH, t as THUMBNAIL_MIN_WIDTH, o as VIRTUAL_SCROLL_ROW_OVERSCAN, s as ZOOM_DEBOUNCE_MS, c as ZOOM_SAFETY_TIMEOUT_MS, a as ZOOM_STEP_PERCENT };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ScrollMode as e, ViewMode as t } from "./types.js";
|
|
2
|
+
//#region lib/utils/documentLayout.ts
|
|
3
|
+
var n = (e, t) => Math.max(0, (e - t) / 2), r = .5, i = (e, t, i) => {
|
|
4
|
+
let a = n(e, i), o = Math.max(0, e - t);
|
|
5
|
+
return Math.max(0, a - o * r);
|
|
6
|
+
}, a = (e) => e.reduce((e, t) => e + t, 0), o = (e) => Math.min(e.widths.length, e.heights.length), s = (e) => e === "WRAPPED", c = (e, t) => {
|
|
7
|
+
let n = t - 1;
|
|
8
|
+
return {
|
|
9
|
+
width: e.widths[n] || 0,
|
|
10
|
+
height: e.heights[n] || 0
|
|
11
|
+
};
|
|
12
|
+
}, l = (e, n, r) => {
|
|
13
|
+
if (!r) return [];
|
|
14
|
+
let i = Math.max(1, Math.min(e, r));
|
|
15
|
+
if (n === t.DUAL_PAGE) {
|
|
16
|
+
let e = Math.floor((i - 1) / 2) * 2 + 1;
|
|
17
|
+
return [e, e + 1].filter((e) => e <= r);
|
|
18
|
+
}
|
|
19
|
+
if (n === t.DUAL_PAGE_WITH_COVER) {
|
|
20
|
+
if (i === 1) return [1];
|
|
21
|
+
let e = Math.floor((i - 2) / 2) * 2 + 2;
|
|
22
|
+
return [e, e + 1].filter((e) => e <= r);
|
|
23
|
+
}
|
|
24
|
+
return [i];
|
|
25
|
+
}, u = (e, t) => {
|
|
26
|
+
let n = t.map((t) => c(e, t));
|
|
27
|
+
return {
|
|
28
|
+
pageNumbers: t,
|
|
29
|
+
width: a(n.map((e) => e.width)),
|
|
30
|
+
height: Math.max(...n.map((e) => e.height), 0)
|
|
31
|
+
};
|
|
32
|
+
}, d = (e, n) => {
|
|
33
|
+
let r = o(e), i = [];
|
|
34
|
+
if (n === t.DUAL_PAGE) {
|
|
35
|
+
for (let t = 1; t <= r; t += 2) i.push(u(e, [t, t + 1].filter((e) => e <= r)));
|
|
36
|
+
return i;
|
|
37
|
+
}
|
|
38
|
+
if (n === t.DUAL_PAGE_WITH_COVER) {
|
|
39
|
+
r >= 1 && i.push(u(e, [1]));
|
|
40
|
+
for (let t = 2; t <= r; t += 2) i.push(u(e, [t, t + 1].filter((e) => e <= r)));
|
|
41
|
+
return i;
|
|
42
|
+
}
|
|
43
|
+
for (let t = 1; t <= r; t += 1) i.push(u(e, [t]));
|
|
44
|
+
return i;
|
|
45
|
+
}, f = (e, t) => {
|
|
46
|
+
let n = o(e), r = Math.max(t, 1), i = [], a = [], s = 0;
|
|
47
|
+
for (let t = 1; t <= n; t += 1) {
|
|
48
|
+
let { width: n } = c(e, t);
|
|
49
|
+
a.length > 0 && s + n > r && (i.push(u(e, a)), a = [], s = 0), a.push(t), s += n;
|
|
50
|
+
}
|
|
51
|
+
return a.length && i.push(u(e, a)), i;
|
|
52
|
+
}, p = ({ pageDimensions: t, viewportWidth: n, scrollMode: r, viewMode: i, focusedPage: a }) => {
|
|
53
|
+
let c = o(t);
|
|
54
|
+
return c ? r === e.PAGE_SCROLLING ? [u(t, l(a || 1, i, c))] : r === e.HORIZONTAL_SCROLLING ? [u(t, Array.from({ length: c }, (e, t) => t + 1))] : s(r) ? f(t, n) : d(t, i) : [];
|
|
55
|
+
}, m = (t) => {
|
|
56
|
+
let { pageDimensions: r, viewportWidth: a, viewportHeight: o, scrollMode: l, viewMode: u } = t, d = p(t), f = s(l) ? Math.max(a, ...d.map((e) => e.width), 0) : Math.max(...d.map((e) => e.width), 0), m = [], h = [], g = 0;
|
|
57
|
+
d.forEach((t, o) => {
|
|
58
|
+
let u = s(l) ? Math.max(f, t.width) : t.width, d = {
|
|
59
|
+
index: o,
|
|
60
|
+
top: g,
|
|
61
|
+
width: u,
|
|
62
|
+
height: t.height,
|
|
63
|
+
pageNumbers: t.pageNumbers
|
|
64
|
+
}, p = l !== e.HORIZONTAL_SCROLLING && !s(l) && t.width < f ? i(f, a, t.width) : n(f, t.width);
|
|
65
|
+
t.pageNumbers.forEach((e) => {
|
|
66
|
+
let { width: t, height: n } = c(r, e);
|
|
67
|
+
h.push({
|
|
68
|
+
pageNumber: e,
|
|
69
|
+
rowIndex: o,
|
|
70
|
+
left: p,
|
|
71
|
+
top: g,
|
|
72
|
+
width: t,
|
|
73
|
+
height: n
|
|
74
|
+
}), p += t;
|
|
75
|
+
}), m.push(d), g += t.height;
|
|
76
|
+
});
|
|
77
|
+
let _ = g, v = l === e.HORIZONTAL_SCROLLING ? 0 : n(a, f), y = l === e.PAGE_SCROLLING || l === e.HORIZONTAL_SCROLLING ? n(o, _) : 0;
|
|
78
|
+
return {
|
|
79
|
+
rows: m,
|
|
80
|
+
pages: h,
|
|
81
|
+
documentWidth: f,
|
|
82
|
+
documentHeight: _,
|
|
83
|
+
offsetLeft: v,
|
|
84
|
+
offsetTop: y,
|
|
85
|
+
scrollWidth: Math.max(a, v + f),
|
|
86
|
+
scrollHeight: Math.max(o, y + _),
|
|
87
|
+
viewportWidth: a,
|
|
88
|
+
viewportHeight: o,
|
|
89
|
+
scrollMode: l,
|
|
90
|
+
viewMode: u
|
|
91
|
+
};
|
|
92
|
+
}, h = (e, t) => e.pages.find((e) => e.pageNumber === t) ?? null, g = (e, t, r, i) => ({
|
|
93
|
+
x: n(e, r),
|
|
94
|
+
y: n(t, i)
|
|
95
|
+
}), _ = (e, t, n) => {
|
|
96
|
+
let r = e.rows.find((e) => n >= e.top && n <= e.top + e.height) ?? e.rows.reduce((e, t) => {
|
|
97
|
+
if (!e) return t;
|
|
98
|
+
let r = e.top + e.height / 2, i = t.top + t.height / 2;
|
|
99
|
+
return Math.abs(n - i) < Math.abs(n - r) ? t : e;
|
|
100
|
+
}, null);
|
|
101
|
+
if (!r) return null;
|
|
102
|
+
let i = e.pages.filter((e) => e.rowIndex === r.index);
|
|
103
|
+
return i.find((e) => t >= e.left && t <= e.left + e.width && n >= e.top && n <= e.top + e.height) || i.reduce((e, n) => {
|
|
104
|
+
if (!e) return n;
|
|
105
|
+
let r = e.left + e.width / 2, i = n.left + n.width / 2;
|
|
106
|
+
return Math.abs(t - i) < Math.abs(t - r) ? n : e;
|
|
107
|
+
}, null);
|
|
108
|
+
}, v = (e, t, n, r, i, a = 1) => {
|
|
109
|
+
let o = t - e.offsetTop, s = o + i, c = n - e.offsetLeft, l = c + r, u = e.rows.filter((e) => e.top + e.height >= o && e.top <= s), d = u[0]?.index ?? 0, f = u[u.length - 1]?.index ?? d, p = Math.max(0, d - a), m = Math.min(e.rows.length - 1, f + a), h = r * Math.max(1, a), g = e.pages.reduce((e, t) => {
|
|
110
|
+
let n = e.get(t.rowIndex);
|
|
111
|
+
return n ? n.push(t) : e.set(t.rowIndex, [t]), e;
|
|
112
|
+
}, /* @__PURE__ */ new Map());
|
|
113
|
+
return e.rows.slice(p, m + 1).map((e) => ({
|
|
114
|
+
...e,
|
|
115
|
+
pages: (g.get(e.index) ?? []).filter((e) => {
|
|
116
|
+
let t = e.left + e.width, n = e.top + e.height;
|
|
117
|
+
return t >= c - h && e.left <= l + h && n >= o && e.top <= s;
|
|
118
|
+
})
|
|
119
|
+
}));
|
|
120
|
+
}, y = (e, t, n) => {
|
|
121
|
+
let r = new Set(t), i = n ? new Set(n) : null, a = e.pages.reduce((e, t) => {
|
|
122
|
+
if (i && !i.has(t.pageNumber)) return e;
|
|
123
|
+
let n = e.get(t.rowIndex);
|
|
124
|
+
return n ? n.push(t) : e.set(t.rowIndex, [t]), e;
|
|
125
|
+
}, /* @__PURE__ */ new Map());
|
|
126
|
+
return e.rows.filter((e) => r.has(e.index)).map((e) => ({
|
|
127
|
+
...e,
|
|
128
|
+
pages: a.get(e.index) ?? []
|
|
129
|
+
}));
|
|
130
|
+
}, b = (t, n) => {
|
|
131
|
+
let r = h(t, n);
|
|
132
|
+
return r ? t.scrollMode === e.HORIZONTAL_SCROLLING ? {
|
|
133
|
+
left: t.offsetLeft + r.left,
|
|
134
|
+
top: 0
|
|
135
|
+
} : (t.scrollMode, e.PAGE_SCROLLING, {
|
|
136
|
+
left: t.offsetLeft + r.left,
|
|
137
|
+
top: t.offsetTop + r.top
|
|
138
|
+
}) : null;
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
export { m as buildDocumentLayout, g as getPageContentOffset, _ as getPageFromDocumentPoint, l as getPageGroupForPage, h as getPagePlacement, y as getRowsByIndexes, b as getScrollTargetForPage, v as getVisibleRows };
|
|
@@ -3,7 +3,7 @@ import { LicenseType as t } from "../types.js";
|
|
|
3
3
|
import { appConsole as n } from "../appConsole.js";
|
|
4
4
|
import { useCallback as r, useEffect as i, useState as a } from "react";
|
|
5
5
|
//#region lib/utils/hooks/useLicense.ts
|
|
6
|
-
var o = /* @__PURE__ */ new Date("2026-07-
|
|
6
|
+
var o = /* @__PURE__ */ new Date("2026-07-31T06:54:28.636Z"), s = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx\ngr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b\nHLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y\nBm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W\nvXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD\nvzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR\nkwIDAQAB\n-----END PUBLIC KEY-----", c = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", l = {
|
|
7
7
|
invalidLicense: `You are currently using without a valid license. ${c}`,
|
|
8
8
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${c}`,
|
|
9
9
|
expired: `Your license key has expired. ${c}`,
|
|
@@ -2,75 +2,83 @@
|
|
|
2
2
|
import { ErrorType as e } from "../types.js";
|
|
3
3
|
import { getThumbnailViewport as t } from "../getThumbnailViewport.js";
|
|
4
4
|
import { useConfigContext as n } from "../../contexts/ConfigContext.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
5
|
+
import { appConsole as r } from "../appConsole.js";
|
|
6
|
+
import { useDocumentPasswordContext as i } from "../../contexts/DocumentPasswordContext.js";
|
|
7
|
+
import { BROWSER_NOT_SUPPORTED_MESSAGE as a, INVALID_OR_CORRUPTED_PDF_MESSAGE as o, WASM_URL_REQUIRED_CONSOLE_MESSAGE as s, WASM_URL_REQUIRED_MESSAGE as c } from "../const.js";
|
|
8
|
+
import { useEffect as l, useRef as u, useState as d } from "react";
|
|
9
|
+
import * as f from "pdfjs-dist";
|
|
9
10
|
//#region lib/utils/hooks/useLoadPdf.ts
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var p = new TextEncoder().encode("/JPXDecode");
|
|
12
|
+
function m(e) {
|
|
13
|
+
return e.some((t, n) => t === p[0] ? p.every((t, r) => e[n + r] === t) : !1);
|
|
14
|
+
}
|
|
15
|
+
function h(e) {
|
|
16
|
+
let t = Error(o);
|
|
12
17
|
return t.cause = e, t;
|
|
13
18
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
19
|
+
function g() {
|
|
20
|
+
return Error(c);
|
|
21
|
+
}
|
|
22
|
+
function _(e) {
|
|
23
|
+
let t = Error(a);
|
|
16
24
|
return t.cause = e, t;
|
|
17
25
|
}
|
|
18
|
-
var
|
|
19
|
-
let [p,
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
if (!
|
|
24
|
-
|
|
25
|
-
let t =
|
|
26
|
-
url:
|
|
27
|
-
cMapPacked:
|
|
28
|
-
...
|
|
29
|
-
...
|
|
30
|
-
...
|
|
31
|
-
...
|
|
32
|
-
...
|
|
33
|
-
...
|
|
34
|
-
...
|
|
35
|
-
...
|
|
36
|
-
verbosity:
|
|
26
|
+
var v = (a, o, c = {}) => {
|
|
27
|
+
let [p, v] = d(), { workerUrlAdded: y, wasmUrl: b } = n(), [x, S] = d(/* @__PURE__ */ new Map()), C = u(), [w, T] = d(0), [E, D] = d(!1), [O, k] = d(), { password: A, passwordError: j, setPasswordError: M, passwordRequired: N, setPasswordRequired: P } = i(), { onLoadError: F, onLoaded: I, onLoadProgress: L, disableAutoFetch: R, disableStream: z, rangeChunkSize: B, withCredentials: V, httpHeaders: H } = c;
|
|
28
|
+
return l(() => {
|
|
29
|
+
L && L(w);
|
|
30
|
+
}, [w, L]), l(() => {
|
|
31
|
+
if (!y || !a) return;
|
|
32
|
+
T(0), k(void 0), C.current = Date.now();
|
|
33
|
+
let t = C.current, n = {
|
|
34
|
+
url: a,
|
|
35
|
+
cMapPacked: o?.isCompressed ?? !0,
|
|
36
|
+
...o?.url && { cMapUrl: o.url },
|
|
37
|
+
...A && { password: A },
|
|
38
|
+
...R !== void 0 && { disableAutoFetch: R },
|
|
39
|
+
...z !== void 0 && { disableStream: z },
|
|
40
|
+
...B !== void 0 && { rangeChunkSize: B },
|
|
41
|
+
...V !== void 0 && { withCredentials: V },
|
|
42
|
+
...H !== void 0 && { httpHeaders: H },
|
|
43
|
+
...b && { wasmUrl: b },
|
|
44
|
+
verbosity: f.VerbosityLevel.ERRORS
|
|
37
45
|
};
|
|
38
46
|
try {
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
if (t ===
|
|
47
|
+
let i = f.getDocument(n);
|
|
48
|
+
i.onProgress = (e) => {
|
|
49
|
+
if (t === C.current) {
|
|
42
50
|
let { loaded: t, total: n } = e;
|
|
43
|
-
|
|
51
|
+
T(n ? Math.min(100, Math.round(t / n * 100)) : 0);
|
|
44
52
|
}
|
|
45
|
-
},
|
|
46
|
-
let
|
|
53
|
+
}, D(!0), v(void 0);
|
|
54
|
+
let a = i.promise.then(async (n) => !b && m(await n.getData()) ? (t === C.current && (v(void 0), k(e.WASM_URL_REQUIRED)), r.error(s), F?.(g()), n) : (t === C.current && (v(n), T(100)), I && I(n), P(!1), M(""), n)).catch((t) => {
|
|
47
55
|
if (t instanceof Error && t.name === "PasswordException") {
|
|
48
56
|
let e = t.code;
|
|
49
|
-
|
|
50
|
-
} else t instanceof Error && t.name === "InvalidPDFException" &&
|
|
57
|
+
P(!0), e === f.PasswordResponses.INCORRECT_PASSWORD ? M("Incorrect password") : M(void 0);
|
|
58
|
+
} else t instanceof Error && t.name === "InvalidPDFException" && A ? (P(!0), M("Incorrect password")) : t instanceof Error && t.name === "InvalidPDFException" ? (k(e.INVALID_OR_CORRUPTED_PDF), F?.(h(t))) : F && F(t);
|
|
51
59
|
}).finally(() => {
|
|
52
|
-
|
|
60
|
+
D(!1);
|
|
53
61
|
});
|
|
54
62
|
return () => {
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
a.finally(() => {
|
|
64
|
+
i.destroy();
|
|
57
65
|
});
|
|
58
66
|
};
|
|
59
67
|
} catch (t) {
|
|
60
|
-
|
|
68
|
+
k(e.NOT_SUPPORTED), F?.(_(t));
|
|
61
69
|
}
|
|
62
70
|
}, [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
]),
|
|
70
|
-
if (
|
|
71
|
+
a,
|
|
72
|
+
y,
|
|
73
|
+
b,
|
|
74
|
+
A,
|
|
75
|
+
F,
|
|
76
|
+
I
|
|
77
|
+
]), l(() => {
|
|
78
|
+
if (N) return;
|
|
71
79
|
let n = /* @__PURE__ */ new Map();
|
|
72
|
-
if (!p ||
|
|
73
|
-
|
|
80
|
+
if (!p || E) {
|
|
81
|
+
S(n);
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
84
|
let r = p.numPages, i = [];
|
|
@@ -78,8 +86,10 @@ var f = (i, a, f = {}) => {
|
|
|
78
86
|
let t = p.getPage(e);
|
|
79
87
|
i.push(t);
|
|
80
88
|
}
|
|
81
|
-
Promise.
|
|
82
|
-
e.map((e) =>
|
|
89
|
+
Promise.allSettled(i).then((e) => {
|
|
90
|
+
let r = e.filter((e) => e.status === "fulfilled").map((e) => e.value);
|
|
91
|
+
if (!r.length) throw e.find((e) => e.status === "rejected")?.reason;
|
|
92
|
+
r.map((e) => {
|
|
83
93
|
let { thumbnailViewport: r, scale: i } = t(e), a = e.getViewport();
|
|
84
94
|
n.set(e.pageNumber, {
|
|
85
95
|
page: e,
|
|
@@ -87,24 +97,24 @@ var f = (i, a, f = {}) => {
|
|
|
87
97
|
thumbnailScale: i,
|
|
88
98
|
defaultRotation: a.rotation
|
|
89
99
|
});
|
|
90
|
-
}),
|
|
100
|
+
}), S(n);
|
|
91
101
|
}).catch((t) => {
|
|
92
|
-
|
|
102
|
+
v(void 0), k(e.INVALID_OR_CORRUPTED_PDF), F?.(h(t));
|
|
93
103
|
});
|
|
94
104
|
}, [
|
|
95
105
|
p,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
E,
|
|
107
|
+
N,
|
|
108
|
+
F
|
|
99
109
|
]), {
|
|
100
110
|
pdf: p,
|
|
101
|
-
pages:
|
|
102
|
-
loading:
|
|
103
|
-
error:
|
|
104
|
-
loadingProgress:
|
|
105
|
-
passwordRequired:
|
|
106
|
-
passwordError:
|
|
111
|
+
pages: x,
|
|
112
|
+
loading: E,
|
|
113
|
+
error: O,
|
|
114
|
+
loadingProgress: w,
|
|
115
|
+
passwordRequired: N,
|
|
116
|
+
passwordError: j
|
|
107
117
|
};
|
|
108
118
|
};
|
|
109
119
|
//#endregion
|
|
110
|
-
export {
|
|
120
|
+
export { v as useLoadPdf };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "../../de_DE-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "../../de_DE-x4Z-jQrz.js";
|
|
2
2
|
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
3
3
|
//#region lib/utils/hooks/useLocalization.ts
|
|
4
4
|
var l = (l) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as e } from "../../PaginationContext-
|
|
1
|
+
import { i as e } from "../../PaginationContext-DIzsZhFd.js";
|
|
2
2
|
export { e as usePaginate };
|
|
@@ -4,18 +4,18 @@ import { getZoomOriginFromClientPoint as n } from "./useZoomOrigin.js";
|
|
|
4
4
|
import { useCallback as r, useEffect as i, useRef as a } from "react";
|
|
5
5
|
//#region lib/utils/hooks/usePinch.ts
|
|
6
6
|
var o = () => 35 / (window.devicePixelRatio || 1), s = (s, c = {}) => {
|
|
7
|
-
let { targetZoom: l, zoomTo: u } = t(), { onBeforeZoom: d, onPinchEnd: f } = c, p = a(null), m = a(!1), h = a(1), g = a(1), _ = a(
|
|
7
|
+
let { targetZoom: l, zoomTo: u } = t(), { onBeforeZoom: d, onPinchEnd: f } = c, p = a(null), m = a(!1), h = a(!1), g = a(!1), _ = a(1), v = a(1), y = a(!1), b = a(!1), x = a(), S = a(l), C = a(null);
|
|
8
8
|
i(() => {
|
|
9
|
-
|
|
9
|
+
S.current = l;
|
|
10
10
|
}, [l]);
|
|
11
|
-
let
|
|
11
|
+
let w = r((e, t, n) => {
|
|
12
12
|
if (t === 1) return 1;
|
|
13
13
|
let r = n.current;
|
|
14
14
|
(r > 1 && t < 1 || r < 1 && t > 1) && (n.current = 1);
|
|
15
15
|
let i = Math.floor(e * t * n.current * 100) / (100 * e);
|
|
16
16
|
return n.current = t / i, i;
|
|
17
|
-
}, []),
|
|
18
|
-
let i =
|
|
17
|
+
}, []), T = r((t, n, r) => {
|
|
18
|
+
let i = S.current || 1, a = 25 / 100, o = e / 100;
|
|
19
19
|
if (i >= o && t > 1 || i <= a && t < 1) return;
|
|
20
20
|
let s = Math.max(a, Math.min(o, Math.round(i * t * 100) / 100));
|
|
21
21
|
Math.abs(s - i) < 1e-10 || (d?.({
|
|
@@ -23,89 +23,96 @@ var o = () => 35 / (window.devicePixelRatio || 1), s = (s, c = {}) => {
|
|
|
23
23
|
previousScale: i,
|
|
24
24
|
nextScale: s,
|
|
25
25
|
origin: n
|
|
26
|
-
}),
|
|
26
|
+
}), S.current = s, u(s * 100, {
|
|
27
27
|
origin: n,
|
|
28
28
|
gesture: r,
|
|
29
29
|
previousTargetZoom: i
|
|
30
30
|
}));
|
|
31
|
-
}, [d, u]),
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
}, [d, u]), E = r((e, t) => n(s, e, t) ?? void 0, [s]), D = r(() => {
|
|
32
|
+
b.current || (y.current = !0, clearTimeout(x.current), x.current = setTimeout(() => {
|
|
33
|
+
y.current = !1;
|
|
34
34
|
}, 100));
|
|
35
|
-
}, []),
|
|
35
|
+
}, []), O = r((e) => {
|
|
36
36
|
if (!e.ctrlKey) {
|
|
37
|
-
|
|
37
|
+
b.current = !1, g.current = !1;
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
g.current || (v.current = 1), g.current = !0, b.current = !0, y.current = !1, clearTimeout(x.current), e.preventDefault();
|
|
41
41
|
let t = Math.exp(-e.deltaY / 100);
|
|
42
|
-
|
|
42
|
+
T(w(S.current || 1, t, v), E(e.clientX, e.clientY), "wheel");
|
|
43
43
|
}, [
|
|
44
|
-
S,
|
|
45
44
|
w,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
E,
|
|
46
|
+
T
|
|
47
|
+
]), k = (e) => Array.from(e.touches).sort((e, t) => e.identifier - t.identifier), A = r(() => {
|
|
48
|
+
!s || C.current || (C.current = {
|
|
49
49
|
touchAction: s.style.touchAction,
|
|
50
50
|
webkitUserSelect: s.style.webkitUserSelect,
|
|
51
51
|
overscrollBehavior: s.style.overscrollBehavior,
|
|
52
52
|
webkitOverflowScrolling: s.style.getPropertyValue("-webkit-overflow-scrolling")
|
|
53
53
|
}, s.style.touchAction = "none", s.style.webkitUserSelect = "none", s.style.overscrollBehavior = "contain", s.style.setProperty("-webkit-overflow-scrolling", "auto"));
|
|
54
|
-
}, [s]),
|
|
55
|
-
!s || !
|
|
56
|
-
}, [s]),
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
}, [s]), j = r(() => {
|
|
55
|
+
!s || !C.current || (s.style.touchAction = C.current.touchAction, s.style.webkitUserSelect = C.current.webkitUserSelect, s.style.overscrollBehavior = C.current.overscrollBehavior, C.current.webkitOverflowScrolling ? s.style.setProperty("-webkit-overflow-scrolling", C.current.webkitOverflowScrolling) : s.style.removeProperty("-webkit-overflow-scrolling"), C.current = null);
|
|
56
|
+
}, [s]), M = r(() => {
|
|
57
|
+
if (!(m.current || p.current || h.current)) {
|
|
58
|
+
j();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
p.current = null, m.current = !1, h.current = !1, _.current = 1, j(), f?.();
|
|
62
|
+
}, [f, j]), N = r((e) => {
|
|
59
63
|
if (e.touches.length !== 2) {
|
|
60
|
-
|
|
64
|
+
M();
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
let [t, n] =
|
|
65
|
-
p.current = {
|
|
67
|
+
A(), e.preventDefault(), e.stopPropagation();
|
|
68
|
+
let [t, n] = k(e);
|
|
69
|
+
m.current = !0, _.current = 1, p.current = {
|
|
66
70
|
touch0ScreenX: t.screenX,
|
|
67
71
|
touch0ScreenY: t.screenY,
|
|
68
72
|
touch1ScreenX: n.screenX,
|
|
69
73
|
touch1ScreenY: n.screenY
|
|
70
|
-
},
|
|
71
|
-
}, [
|
|
74
|
+
}, h.current = !1;
|
|
75
|
+
}, [A, M]), P = r((e) => {
|
|
72
76
|
let t = p.current;
|
|
73
77
|
if (!t || e.touches.length !== 2) {
|
|
74
|
-
|
|
78
|
+
M();
|
|
75
79
|
return;
|
|
76
80
|
}
|
|
77
81
|
e.preventDefault(), e.stopPropagation();
|
|
78
|
-
let [n, r] =
|
|
79
|
-
if (!
|
|
80
|
-
if (t.touch0ScreenX = n.screenX, t.touch0ScreenY = n.screenY, t.touch1ScreenX = r.screenX, t.touch1ScreenY = r.screenY, !
|
|
81
|
-
|
|
82
|
+
let [n, r] = k(e), i = t.touch1ScreenX - t.touch0ScreenX, a = t.touch1ScreenY - t.touch0ScreenY, s = r.screenX - n.screenX, c = r.screenY - n.screenY, l = Math.hypot(i, a) || 1, u = Math.hypot(s, c) || 1;
|
|
83
|
+
if (!h.current && Math.abs(l - u) <= o()) return;
|
|
84
|
+
if (t.touch0ScreenX = n.screenX, t.touch0ScreenY = n.screenY, t.touch1ScreenX = r.screenX, t.touch1ScreenY = r.screenY, !h.current) {
|
|
85
|
+
h.current = !0;
|
|
82
86
|
return;
|
|
83
87
|
}
|
|
84
88
|
let d = u / l;
|
|
85
|
-
|
|
89
|
+
T(w(S.current || 1, d, _), E((n.clientX + r.clientX) / 2, (n.clientY + r.clientY) / 2), "touch");
|
|
86
90
|
}, [
|
|
87
|
-
S,
|
|
88
91
|
w,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
E,
|
|
93
|
+
M,
|
|
94
|
+
T
|
|
95
|
+
]), F = r((e) => {
|
|
96
|
+
e.touches.length >= 2 || (M(), v.current = 1);
|
|
97
|
+
}, [M]), I = r(() => {
|
|
98
|
+
M(), v.current = 1;
|
|
99
|
+
}, [M]), L = r(() => {
|
|
100
|
+
b.current = !1, g.current = !1, v.current = 1, y.current = !1, clearTimeout(x.current), M();
|
|
101
|
+
}, [M]);
|
|
96
102
|
i(() => {
|
|
97
|
-
if (s) return s.addEventListener("wheel",
|
|
98
|
-
|
|
103
|
+
if (s) return s.addEventListener("wheel", O, { passive: !1 }), s.addEventListener("scroll", D, { passive: !0 }), s.addEventListener("touchstart", N, { passive: !1 }), s.addEventListener("touchmove", P, { passive: !1 }), s.addEventListener("touchend", F, { passive: !1 }), s.addEventListener("touchcancel", I, { passive: !1 }), window.addEventListener("touchend", F, { passive: !1 }), window.addEventListener("touchcancel", I, { passive: !1 }), window.addEventListener("blur", L), () => {
|
|
104
|
+
j(), s.removeEventListener("wheel", O), s.removeEventListener("scroll", D), s.removeEventListener("touchstart", N), s.removeEventListener("touchmove", P), s.removeEventListener("touchend", F), s.removeEventListener("touchcancel", I), window.removeEventListener("touchend", F), window.removeEventListener("touchcancel", I), window.removeEventListener("blur", L), clearTimeout(x.current);
|
|
99
105
|
};
|
|
100
106
|
}, [
|
|
101
107
|
s,
|
|
102
|
-
|
|
108
|
+
D,
|
|
109
|
+
I,
|
|
110
|
+
F,
|
|
103
111
|
P,
|
|
104
112
|
N,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
k
|
|
113
|
+
O,
|
|
114
|
+
L,
|
|
115
|
+
j
|
|
109
116
|
]);
|
|
110
117
|
};
|
|
111
118
|
//#endregion
|