@pdf-viewer/react 1.4.0-beta.1 → 1.4.0-beta.10
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/Popover-5281103c.js +3061 -0
- package/dist/RPDefaultLayout-ec67ce59.js +2911 -0
- package/dist/assets/RPDefaultLayout.css +1 -1
- package/dist/components/RPController.js +13 -12
- package/dist/components/RPPages.js +3 -2
- package/dist/components/RPProvider.js +1 -1
- package/dist/components/layout/RPDefaultLayout.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/DocumentDialog.js +3 -2
- package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +3 -2
- package/dist/components/layout/toolbar/OtherTool.js +1 -1
- package/dist/components/layout/toolbar/Paginate.js +1 -1
- package/dist/components/layout/toolbar/PrintTool.js +1 -1
- package/dist/components/layout/toolbar/RPToolbar.js +1 -1
- package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
- package/dist/components/layout/toolbar/SearchTool.js +4 -3
- package/dist/components/layout/toolbar/ZoomTool.js +3 -2
- package/dist/components/page/AnnotationLayer.js +3 -2
- package/dist/components/page/CanvasLayer.js +3 -2
- package/dist/components/page/DualPage.js +1 -1
- package/dist/components/page/RPPage.js +3 -2
- package/dist/components/page/SinglePage.js +1 -1
- package/dist/components/page/TextHighlightLayer.js +3 -2
- package/dist/components/page/TextLayer.js +3 -2
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/Popover.js +4 -3058
- package/dist/contexts/LoaderContext.js +16 -20
- package/dist/contexts/PaginationContext.js +1 -1
- package/dist/contexts/PrintContext.js +1 -1
- package/dist/contexts/RPDocumentContext.js +27 -25
- package/dist/contexts/SearchContext.js +1 -1
- package/dist/contexts/SmoothScrollContext.js +13 -0
- package/dist/contexts/ThumbnailsContext.js +1 -1
- package/dist/contexts/ToolbarComponentContext.js +10 -8
- package/dist/contexts/ViewportContext.js +1 -1
- package/dist/main.js +1 -1
- package/dist/types/contexts/LoaderContext.d.ts +5 -2
- package/dist/types/contexts/SmoothScrollContext.d.ts +10 -0
- package/dist/types/utils/hooks/useLoadPdf.d.ts +1 -0
- package/dist/types/utils/types.d.ts +6 -3
- package/dist/utils/hooks/useFileDownload.js +3 -2
- package/dist/utils/hooks/useHighlight.js +13 -13
- package/dist/utils/hooks/useLicense.js +60 -59
- package/dist/utils/hooks/useLoadPdf.js +44 -38
- package/dist/utils/hooks/usePaginate.js +3 -2
- package/dist/utils/hooks/usePrint.js +3 -2
- package/dist/utils/hooks/useScrollToPage.js +3 -2
- package/dist/utils/hooks/useSearch.js +3 -2
- package/dist/utils/hooks/useThumbnail.js +3 -2
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
- package/dist/utils/smoothScrollTo.js +3 -15
- package/package.json +1 -1
- package/dist/RPDefaultLayout-838ad8e8.js +0 -2907
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { appConsole as
|
|
4
|
-
import { LoaderIcon as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as d, useContext as i } from "react";
|
|
3
|
+
import { appConsole as m } from "../utils/appConsole.js";
|
|
4
|
+
import { LoaderIcon as s } from "../components/icons/LoaderIcon.js";
|
|
5
|
+
const t = d({
|
|
6
6
|
LoaderImageComponent: void 0
|
|
7
|
-
}),
|
|
8
|
-
const o =
|
|
9
|
-
return typeof o.LoaderImageComponent > "u" &&
|
|
10
|
-
},
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, [r]);
|
|
15
|
-
const i = () => e ? (e == null ? void 0 : e.trim().startsWith("<svg")) ? /* @__PURE__ */ t("span", { dangerouslySetInnerHTML: { __html: e } }) : /* @__PURE__ */ t("img", { src: e, alt: "react-pdf-viewer-loader" }) : /* @__PURE__ */ t(p, {});
|
|
16
|
-
return /* @__PURE__ */ t(
|
|
17
|
-
n.Provider,
|
|
7
|
+
}), u = () => {
|
|
8
|
+
const o = i(t);
|
|
9
|
+
return typeof o.LoaderImageComponent > "u" && m.error("Please use this hooks inside children component of RPProvider"), o;
|
|
10
|
+
}, C = ({ children: o, loaderImage: e }) => {
|
|
11
|
+
const n = () => e || /* @__PURE__ */ r(s, {});
|
|
12
|
+
return /* @__PURE__ */ r(
|
|
13
|
+
t.Provider,
|
|
18
14
|
{
|
|
19
15
|
value: {
|
|
20
|
-
LoaderImageComponent:
|
|
16
|
+
LoaderImageComponent: n
|
|
21
17
|
},
|
|
22
18
|
children: o
|
|
23
19
|
}
|
|
24
20
|
);
|
|
25
21
|
};
|
|
26
22
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
t as LoaderContext,
|
|
24
|
+
C as LoaderProvider,
|
|
25
|
+
u as useLoaderContext
|
|
30
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { h as e, P as m, u as p } from "../RPDefaultLayout-
|
|
3
|
+
import { h as e, P as m, u as p } from "../RPDefaultLayout-ec67ce59.js";
|
|
4
4
|
import "./RPDocumentContext.js";
|
|
5
5
|
import "../utils/appConsole.js";
|
|
6
6
|
export {
|
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as C, useState as
|
|
3
|
-
import { useLoadPdf as
|
|
4
|
-
import { usePdfProperties as
|
|
5
|
-
import { appConsole as
|
|
6
|
-
const
|
|
2
|
+
import { createContext as C, useState as l, useEffect as h, useMemo as S, useContext as v } from "react";
|
|
3
|
+
import { useLoadPdf as D } from "../utils/hooks/useLoadPdf.js";
|
|
4
|
+
import { usePdfProperties as F } from "../utils/hooks/usePdfProperties.js";
|
|
5
|
+
import { appConsole as M } from "../utils/appConsole.js";
|
|
6
|
+
const m = C({
|
|
7
7
|
pdf: void 0,
|
|
8
8
|
pages: /* @__PURE__ */ new Map(),
|
|
9
9
|
setPdfSrc: () => {
|
|
10
10
|
},
|
|
11
11
|
setFilename: () => {
|
|
12
12
|
},
|
|
13
|
-
loading: !1
|
|
14
|
-
|
|
13
|
+
loading: !1,
|
|
14
|
+
loaderProgress: 0
|
|
15
|
+
}), R = ({
|
|
15
16
|
children: t,
|
|
16
17
|
src: e,
|
|
17
|
-
characterMap:
|
|
18
|
+
characterMap: u,
|
|
18
19
|
onLoadError: c,
|
|
19
|
-
onLoaded:
|
|
20
|
+
onLoaded: P
|
|
20
21
|
}) => {
|
|
21
|
-
const [o,
|
|
22
|
+
const [o, n] = l(e), { pdf: r, pages: s, loading: i, loadingProgress: p } = D(o, u, { onLoadError: c, onLoaded: P }), [d, f] = l(), a = F(o, r, d);
|
|
22
23
|
h(() => {
|
|
23
|
-
f(e == null ? void 0 : e.split("/").pop()),
|
|
24
|
+
f(e == null ? void 0 : e.split("/").pop()), n(e);
|
|
24
25
|
}, [e]);
|
|
25
|
-
const
|
|
26
|
-
pdf:
|
|
26
|
+
const g = S(() => ({
|
|
27
|
+
pdf: r,
|
|
27
28
|
pages: s,
|
|
28
29
|
pdfSrc: o,
|
|
29
|
-
setPdfSrc:
|
|
30
|
-
pdfProperties:
|
|
30
|
+
setPdfSrc: n,
|
|
31
|
+
pdfProperties: a,
|
|
31
32
|
setFilename: f,
|
|
32
|
-
filename:
|
|
33
|
-
loading: i
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
filename: d,
|
|
34
|
+
loading: i,
|
|
35
|
+
loaderProgress: p
|
|
36
|
+
}), [r, s, o, a, i, p]);
|
|
37
|
+
return /* @__PURE__ */ x(m.Provider, { value: g, children: o ? t : null });
|
|
38
|
+
}, b = () => {
|
|
39
|
+
const t = v(m);
|
|
40
|
+
return t.pdfSrc || M.error("Please use this hooks inside children component of RPDocument"), t;
|
|
39
41
|
};
|
|
40
42
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
R as DocumentProvider,
|
|
44
|
+
m as default,
|
|
45
|
+
b as useDocumentContext
|
|
44
46
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as c, useRef as o, useContext as s } from "react";
|
|
3
|
+
const t = c({
|
|
4
|
+
smoothScrolling: { current: !1 },
|
|
5
|
+
targetScrollPosition: { current: { left: 0, top: 0 } }
|
|
6
|
+
}), m = ({ children: r }) => {
|
|
7
|
+
const e = o(!1), l = o({ left: 0, top: 0 });
|
|
8
|
+
return /* @__PURE__ */ n(t.Provider, { value: { smoothScrolling: e, targetScrollPosition: l }, children: r });
|
|
9
|
+
}, u = () => s(t);
|
|
10
|
+
export {
|
|
11
|
+
m as SmoothScrollProvider,
|
|
12
|
+
u as useSmoothScrollContext
|
|
13
|
+
};
|
|
@@ -13,8 +13,9 @@ const e = l({
|
|
|
13
13
|
printTool: !0,
|
|
14
14
|
showPrintProgress: !0,
|
|
15
15
|
selectionModeTool: !0,
|
|
16
|
-
jumpNavigationTool: !0
|
|
17
|
-
|
|
16
|
+
jumpNavigationTool: !0,
|
|
17
|
+
sidebarEnable: !0
|
|
18
|
+
}), d = () => n(e), s = {
|
|
18
19
|
themeSwitcher: !0,
|
|
19
20
|
documentProperties: !0,
|
|
20
21
|
rotateTool: !0,
|
|
@@ -28,16 +29,17 @@ const e = l({
|
|
|
28
29
|
thumbnailTool: !0,
|
|
29
30
|
showPrintProgress: !0,
|
|
30
31
|
selectionModeTool: !0,
|
|
31
|
-
jumpNavigationTool: !0
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
jumpNavigationTool: !0,
|
|
33
|
+
sidebarEnable: !0
|
|
34
|
+
}, c = ({ children: r, slots: o }) => {
|
|
35
|
+
const t = i(() => ({
|
|
36
|
+
...s,
|
|
35
37
|
...o
|
|
36
38
|
}), [o]);
|
|
37
|
-
return /* @__PURE__ */ u(e.Provider, { value:
|
|
39
|
+
return /* @__PURE__ */ u(e.Provider, { value: t, children: r });
|
|
38
40
|
};
|
|
39
41
|
export {
|
|
40
42
|
e as ToolbarComponentContext,
|
|
41
43
|
c as ToolbarComponentProvider,
|
|
42
|
-
|
|
44
|
+
d as useToolbarComponentContext
|
|
43
45
|
};
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RPProvider as t } from "./components/RPProvider.js";
|
|
2
|
-
import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-
|
|
2
|
+
import { b as x, R as n, c as s, u as m, d as p, e as f } from "./RPDefaultLayout-ec67ce59.js";
|
|
3
3
|
import { RPConfig as a } from "./components/RPConfig.js";
|
|
4
4
|
import { RPController as l } from "./components/RPController.js";
|
|
5
5
|
import { RPTheme as P } from "./components/RPTheme.js";
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { LoaderImage } from '../utils/types';
|
|
3
|
+
interface LoaderContextType {
|
|
4
|
+
LoaderImageComponent?: FC;
|
|
5
|
+
}
|
|
3
6
|
export declare const LoaderContext: import('react').Context<LoaderContextType>;
|
|
4
7
|
interface Props extends PropsWithChildren {
|
|
5
|
-
loaderImage?:
|
|
8
|
+
loaderImage?: LoaderImage;
|
|
6
9
|
}
|
|
7
10
|
export declare const useLoaderContext: () => LoaderContextType;
|
|
8
11
|
export declare const LoaderProvider: FC<PropsWithChildren<Props>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ScrollPosition } from '../utils/types';
|
|
2
|
+
interface SmoothScrollContextType {
|
|
3
|
+
smoothScrolling: React.MutableRefObject<boolean>;
|
|
4
|
+
targetScrollPosition: React.MutableRefObject<ScrollPosition>;
|
|
5
|
+
}
|
|
6
|
+
export declare const SmoothScrollProvider: ({ children }: {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const useSmoothScrollContext: () => SmoothScrollContextType;
|
|
10
|
+
export {};
|
|
@@ -11,6 +11,7 @@ export interface DocumentContextType {
|
|
|
11
11
|
setFilename: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
12
12
|
filename?: string | null;
|
|
13
13
|
loading: boolean;
|
|
14
|
+
loaderProgress: number;
|
|
14
15
|
}
|
|
15
16
|
export declare enum AnnotationSubType {
|
|
16
17
|
Text = 1,
|
|
@@ -243,7 +244,7 @@ export interface SetPageResult {
|
|
|
243
244
|
export interface PageControl {
|
|
244
245
|
focusedPage: number;
|
|
245
246
|
setFocusedPage: (page: number | string) => void;
|
|
246
|
-
goToPage: (page: number | string) =>
|
|
247
|
+
goToPage: (page: number | string) => SetPageResult;
|
|
247
248
|
totalPages: number;
|
|
248
249
|
setTotalPages: (page: number) => void;
|
|
249
250
|
nextPage: () => void;
|
|
@@ -295,7 +296,7 @@ export interface PageNavigationToolProps {
|
|
|
295
296
|
nextPage: () => void;
|
|
296
297
|
prevPage: () => void;
|
|
297
298
|
changePage: (page: number) => void;
|
|
298
|
-
goToPage: (page: number) =>
|
|
299
|
+
goToPage: (page: number) => SetPageResult;
|
|
299
300
|
}
|
|
300
301
|
export interface PreparePrintProgress {
|
|
301
302
|
loadedPages: number;
|
|
@@ -333,6 +334,7 @@ export interface RPSlots {
|
|
|
333
334
|
selectionModeTool?: boolean;
|
|
334
335
|
searchTool?: boolean;
|
|
335
336
|
jumpNavigationTool?: boolean;
|
|
337
|
+
sidebarEnable?: boolean;
|
|
336
338
|
}
|
|
337
339
|
export interface RPIcons {
|
|
338
340
|
goToFirstPageIcon?: React.ReactNode;
|
|
@@ -582,10 +584,11 @@ export interface SelectionModeContextType {
|
|
|
582
584
|
export interface SelectionModeProps {
|
|
583
585
|
initialSelectionMode?: SelectionMode;
|
|
584
586
|
}
|
|
587
|
+
export type LoaderImage = JSX.Element | string;
|
|
585
588
|
export interface LoadPDFOptions {
|
|
586
589
|
onLoadError?: (error: any) => void;
|
|
587
590
|
onLoaded?: (pdfDocument: PDFDocumentProxy) => void;
|
|
588
|
-
loaderImage?:
|
|
591
|
+
loaderImage?: LoaderImage;
|
|
589
592
|
}
|
|
590
593
|
export interface ScrollPosition {
|
|
591
594
|
left: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../contexts/RPDocumentContext.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { c as
|
|
4
|
+
import { c as B } from "../../RPDefaultLayout-ec67ce59.js";
|
|
5
5
|
import "../../contexts/DarkModeContext.js";
|
|
6
6
|
import "../../contexts/RotationContext.js";
|
|
7
7
|
import "../../contexts/LayerContext.js";
|
|
@@ -20,11 +20,12 @@ import "../../contexts/LayoutContainerContext.js";
|
|
|
20
20
|
import "../../contexts/DimensionPagesContext.js";
|
|
21
21
|
import "../../contexts/LocalizationContext.js";
|
|
22
22
|
import "../../contexts/HighlightContext.js";
|
|
23
|
+
import "../../contexts/SmoothScrollContext.js";
|
|
23
24
|
import "../../contexts/LoaderContext.js";
|
|
24
25
|
import "../../components/RPConfig.js";
|
|
25
26
|
import "../../contexts/ThemeContext.js";
|
|
26
27
|
import "../../components/RPDropFileZone.js";
|
|
27
28
|
import "../../contexts/ToolbarComponentContext.js";
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
B as useFileDownload
|
|
30
31
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as l, useCallback as x, useEffect as C } from "react";
|
|
2
2
|
import { getHighlightOptionsWithDefaults as H, findMatches as M } from "../highlight.js";
|
|
3
3
|
const d = (i) => {
|
|
4
|
-
const [g,
|
|
4
|
+
const [g, a] = l(void 0), [u, r] = l([]), m = x(async (t) => {
|
|
5
5
|
if (!t)
|
|
6
6
|
return {};
|
|
7
7
|
const o = t.numPages, s = {};
|
|
@@ -10,13 +10,13 @@ const d = (i) => {
|
|
|
10
10
|
s[e.toString()] = await h.getTextContent();
|
|
11
11
|
}
|
|
12
12
|
return s;
|
|
13
|
-
}, []),
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
13
|
+
}, []), f = async (t) => {
|
|
14
|
+
a(t);
|
|
15
|
+
}, c = () => {
|
|
16
|
+
r([]), a(void 0);
|
|
17
17
|
};
|
|
18
18
|
return C(() => {
|
|
19
|
-
i &&
|
|
19
|
+
i && m(i).then((t) => {
|
|
20
20
|
let o = [];
|
|
21
21
|
for (const { keyword: s, highlightColor: e, options: h } of g) {
|
|
22
22
|
const p = H(h);
|
|
@@ -36,14 +36,14 @@ const d = (i) => {
|
|
|
36
36
|
o = [...o, ...y];
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
}).catch((
|
|
41
|
-
|
|
39
|
+
r(o);
|
|
40
|
+
}).catch(() => {
|
|
41
|
+
c();
|
|
42
42
|
});
|
|
43
43
|
}, [g, i]), {
|
|
44
|
-
highlight:
|
|
45
|
-
clear:
|
|
46
|
-
highlightMatches:
|
|
44
|
+
highlight: f,
|
|
45
|
+
clear: c,
|
|
46
|
+
highlightMatches: u,
|
|
47
47
|
highlightKeywords: g
|
|
48
48
|
};
|
|
49
49
|
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { appConsole as
|
|
3
|
-
const
|
|
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 c } from "../appConsole.js";
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2025-04-23T03:32:21.513Z"), l = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
|
|
4
|
+
invalidLicense: `You are currently using without a valid license. ${l}`,
|
|
5
|
+
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${l}`,
|
|
6
|
+
expired: `Your license key has expired. ${l}`,
|
|
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 t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""),
|
|
12
|
-
for (let
|
|
13
|
-
n[
|
|
10
|
+
function L(r) {
|
|
11
|
+
const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), n = new Uint8Array(e.length);
|
|
12
|
+
for (let i = 0; i < e.length; i++)
|
|
13
|
+
n[i] = e.charCodeAt(i);
|
|
14
14
|
return n.buffer;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const t = atob(r),
|
|
16
|
+
function S(r) {
|
|
17
|
+
const t = atob(r), e = new Uint8Array(t.length);
|
|
18
18
|
for (let n = 0; n < t.length; n++)
|
|
19
|
-
|
|
20
|
-
return
|
|
19
|
+
e[n] = t.charCodeAt(n);
|
|
20
|
+
return e.buffer;
|
|
21
21
|
}
|
|
22
|
-
async function
|
|
22
|
+
async function I(r, t = "SHA-256") {
|
|
23
23
|
try {
|
|
24
|
-
const { data:
|
|
24
|
+
const { data: e, signature: n } = JSON.parse(atob(r)), i = L(`-----BEGIN PUBLIC KEY-----
|
|
25
25
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
|
|
26
26
|
gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
|
|
27
27
|
HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
|
|
@@ -32,7 +32,7 @@ kwIDAQAB
|
|
|
32
32
|
-----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
|
|
33
33
|
"spki",
|
|
34
34
|
// str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
|
|
35
|
-
|
|
35
|
+
i,
|
|
36
36
|
{ name: "RSA-PSS", hash: t },
|
|
37
37
|
!0,
|
|
38
38
|
["verify"]
|
|
@@ -40,68 +40,69 @@ kwIDAQAB
|
|
|
40
40
|
if (!await window.crypto.subtle.verify(
|
|
41
41
|
{ name: "RSA-PSS", saltLength: 32 },
|
|
42
42
|
a,
|
|
43
|
-
|
|
43
|
+
S(n),
|
|
44
44
|
// Convert signature to ArrayBuffer
|
|
45
|
-
new TextEncoder().encode(atob(
|
|
45
|
+
new TextEncoder().encode(atob(e))
|
|
46
46
|
))
|
|
47
47
|
throw new Error(o.invalidSignature);
|
|
48
|
-
return JSON.parse(atob(
|
|
48
|
+
return JSON.parse(atob(e));
|
|
49
49
|
} catch {
|
|
50
50
|
throw new Error(o.invalidLicense);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const y = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), d = {
|
|
54
54
|
isValid: !0,
|
|
55
55
|
invalidatedMessage: o.invalidLicense,
|
|
56
56
|
type: void 0
|
|
57
|
-
},
|
|
58
|
-
const [t,
|
|
57
|
+
}, x = (r) => {
|
|
58
|
+
const [t, e] = E(d), n = h(async () => {
|
|
59
59
|
if (!r)
|
|
60
|
-
throw
|
|
60
|
+
throw e(d), new Error("License is missing");
|
|
61
|
+
let i;
|
|
61
62
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (!s)
|
|
66
|
-
throw new Error("License is missing expiration timestamp");
|
|
67
|
-
if (s > Number.MAX_SAFE_INTEGER / 1e3)
|
|
68
|
-
throw new Error("Invalid expiration timestamp: value too large");
|
|
69
|
-
const v = new Date(s * 1e3), f = (/* @__PURE__ */ new Date()).getTime();
|
|
70
|
-
if (v.getTime() < f)
|
|
71
|
-
throw new Error(o.expired);
|
|
72
|
-
if (!a)
|
|
73
|
-
throw new Error("License is missing available until version timestamp");
|
|
74
|
-
if (a > Number.MAX_SAFE_INTEGER / 1e3)
|
|
75
|
-
throw new Error("Invalid available until version timestamp: value too large");
|
|
76
|
-
const u = new Date(a * 1e3);
|
|
77
|
-
if (l.debug("availableUntilTimestamp", u), u.getTime() < A.getTime())
|
|
78
|
-
throw new Error(o.exceededVersion);
|
|
79
|
-
if (!I(m, p))
|
|
80
|
-
throw new Error(o.mismatchedDomain);
|
|
81
|
-
return {
|
|
82
|
-
isValid: !0,
|
|
83
|
-
type: w,
|
|
84
|
-
invalidatedMessage: void 0
|
|
85
|
-
};
|
|
86
|
-
} catch (e) {
|
|
87
|
-
return l.warn(e.message), { ...c, invalidatedMessage: e.message };
|
|
63
|
+
i = await I(r);
|
|
64
|
+
} catch (m) {
|
|
65
|
+
throw c.warn(m.message), new Error(m.message);
|
|
88
66
|
}
|
|
67
|
+
c.debug(">>> validatedLicense", i);
|
|
68
|
+
const { avu: a, exp: s, dmt: w, dm: p, t: f } = i;
|
|
69
|
+
if (!s)
|
|
70
|
+
throw new Error("License is missing expiration timestamp");
|
|
71
|
+
if (s > Number.MAX_SAFE_INTEGER / 1e3)
|
|
72
|
+
throw new Error("Invalid expiration timestamp: value too large");
|
|
73
|
+
const v = new Date(s * 1e3), g = (/* @__PURE__ */ new Date()).getTime();
|
|
74
|
+
if (v.getTime() < g)
|
|
75
|
+
throw new Error(o.expired);
|
|
76
|
+
if (!a)
|
|
77
|
+
throw new Error("License is missing available until version timestamp");
|
|
78
|
+
if (a > Number.MAX_SAFE_INTEGER / 1e3)
|
|
79
|
+
throw new Error("Invalid available until version timestamp: value too large");
|
|
80
|
+
const u = new Date(a * 1e3);
|
|
81
|
+
if (c.debug("availableUntilTimestamp", u), u.getTime() < b.getTime())
|
|
82
|
+
throw new Error(o.exceededVersion);
|
|
83
|
+
if (!y(w, p))
|
|
84
|
+
throw new Error(o.mismatchedDomain);
|
|
85
|
+
return {
|
|
86
|
+
isValid: !0,
|
|
87
|
+
type: f,
|
|
88
|
+
invalidatedMessage: void 0
|
|
89
|
+
};
|
|
89
90
|
}, [r]);
|
|
90
|
-
return
|
|
91
|
-
n().then(({ isValid:
|
|
92
|
-
|
|
93
|
-
isValid:
|
|
91
|
+
return A(() => {
|
|
92
|
+
n().then(({ isValid: i, type: a, invalidatedMessage: s }) => {
|
|
93
|
+
e({
|
|
94
|
+
isValid: i,
|
|
94
95
|
type: a,
|
|
95
96
|
invalidatedMessage: s
|
|
96
97
|
});
|
|
97
|
-
}).catch((
|
|
98
|
-
|
|
99
|
-
...
|
|
98
|
+
}).catch((i) => {
|
|
99
|
+
e({
|
|
100
|
+
...d,
|
|
100
101
|
isValid: !1
|
|
101
|
-
}),
|
|
102
|
+
}), c.warn(i.message);
|
|
102
103
|
});
|
|
103
104
|
}, [n]), t;
|
|
104
105
|
};
|
|
105
106
|
export {
|
|
106
|
-
|
|
107
|
+
x as useLicense
|
|
107
108
|
};
|
|
@@ -1,50 +1,56 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import * as
|
|
3
|
-
import { getThumbnailViewport as
|
|
4
|
-
import { useConfigContext as
|
|
5
|
-
const
|
|
6
|
-
const [
|
|
7
|
-
return
|
|
8
|
-
if (!
|
|
1
|
+
import { useState as l, useRef as E, useEffect as k } from "react";
|
|
2
|
+
import * as I from "pdfjs-dist";
|
|
3
|
+
import { getThumbnailViewport as N } from "../getThumbnailViewport.js";
|
|
4
|
+
import { useConfigContext as S } from "../../contexts/ConfigContext.js";
|
|
5
|
+
const A = (d, e, L = {}) => {
|
|
6
|
+
const [r, y] = l(), { workerUrlAdded: p } = S(), [C, w] = l(/* @__PURE__ */ new Map()), i = E(), [T, m] = l(0), [f, b] = l(!1), { onLoadError: g, onLoaded: a } = L;
|
|
7
|
+
return k(() => {
|
|
8
|
+
if (!p || !d)
|
|
9
9
|
return;
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
url:
|
|
13
|
-
cMapPacked: (
|
|
14
|
-
...(
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
i.current = Date.now();
|
|
11
|
+
const t = i.current, P = {
|
|
12
|
+
url: d,
|
|
13
|
+
cMapPacked: (e == null ? void 0 : e.isCompressed) ?? !0,
|
|
14
|
+
...(e == null ? void 0 : e.url) && { cMapUrl: e.url }
|
|
15
|
+
}, n = I.getDocument(P);
|
|
16
|
+
n.onProgress = (o) => {
|
|
17
|
+
if (t === i.current) {
|
|
18
|
+
const { loaded: c, total: u } = o, x = u ? Math.min(100, Math.round(c / u * 100)) : 0;
|
|
19
|
+
m(x);
|
|
20
|
+
}
|
|
21
|
+
}, b(!0), m(0);
|
|
22
|
+
const s = n.promise.then((o) => (t === i.current && (y(o), m(100)), a && a(o), o)).catch((o) => {
|
|
23
|
+
g && g(o);
|
|
24
|
+
}).finally(() => b(!1));
|
|
20
25
|
return () => {
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
s.finally(() => {
|
|
27
|
+
n.destroy();
|
|
23
28
|
});
|
|
24
29
|
};
|
|
25
|
-
}, [
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
28
|
-
|
|
30
|
+
}, [d, p, g, a]), k(() => {
|
|
31
|
+
const t = /* @__PURE__ */ new Map();
|
|
32
|
+
if (!r || f) {
|
|
33
|
+
w(t);
|
|
29
34
|
return;
|
|
30
35
|
}
|
|
31
|
-
const
|
|
32
|
-
for (let
|
|
33
|
-
const
|
|
34
|
-
|
|
36
|
+
const P = r.numPages, n = [];
|
|
37
|
+
for (let s = 1; s <= P; s++) {
|
|
38
|
+
const o = r.getPage(s);
|
|
39
|
+
n.push(o);
|
|
35
40
|
}
|
|
36
|
-
Promise.all(
|
|
37
|
-
|
|
38
|
-
const { thumbnailViewport:
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
+
Promise.all(n).then((s) => {
|
|
42
|
+
s.map((o) => {
|
|
43
|
+
const { thumbnailViewport: c, scale: u } = N(o);
|
|
44
|
+
t.set(o.pageNumber, { page: o, thumbnailViewport: c, thumbnailScale: u });
|
|
45
|
+
}), w(t);
|
|
41
46
|
});
|
|
42
|
-
}, [
|
|
43
|
-
pdf:
|
|
44
|
-
pages:
|
|
45
|
-
loading:
|
|
47
|
+
}, [r, f]), {
|
|
48
|
+
pdf: r,
|
|
49
|
+
pages: C,
|
|
50
|
+
loading: f,
|
|
51
|
+
loadingProgress: T
|
|
46
52
|
};
|
|
47
53
|
};
|
|
48
54
|
export {
|
|
49
|
-
|
|
55
|
+
A as useLoadPdf
|
|
50
56
|
};
|