pdf-tsx 0.17.8 → 0.17.9
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 +1 @@
|
|
|
1
|
-
const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../context/PDFViewerContext.cjs`),n=require(`../hooks/useScrollTracking.cjs`),r=require(`../hooks/useKeyboardShortcuts.cjs`),i=require(`../hooks/useTextLayer.cjs`),a=require(`../utils/url.cjs`),ee=require(`../hooks/useAnnotationLayer.cjs`),te=require(`../hooks/usePDFLoader.cjs`),
|
|
1
|
+
const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../context/PDFViewerContext.cjs`),n=require(`../hooks/useScrollTracking.cjs`),r=require(`../hooks/useKeyboardShortcuts.cjs`),i=require(`../hooks/useTextLayer.cjs`),a=require(`../utils/url.cjs`),ee=require(`../hooks/useAnnotationLayer.cjs`),te=require(`../hooks/usePDFLoader.cjs`),ne=require(`../hooks/usePDFRenderer.cjs`),re=require(`../hooks/useOverlayRects.cjs`),ie=require(`../hooks/usePinchZoom.cjs`),o=require(`../utils/pdfjsPolyfill.cjs`),s=require(`../utils/pdfFit.cjs`),ae=require(`../context/ThemeContext.cjs`),oe=require(`../context/LabelsContext.cjs`),c=require(`../hooks/useLabels.cjs`),l=require(`./PDFViewer.module.cjs`);let u=require(`react`);u=e.__toESM(u,1);let d=require(`pdfjs-dist`);d=e.__toESM(d,1);let f=require(`react/jsx-runtime`);o.applyPdfjsPolyfill();var p=2;function se({hasRead:e}){let t=c.useLabels();return(0,f.jsxs)(`div`,{className:`${l.default.requireReadBanner} ${e?l.default.requireReadDone:``}`,children:[e?(0,f.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M3 8l3.5 3.5L13 4.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}):(0,f.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:(0,f.jsx)(`path`,{d:`M8 3v10M4 9l4 4 4-4`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,f.jsx)(`span`,{children:e?t.requireReadDone:t.requireReadPending})]})}var m=({file:e,workerSrc:c,sidebar:m,toolbar:h,onChangeFile:g,themeOverrides:ce,defaultTheme:le,defaultFit:_,language:ue,className:v,style:de,requireRead:y,onDocumentRead:b})=>{(0,u.useEffect)(()=>{let e=new URL(c,location.href).href,t=new Blob([`${o.PDFJS_POLYFILL}\nimport(${JSON.stringify(e)});`],{type:`application/javascript`}),n=URL.createObjectURL(t);return d.GlobalWorkerOptions.workerSrc=n,()=>URL.revokeObjectURL(n)},[c]);let[x,S]=(0,u.useState)(1),[C,w]=(0,u.useState)(0),[T,E]=(0,u.useState)(null),[D,fe]=(0,u.useState)([]),[O,pe]=(0,u.useState)(!1),[k,A]=(0,u.useState)(_??null),[j,M]=(0,u.useState)(null),[N,P]=(0,u.useState)(!1),F=(0,u.useRef)(!1),I=(0,u.useRef)(null),L=(0,u.useRef)([]),R=(0,u.useRef)([]),z=(0,u.useRef)(C);(0,u.useEffect)(()=>{z.current=C},[C]);let[B,me]=(0,u.useState)(null);B!==e&&(me(e),E(null),P(!1)),(0,u.useEffect)(()=>{F.current=!1},[e]);let{pdf:V,numPages:H,loading:he}=te.usePDFLoader(e);(0,u.useEffect)(()=>{V&&(L.current=Array(V.numPages).fill(null),R.current=Array(V.numPages).fill(null))},[V]),(0,u.useEffect)(()=>{!V||!_||!I.current||s.computeFit(_,V,I.current,z.current).then(S)},[V,_]);let U=(0,u.useRef)(k);(0,u.useEffect)(()=>{U.current=k},[k]),(0,u.useEffect)(()=>{if(!V||!I.current)return;let e=I.current,t=new ResizeObserver(()=>{U.current&&s.computeFit(U.current,V,e,z.current).then(S)});return t.observe(e),()=>t.disconnect()},[V]);let{currentPage:W,goToPage:G}=n.useScrollTracking({numPages:H,containerRef:I,pageRefs:L});(0,u.useEffect)(()=>{H===0||W<H||(y&&!N&&P(!0),F.current||(F.current=!0,b?.()))},[W,H,y,N,b]);let K=(0,u.useMemo)(()=>{if(H===0)return[];let e=new Set,t=Math.max(W-p,1),n=Math.min(W+p,H);for(let r=t;r<=n;r++)e.add(r);T&&e.add(T.page);for(let t of D)e.add(t.page);return Array.from(e).sort((e,t)=>e-t)},[W,H,T,D]),{pageSizes:ge,renderedPages:q}=ne.usePDFRenderer({pdf:V,zoom:x,rotation:C,visiblePages:K,canvasRefs:R}),J=(0,u.useMemo)(()=>{let e=new Set(K);for(let t of q)e.add(t);return Array.from(e).sort((e,t)=>e-t)},[K,q]);r.useKeyboardShortcuts({pdf:V,currentPage:W,goToPage:G,setRotation:w}),ie.usePinchZoom(I,x,S,A);let _e=i.useTextLayer({pdf:V,zoom:x,rotation:C,mountedPages:J,canvasRefs:R}),{linkOverlays:ve,noteOverlays:ye}=ee.useAnnotationLayer({pdf:V,zoom:x,rotation:C,mountedPages:J,goToPage:G});(0,u.useEffect)(()=>{if(!j)return;let e=()=>M(null),t=e=>{e.key===`Escape`&&M(null)};return document.addEventListener(`click`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`keydown`,t)}},[j]);let{overlayRect:Y,searchOverlays:be}=re.useOverlayRects({pdf:V,highlight:T,searchMatches:D,zoom:x,rotation:C}),xe=(0,u.useCallback)((e,t)=>{(!e.url||!a.isSafeUrl(e.url))&&(t.preventDefault(),e.url||e._handleClick())},[]),X=(0,u.useRef)(null),Z=(0,u.useCallback)((e,t)=>{X.current&&clearTimeout(X.current);let n=t.clientY>window.innerHeight*.6;M({x:Math.min(t.clientX,window.innerWidth-304),y:n?window.innerHeight-t.clientY+8:t.clientY+12,above:n,contents:e.contents,title:e.title})},[]),Q=(0,u.useCallback)(()=>{X.current=setTimeout(()=>M(null),200)},[]),$=(0,u.useCallback)(e=>{E({page:e.page,pdfRect:e.pdfRect}),G(e.page)},[E,G]),Se=(0,u.useMemo)(()=>({pdf:V,numPages:H,zoom:x,setZoom:S,rotation:C,setRotation:w,currentPage:W,goToPage:G,containerRef:I,canvasRefs:R,file:e,highlight:T,setHighlight:E,searchMatches:D,setSearchMatches:fe,onChangeFile:g,sidebarCollapsed:O,setSidebarCollapsed:pe,fitMode:k,setFitMode:A,navigationLocked:!!y&&!N}),[V,H,x,C,W,G,e,T,D,g,O,k,y,N]);return(0,f.jsx)(ae.ThemeProvider,{themeOverrides:ce,defaultTheme:le,children:(0,f.jsx)(oe.LabelsProvider,{language:ue,children:(0,f.jsxs)(t.PDFViewerContext.Provider,{value:Se,children:[(0,f.jsxs)(`div`,{className:`${l.default.appLayout}${v?` ${v}`:``}`,style:de,children:[h&&(0,f.jsx)(`div`,{className:l.default.toolbar,children:h}),(0,f.jsxs)(`div`,{className:l.default.body,children:[m,(0,f.jsxs)(`div`,{className:l.default.scrollContainer,ref:I,children:[he&&(0,f.jsx)(`div`,{className:l.default.documentLoading}),Array.from({length:H},(e,t)=>{let n=q.has(t+1),r=ge[t],i=J.includes(t+1);return(0,f.jsxs)(`div`,{className:l.default.pageWrapper,ref:e=>{L.current[t]=e},style:r?{width:r.width,height:r.height}:void 0,children:[r&&!n&&(0,f.jsx)(`div`,{className:l.default.pageSkeleton,style:{width:r.width,height:r.height}}),i&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`canvas`,{className:l.default.pageCanvas,ref:e=>{R.current[t]=e},style:{display:n?`block`:`none`}}),(0,f.jsx)(`div`,{className:`textLayer ${l.default.textLayer}`,ref:e=>{_e.current[t]=e}})]}),ve.filter(e=>e.page===t+1).map((e,t)=>(0,f.jsx)(`a`,{className:l.default.linkOverlay,href:e.url&&a.isSafeUrl(e.url)?e.url:`#`,target:`_blank`,rel:`noopener noreferrer`,style:{left:e.x,top:e.y,width:e.width,height:e.height},onClick:t=>xe(e,t)},t)),ye.filter(e=>e.page===t+1).map((e,t)=>e.subtype===`Text`?(0,f.jsx)(`div`,{className:l.default.noteIconOverlay,style:{left:e.x,top:e.y,width:Math.max(e.width,26),height:Math.max(e.height,26)},onMouseEnter:t=>Z(e,t),onMouseLeave:Q,onClick:()=>$(e),children:(0,f.jsxs)(`svg`,{width:`22`,height:`22`,viewBox:`0 0 12 12`,fill:`none`,"aria-hidden":`true`,children:[(0,f.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`9`,height:`8`,rx:`1`,fill:`rgba(255,210,0,0.9)`,stroke:`rgba(160,120,0,0.7)`,strokeWidth:`1`}),(0,f.jsx)(`path`,{d:`M9.5 5.5v3l2.5-3z`,fill:`rgba(255,210,0,0.9)`,stroke:`rgba(160,120,0,0.7)`,strokeWidth:`1`}),(0,f.jsx)(`line`,{x1:`2`,y1:`3`,x2:`8`,y2:`3`,stroke:`rgba(90,60,0,0.8)`,strokeWidth:`1`,strokeLinecap:`round`}),(0,f.jsx)(`line`,{x1:`2`,y1:`5.5`,x2:`7`,y2:`5.5`,stroke:`rgba(90,60,0,0.8)`,strokeWidth:`1`,strokeLinecap:`round`})]})},t):(0,f.jsx)(`div`,{className:l.default.noteOverlay,style:{left:e.x,top:e.y,width:e.width,height:e.height},onMouseEnter:t=>Z(e,t),onMouseLeave:Q,onClick:()=>$(e)},t)),be.filter(e=>e.page===t+1).map((e,t)=>(0,f.jsx)(`div`,{className:l.default.searchMatchOverlay,style:{left:e.x,top:e.y,width:e.width,height:e.height}},t)),T&&Y?.page===t+1&&(0,f.jsx)(`div`,{className:l.default.highlightOverlay,style:{left:Y.x,top:Y.y,width:Y.width,height:Y.height}})]},`${t}-${C}`)}),y&&(0,f.jsx)(se,{hasRead:N})]})]})]}),j&&(0,f.jsxs)(`div`,{className:l.default.notePopover,style:j.above?{left:j.x,bottom:j.y}:{left:j.x,top:j.y},onMouseEnter:()=>{X.current&&clearTimeout(X.current)},onMouseLeave:Q,onClick:e=>e.stopPropagation(),children:[j.title&&(0,f.jsx)(`div`,{className:l.default.notePopoverTitle,children:j.title}),(0,f.jsx)(`p`,{className:l.default.notePopoverContent,children:j.contents})]})]})})})};exports.default=m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`(function(){function g(k,f){if(!this.has(k))this.set(k,f(k));return this.get(k);}if(typeof Map!=="undefined"&&!("getOrInsertComputed" in Map.prototype))Map.prototype.getOrInsertComputed=g;if(typeof WeakMap!=="undefined"&&!("getOrInsertComputed" in WeakMap.prototype))WeakMap.prototype.getOrInsertComputed=g;})();`;function t(){let e=function(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)};`getOrInsertComputed`in Map.prototype||(Map.prototype.getOrInsertComputed=e),`getOrInsertComputed`in WeakMap.prototype||(WeakMap.prototype.getOrInsertComputed=e)}exports.PDFJS_POLYFILL=e,exports.applyPdfjsPolyfill=t;
|
|
@@ -8,262 +8,261 @@ import { usePDFLoader as ee } from "../hooks/usePDFLoader.js";
|
|
|
8
8
|
import { usePDFRenderer as te } from "../hooks/usePDFRenderer.js";
|
|
9
9
|
import { useOverlayRects as ne } from "../hooks/useOverlayRects.js";
|
|
10
10
|
import { usePinchZoom as re } from "../hooks/usePinchZoom.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import c from "
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
11
|
+
import { PDFJS_POLYFILL as ie, applyPdfjsPolyfill as o } from "../utils/pdfjsPolyfill.js";
|
|
12
|
+
import { computeFit as s } from "../utils/pdfFit.js";
|
|
13
|
+
import { ThemeProvider as ae } from "../context/ThemeContext.js";
|
|
14
|
+
import { LabelsProvider as oe } from "../context/LabelsContext.js";
|
|
15
|
+
import { useLabels as c } from "../hooks/useLabels.js";
|
|
16
|
+
import l from "./PDFViewer.module.js";
|
|
17
|
+
import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
18
|
+
import * as se from "pdfjs-dist";
|
|
19
|
+
import { Fragment as ce, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
19
20
|
//#region src/components/PDFViewer.tsx
|
|
20
|
-
|
|
21
|
+
o();
|
|
22
|
+
var _ = 2;
|
|
21
23
|
function le({ hasRead: e }) {
|
|
22
|
-
let t =
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
className: `${
|
|
25
|
-
children: [e ? /* @__PURE__ */
|
|
24
|
+
let t = c();
|
|
25
|
+
return /* @__PURE__ */ g("div", {
|
|
26
|
+
className: `${l.requireReadBanner} ${e ? l.requireReadDone : ""}`,
|
|
27
|
+
children: [e ? /* @__PURE__ */ h("svg", {
|
|
26
28
|
width: "16",
|
|
27
29
|
height: "16",
|
|
28
30
|
viewBox: "0 0 16 16",
|
|
29
31
|
fill: "none",
|
|
30
32
|
"aria-hidden": "true",
|
|
31
|
-
children: /* @__PURE__ */
|
|
33
|
+
children: /* @__PURE__ */ h("path", {
|
|
32
34
|
d: "M3 8l3.5 3.5L13 4.5",
|
|
33
35
|
stroke: "currentColor",
|
|
34
36
|
strokeWidth: "2",
|
|
35
37
|
strokeLinecap: "round",
|
|
36
38
|
strokeLinejoin: "round"
|
|
37
39
|
})
|
|
38
|
-
}) : /* @__PURE__ */
|
|
40
|
+
}) : /* @__PURE__ */ h("svg", {
|
|
39
41
|
width: "16",
|
|
40
42
|
height: "16",
|
|
41
43
|
viewBox: "0 0 16 16",
|
|
42
44
|
fill: "none",
|
|
43
45
|
"aria-hidden": "true",
|
|
44
|
-
children: /* @__PURE__ */
|
|
46
|
+
children: /* @__PURE__ */ h("path", {
|
|
45
47
|
d: "M8 3v10M4 9l4 4 4-4",
|
|
46
48
|
stroke: "currentColor",
|
|
47
49
|
strokeWidth: "2",
|
|
48
50
|
strokeLinecap: "round",
|
|
49
51
|
strokeLinejoin: "round"
|
|
50
52
|
})
|
|
51
|
-
}), /* @__PURE__ */
|
|
53
|
+
}), /* @__PURE__ */ h("span", { children: e ? t.requireReadDone : t.requireReadPending })]
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
let n =
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!H || !R.current) return;
|
|
81
|
-
let e = R.current, t = new ResizeObserver(() => {
|
|
82
|
-
W.current && o(W.current, H, e, V.current).then(T);
|
|
56
|
+
var v = ({ file: o, workerSrc: c, sidebar: v, toolbar: y, onChangeFile: b, themeOverrides: ue, defaultTheme: de, defaultFit: x, language: fe, className: S, style: pe, requireRead: C, onDocumentRead: w }) => {
|
|
57
|
+
d(() => {
|
|
58
|
+
let e = new URL(c, location.href).href, t = new Blob([`${ie}\nimport(${JSON.stringify(e)});`], { type: "application/javascript" }), n = URL.createObjectURL(t);
|
|
59
|
+
return se.GlobalWorkerOptions.workerSrc = n, () => URL.revokeObjectURL(n);
|
|
60
|
+
}, [c]);
|
|
61
|
+
let [T, E] = m(1), [D, me] = m(0), [O, k] = m(null), [A, he] = m([]), [j, ge] = m(!1), [M, N] = m(x ?? null), [P, F] = m(null), [I, L] = m(!1), R = p(!1), z = p(null), B = p([]), V = p([]), H = p(D);
|
|
62
|
+
d(() => {
|
|
63
|
+
H.current = D;
|
|
64
|
+
}, [D]);
|
|
65
|
+
let [_e, ve] = m(null);
|
|
66
|
+
_e !== o && (ve(o), k(null), L(!1)), d(() => {
|
|
67
|
+
R.current = !1;
|
|
68
|
+
}, [o]);
|
|
69
|
+
let { pdf: U, numPages: W, loading: ye } = ee(o);
|
|
70
|
+
d(() => {
|
|
71
|
+
U && (B.current = Array(U.numPages).fill(null), V.current = Array(U.numPages).fill(null));
|
|
72
|
+
}, [U]), d(() => {
|
|
73
|
+
!U || !x || !z.current || s(x, U, z.current, H.current).then(E);
|
|
74
|
+
}, [U, x]);
|
|
75
|
+
let G = p(M);
|
|
76
|
+
d(() => {
|
|
77
|
+
G.current = M;
|
|
78
|
+
}, [M]), d(() => {
|
|
79
|
+
if (!U || !z.current) return;
|
|
80
|
+
let e = z.current, t = new ResizeObserver(() => {
|
|
81
|
+
G.current && s(G.current, U, e, H.current).then(E);
|
|
83
82
|
});
|
|
84
83
|
return t.observe(e), () => t.disconnect();
|
|
85
|
-
}, [
|
|
86
|
-
let { currentPage:
|
|
87
|
-
numPages:
|
|
88
|
-
containerRef:
|
|
89
|
-
pageRefs:
|
|
84
|
+
}, [U]);
|
|
85
|
+
let { currentPage: K, goToPage: q } = t({
|
|
86
|
+
numPages: W,
|
|
87
|
+
containerRef: z,
|
|
88
|
+
pageRefs: B
|
|
90
89
|
});
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
d(() => {
|
|
91
|
+
W === 0 || K < W || (C && !I && L(!0), R.current || (R.current = !0, w?.()));
|
|
93
92
|
}, [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
K,
|
|
94
|
+
W,
|
|
95
|
+
C,
|
|
96
|
+
I,
|
|
97
|
+
w
|
|
99
98
|
]);
|
|
100
|
-
let
|
|
101
|
-
if (
|
|
102
|
-
let e = /* @__PURE__ */ new Set(), t = Math.max(
|
|
99
|
+
let J = f(() => {
|
|
100
|
+
if (W === 0) return [];
|
|
101
|
+
let e = /* @__PURE__ */ new Set(), t = Math.max(K - _, 1), n = Math.min(K + _, W);
|
|
103
102
|
for (let r = t; r <= n; r++) e.add(r);
|
|
104
|
-
|
|
105
|
-
for (let t of
|
|
103
|
+
O && e.add(O.page);
|
|
104
|
+
for (let t of A) e.add(t.page);
|
|
106
105
|
return Array.from(e).sort((e, t) => e - t);
|
|
107
106
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]), { pageSizes:
|
|
113
|
-
pdf:
|
|
114
|
-
zoom:
|
|
115
|
-
rotation:
|
|
116
|
-
visiblePages:
|
|
117
|
-
canvasRefs:
|
|
118
|
-
}),
|
|
119
|
-
let e = new Set(
|
|
120
|
-
for (let t of
|
|
107
|
+
K,
|
|
108
|
+
W,
|
|
109
|
+
O,
|
|
110
|
+
A
|
|
111
|
+
]), { pageSizes: be, renderedPages: Y } = te({
|
|
112
|
+
pdf: U,
|
|
113
|
+
zoom: T,
|
|
114
|
+
rotation: D,
|
|
115
|
+
visiblePages: J,
|
|
116
|
+
canvasRefs: V
|
|
117
|
+
}), X = f(() => {
|
|
118
|
+
let e = new Set(J);
|
|
119
|
+
for (let t of Y) e.add(t);
|
|
121
120
|
return Array.from(e).sort((e, t) => e - t);
|
|
122
|
-
}, [
|
|
121
|
+
}, [J, Y]);
|
|
123
122
|
n({
|
|
124
|
-
pdf:
|
|
125
|
-
currentPage:
|
|
126
|
-
goToPage:
|
|
127
|
-
setRotation:
|
|
128
|
-
}), re(
|
|
129
|
-
let
|
|
130
|
-
pdf:
|
|
131
|
-
zoom:
|
|
132
|
-
rotation:
|
|
133
|
-
mountedPages:
|
|
134
|
-
canvasRefs:
|
|
135
|
-
}), { linkOverlays:
|
|
136
|
-
pdf:
|
|
137
|
-
zoom:
|
|
138
|
-
rotation:
|
|
139
|
-
mountedPages:
|
|
140
|
-
goToPage:
|
|
123
|
+
pdf: U,
|
|
124
|
+
currentPage: K,
|
|
125
|
+
goToPage: q,
|
|
126
|
+
setRotation: me
|
|
127
|
+
}), re(z, T, E, N);
|
|
128
|
+
let xe = r({
|
|
129
|
+
pdf: U,
|
|
130
|
+
zoom: T,
|
|
131
|
+
rotation: D,
|
|
132
|
+
mountedPages: X,
|
|
133
|
+
canvasRefs: V
|
|
134
|
+
}), { linkOverlays: Se, noteOverlays: Ce } = a({
|
|
135
|
+
pdf: U,
|
|
136
|
+
zoom: T,
|
|
137
|
+
rotation: D,
|
|
138
|
+
mountedPages: X,
|
|
139
|
+
goToPage: q
|
|
141
140
|
});
|
|
142
|
-
|
|
143
|
-
if (!
|
|
144
|
-
let e = () =>
|
|
145
|
-
e.key === "Escape" &&
|
|
141
|
+
d(() => {
|
|
142
|
+
if (!P) return;
|
|
143
|
+
let e = () => F(null), t = (e) => {
|
|
144
|
+
e.key === "Escape" && F(null);
|
|
146
145
|
};
|
|
147
146
|
return document.addEventListener("click", e), document.addEventListener("keydown", t), () => {
|
|
148
147
|
document.removeEventListener("click", e), document.removeEventListener("keydown", t);
|
|
149
148
|
};
|
|
150
|
-
}, [
|
|
151
|
-
let { overlayRect:
|
|
152
|
-
pdf:
|
|
153
|
-
highlight:
|
|
154
|
-
searchMatches:
|
|
155
|
-
zoom:
|
|
156
|
-
rotation:
|
|
157
|
-
}),
|
|
149
|
+
}, [P]);
|
|
150
|
+
let { overlayRect: Z, searchOverlays: we } = ne({
|
|
151
|
+
pdf: U,
|
|
152
|
+
highlight: O,
|
|
153
|
+
searchMatches: A,
|
|
154
|
+
zoom: T,
|
|
155
|
+
rotation: D
|
|
156
|
+
}), Te = u((e, t) => {
|
|
158
157
|
(!e.url || !i(e.url)) && (t.preventDefault(), e.url || e._handleClick());
|
|
159
|
-
}, []),
|
|
160
|
-
|
|
158
|
+
}, []), Q = p(null), Ee = u((e, t) => {
|
|
159
|
+
Q.current && clearTimeout(Q.current);
|
|
161
160
|
let n = t.clientY > window.innerHeight * .6;
|
|
162
|
-
|
|
161
|
+
F({
|
|
163
162
|
x: Math.min(t.clientX, window.innerWidth - 304),
|
|
164
163
|
y: n ? window.innerHeight - t.clientY + 8 : t.clientY + 12,
|
|
165
164
|
above: n,
|
|
166
165
|
contents: e.contents,
|
|
167
166
|
title: e.title
|
|
168
167
|
});
|
|
169
|
-
}, []),
|
|
170
|
-
|
|
171
|
-
}, []),
|
|
172
|
-
|
|
168
|
+
}, []), $ = u(() => {
|
|
169
|
+
Q.current = setTimeout(() => F(null), 200);
|
|
170
|
+
}, []), De = u((e) => {
|
|
171
|
+
k({
|
|
173
172
|
page: e.page,
|
|
174
173
|
pdfRect: e.pdfRect
|
|
175
|
-
}),
|
|
176
|
-
}, [
|
|
177
|
-
pdf:
|
|
178
|
-
numPages:
|
|
179
|
-
zoom:
|
|
180
|
-
setZoom:
|
|
181
|
-
rotation:
|
|
182
|
-
setRotation:
|
|
183
|
-
currentPage:
|
|
184
|
-
goToPage:
|
|
185
|
-
containerRef:
|
|
186
|
-
canvasRefs:
|
|
187
|
-
file:
|
|
188
|
-
highlight:
|
|
189
|
-
setHighlight:
|
|
190
|
-
searchMatches:
|
|
191
|
-
setSearchMatches:
|
|
192
|
-
onChangeFile:
|
|
193
|
-
sidebarCollapsed:
|
|
194
|
-
setSidebarCollapsed:
|
|
195
|
-
fitMode:
|
|
196
|
-
setFitMode:
|
|
197
|
-
navigationLocked: !!
|
|
174
|
+
}), q(e.page);
|
|
175
|
+
}, [k, q]), Oe = f(() => ({
|
|
176
|
+
pdf: U,
|
|
177
|
+
numPages: W,
|
|
178
|
+
zoom: T,
|
|
179
|
+
setZoom: E,
|
|
180
|
+
rotation: D,
|
|
181
|
+
setRotation: me,
|
|
182
|
+
currentPage: K,
|
|
183
|
+
goToPage: q,
|
|
184
|
+
containerRef: z,
|
|
185
|
+
canvasRefs: V,
|
|
186
|
+
file: o,
|
|
187
|
+
highlight: O,
|
|
188
|
+
setHighlight: k,
|
|
189
|
+
searchMatches: A,
|
|
190
|
+
setSearchMatches: he,
|
|
191
|
+
onChangeFile: b,
|
|
192
|
+
sidebarCollapsed: j,
|
|
193
|
+
setSidebarCollapsed: ge,
|
|
194
|
+
fitMode: M,
|
|
195
|
+
setFitMode: N,
|
|
196
|
+
navigationLocked: !!C && !I
|
|
198
197
|
}), [
|
|
199
|
-
H,
|
|
200
198
|
U,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
G,
|
|
204
|
-
K,
|
|
205
|
-
s,
|
|
199
|
+
W,
|
|
200
|
+
T,
|
|
206
201
|
D,
|
|
207
|
-
|
|
208
|
-
|
|
202
|
+
K,
|
|
203
|
+
q,
|
|
204
|
+
o,
|
|
205
|
+
O,
|
|
209
206
|
A,
|
|
207
|
+
b,
|
|
210
208
|
j,
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
M,
|
|
210
|
+
C,
|
|
211
|
+
I
|
|
213
212
|
]);
|
|
214
|
-
return /* @__PURE__ */
|
|
215
|
-
themeOverrides:
|
|
216
|
-
defaultTheme:
|
|
217
|
-
children: /* @__PURE__ */
|
|
218
|
-
language:
|
|
219
|
-
children: /* @__PURE__ */
|
|
213
|
+
return /* @__PURE__ */ h(ae, {
|
|
214
|
+
themeOverrides: ue,
|
|
215
|
+
defaultTheme: de,
|
|
216
|
+
children: /* @__PURE__ */ h(oe, {
|
|
217
|
+
language: fe,
|
|
218
|
+
children: /* @__PURE__ */ g(e.Provider, {
|
|
220
219
|
value: Oe,
|
|
221
|
-
children: [/* @__PURE__ */
|
|
222
|
-
className: `${
|
|
223
|
-
style:
|
|
224
|
-
children: [
|
|
225
|
-
className:
|
|
226
|
-
children:
|
|
227
|
-
}), /* @__PURE__ */
|
|
228
|
-
className:
|
|
229
|
-
children: [
|
|
230
|
-
className:
|
|
231
|
-
ref:
|
|
220
|
+
children: [/* @__PURE__ */ g("div", {
|
|
221
|
+
className: `${l.appLayout}${S ? ` ${S}` : ""}`,
|
|
222
|
+
style: pe,
|
|
223
|
+
children: [y && /* @__PURE__ */ h("div", {
|
|
224
|
+
className: l.toolbar,
|
|
225
|
+
children: y
|
|
226
|
+
}), /* @__PURE__ */ g("div", {
|
|
227
|
+
className: l.body,
|
|
228
|
+
children: [v, /* @__PURE__ */ g("div", {
|
|
229
|
+
className: l.scrollContainer,
|
|
230
|
+
ref: z,
|
|
232
231
|
children: [
|
|
233
|
-
|
|
234
|
-
Array.from({ length:
|
|
235
|
-
let n =
|
|
236
|
-
return /* @__PURE__ */
|
|
237
|
-
className:
|
|
232
|
+
ye && /* @__PURE__ */ h("div", { className: l.documentLoading }),
|
|
233
|
+
Array.from({ length: W }, (e, t) => {
|
|
234
|
+
let n = Y.has(t + 1), r = be[t], a = X.includes(t + 1);
|
|
235
|
+
return /* @__PURE__ */ g("div", {
|
|
236
|
+
className: l.pageWrapper,
|
|
238
237
|
ref: (e) => {
|
|
239
|
-
|
|
238
|
+
B.current[t] = e;
|
|
240
239
|
},
|
|
241
240
|
style: r ? {
|
|
242
241
|
width: r.width,
|
|
243
242
|
height: r.height
|
|
244
243
|
} : void 0,
|
|
245
244
|
children: [
|
|
246
|
-
r && !n && /* @__PURE__ */
|
|
247
|
-
className:
|
|
245
|
+
r && !n && /* @__PURE__ */ h("div", {
|
|
246
|
+
className: l.pageSkeleton,
|
|
248
247
|
style: {
|
|
249
248
|
width: r.width,
|
|
250
249
|
height: r.height
|
|
251
250
|
}
|
|
252
251
|
}),
|
|
253
|
-
a && /* @__PURE__ */
|
|
254
|
-
className:
|
|
252
|
+
a && /* @__PURE__ */ g(ce, { children: [/* @__PURE__ */ h("canvas", {
|
|
253
|
+
className: l.pageCanvas,
|
|
255
254
|
ref: (e) => {
|
|
256
|
-
|
|
255
|
+
V.current[t] = e;
|
|
257
256
|
},
|
|
258
257
|
style: { display: n ? "block" : "none" }
|
|
259
|
-
}), /* @__PURE__ */
|
|
260
|
-
className: `textLayer ${
|
|
258
|
+
}), /* @__PURE__ */ h("div", {
|
|
259
|
+
className: `textLayer ${l.textLayer}`,
|
|
261
260
|
ref: (e) => {
|
|
262
|
-
|
|
261
|
+
xe.current[t] = e;
|
|
263
262
|
}
|
|
264
263
|
})] }),
|
|
265
|
-
|
|
266
|
-
className:
|
|
264
|
+
Se.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ h("a", {
|
|
265
|
+
className: l.linkOverlay,
|
|
267
266
|
href: e.url && i(e.url) ? e.url : "#",
|
|
268
267
|
target: "_blank",
|
|
269
268
|
rel: "noopener noreferrer",
|
|
@@ -273,27 +272,27 @@ var _ = ({ file: s, workerSrc: _, sidebar: ue, toolbar: v, onChangeFile: y, them
|
|
|
273
272
|
width: e.width,
|
|
274
273
|
height: e.height
|
|
275
274
|
},
|
|
276
|
-
onClick: (t) =>
|
|
275
|
+
onClick: (t) => Te(e, t)
|
|
277
276
|
}, t)),
|
|
278
|
-
|
|
279
|
-
className:
|
|
277
|
+
Ce.filter((e) => e.page === t + 1).map((e, t) => e.subtype === "Text" ? /* @__PURE__ */ h("div", {
|
|
278
|
+
className: l.noteIconOverlay,
|
|
280
279
|
style: {
|
|
281
280
|
left: e.x,
|
|
282
281
|
top: e.y,
|
|
283
282
|
width: Math.max(e.width, 26),
|
|
284
283
|
height: Math.max(e.height, 26)
|
|
285
284
|
},
|
|
286
|
-
onMouseEnter: (t) =>
|
|
287
|
-
onMouseLeave:
|
|
288
|
-
onClick: () =>
|
|
289
|
-
children: /* @__PURE__ */
|
|
285
|
+
onMouseEnter: (t) => Ee(e, t),
|
|
286
|
+
onMouseLeave: $,
|
|
287
|
+
onClick: () => De(e),
|
|
288
|
+
children: /* @__PURE__ */ g("svg", {
|
|
290
289
|
width: "22",
|
|
291
290
|
height: "22",
|
|
292
291
|
viewBox: "0 0 12 12",
|
|
293
292
|
fill: "none",
|
|
294
293
|
"aria-hidden": "true",
|
|
295
294
|
children: [
|
|
296
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ h("rect", {
|
|
297
296
|
x: "0.5",
|
|
298
297
|
y: "0.5",
|
|
299
298
|
width: "9",
|
|
@@ -303,13 +302,13 @@ var _ = ({ file: s, workerSrc: _, sidebar: ue, toolbar: v, onChangeFile: y, them
|
|
|
303
302
|
stroke: "rgba(160,120,0,0.7)",
|
|
304
303
|
strokeWidth: "1"
|
|
305
304
|
}),
|
|
306
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ h("path", {
|
|
307
306
|
d: "M9.5 5.5v3l2.5-3z",
|
|
308
307
|
fill: "rgba(255,210,0,0.9)",
|
|
309
308
|
stroke: "rgba(160,120,0,0.7)",
|
|
310
309
|
strokeWidth: "1"
|
|
311
310
|
}),
|
|
312
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ h("line", {
|
|
313
312
|
x1: "2",
|
|
314
313
|
y1: "3",
|
|
315
314
|
x2: "8",
|
|
@@ -318,7 +317,7 @@ var _ = ({ file: s, workerSrc: _, sidebar: ue, toolbar: v, onChangeFile: y, them
|
|
|
318
317
|
strokeWidth: "1",
|
|
319
318
|
strokeLinecap: "round"
|
|
320
319
|
}),
|
|
321
|
-
/* @__PURE__ */
|
|
320
|
+
/* @__PURE__ */ h("line", {
|
|
322
321
|
x1: "2",
|
|
323
322
|
y1: "5.5",
|
|
324
323
|
x2: "7",
|
|
@@ -329,20 +328,20 @@ var _ = ({ file: s, workerSrc: _, sidebar: ue, toolbar: v, onChangeFile: y, them
|
|
|
329
328
|
})
|
|
330
329
|
]
|
|
331
330
|
})
|
|
332
|
-
}, t) : /* @__PURE__ */
|
|
333
|
-
className:
|
|
331
|
+
}, t) : /* @__PURE__ */ h("div", {
|
|
332
|
+
className: l.noteOverlay,
|
|
334
333
|
style: {
|
|
335
334
|
left: e.x,
|
|
336
335
|
top: e.y,
|
|
337
336
|
width: e.width,
|
|
338
337
|
height: e.height
|
|
339
338
|
},
|
|
340
|
-
onMouseEnter: (t) =>
|
|
341
|
-
onMouseLeave:
|
|
342
|
-
onClick: () =>
|
|
339
|
+
onMouseEnter: (t) => Ee(e, t),
|
|
340
|
+
onMouseLeave: $,
|
|
341
|
+
onClick: () => De(e)
|
|
343
342
|
}, t)),
|
|
344
|
-
|
|
345
|
-
className:
|
|
343
|
+
we.filter((e) => e.page === t + 1).map((e, t) => /* @__PURE__ */ h("div", {
|
|
344
|
+
className: l.searchMatchOverlay,
|
|
346
345
|
style: {
|
|
347
346
|
left: e.x,
|
|
348
347
|
top: e.y,
|
|
@@ -350,42 +349,42 @@ var _ = ({ file: s, workerSrc: _, sidebar: ue, toolbar: v, onChangeFile: y, them
|
|
|
350
349
|
height: e.height
|
|
351
350
|
}
|
|
352
351
|
}, t)),
|
|
353
|
-
|
|
354
|
-
className:
|
|
352
|
+
O && Z?.page === t + 1 && /* @__PURE__ */ h("div", {
|
|
353
|
+
className: l.highlightOverlay,
|
|
355
354
|
style: {
|
|
356
|
-
left:
|
|
357
|
-
top:
|
|
358
|
-
width:
|
|
359
|
-
height:
|
|
355
|
+
left: Z.x,
|
|
356
|
+
top: Z.y,
|
|
357
|
+
width: Z.width,
|
|
358
|
+
height: Z.height
|
|
360
359
|
}
|
|
361
360
|
})
|
|
362
361
|
]
|
|
363
|
-
}, `${t}-${
|
|
362
|
+
}, `${t}-${D}`);
|
|
364
363
|
}),
|
|
365
|
-
|
|
364
|
+
C && /* @__PURE__ */ h(le, { hasRead: I })
|
|
366
365
|
]
|
|
367
366
|
})]
|
|
368
367
|
})]
|
|
369
|
-
}),
|
|
370
|
-
className:
|
|
371
|
-
style:
|
|
372
|
-
left:
|
|
373
|
-
bottom:
|
|
368
|
+
}), P && /* @__PURE__ */ g("div", {
|
|
369
|
+
className: l.notePopover,
|
|
370
|
+
style: P.above ? {
|
|
371
|
+
left: P.x,
|
|
372
|
+
bottom: P.y
|
|
374
373
|
} : {
|
|
375
|
-
left:
|
|
376
|
-
top:
|
|
374
|
+
left: P.x,
|
|
375
|
+
top: P.y
|
|
377
376
|
},
|
|
378
377
|
onMouseEnter: () => {
|
|
379
|
-
|
|
378
|
+
Q.current && clearTimeout(Q.current);
|
|
380
379
|
},
|
|
381
|
-
onMouseLeave:
|
|
380
|
+
onMouseLeave: $,
|
|
382
381
|
onClick: (e) => e.stopPropagation(),
|
|
383
|
-
children: [
|
|
384
|
-
className:
|
|
385
|
-
children:
|
|
386
|
-
}), /* @__PURE__ */
|
|
387
|
-
className:
|
|
388
|
-
children:
|
|
382
|
+
children: [P.title && /* @__PURE__ */ h("div", {
|
|
383
|
+
className: l.notePopoverTitle,
|
|
384
|
+
children: P.title
|
|
385
|
+
}), /* @__PURE__ */ h("p", {
|
|
386
|
+
className: l.notePopoverContent,
|
|
387
|
+
children: P.contents
|
|
389
388
|
})]
|
|
390
389
|
})]
|
|
391
390
|
})
|
|
@@ -393,4 +392,4 @@ var _ = ({ file: s, workerSrc: _, sidebar: ue, toolbar: v, onChangeFile: y, them
|
|
|
393
392
|
});
|
|
394
393
|
};
|
|
395
394
|
//#endregion
|
|
396
|
-
export {
|
|
395
|
+
export { v as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/utils/pdfjsPolyfill.ts
|
|
2
|
+
var e = "(function(){function g(k,f){if(!this.has(k))this.set(k,f(k));return this.get(k);}if(typeof Map!==\"undefined\"&&!(\"getOrInsertComputed\" in Map.prototype))Map.prototype.getOrInsertComputed=g;if(typeof WeakMap!==\"undefined\"&&!(\"getOrInsertComputed\" in WeakMap.prototype))WeakMap.prototype.getOrInsertComputed=g;})();";
|
|
3
|
+
function t() {
|
|
4
|
+
let e = function(e, t) {
|
|
5
|
+
return this.has(e) || this.set(e, t(e)), this.get(e);
|
|
6
|
+
};
|
|
7
|
+
"getOrInsertComputed" in Map.prototype || (Map.prototype.getOrInsertComputed = e), "getOrInsertComputed" in WeakMap.prototype || (WeakMap.prototype.getOrInsertComputed = e);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as PDFJS_POLYFILL, t as applyPdfjsPolyfill };
|