laif-ds 0.2.30 → 0.2.31
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/_virtual/index2.js +2 -5
- package/dist/_virtual/index3.js +5 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/_virtual/warning.js +8 -0
- package/dist/components/ui/file-previewer.js +46 -36
- package/dist/components/ui/secure-pdf-viewer.js +115 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +131 -129
- package/dist/laif-ds.css +1 -1
- package/dist/node_modules/dequal/dist/index.js +56 -0
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/make-cancellable-promise/dist/index.js +15 -0
- package/dist/node_modules/make-event-props/dist/index.js +114 -0
- package/dist/node_modules/merge-refs/dist/index.js +19 -0
- package/dist/node_modules/react-pdf/dist/Document.js +180 -0
- package/dist/node_modules/react-pdf/dist/DocumentContext.js +6 -0
- package/dist/node_modules/react-pdf/dist/LinkService.js +94 -0
- package/dist/node_modules/react-pdf/dist/Message.js +8 -0
- package/dist/node_modules/react-pdf/dist/Page/AnnotationLayer.js +97 -0
- package/dist/node_modules/react-pdf/dist/Page/Canvas.js +55 -0
- package/dist/node_modules/react-pdf/dist/Page/TextLayer.js +111 -0
- package/dist/node_modules/react-pdf/dist/Page.js +180 -0
- package/dist/node_modules/react-pdf/dist/PageContext.js +6 -0
- package/dist/node_modules/react-pdf/dist/PasswordResponses.js +8 -0
- package/dist/node_modules/react-pdf/dist/StructTree.js +44 -0
- package/dist/node_modules/react-pdf/dist/StructTreeItem.js +14 -0
- package/dist/node_modules/react-pdf/dist/index.js +9 -0
- package/dist/node_modules/react-pdf/dist/shared/constants.js +62 -0
- package/dist/node_modules/react-pdf/dist/shared/hooks/useDocumentContext.js +9 -0
- package/dist/node_modules/react-pdf/dist/shared/hooks/usePageContext.js +9 -0
- package/dist/node_modules/react-pdf/dist/shared/hooks/useResolver.js +20 -0
- package/dist/node_modules/react-pdf/dist/shared/structTreeUtils.js +55 -0
- package/dist/node_modules/react-pdf/dist/shared/utils.js +110 -0
- package/dist/node_modules/react-pdf/node_modules/pdfjs-dist/build/pdf.js +15282 -0
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +13 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/node_modules/warning/warning.js +39 -0
- package/dist/styles.v3.css +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const r = ["onCopy", "onCut", "onPaste"], i = [
|
|
3
|
+
"onCompositionEnd",
|
|
4
|
+
"onCompositionStart",
|
|
5
|
+
"onCompositionUpdate"
|
|
6
|
+
], c = ["onFocus", "onBlur"], u = ["onInput", "onInvalid", "onReset", "onSubmit"], E = ["onLoad", "onError"], v = ["onKeyDown", "onKeyPress", "onKeyUp"], d = [
|
|
7
|
+
"onAbort",
|
|
8
|
+
"onCanPlay",
|
|
9
|
+
"onCanPlayThrough",
|
|
10
|
+
"onDurationChange",
|
|
11
|
+
"onEmptied",
|
|
12
|
+
"onEncrypted",
|
|
13
|
+
"onEnded",
|
|
14
|
+
"onError",
|
|
15
|
+
"onLoadedData",
|
|
16
|
+
"onLoadedMetadata",
|
|
17
|
+
"onLoadStart",
|
|
18
|
+
"onPause",
|
|
19
|
+
"onPlay",
|
|
20
|
+
"onPlaying",
|
|
21
|
+
"onProgress",
|
|
22
|
+
"onRateChange",
|
|
23
|
+
"onSeeked",
|
|
24
|
+
"onSeeking",
|
|
25
|
+
"onStalled",
|
|
26
|
+
"onSuspend",
|
|
27
|
+
"onTimeUpdate",
|
|
28
|
+
"onVolumeChange",
|
|
29
|
+
"onWaiting"
|
|
30
|
+
], l = [
|
|
31
|
+
"onClick",
|
|
32
|
+
"onContextMenu",
|
|
33
|
+
"onDoubleClick",
|
|
34
|
+
"onMouseDown",
|
|
35
|
+
"onMouseEnter",
|
|
36
|
+
"onMouseLeave",
|
|
37
|
+
"onMouseMove",
|
|
38
|
+
"onMouseOut",
|
|
39
|
+
"onMouseOver",
|
|
40
|
+
"onMouseUp"
|
|
41
|
+
], p = [
|
|
42
|
+
"onDrag",
|
|
43
|
+
"onDragEnd",
|
|
44
|
+
"onDragEnter",
|
|
45
|
+
"onDragExit",
|
|
46
|
+
"onDragLeave",
|
|
47
|
+
"onDragOver",
|
|
48
|
+
"onDragStart",
|
|
49
|
+
"onDrop"
|
|
50
|
+
], P = ["onSelect"], g = ["onTouchCancel", "onTouchEnd", "onTouchMove", "onTouchStart"], m = [
|
|
51
|
+
"onPointerDown",
|
|
52
|
+
"onPointerMove",
|
|
53
|
+
"onPointerUp",
|
|
54
|
+
"onPointerCancel",
|
|
55
|
+
"onGotPointerCapture",
|
|
56
|
+
"onLostPointerCapture",
|
|
57
|
+
"onPointerEnter",
|
|
58
|
+
"onPointerLeave",
|
|
59
|
+
"onPointerOver",
|
|
60
|
+
"onPointerOut"
|
|
61
|
+
], C = ["onScroll"], h = ["onWheel"], D = [
|
|
62
|
+
"onAnimationStart",
|
|
63
|
+
"onAnimationEnd",
|
|
64
|
+
"onAnimationIteration"
|
|
65
|
+
], M = ["onTransitionEnd"], S = ["onToggle"], y = ["onChange"], f = [
|
|
66
|
+
...r,
|
|
67
|
+
...i,
|
|
68
|
+
...c,
|
|
69
|
+
...u,
|
|
70
|
+
...E,
|
|
71
|
+
...v,
|
|
72
|
+
...d,
|
|
73
|
+
...l,
|
|
74
|
+
...p,
|
|
75
|
+
...P,
|
|
76
|
+
...g,
|
|
77
|
+
...m,
|
|
78
|
+
...C,
|
|
79
|
+
...h,
|
|
80
|
+
...D,
|
|
81
|
+
...M,
|
|
82
|
+
...y,
|
|
83
|
+
...S
|
|
84
|
+
];
|
|
85
|
+
function L(s, t) {
|
|
86
|
+
const o = {};
|
|
87
|
+
for (const n of f) {
|
|
88
|
+
const e = s[n];
|
|
89
|
+
e && (t ? o[n] = ((a) => e(a, t(n))) : o[n] = e);
|
|
90
|
+
}
|
|
91
|
+
return o;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
f as allEvents,
|
|
95
|
+
D as animationEvents,
|
|
96
|
+
y as changeEvents,
|
|
97
|
+
r as clipboardEvents,
|
|
98
|
+
i as compositionEvents,
|
|
99
|
+
L as default,
|
|
100
|
+
p as dragEvents,
|
|
101
|
+
c as focusEvents,
|
|
102
|
+
u as formEvents,
|
|
103
|
+
E as imageEvents,
|
|
104
|
+
v as keyboardEvents,
|
|
105
|
+
d as mediaEvents,
|
|
106
|
+
l as mouseEvents,
|
|
107
|
+
S as otherEvents,
|
|
108
|
+
m as pointerEvents,
|
|
109
|
+
P as selectionEvents,
|
|
110
|
+
g as touchEvents,
|
|
111
|
+
M as transitionEvents,
|
|
112
|
+
C as uiEvents,
|
|
113
|
+
h as wheelEvents
|
|
114
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function s() {
|
|
3
|
+
for (var a = [], e = 0; e < arguments.length; e++)
|
|
4
|
+
a[e] = arguments[e];
|
|
5
|
+
var n = a.filter(Boolean);
|
|
6
|
+
if (n.length <= 1) {
|
|
7
|
+
var o = n[0];
|
|
8
|
+
return o || null;
|
|
9
|
+
}
|
|
10
|
+
return function(f) {
|
|
11
|
+
for (var t = 0, l = n; t < l.length; t++) {
|
|
12
|
+
var r = l[t];
|
|
13
|
+
typeof r == "function" ? r(f) : r && (r.current = f);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
s as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as ye, useRef as h, useImperativeHandle as he, useEffect as u, useCallback as O, useMemo as K } from "react";
|
|
4
|
+
import { clsx as ve } from "../../clsx/dist/clsx.js";
|
|
5
|
+
import { dequal as Q } from "../../dequal/dist/index.js";
|
|
6
|
+
import Se from "../../make-cancellable-promise/dist/index.js";
|
|
7
|
+
import Ee from "../../make-event-props/dist/index.js";
|
|
8
|
+
import * as we from "../node_modules/pdfjs-dist/build/pdf.js";
|
|
9
|
+
import { getDocument as De } from "../node_modules/pdfjs-dist/build/pdf.js";
|
|
10
|
+
import X from "../../tiny-invariant/dist/esm/tiny-invariant.js";
|
|
11
|
+
import v from "../../../_virtual/warning.js";
|
|
12
|
+
import Re from "./DocumentContext.js";
|
|
13
|
+
import be from "./LinkService.js";
|
|
14
|
+
import T from "./Message.js";
|
|
15
|
+
import Y from "./PasswordResponses.js";
|
|
16
|
+
import Z from "./shared/hooks/useResolver.js";
|
|
17
|
+
import { isDataURI as ee, dataURItoByteString as re, displayCORSWarning as te, isArrayBuffer as Pe, isBrowser as Ce, isBlob as ke, loadFromFile as Fe, cancelRunningTask as Ie } from "./shared/utils.js";
|
|
18
|
+
const { PDFDataRangeTransport: Oe } = we, Te = (i, f) => {
|
|
19
|
+
switch (f) {
|
|
20
|
+
case Y.NEED_PASSWORD: {
|
|
21
|
+
const p = prompt("Enter the password to open this PDF file.");
|
|
22
|
+
i(p);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
case Y.INCORRECT_PASSWORD: {
|
|
26
|
+
const p = prompt("Invalid password. Please try again.");
|
|
27
|
+
i(p);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function ne(i) {
|
|
33
|
+
return typeof i == "object" && i !== null && ("data" in i || "range" in i || "url" in i);
|
|
34
|
+
}
|
|
35
|
+
const Me = ye(function({ children: f, className: p, error: w = "Failed to load PDF file.", externalLinkRel: B, externalLinkTarget: j, file: e, inputRef: oe, imageResourcesPath: A, loading: D = "Loading PDF…", noData: R = "No PDF file specified.", onItemClick: S, onLoadError: L, onLoadProgress: x, onLoadSuccess: N, onPassword: V = Te, onSourceError: _, onSourceSuccess: q, options: a, renderMode: U, rotate: W, scale: z, ...J }, ie) {
|
|
36
|
+
const [se, l] = Z(), { value: s, error: b } = se, [ae, m] = Z(), { value: t, error: P } = ae, c = h(new be()), g = h([]), C = h(void 0), k = h(void 0);
|
|
37
|
+
e && e !== C.current && ne(e) && (v(!Q(e, C.current), `File prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`), C.current = e), a && a !== k.current && (v(!Q(a, k.current), `Options prop passed to <Document /> changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`), k.current = a);
|
|
38
|
+
const $ = h({
|
|
39
|
+
// Handling jumping to internal links target
|
|
40
|
+
scrollPageIntoView: (r) => {
|
|
41
|
+
const { dest: n, pageNumber: o, pageIndex: d = o - 1 } = r;
|
|
42
|
+
if (S) {
|
|
43
|
+
S({ dest: n, pageIndex: d, pageNumber: o });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const E = g.current[d];
|
|
47
|
+
if (E) {
|
|
48
|
+
E.scrollIntoView();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
v(!1, `An internal link leading to page ${o} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
he(ie, () => ({
|
|
55
|
+
linkService: c,
|
|
56
|
+
pages: g,
|
|
57
|
+
viewer: $
|
|
58
|
+
}), []);
|
|
59
|
+
function ue() {
|
|
60
|
+
q && q();
|
|
61
|
+
}
|
|
62
|
+
function ce() {
|
|
63
|
+
b && (v(!1, b.toString()), _ && _(b));
|
|
64
|
+
}
|
|
65
|
+
function de() {
|
|
66
|
+
l({ type: "RESET" });
|
|
67
|
+
}
|
|
68
|
+
u(de, [e, l]);
|
|
69
|
+
const H = O(async () => {
|
|
70
|
+
if (!e)
|
|
71
|
+
return null;
|
|
72
|
+
if (typeof e == "string")
|
|
73
|
+
return ee(e) ? { data: re(e) } : (te(), { url: e });
|
|
74
|
+
if (e instanceof Oe)
|
|
75
|
+
return { range: e };
|
|
76
|
+
if (Pe(e))
|
|
77
|
+
return { data: e };
|
|
78
|
+
if (Ce && ke(e))
|
|
79
|
+
return { data: await Fe(e) };
|
|
80
|
+
if (X(typeof e == "object", "Invalid parameter in file, need either Uint8Array, string or a parameter object"), X(ne(e), "Invalid parameter object: need either .data, .range or .url"), "url" in e && typeof e.url == "string") {
|
|
81
|
+
if (ee(e.url)) {
|
|
82
|
+
const { url: r, ...n } = e;
|
|
83
|
+
return { data: re(r), ...n };
|
|
84
|
+
}
|
|
85
|
+
te();
|
|
86
|
+
}
|
|
87
|
+
return e;
|
|
88
|
+
}, [e]);
|
|
89
|
+
u(() => {
|
|
90
|
+
const r = Se(H());
|
|
91
|
+
return r.promise.then((n) => {
|
|
92
|
+
l({ type: "RESOLVE", value: n });
|
|
93
|
+
}).catch((n) => {
|
|
94
|
+
l({ type: "REJECT", error: n });
|
|
95
|
+
}), () => {
|
|
96
|
+
Ie(r);
|
|
97
|
+
};
|
|
98
|
+
}, [H, l]), u(() => {
|
|
99
|
+
if (!(typeof s > "u")) {
|
|
100
|
+
if (s === !1) {
|
|
101
|
+
ce();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
ue();
|
|
105
|
+
}
|
|
106
|
+
}, [s]);
|
|
107
|
+
function fe() {
|
|
108
|
+
t && (N && N(t), g.current = new Array(t.numPages), c.current.setDocument(t));
|
|
109
|
+
}
|
|
110
|
+
function pe() {
|
|
111
|
+
P && (v(!1, P.toString()), L && L(P));
|
|
112
|
+
}
|
|
113
|
+
u(function() {
|
|
114
|
+
m({ type: "RESET" });
|
|
115
|
+
}, [m, s]), u(function() {
|
|
116
|
+
if (!s)
|
|
117
|
+
return;
|
|
118
|
+
const n = a ? { ...s, ...a } : s, o = De(n);
|
|
119
|
+
x && (o.onProgress = x), V && (o.onPassword = V);
|
|
120
|
+
const d = o, E = d.promise.then((I) => {
|
|
121
|
+
m({ type: "RESOLVE", value: I });
|
|
122
|
+
}).catch((I) => {
|
|
123
|
+
d.destroyed || m({ type: "REJECT", error: I });
|
|
124
|
+
});
|
|
125
|
+
return () => {
|
|
126
|
+
E.finally(() => d.destroy());
|
|
127
|
+
};
|
|
128
|
+
}, [a, m, s]), u(() => {
|
|
129
|
+
if (!(typeof t > "u")) {
|
|
130
|
+
if (t === !1) {
|
|
131
|
+
pe();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
fe();
|
|
135
|
+
}
|
|
136
|
+
}, [t]), u(function() {
|
|
137
|
+
c.current.setViewer($.current), c.current.setExternalLinkRel(B), c.current.setExternalLinkTarget(j);
|
|
138
|
+
}, [B, j]);
|
|
139
|
+
const M = O((r, n) => {
|
|
140
|
+
g.current[r] = n;
|
|
141
|
+
}, []), G = O((r) => {
|
|
142
|
+
delete g.current[r];
|
|
143
|
+
}, []), F = K(() => ({
|
|
144
|
+
imageResourcesPath: A,
|
|
145
|
+
linkService: c.current,
|
|
146
|
+
onItemClick: S,
|
|
147
|
+
pdf: t,
|
|
148
|
+
registerPage: M,
|
|
149
|
+
renderMode: U,
|
|
150
|
+
rotate: W,
|
|
151
|
+
scale: z,
|
|
152
|
+
unregisterPage: G
|
|
153
|
+
}), [A, S, t, M, U, W, z, G]), le = K(
|
|
154
|
+
() => Ee(J, () => t),
|
|
155
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: FIXME
|
|
156
|
+
[J, t]
|
|
157
|
+
);
|
|
158
|
+
function me() {
|
|
159
|
+
function r(o) {
|
|
160
|
+
return !!o?.pdf;
|
|
161
|
+
}
|
|
162
|
+
if (!r(F))
|
|
163
|
+
throw new Error("pdf is undefined");
|
|
164
|
+
const n = typeof f == "function" ? f(F) : f;
|
|
165
|
+
return y(Re.Provider, { value: F, children: n });
|
|
166
|
+
}
|
|
167
|
+
function ge() {
|
|
168
|
+
return e ? t == null ? y(T, { type: "loading", children: typeof D == "function" ? D() : D }) : t === !1 ? y(T, { type: "error", children: typeof w == "function" ? w() : w }) : me() : y(T, { type: "no-data", children: typeof R == "function" ? R() : R });
|
|
169
|
+
}
|
|
170
|
+
return y("div", {
|
|
171
|
+
className: ve("react-pdf__Document", p),
|
|
172
|
+
// Assertion is needed for React 18 compatibility
|
|
173
|
+
ref: oe,
|
|
174
|
+
...le,
|
|
175
|
+
children: ge()
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
export {
|
|
179
|
+
Me as default
|
|
180
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import i from "../../tiny-invariant/dist/esm/tiny-invariant.js";
|
|
3
|
+
const s = "noopener noreferrer nofollow";
|
|
4
|
+
class f {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.externalLinkEnabled = !0, this.externalLinkRel = void 0, this.externalLinkTarget = void 0, this.isInPresentationMode = !1, this.pdfDocument = void 0, this.pdfViewer = void 0;
|
|
7
|
+
}
|
|
8
|
+
setDocument(e) {
|
|
9
|
+
this.pdfDocument = e;
|
|
10
|
+
}
|
|
11
|
+
setViewer(e) {
|
|
12
|
+
this.pdfViewer = e;
|
|
13
|
+
}
|
|
14
|
+
setExternalLinkRel(e) {
|
|
15
|
+
this.externalLinkRel = e;
|
|
16
|
+
}
|
|
17
|
+
setExternalLinkTarget(e) {
|
|
18
|
+
this.externalLinkTarget = e;
|
|
19
|
+
}
|
|
20
|
+
setHistory() {
|
|
21
|
+
}
|
|
22
|
+
get pagesCount() {
|
|
23
|
+
return this.pdfDocument ? this.pdfDocument.numPages : 0;
|
|
24
|
+
}
|
|
25
|
+
get page() {
|
|
26
|
+
return i(this.pdfViewer, "PDF viewer is not initialized."), this.pdfViewer.currentPageNumber || 0;
|
|
27
|
+
}
|
|
28
|
+
set page(e) {
|
|
29
|
+
i(this.pdfViewer, "PDF viewer is not initialized."), this.pdfViewer.currentPageNumber = e;
|
|
30
|
+
}
|
|
31
|
+
get rotation() {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
set rotation(e) {
|
|
35
|
+
}
|
|
36
|
+
goToDestination(e) {
|
|
37
|
+
return new Promise((t) => {
|
|
38
|
+
i(this.pdfDocument, "PDF document not loaded."), i(e, "Destination is not specified."), typeof e == "string" ? this.pdfDocument.getDestination(e).then(t) : Array.isArray(e) ? t(e) : e.then(t);
|
|
39
|
+
}).then((t) => {
|
|
40
|
+
i(Array.isArray(t), `"${t}" is not a valid destination array.`);
|
|
41
|
+
const n = t[0];
|
|
42
|
+
new Promise((a) => {
|
|
43
|
+
i(this.pdfDocument, "PDF document not loaded."), n instanceof Object ? this.pdfDocument.getPageIndex(n).then((r) => {
|
|
44
|
+
a(r);
|
|
45
|
+
}).catch(() => {
|
|
46
|
+
i(!1, `"${n}" is not a valid page reference.`);
|
|
47
|
+
}) : typeof n == "number" ? a(n) : i(!1, `"${n}" is not a valid destination reference.`);
|
|
48
|
+
}).then((a) => {
|
|
49
|
+
const r = a + 1;
|
|
50
|
+
i(this.pdfViewer, "PDF viewer is not initialized."), i(r >= 1 && r <= this.pagesCount, `"${r}" is not a valid page number.`), this.pdfViewer.scrollPageIntoView({
|
|
51
|
+
dest: t,
|
|
52
|
+
pageIndex: a,
|
|
53
|
+
pageNumber: r
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
navigateTo(e) {
|
|
59
|
+
this.goToDestination(e);
|
|
60
|
+
}
|
|
61
|
+
goToPage(e) {
|
|
62
|
+
const t = e - 1;
|
|
63
|
+
i(this.pdfViewer, "PDF viewer is not initialized."), i(e >= 1 && e <= this.pagesCount, `"${e}" is not a valid page number.`), this.pdfViewer.scrollPageIntoView({
|
|
64
|
+
pageIndex: t,
|
|
65
|
+
pageNumber: e
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
addLinkAttributes(e, t, n) {
|
|
69
|
+
e.href = t, e.rel = this.externalLinkRel || s, e.target = n ? "_blank" : this.externalLinkTarget || "";
|
|
70
|
+
}
|
|
71
|
+
getDestinationHash() {
|
|
72
|
+
return "#";
|
|
73
|
+
}
|
|
74
|
+
getAnchorUrl() {
|
|
75
|
+
return "#";
|
|
76
|
+
}
|
|
77
|
+
setHash() {
|
|
78
|
+
}
|
|
79
|
+
executeNamedAction() {
|
|
80
|
+
}
|
|
81
|
+
cachePageRef() {
|
|
82
|
+
}
|
|
83
|
+
isPageVisible() {
|
|
84
|
+
return !0;
|
|
85
|
+
}
|
|
86
|
+
isPageCached() {
|
|
87
|
+
return !0;
|
|
88
|
+
}
|
|
89
|
+
executeSetOCGState() {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
f as default
|
|
94
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as V } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as _, useEffect as u, useMemo as j } from "react";
|
|
4
|
+
import { clsx as D } from "../../../clsx/dist/clsx.js";
|
|
5
|
+
import $ from "../../../make-cancellable-promise/dist/index.js";
|
|
6
|
+
import { AnnotationLayer as F } from "../../node_modules/pdfjs-dist/build/pdf.js";
|
|
7
|
+
import p from "../../../tiny-invariant/dist/esm/tiny-invariant.js";
|
|
8
|
+
import l from "../../../../_virtual/warning.js";
|
|
9
|
+
import I from "../shared/hooks/useDocumentContext.js";
|
|
10
|
+
import N from "../shared/hooks/usePageContext.js";
|
|
11
|
+
import U from "../shared/hooks/useResolver.js";
|
|
12
|
+
import { cancelRunningTask as H } from "../shared/utils.js";
|
|
13
|
+
function nn() {
|
|
14
|
+
const w = I(), d = N();
|
|
15
|
+
p(d, "Unable to find Page context.");
|
|
16
|
+
const b = { ...w, ...d }, { imageResourcesPath: m, linkService: i, onGetAnnotationsError: g, onGetAnnotationsSuccess: y, onRenderAnnotationLayerError: A, onRenderAnnotationLayerSuccess: E, page: n, pdf: s, renderForms: L, rotate: S, scale: P = 1 } = b;
|
|
17
|
+
p(s, "Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."), p(n, "Attempted to load page annotations, but no page was specified."), p(i, "Attempted to load page annotations, but no linkService was specified.");
|
|
18
|
+
const [x, e] = U(), { value: t, error: f } = x, R = _(null);
|
|
19
|
+
l(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"), 10) === 1, "AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");
|
|
20
|
+
function C() {
|
|
21
|
+
t && y && y(t);
|
|
22
|
+
}
|
|
23
|
+
function h() {
|
|
24
|
+
f && (l(!1, f.toString()), g && g(f));
|
|
25
|
+
}
|
|
26
|
+
u(function() {
|
|
27
|
+
e({ type: "RESET" });
|
|
28
|
+
}, [e, n]), u(function() {
|
|
29
|
+
if (!n)
|
|
30
|
+
return;
|
|
31
|
+
const o = $(n.getAnnotations()), c = o;
|
|
32
|
+
return o.promise.then((a) => {
|
|
33
|
+
e({ type: "RESOLVE", value: a });
|
|
34
|
+
}).catch((a) => {
|
|
35
|
+
e({ type: "REJECT", error: a });
|
|
36
|
+
}), () => {
|
|
37
|
+
H(c);
|
|
38
|
+
};
|
|
39
|
+
}, [e, n]), u(() => {
|
|
40
|
+
if (t !== void 0) {
|
|
41
|
+
if (t === !1) {
|
|
42
|
+
h();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
C();
|
|
46
|
+
}
|
|
47
|
+
}, [t]);
|
|
48
|
+
function k() {
|
|
49
|
+
E && E();
|
|
50
|
+
}
|
|
51
|
+
function T(r) {
|
|
52
|
+
l(!1, `${r}`), A && A(r);
|
|
53
|
+
}
|
|
54
|
+
const v = j(() => n.getViewport({ scale: P, rotation: S }), [n, S, P]);
|
|
55
|
+
return u(function() {
|
|
56
|
+
if (!s || !n || !i || !t)
|
|
57
|
+
return;
|
|
58
|
+
const { current: o } = R;
|
|
59
|
+
if (!o)
|
|
60
|
+
return;
|
|
61
|
+
const c = v.clone({ dontFlip: !0 }), a = {
|
|
62
|
+
accessibilityManager: null,
|
|
63
|
+
// TODO: Implement this
|
|
64
|
+
annotationCanvasMap: null,
|
|
65
|
+
// TODO: Implement this
|
|
66
|
+
annotationEditorUIManager: null,
|
|
67
|
+
// TODO: Implement this
|
|
68
|
+
div: o,
|
|
69
|
+
l10n: null,
|
|
70
|
+
// TODO: Implement this
|
|
71
|
+
page: n,
|
|
72
|
+
structTreeLayer: null,
|
|
73
|
+
// TODO: Implement this
|
|
74
|
+
viewport: c
|
|
75
|
+
}, M = {
|
|
76
|
+
annotations: t,
|
|
77
|
+
annotationStorage: s.annotationStorage,
|
|
78
|
+
div: o,
|
|
79
|
+
imageResourcesPath: m,
|
|
80
|
+
linkService: i,
|
|
81
|
+
page: n,
|
|
82
|
+
renderForms: L,
|
|
83
|
+
viewport: c
|
|
84
|
+
};
|
|
85
|
+
o.innerHTML = "";
|
|
86
|
+
try {
|
|
87
|
+
new F(a).render(M), k();
|
|
88
|
+
} catch (G) {
|
|
89
|
+
T(G);
|
|
90
|
+
}
|
|
91
|
+
return () => {
|
|
92
|
+
};
|
|
93
|
+
}, [t, m, i, n, s, L, v]), V("div", { className: D("react-pdf__Page__annotations", "annotationLayer"), ref: R });
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
nn as default
|
|
97
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as A, useMemo as w, useEffect as R, useCallback as T } from "react";
|
|
4
|
+
import O from "../../../merge-refs/dist/index.js";
|
|
5
|
+
import { AnnotationMode as _ } from "../../node_modules/pdfjs-dist/build/pdf.js";
|
|
6
|
+
import E from "../../../tiny-invariant/dist/esm/tiny-invariant.js";
|
|
7
|
+
import B from "../../../../_virtual/warning.js";
|
|
8
|
+
import L from "../StructTree.js";
|
|
9
|
+
import V from "../shared/hooks/usePageContext.js";
|
|
10
|
+
import { getDevicePixelRatio as $, cancelRunningTask as D, makePageCallback as F, isCancelException as j } from "../shared/utils.js";
|
|
11
|
+
const C = _;
|
|
12
|
+
function W(l) {
|
|
13
|
+
const d = V();
|
|
14
|
+
E(d, "Unable to find Page context.");
|
|
15
|
+
const b = { ...d, ...l }, { _className: y, canvasBackground: i, devicePixelRatio: f = $(), onRenderError: u, onRenderSuccess: p, page: e, renderForms: m, renderTextLayer: P, rotate: o, scale: r } = b, { canvasRef: k } = l;
|
|
16
|
+
E(e, "Attempted to render page canvas, but no page was specified.");
|
|
17
|
+
const s = A(null);
|
|
18
|
+
function M() {
|
|
19
|
+
e && p && p(F(e, r));
|
|
20
|
+
}
|
|
21
|
+
function N(t) {
|
|
22
|
+
j(t) || (B(!1, t.toString()), u && u(t));
|
|
23
|
+
}
|
|
24
|
+
const a = w(() => e.getViewport({ scale: r * f, rotation: o }), [f, e, o, r]), c = w(() => e.getViewport({ scale: r, rotation: o }), [e, o, r]);
|
|
25
|
+
R(function() {
|
|
26
|
+
if (!e)
|
|
27
|
+
return;
|
|
28
|
+
e.cleanup();
|
|
29
|
+
const { current: n } = s;
|
|
30
|
+
if (!n)
|
|
31
|
+
return;
|
|
32
|
+
n.width = a.width, n.height = a.height, n.style.width = `${Math.floor(c.width)}px`, n.style.height = `${Math.floor(c.height)}px`, n.style.visibility = "hidden";
|
|
33
|
+
const h = {
|
|
34
|
+
annotationMode: m ? C.ENABLE_FORMS : C.ENABLE,
|
|
35
|
+
canvasContext: n.getContext("2d", { alpha: !1 }),
|
|
36
|
+
viewport: a
|
|
37
|
+
};
|
|
38
|
+
i && (h.background = i);
|
|
39
|
+
const v = e.render(h), S = v;
|
|
40
|
+
return v.promise.then(() => {
|
|
41
|
+
n.style.visibility = "", M();
|
|
42
|
+
}).catch(N), () => D(S);
|
|
43
|
+
}, [i, e, m, a, c]);
|
|
44
|
+
const g = T(() => {
|
|
45
|
+
const { current: t } = s;
|
|
46
|
+
t && (t.width = 0, t.height = 0);
|
|
47
|
+
}, []);
|
|
48
|
+
return R(() => g, [g]), x("canvas", { className: `${y}__canvas`, dir: "ltr", ref: O(k, s), style: {
|
|
49
|
+
display: "block",
|
|
50
|
+
userSelect: "none"
|
|
51
|
+
}, children: P ? x(L, {}) : null });
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
W as default
|
|
55
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as H } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as q, useEffect as m, useCallback as k, useMemo as J, useLayoutEffect as $ } from "react";
|
|
4
|
+
import { clsx as z } from "../../../clsx/dist/clsx.js";
|
|
5
|
+
import B from "../../../make-cancellable-promise/dist/index.js";
|
|
6
|
+
import { TextLayer as F } from "../../node_modules/pdfjs-dist/build/pdf.js";
|
|
7
|
+
import P from "../../../tiny-invariant/dist/esm/tiny-invariant.js";
|
|
8
|
+
import x from "../../../../_virtual/warning.js";
|
|
9
|
+
import K from "../shared/hooks/usePageContext.js";
|
|
10
|
+
import Q from "../shared/hooks/useResolver.js";
|
|
11
|
+
import { cancelRunningTask as N } from "../shared/utils.js";
|
|
12
|
+
function W(s) {
|
|
13
|
+
return "str" in s;
|
|
14
|
+
}
|
|
15
|
+
function ce() {
|
|
16
|
+
const s = K();
|
|
17
|
+
P(s, "Unable to find Page context.");
|
|
18
|
+
const { customTextRenderer: u, onGetTextError: y, onGetTextSuccess: g, onRenderTextLayerError: f, onRenderTextLayerSuccess: l, page: t, pageIndex: T, pageNumber: C, rotate: E, scale: L } = s;
|
|
19
|
+
P(t, "Attempted to load page text content, but no page was specified.");
|
|
20
|
+
const [_, o] = Q(), { value: n, error: p } = _, c = q(null);
|
|
21
|
+
x(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"), 10) === 1, "TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");
|
|
22
|
+
function j() {
|
|
23
|
+
n && g && g(n);
|
|
24
|
+
}
|
|
25
|
+
function D() {
|
|
26
|
+
p && (x(!1, p.toString()), y && y(p));
|
|
27
|
+
}
|
|
28
|
+
m(function() {
|
|
29
|
+
o({ type: "RESET" });
|
|
30
|
+
}, [t, o]), m(function() {
|
|
31
|
+
if (!t)
|
|
32
|
+
return;
|
|
33
|
+
const r = B(t.getTextContent()), d = r;
|
|
34
|
+
return r.promise.then((a) => {
|
|
35
|
+
o({ type: "RESOLVE", value: a });
|
|
36
|
+
}).catch((a) => {
|
|
37
|
+
o({ type: "REJECT", error: a });
|
|
38
|
+
}), () => N(d);
|
|
39
|
+
}, [t, o]), m(() => {
|
|
40
|
+
if (n !== void 0) {
|
|
41
|
+
if (n === !1) {
|
|
42
|
+
D();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
j();
|
|
46
|
+
}
|
|
47
|
+
}, [n]);
|
|
48
|
+
const R = k(() => {
|
|
49
|
+
l && l();
|
|
50
|
+
}, [l]), S = k((e) => {
|
|
51
|
+
x(!1, e.toString()), f && f(e);
|
|
52
|
+
}, [f]);
|
|
53
|
+
function I() {
|
|
54
|
+
const e = c.current;
|
|
55
|
+
e && e.classList.add("selecting");
|
|
56
|
+
}
|
|
57
|
+
function O() {
|
|
58
|
+
const e = c.current;
|
|
59
|
+
e && e.classList.remove("selecting");
|
|
60
|
+
}
|
|
61
|
+
const h = J(() => t.getViewport({ scale: L, rotation: E }), [t, E, L]);
|
|
62
|
+
return $(function() {
|
|
63
|
+
if (!t || !n)
|
|
64
|
+
return;
|
|
65
|
+
const { current: r } = c;
|
|
66
|
+
if (!r)
|
|
67
|
+
return;
|
|
68
|
+
r.innerHTML = "";
|
|
69
|
+
const d = t.streamTextContent({ includeMarkedContent: !0 }), a = {
|
|
70
|
+
container: r,
|
|
71
|
+
textContentSource: d,
|
|
72
|
+
viewport: h
|
|
73
|
+
}, b = new F(a), U = b;
|
|
74
|
+
return b.render().then(() => {
|
|
75
|
+
const w = document.createElement("div");
|
|
76
|
+
w.className = "endOfContent", r.append(w);
|
|
77
|
+
const V = r.querySelectorAll('[role="presentation"]');
|
|
78
|
+
if (u) {
|
|
79
|
+
let v = 0;
|
|
80
|
+
n.items.forEach((i, A) => {
|
|
81
|
+
if (!W(i))
|
|
82
|
+
return;
|
|
83
|
+
const M = V[v];
|
|
84
|
+
if (!M)
|
|
85
|
+
return;
|
|
86
|
+
const G = u({
|
|
87
|
+
pageIndex: T,
|
|
88
|
+
pageNumber: C,
|
|
89
|
+
itemIndex: A,
|
|
90
|
+
...i
|
|
91
|
+
});
|
|
92
|
+
M.innerHTML = G, v += i.str && i.hasEOL ? 2 : 1;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
R();
|
|
96
|
+
}).catch(S), () => N(U);
|
|
97
|
+
}, [
|
|
98
|
+
u,
|
|
99
|
+
S,
|
|
100
|
+
R,
|
|
101
|
+
t,
|
|
102
|
+
T,
|
|
103
|
+
C,
|
|
104
|
+
n,
|
|
105
|
+
h
|
|
106
|
+
]), // biome-ignore lint/a11y/noStaticElementInteractions: False positive caused by non interactive wrapper listening for bubbling events
|
|
107
|
+
H("div", { className: z("react-pdf__Page__textContent", "textLayer"), onMouseUp: O, onMouseDown: I, ref: c });
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
ce as default
|
|
111
|
+
};
|