pdf-tsx 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +263 -212
  3. package/dist/cjs/components/PDFSidebar.module.cjs +1 -1
  4. package/dist/cjs/components/PDFViewer.cjs +1 -1
  5. package/dist/cjs/components/PDFViewer.module.cjs +1 -1
  6. package/dist/cjs/components/features/PDFAnnotations.module.cjs +1 -1
  7. package/dist/cjs/components/features/PDFNavigation.module.cjs +1 -1
  8. package/dist/cjs/components/features/PDFOutline.module.cjs +1 -1
  9. package/dist/cjs/components/features/PDFSearch.module.cjs +1 -1
  10. package/dist/cjs/components/features/PDFSignatures.module.cjs +1 -1
  11. package/dist/cjs/components/features/PDFThumbnails.module.cjs +1 -1
  12. package/dist/cjs/components/features/PDFZoomControls.module.cjs +1 -1
  13. package/dist/cjs/components/ui/ToolbarButton.module.cjs +1 -1
  14. package/dist/cjs/context/ThemeContext.cjs +1 -1
  15. package/dist/cjs/hooks/useTextLayer.cjs +1 -1
  16. package/dist/cjs/index.cjs +1 -1
  17. package/dist/cjs/pdf-tsx.css +1 -1
  18. package/dist/components/PDFViewer.d.ts +5 -0
  19. package/dist/context/ThemeContext.d.ts +7 -2
  20. package/dist/es/components/PDFSidebar.module.js +7 -7
  21. package/dist/es/components/PDFViewer.js +165 -162
  22. package/dist/es/components/PDFViewer.module.js +15 -12
  23. package/dist/es/components/features/PDFAnnotations.module.js +10 -10
  24. package/dist/es/components/features/PDFNavigation.module.js +3 -3
  25. package/dist/es/components/features/PDFOutline.module.js +5 -5
  26. package/dist/es/components/features/PDFSearch.module.js +4 -4
  27. package/dist/es/components/features/PDFSignatures.module.js +14 -14
  28. package/dist/es/components/features/PDFThumbnails.module.js +7 -7
  29. package/dist/es/components/features/PDFZoomControls.module.js +1 -1
  30. package/dist/es/components/ui/ToolbarButton.module.js +2 -2
  31. package/dist/es/context/ThemeContext.js +31 -24
  32. package/dist/es/hooks/useTextLayer.js +0 -1
  33. package/dist/es/index.js +17 -16
  34. package/dist/es/pdf-tsx.css +1 -1
  35. package/dist/index.d.ts +2 -0
  36. package/package.json +61 -61
  37. package/dist/pdf-tsx.cjs.js +0 -5
  38. package/dist/pdf-tsx.css +0 -2
  39. package/dist/pdf-tsx.es.js +0 -2637
  40. package/dist/vite.svg +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Riccardo Grossano
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Riccardo Grossano
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,212 +1,263 @@
1
- # pdf-tsx
2
-
3
- A fully-featured, composable PDF viewer component for React.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install pdf-tsx
9
- ```
10
-
11
- ### Peer dependencies
12
-
13
- ```bash
14
- npm install react react-dom pdfjs-dist
15
- ```
16
-
17
- ---
18
-
19
- ## CSS
20
-
21
- Import the stylesheet once in your app entry point:
22
-
23
- ```ts
24
- import 'pdf-tsx/dist/es/pdf-tsx.css'
25
- ```
26
-
27
- ---
28
-
29
- ## Quick start
30
-
31
- `PDFViewer` requires a `workerSrc` prop — the URL of the pdfjs worker script. The easiest way is to serve it from the `pdfjs-dist` package directly:
32
-
33
- ```tsx
34
- import { PDFViewer } from 'pdf-tsx'
35
- import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url'
36
-
37
- function App() {
38
- const [file, setFile] = useState<File | null>(null)
39
-
40
- if (!file) return <input type="file" accept=".pdf" onChange={e => setFile(e.target.files![0])} />
41
-
42
- return <PDFViewer file={file} workerSrc={workerUrl} />
43
- }
44
- ```
45
-
46
- > The `?url` suffix is a Vite feature that returns the asset URL as a string. If you use a different bundler, import the worker URL accordingly or pass a CDN URL:
47
- > ```ts
48
- > workerSrc="https://unpkg.com/pdfjs-dist@5/build/pdf.worker.min.mjs"
49
- > ```
50
-
51
- ---
52
-
53
- ## Icons
54
-
55
- Feature components do not bundle any icon library. Each component that shows an icon requires you to pass it explicitly as a prop — use any icon library or custom SVG you prefer.
56
-
57
- ```tsx
58
- import { FiZoomIn, FiZoomOut } from 'react-icons/fi'
59
-
60
- <PDFZoomControls zoomInIcon={<FiZoomIn size={16} />} zoomOutIcon={<FiZoomOut size={16} />} />
61
- ```
62
-
63
- ---
64
-
65
- ## PDFViewer
66
-
67
- The main component. Must wrap all feature components.
68
-
69
- ```tsx
70
- <PDFViewer
71
- file={file}
72
- workerSrc={workerUrl}
73
- sidebar={<PDFSidebar panels={[...]} />}
74
- toolbar={<>...</>}
75
- onChangeFile={(newFile) => setFile(newFile)}
76
- />
77
- ```
78
-
79
- | Prop | Type | Required | Description |
80
- |----------------|------------------------|----------|------------------------------------------------------|
81
- | `file` | `File` | yes | The PDF file object to display |
82
- | `workerSrc` | `string` | yes | URL of the pdfjs worker script (see Quick start) |
83
- | `sidebar` | `ReactNode` | no | Content rendered on the left side |
84
- | `toolbar` | `ReactNode` | no | Content rendered in the top toolbar |
85
- | `onChangeFile` | `(file: File) => void` | no | Called when the user opens a different file |
86
-
87
- ---
88
-
89
- ## PDFSidebar
90
-
91
- A collapsible icon sidebar. Each panel has an icon button — clicking it toggles the panel open/closed.
92
-
93
- ```tsx
94
- import { PDFSidebar } from 'pdf-tsx'
95
- import { FiImage, FiList } from 'react-icons/fi'
96
-
97
- <PDFSidebar panels={[
98
- { icon: <FiImage size={18} />, label: 'Thumbnails', content: <PDFThumbnails /> },
99
- { icon: <FiList size={18} />, label: 'Outline', content: <PDFOutline /> },
100
- ]} />
101
- ```
102
-
103
- | Prop | Type | Description |
104
- |----------|------------------|------------------------------------|
105
- | `panels` | `SidebarPanel[]` | Array of panels to display |
106
-
107
- **SidebarPanel**
108
-
109
- | Field | Type | Description |
110
- |-----------|-------------|----------------------------------------|
111
- | `icon` | `ReactNode` | Icon shown in the sidebar button bar |
112
- | `label` | `string` | Panel title shown in the header |
113
- | `content` | `ReactNode` | Content rendered inside the open panel |
114
-
115
- ---
116
-
117
- ## Feature components
118
-
119
- All feature components must be rendered inside `<PDFViewer>`. They read and write state via `usePDFViewer()` internally.
120
-
121
- | Component | Icon props | Description |
122
- |----------------------|-----------------------------------------------------|------------------------------------------------------|
123
- | `PDFThumbnails` | — | Page thumbnail strip for quick navigation |
124
- | `PDFOutline` | — | Document outline / bookmarks tree |
125
- | `PDFAnnotations` | — | Display PDF annotations |
126
- | `PDFSignatures` | — | Display PDF digital signatures |
127
- | `PDFSearch` | `searchIcon` `prevIcon` `nextIcon` `clearIcon` | Full-text search with match highlighting |
128
- | `PDFZoomControls` | `zoomInIcon` `zoomOutIcon` | Zoom in / zoom out buttons with percentage display |
129
- | `PDFPageFit` | `fitWidthIcon` `fitPageIcon` | Fit-to-width and fit-to-page buttons |
130
- | `PDFRotationControl` | `icon` | Rotate page clockwise |
131
- | `PDFNavigation` | `prevIcon` `nextIcon` | Previous / next page buttons with current page input |
132
- | `PDFDownloadButton` | `icon` | Download the current PDF file |
133
- | `PDFChangeFile` | `icon` | Button to open a new PDF file |
134
- | `PDFThemeToggle` | `lightIcon` `darkIcon` | Toggle between dark and light mode |
135
- | `PDFPrintButton` | `icon` | Print the PDF using the browser's native print dialog|
136
-
137
- ---
138
-
139
- ## Full example
140
-
141
- ```tsx
142
- import { useState, Suspense, lazy } from 'react'
143
- import {
144
- PDFSidebar, PDFThumbnails, PDFOutline, PDFSearch,
145
- PDFZoomControls, PDFPageFit, PDFRotationControl,
146
- PDFNavigation, PDFDownloadButton, PDFChangeFile,
147
- PDFThemeToggle, PDFPrintButton,
148
- } from 'pdf-tsx'
149
- import {
150
- FiImage, FiList, FiSearch, FiChevronUp, FiChevronDown, FiX,
151
- FiZoomIn, FiZoomOut, FiAlignJustify, FiMaximize2, FiRotateCw,
152
- FiChevronLeft, FiChevronRight, FiDownload, FiFolderPlus,
153
- FiPrinter, FiSun, FiMoon,
154
- } from 'react-icons/fi'
155
- import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url'
156
-
157
- const PDFViewer = lazy(() => import('pdf-tsx').then(m => ({ default: m.PDFViewer })))
158
-
159
- function App() {
160
- const [file, setFile] = useState<File | null>(null)
161
-
162
- if (!file) {
163
- return (
164
- <input
165
- type="file"
166
- accept=".pdf"
167
- onChange={e => setFile(e.target.files![0])}
168
- />
169
- )
170
- }
171
-
172
- return (
173
- <Suspense fallback={<div>Loading...</div>}>
174
- <PDFViewer
175
- file={file}
176
- workerSrc={workerUrl}
177
- onChangeFile={setFile}
178
- sidebar={
179
- <PDFSidebar panels={[
180
- { icon: <FiImage size={18} />, label: 'Thumbnails', content: <PDFThumbnails /> },
181
- { icon: <FiList size={18} />, label: 'Outline', content: <PDFOutline /> },
182
- ]} />
183
- }
184
- toolbar={
185
- <>
186
- <PDFSearch
187
- searchIcon={<FiSearch size={14} />}
188
- prevIcon={<FiChevronUp size={14} />}
189
- nextIcon={<FiChevronDown size={14} />}
190
- clearIcon={<FiX size={14} />}
191
- />
192
- <PDFZoomControls zoomOutIcon={<FiZoomOut size={16} />} zoomInIcon={<FiZoomIn size={16} />} />
193
- <PDFPageFit fitWidthIcon={<FiAlignJustify size={16} />} fitPageIcon={<FiMaximize2 size={16} />} />
194
- <PDFRotationControl icon={<FiRotateCw size={16} />} />
195
- <PDFNavigation prevIcon={<FiChevronLeft size={16} />} nextIcon={<FiChevronRight size={16} />} />
196
- <PDFChangeFile icon={<FiFolderPlus size={16} />} />
197
- <PDFDownloadButton icon={<FiDownload size={15} />} />
198
- <PDFThemeToggle lightIcon={<FiSun size={16} />} darkIcon={<FiMoon size={16} />} />
199
- <PDFPrintButton icon={<FiPrinter size={16} />} />
200
- </>
201
- }
202
- />
203
- </Suspense>
204
- )
205
- }
206
- ```
207
-
208
- ---
209
-
210
- ## License
211
-
212
- MIT © Riccardo Grossano — see [LICENSE](./LICENSE) for full terms.
1
+ # pdf-tsx
2
+
3
+ A fully-featured, composable PDF viewer component for React.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install pdf-tsx
9
+ ```
10
+
11
+ ### Peer dependencies
12
+
13
+ ```bash
14
+ npm install react react-dom pdfjs-dist
15
+ ```
16
+
17
+ ---
18
+
19
+ ## CSS
20
+
21
+ Import the stylesheet once in your app entry point:
22
+
23
+ ```ts
24
+ import 'pdf-tsx/dist/es/pdf-tsx.css'
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Quick start
30
+
31
+ `PDFViewer` requires a `workerSrc` prop — the URL of the pdfjs worker script. The easiest way is to serve it from the `pdfjs-dist` package directly:
32
+
33
+ ```tsx
34
+ import { PDFViewer } from 'pdf-tsx'
35
+ import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url'
36
+
37
+ function App() {
38
+ const [file, setFile] = useState<File | null>(null)
39
+
40
+ if (!file) return <input type="file" accept=".pdf" onChange={e => setFile(e.target.files![0])} />
41
+
42
+ return <PDFViewer file={file} workerSrc={workerUrl} />
43
+ }
44
+ ```
45
+
46
+ > The `?url` suffix is a Vite feature that returns the asset URL as a string. If you use a different bundler, import the worker URL accordingly or pass a CDN URL:
47
+ > ```ts
48
+ > workerSrc="https://unpkg.com/pdfjs-dist@5/build/pdf.worker.min.mjs"
49
+ > ```
50
+
51
+ ---
52
+
53
+ ## Icons
54
+
55
+ Feature components do not bundle any icon library. Each component that shows an icon requires you to pass it explicitly as a prop — use any icon library or custom SVG you prefer.
56
+
57
+ ```tsx
58
+ import { FiZoomIn, FiZoomOut } from 'react-icons/fi'
59
+
60
+ <PDFZoomControls zoomInIcon={<FiZoomIn size={16} />} zoomOutIcon={<FiZoomOut size={16} />} />
61
+ ```
62
+
63
+ ---
64
+
65
+ ## PDFViewer
66
+
67
+ The main component. Must wrap all feature components.
68
+
69
+ ```tsx
70
+ <PDFViewer
71
+ file={file}
72
+ workerSrc={workerUrl}
73
+ sidebar={<PDFSidebar panels={[...]} />}
74
+ toolbar={<>...</>}
75
+ onChangeFile={(newFile) => setFile(newFile)}
76
+ />
77
+ ```
78
+
79
+ | Prop | Type | Required | Description |
80
+ |------------------|---------------------------------------------------------|----------|------------------------------------------------------|
81
+ | `file` | `File` | yes | The PDF file object to display |
82
+ | `workerSrc` | `string` | yes | URL of the pdfjs worker script (see Quick start) |
83
+ | `sidebar` | `ReactNode` | no | Content rendered on the left side |
84
+ | `toolbar` | `ReactNode` | no | Content rendered in the top toolbar |
85
+ | `onChangeFile` | `(file: File) => void` | no | Called when the user opens a different file |
86
+ | `themeOverrides` | `{ light?: Partial<Theme>; dark?: Partial<Theme> }` | no | Override individual theme tokens (see Theming) |
87
+
88
+ ---
89
+
90
+ ## Theming
91
+
92
+ `PDFViewer` ships with built-in dark and light themes. Use `themeOverrides` to override individual tokens without replacing the whole theme.
93
+
94
+ ```tsx
95
+ import { PDFViewer, darkTheme } from 'pdf-tsx'
96
+
97
+ <PDFViewer
98
+ themeOverrides={{
99
+ dark: { accent: '#e11d48', accentHover: '#be123c', accentDark: '#9f1239' },
100
+ light: { accent: '#e11d48', accentHover: '#be123c', accentDark: '#9f1239' },
101
+ }}
102
+ ...
103
+ />
104
+ ```
105
+
106
+ Both `darkTheme` and `lightTheme` are exported so you can spread them as a base:
107
+
108
+ ```tsx
109
+ import { darkTheme } from 'pdf-tsx'
110
+
111
+ themeOverrides={{ dark: { ...darkTheme, bg: '#0f0f0f' } }}
112
+ ```
113
+
114
+ **Theme tokens** (`Theme` interface):
115
+
116
+ | Token | Description |
117
+ |--------------------|--------------------------------------|
118
+ | `bg` | Main background |
119
+ | `surface` | Card / panel surface |
120
+ | `surfaceHover` | Surface hover state |
121
+ | `border` | Default border color |
122
+ | `borderLight` | Subtle border color |
123
+ | `scrollArea` | Scroll container background |
124
+ | `textPrimary` | Primary text |
125
+ | `textSecondary` | Secondary text |
126
+ | `textMuted` | Muted / placeholder text |
127
+ | `textPlaceholder` | Input placeholder text |
128
+ | `accent` | Accent / interactive color |
129
+ | `accentHover` | Accent hover state |
130
+ | `accentDark` | Accent dark variant |
131
+ | `accentLight` | Accent light variant |
132
+ | `accentSubtle` | Accent with low opacity |
133
+ | `panelBg` | Sidebar panel background |
134
+ | `panelBorder` | Sidebar panel border |
135
+ | `panelHeaderBg` | Sidebar panel header background |
136
+ | `shadowPage` | Drop shadow color for PDF pages |
137
+
138
+ ---
139
+
140
+ ## PDFSidebar
141
+
142
+ A collapsible icon sidebar. Each panel has an icon button — clicking it toggles the panel open/closed.
143
+
144
+ ```tsx
145
+ import { PDFSidebar } from 'pdf-tsx'
146
+ import { FiImage, FiList } from 'react-icons/fi'
147
+
148
+ <PDFSidebar panels={[
149
+ { icon: <FiImage size={18} />, label: 'Thumbnails', content: <PDFThumbnails /> },
150
+ { icon: <FiList size={18} />, label: 'Outline', content: <PDFOutline /> },
151
+ ]} />
152
+ ```
153
+
154
+ | Prop | Type | Description |
155
+ |----------|------------------|------------------------------------|
156
+ | `panels` | `SidebarPanel[]` | Array of panels to display |
157
+
158
+ **SidebarPanel**
159
+
160
+ | Field | Type | Description |
161
+ |-----------|-------------|----------------------------------------|
162
+ | `icon` | `ReactNode` | Icon shown in the sidebar button bar |
163
+ | `label` | `string` | Panel title shown in the header |
164
+ | `content` | `ReactNode` | Content rendered inside the open panel |
165
+
166
+ ---
167
+
168
+ ## Feature components
169
+
170
+ All feature components must be rendered inside `<PDFViewer>`. They read and write state via `usePDFViewer()` internally.
171
+
172
+ | Component | Icon props | Description |
173
+ |----------------------|-----------------------------------------------------|------------------------------------------------------|
174
+ | `PDFThumbnails` | — | Page thumbnail strip for quick navigation |
175
+ | `PDFOutline` | — | Document outline / bookmarks tree |
176
+ | `PDFAnnotations` | — | Display PDF annotations |
177
+ | `PDFSignatures` | — | Display PDF digital signatures |
178
+ | `PDFSearch` | `searchIcon` `prevIcon` `nextIcon` `clearIcon` | Full-text search with match highlighting |
179
+ | `PDFZoomControls` | `zoomInIcon` `zoomOutIcon` | Zoom in / zoom out buttons with percentage display |
180
+ | `PDFPageFit` | `fitWidthIcon` `fitPageIcon` | Fit-to-width and fit-to-page buttons |
181
+ | `PDFRotationControl` | `icon` | Rotate page clockwise |
182
+ | `PDFNavigation` | `prevIcon` `nextIcon` | Previous / next page buttons with current page input |
183
+ | `PDFDownloadButton` | `icon` | Download the current PDF file |
184
+ | `PDFChangeFile` | `icon` | Button to open a new PDF file |
185
+ | `PDFThemeToggle` | `lightIcon` `darkIcon` | Toggle between dark and light mode |
186
+ | `PDFPrintButton` | `icon` | Print the PDF using the browser's native print dialog|
187
+
188
+ ---
189
+
190
+ ## Full example
191
+
192
+ ```tsx
193
+ import { useState, Suspense, lazy } from 'react'
194
+ import {
195
+ PDFSidebar, PDFThumbnails, PDFOutline, PDFSearch,
196
+ PDFZoomControls, PDFPageFit, PDFRotationControl,
197
+ PDFNavigation, PDFDownloadButton, PDFChangeFile,
198
+ PDFThemeToggle, PDFPrintButton,
199
+ } from 'pdf-tsx'
200
+ import {
201
+ FiImage, FiList, FiSearch, FiChevronUp, FiChevronDown, FiX,
202
+ FiZoomIn, FiZoomOut, FiAlignJustify, FiMaximize2, FiRotateCw,
203
+ FiChevronLeft, FiChevronRight, FiDownload, FiFolderPlus,
204
+ FiPrinter, FiSun, FiMoon,
205
+ } from 'react-icons/fi'
206
+ import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url'
207
+
208
+ const PDFViewer = lazy(() => import('pdf-tsx').then(m => ({ default: m.PDFViewer })))
209
+
210
+ function App() {
211
+ const [file, setFile] = useState<File | null>(null)
212
+
213
+ if (!file) {
214
+ return (
215
+ <input
216
+ type="file"
217
+ accept=".pdf"
218
+ onChange={e => setFile(e.target.files![0])}
219
+ />
220
+ )
221
+ }
222
+
223
+ return (
224
+ <Suspense fallback={<div>Loading...</div>}>
225
+ <PDFViewer
226
+ file={file}
227
+ workerSrc={workerUrl}
228
+ onChangeFile={setFile}
229
+ sidebar={
230
+ <PDFSidebar panels={[
231
+ { icon: <FiImage size={18} />, label: 'Thumbnails', content: <PDFThumbnails /> },
232
+ { icon: <FiList size={18} />, label: 'Outline', content: <PDFOutline /> },
233
+ ]} />
234
+ }
235
+ toolbar={
236
+ <>
237
+ <PDFSearch
238
+ searchIcon={<FiSearch size={14} />}
239
+ prevIcon={<FiChevronUp size={14} />}
240
+ nextIcon={<FiChevronDown size={14} />}
241
+ clearIcon={<FiX size={14} />}
242
+ />
243
+ <PDFZoomControls zoomOutIcon={<FiZoomOut size={16} />} zoomInIcon={<FiZoomIn size={16} />} />
244
+ <PDFPageFit fitWidthIcon={<FiAlignJustify size={16} />} fitPageIcon={<FiMaximize2 size={16} />} />
245
+ <PDFRotationControl icon={<FiRotateCw size={16} />} />
246
+ <PDFNavigation prevIcon={<FiChevronLeft size={16} />} nextIcon={<FiChevronRight size={16} />} />
247
+ <PDFChangeFile icon={<FiFolderPlus size={16} />} />
248
+ <PDFDownloadButton icon={<FiDownload size={15} />} />
249
+ <PDFThemeToggle lightIcon={<FiSun size={16} />} darkIcon={<FiMoon size={16} />} />
250
+ <PDFPrintButton icon={<FiPrinter size={16} />} />
251
+ </>
252
+ }
253
+ />
254
+ </Suspense>
255
+ )
256
+ }
257
+ ```
258
+
259
+ ---
260
+
261
+ ## License
262
+
263
+ MIT © Riccardo Grossano — see [LICENSE](./LICENSE) for full terms.
@@ -1 +1 @@
1
- var e={wrapper:`_wrapper_1bxn4_1`,buttonBar:`_buttonBar_1bxn4_7`,panelButton:`_panelButton_1bxn4_17`,panelButtonActive:`_panelButtonActive_1bxn4_37`,contentPanel:`_contentPanel_1bxn4_46`,panelHeader:`_panelHeader_1bxn4_54`,panelBody:`_panelBody_1bxn4_66`};exports.default=e;
1
+ var e={wrapper:`_wrapper_184n8_1`,buttonBar:`_buttonBar_184n8_13`,panelButton:`_panelButton_184n8_33`,panelButtonActive:`_panelButtonActive_184n8_73`,contentPanel:`_contentPanel_184n8_91`,panelHeader:`_panelHeader_184n8_107`,panelBody:`_panelBody_184n8_131`};exports.default=e;
@@ -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`),o=require(`../hooks/useAnnotationLayer.cjs`),s=require(`../context/ThemeContext.cjs`),c=require(`./PDFViewer.module.cjs`);let l=require(`react`);l=e.__toESM(l,1);let u=require(`pdfjs-dist`);u=e.__toESM(u,1);let d=require(`react/jsx-runtime`);var f=({file:e,workerSrc:f,sidebar:p,toolbar:m,onChangeFile:h})=>{(0,l.useEffect)(()=>{u.GlobalWorkerOptions.workerSrc=f},[f]);let[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(0),[b,x]=(0,l.useState)(1),[S,C]=(0,l.useState)(0),[w,T]=(0,l.useState)(null),[E,D]=(0,l.useState)(null),[O,k]=(0,l.useState)([]),[A,j]=(0,l.useState)(new Set),[M,N]=(0,l.useState)([]),P=(0,l.useRef)(null),F=(0,l.useRef)([]),I=(0,l.useRef)([]),{currentPage:L,goToPage:R}=n.useScrollTracking({pdf:g,numPages:v,zoom:b,rotation:S,containerRef:P,canvasRefs:F});r.useKeyboardShortcuts({pdf:g,currentPage:L,numPages:v,goToPage:R,setZoom:x,setRotation:C});let z=i.useTextLayer({pdf:g,zoom:b,rotation:S,numPages:v,canvasRefs:F}),B=o.useAnnotationLayer({pdf:g,zoom:b,rotation:S,numPages:v,goToPage:R});(0,l.useEffect)(()=>{(async()=>{let t=new FileReader;t.onload=async e=>{let t=new Uint8Array(e.target?.result);try{let e=await u.getDocument(t).promise;_(e),y(e.numPages),T(null),D(null),j(new Set),N([]),F.current=Array(e.numPages).fill(null),I.current=Array(e.numPages).fill(null)}catch(e){console.error(`Errore caricamento:`,e)}},t.readAsArrayBuffer(e)})()},[e]),(0,l.useEffect)(()=>{if(!g)return;j(new Set);let e=!1;return(async()=>{let t=I.current.map(e=>e?(e.cancel(),e.promise.catch(()=>{})):Promise.resolve());if(await Promise.all(t),I.current=Array(g.numPages).fill(null),e)return;let n=[];for(let e=1;e<=g.numPages;e++){let t=(await g.getPage(e)).getViewport({scale:b,rotation:S});n.push({width:t.width,height:t.height})}if(!e){N(n);for(let t=1;t<=g.numPages;t++){if(e)return;let n=await g.getPage(t),r=n.getViewport({scale:b,rotation:S}),i=F.current[t-1];if(i){let a=i.getContext(`2d`);if(a){i.height=r.height,i.width=r.width;let o=n.render({canvasContext:a,viewport:r,canvas:i});I.current[t-1]=o;try{await o.promise,e||j(e=>new Set(e).add(t))}catch(e){e&&typeof e==`object`&&`name`in e&&e.name!==`RenderingCancelledException`&&console.error(`Render error:`,e)}}}}}})(),()=>{e=!0,I.current.forEach(e=>e?.cancel())}},[g,b,S]);let[V,H]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!g||O.length===0){H([]);return}let e=!1;return(async()=>{let t=[];for(let n of O){if(e)break;let[r,i,a,o]=(await g.getPage(n.page)).getViewport({scale:b,rotation:S}).convertToViewportRectangle(n.pdfRect);t.push({page:n.page,x:Math.min(r,a),y:Math.min(i,o),width:Math.abs(a-r),height:Math.abs(o-i)})}e||H(t)})(),()=>{e=!0}},[O,b,S,g]),(0,l.useEffect)(()=>{if(!w||!g)return;let e=!1;return(async()=>{let[t,n,r,i]=(await g.getPage(w.page)).getViewport({scale:b,rotation:S}).convertToViewportRectangle(w.pdfRect);e||D({page:w.page,x:Math.min(t,r),y:Math.min(n,i),width:Math.abs(r-t),height:Math.abs(i-n)})})(),()=>{e=!0}},[w,b,S,g]),(0,d.jsx)(s.ThemeProvider,{children:(0,d.jsx)(t.PDFViewerContext.Provider,{value:{pdf:g,numPages:v,zoom:b,setZoom:x,rotation:S,setRotation:C,currentPage:L,goToPage:R,containerRef:P,canvasRefs:F,file:e,highlight:w,setHighlight:T,searchMatches:O,setSearchMatches:k,onChangeFile:h},children:(0,d.jsxs)(`div`,{className:c.default.appLayout,children:[p,(0,d.jsxs)(`div`,{className:c.default.mainContent,children:[m&&(0,d.jsx)(`div`,{className:c.default.toolbar,children:m}),(0,d.jsx)(`div`,{className:c.default.scrollContainer,ref:P,children:Array.from({length:v},(e,t)=>{let n=A.has(t+1),r=M[t];return(0,d.jsxs)(`div`,{className:c.default.pageWrapper,children:[!n&&r&&(0,d.jsx)(`div`,{className:c.default.pageSkeleton,style:{width:r.width,height:r.height}}),(0,d.jsx)(`canvas`,{className:c.default.pageCanvas,ref:e=>{F.current[t]=e},style:{display:n?`block`:`none`}}),(0,d.jsx)(`div`,{className:`textLayer ${c.default.textLayer}`,ref:e=>{z.current[t]=e}}),B.filter(e=>e.page===t+1).map((e,t)=>(0,d.jsx)(`a`,{className:c.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=>{(!e.url||!a.isSafeUrl(e.url))&&(t.preventDefault(),e.url||e._handleClick())}},t)),V.filter(e=>e.page===t+1).map((e,t)=>(0,d.jsx)(`div`,{className:c.default.searchMatchOverlay,style:{left:e.x,top:e.y,width:e.width,height:e.height}},t)),w&&E?.page===t+1&&(0,d.jsx)(`div`,{className:c.default.highlightOverlay,style:{left:E.x,top:E.y,width:E.width,height:E.height}})]},`${t}-${S}`)})})]})]})})})};exports.default=f;
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`),o=require(`../hooks/useAnnotationLayer.cjs`),s=require(`../context/ThemeContext.cjs`),c=require(`./PDFViewer.module.cjs`);let l=require(`react`);l=e.__toESM(l,1);let u=require(`pdfjs-dist`);u=e.__toESM(u,1);let d=require(`react/jsx-runtime`);var f=({file:e,workerSrc:f,sidebar:p,toolbar:m,onChangeFile:h,themeOverrides:g})=>{(0,l.useEffect)(()=>{u.GlobalWorkerOptions.workerSrc=f},[f]);let[_,v]=(0,l.useState)(null),[y,b]=(0,l.useState)(0),[x,S]=(0,l.useState)(1),[C,w]=(0,l.useState)(0),[T,E]=(0,l.useState)(null),[D,O]=(0,l.useState)(null),[k,A]=(0,l.useState)([]),[j,M]=(0,l.useState)(new Set),[N,P]=(0,l.useState)([]),F=(0,l.useRef)(null),I=(0,l.useRef)([]),L=(0,l.useRef)([]),{currentPage:R,goToPage:z}=n.useScrollTracking({pdf:_,numPages:y,zoom:x,rotation:C,containerRef:F,canvasRefs:I});r.useKeyboardShortcuts({pdf:_,currentPage:R,numPages:y,goToPage:z,setZoom:S,setRotation:w});let B=i.useTextLayer({pdf:_,zoom:x,rotation:C,numPages:y,canvasRefs:I}),V=o.useAnnotationLayer({pdf:_,zoom:x,rotation:C,numPages:y,goToPage:z});(0,l.useEffect)(()=>{(async()=>{let t=new FileReader;t.onload=async e=>{let t=new Uint8Array(e.target?.result);try{let e=await u.getDocument(t).promise;v(e),b(e.numPages),E(null),O(null),M(new Set),P([]),I.current=Array(e.numPages).fill(null),L.current=Array(e.numPages).fill(null)}catch(e){console.error(`Errore caricamento:`,e)}},t.readAsArrayBuffer(e)})()},[e]),(0,l.useEffect)(()=>{if(!_)return;M(new Set);let e=!1;return(async()=>{let t=L.current.map(e=>e?(e.cancel(),e.promise.catch(()=>{})):Promise.resolve());if(await Promise.all(t),L.current=Array(_.numPages).fill(null),e)return;let n=[];for(let e=1;e<=_.numPages;e++){let t=(await _.getPage(e)).getViewport({scale:x,rotation:C});n.push({width:t.width,height:t.height})}if(!e){P(n);for(let t=1;t<=_.numPages;t++){if(e)return;let n=await _.getPage(t),r=n.getViewport({scale:x,rotation:C}),i=I.current[t-1];if(i){let a=i.getContext(`2d`);if(a){i.height=r.height,i.width=r.width;let o=n.render({canvasContext:a,viewport:r,canvas:i});L.current[t-1]=o;try{await o.promise,e||M(e=>new Set(e).add(t))}catch(e){e&&typeof e==`object`&&`name`in e&&e.name!==`RenderingCancelledException`&&console.error(`Render error:`,e)}}}}}})(),()=>{e=!0,L.current.forEach(e=>e?.cancel())}},[_,x,C]);let[H,U]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!_||k.length===0){U([]);return}let e=!1;return(async()=>{let t=[];for(let n of k){if(e)break;let[r,i,a,o]=(await _.getPage(n.page)).getViewport({scale:x,rotation:C}).convertToViewportRectangle(n.pdfRect);t.push({page:n.page,x:Math.min(r,a),y:Math.min(i,o),width:Math.abs(a-r),height:Math.abs(o-i)})}e||U(t)})(),()=>{e=!0}},[k,x,C,_]),(0,l.useEffect)(()=>{if(!T||!_)return;let e=!1;return(async()=>{let[t,n,r,i]=(await _.getPage(T.page)).getViewport({scale:x,rotation:C}).convertToViewportRectangle(T.pdfRect);e||O({page:T.page,x:Math.min(t,r),y:Math.min(n,i),width:Math.abs(r-t),height:Math.abs(i-n)})})(),()=>{e=!0}},[T,x,C,_]),(0,d.jsx)(s.ThemeProvider,{themeOverrides:g,children:(0,d.jsx)(t.PDFViewerContext.Provider,{value:{pdf:_,numPages:y,zoom:x,setZoom:S,rotation:C,setRotation:w,currentPage:R,goToPage:z,containerRef:F,canvasRefs:I,file:e,highlight:T,setHighlight:E,searchMatches:k,setSearchMatches:A,onChangeFile:h},children:(0,d.jsxs)(`div`,{className:c.default.appLayout,children:[p,(0,d.jsxs)(`div`,{className:c.default.mainContent,children:[m&&(0,d.jsx)(`div`,{className:c.default.toolbar,children:m}),(0,d.jsx)(`div`,{className:c.default.scrollContainer,ref:F,children:Array.from({length:y},(e,t)=>{let n=j.has(t+1),r=N[t];return(0,d.jsxs)(`div`,{className:c.default.pageWrapper,children:[!n&&r&&(0,d.jsx)(`div`,{className:c.default.pageSkeleton,style:{width:r.width,height:r.height}}),(0,d.jsx)(`canvas`,{className:c.default.pageCanvas,ref:e=>{I.current[t]=e},style:{display:n?`block`:`none`}}),(0,d.jsx)(`div`,{className:`textLayer ${c.default.textLayer}`,ref:e=>{B.current[t]=e}}),V.filter(e=>e.page===t+1).map((e,t)=>(0,d.jsx)(`a`,{className:c.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=>{(!e.url||!a.isSafeUrl(e.url))&&(t.preventDefault(),e.url||e._handleClick())}},t)),H.filter(e=>e.page===t+1).map((e,t)=>(0,d.jsx)(`div`,{className:c.default.searchMatchOverlay,style:{left:e.x,top:e.y,width:e.width,height:e.height}},t)),T&&D?.page===t+1&&(0,d.jsx)(`div`,{className:c.default.highlightOverlay,style:{left:D.x,top:D.y,width:D.width,height:D.height}})]},`${t}-${C}`)})})]})]})})})};exports.default=f;
@@ -1 +1 @@
1
- var e={appLayout:`_appLayout_1k76a_1`,mainContent:`_mainContent_1k76a_7`,toolbar:`_toolbar_1k76a_14`,scrollContainer:`_scrollContainer_1k76a_26`,pageWrapper:`_pageWrapper_1k76a_36`,pageCanvas:`_pageCanvas_1k76a_41`,textLayer:`_textLayer_1k76a_48`,pageSkeleton:`_pageSkeleton_1k76a_54`,shimmer:`_shimmer_1k76a_1`,highlightOverlay:`_highlightOverlay_1k76a_66`,linkOverlay:`_linkOverlay_1k76a_74`,searchMatchOverlay:`_searchMatchOverlay_1k76a_80`};exports.default=e;
1
+ var e={appLayout:`_appLayout_nel8e_1`,mainContent:`_mainContent_nel8e_15`,toolbar:`_toolbar_nel8e_29`,scrollContainer:`_scrollContainer_nel8e_53`,pageWrapper:`_pageWrapper_nel8e_73`,pageCanvas:`_pageCanvas_nel8e_83`,textLayer:`_textLayer_nel8e_97`,markedContent:`_markedContent_nel8e_149`,endOfContent:`_endOfContent_nel8e_177`,selecting:`_selecting_nel8e_195`,pageSkeleton:`_pageSkeleton_nel8e_235`,shimmer:`_shimmer_nel8e_1`,highlightOverlay:`_highlightOverlay_nel8e_267`,linkOverlay:`_linkOverlay_nel8e_283`,searchMatchOverlay:`_searchMatchOverlay_nel8e_295`};exports.default=e;
@@ -1 +1 @@
1
- var e={list:`_list_xo7yf_1`,emptyState:`_emptyState_xo7yf_6`,pageHeader:`_pageHeader_xo7yf_12`,card:`_card_xo7yf_23`,cardClickable:`_cardClickable_xo7yf_33`,cardHeader:`_cardHeader_xo7yf_41`,cardLabel:`_cardLabel_xo7yf_48`,cardPage:`_cardPage_xo7yf_54`,cardAuthor:`_cardAuthor_xo7yf_59`,cardContent:`_cardContent_xo7yf_65`};exports.default=e;
1
+ var e={list:`_list_173qc_1`,emptyState:`_emptyState_173qc_11`,pageHeader:`_pageHeader_173qc_23`,card:`_card_173qc_45`,cardClickable:`_cardClickable_173qc_65`,cardHeader:`_cardHeader_173qc_81`,cardLabel:`_cardLabel_173qc_95`,cardPage:`_cardPage_173qc_107`,cardAuthor:`_cardAuthor_173qc_117`,cardContent:`_cardContent_173qc_129`};exports.default=e;
@@ -1 +1 @@
1
- var e={navWrapper:`_navWrapper_ew1r2_1`,pageInput:`_pageInput_ew1r2_8`,pageTotal:`_pageTotal_ew1r2_36`};exports.default=e;
1
+ var e={navWrapper:`_navWrapper_6ysgx_1`,pageInput:`_pageInput_6ysgx_15`,pageTotal:`_pageTotal_6ysgx_71`};exports.default=e;
@@ -1 +1 @@
1
- var e={emptyState:`_emptyState_hqvdn_1`,tree:`_tree_hqvdn_7`,row:`_row_hqvdn_13`,chevronBtn:`_chevronBtn_hqvdn_31`,title:`_title_hqvdn_46`};exports.default=e;
1
+ var e={emptyState:`_emptyState_1w4ic_1`,tree:`_tree_1w4ic_13`,row:`_row_1w4ic_25`,chevronBtn:`_chevronBtn_1w4ic_61`,title:`_title_1w4ic_91`};exports.default=e;
@@ -1 +1 @@
1
- var e={wrapper:`_wrapper_1x913_1`,searchInput:`_searchInput_1x913_7`,navButton:`_navButton_1x913_27`,counter:`_counter_1x913_48`};exports.default=e;
1
+ var e={wrapper:`_wrapper_yinyt_1`,searchInput:`_searchInput_yinyt_13`,navButton:`_navButton_yinyt_53`,counter:`_counter_yinyt_95`};exports.default=e;
@@ -1 +1 @@
1
- var e={list:`_list_m6w4t_1`,emptyState:`_emptyState_m6w4t_6`,card:`_card_m6w4t_12`,cardClickable:`_cardClickable_m6w4t_23`,cardSigned:`_cardSigned_m6w4t_31`,cardHeader:`_cardHeader_m6w4t_36`,statusDot:`_statusDot_m6w4t_43`,statusDotSigned:`_statusDotSigned_m6w4t_57`,statusLabel:`_statusLabel_m6w4t_61`,statusLabelSigned:`_statusLabelSigned_m6w4t_69`,fieldList:`_fieldList_m6w4t_73`,fieldRow:`_fieldRow_m6w4t_79`,fieldLabel:`_fieldLabel_m6w4t_84`,disclaimer:`_disclaimer_m6w4t_88`};exports.default=e;
1
+ var e={list:`_list_1xon0_1`,emptyState:`_emptyState_1xon0_11`,card:`_card_1xon0_23`,cardClickable:`_cardClickable_1xon0_45`,cardSigned:`_cardSigned_1xon0_61`,cardHeader:`_cardHeader_1xon0_71`,statusDot:`_statusDot_1xon0_85`,statusDotSigned:`_statusDotSigned_1xon0_113`,statusLabel:`_statusLabel_1xon0_121`,statusLabelSigned:`_statusLabelSigned_1xon0_137`,fieldList:`_fieldList_1xon0_145`,fieldRow:`_fieldRow_1xon0_157`,fieldLabel:`_fieldLabel_1xon0_167`,disclaimer:`_disclaimer_1xon0_175`};exports.default=e;
@@ -1 +1 @@
1
- var e={thumbnailList:`_thumbnailList_f8jl0_1`,thumbnailItem:`_thumbnailItem_f8jl0_6`,thumbnailItemActive:`_thumbnailItemActive_f8jl0_19`,thumbnailImg:`_thumbnailImg_f8jl0_28`,thumbnailImgActive:`_thumbnailImgActive_f8jl0_34`,thumbnailLabel:`_thumbnailLabel_f8jl0_38`,thumbnailLabelActive:`_thumbnailLabelActive_f8jl0_45`};exports.default=e;
1
+ var e={thumbnailList:`_thumbnailList_116om_1`,thumbnailItem:`_thumbnailItem_116om_11`,thumbnailItemActive:`_thumbnailItemActive_116om_37`,thumbnailImg:`_thumbnailImg_116om_55`,thumbnailImgActive:`_thumbnailImgActive_116om_67`,thumbnailLabel:`_thumbnailLabel_116om_75`,thumbnailLabelActive:`_thumbnailLabelActive_116om_89`};exports.default=e;
@@ -1 +1 @@
1
- var e={zoomLabel:`_zoomLabel_m8iv9_1`};exports.default=e;
1
+ var e={zoomLabel:`_zoomLabel_1r6if_1`};exports.default=e;
@@ -1 +1 @@
1
- var e={btn:`_btn_1x6vc_1`,primary:`_primary_1x6vc_29`};exports.default=e;
1
+ var e={btn:`_btn_12ml0_1`,primary:`_primary_12ml0_57`};exports.default=e;
@@ -1 +1 @@
1
- require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../theme.cjs`);let t=require(`react`),n=require(`react/compiler-runtime`),r=require(`react/jsx-runtime`);var i=(0,t.createContext)(null);function a(a){let s=(0,n.c)(14),{children:c}=a,[l,u]=(0,t.useState)(!0),d=l?e.darkTheme:e.lightTheme,f;s[0]===d?f=s[1]:(f=e.themeToCssVars(d),s[0]=d,s[1]=f);let p=f,m;s[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>u(o),s[2]=m):m=s[2];let h;s[3]!==l||s[4]!==d?(h={isDark:l,toggleTheme:m,theme:d},s[3]=l,s[4]=d,s[5]=h):h=s[5];let g=p,_;s[6]===g?_=s[7]:(_={...g,display:`contents`},s[6]=g,s[7]=_);let v;s[8]!==c||s[9]!==_?(v=(0,r.jsx)(`div`,{style:_,children:c}),s[8]=c,s[9]=_,s[10]=v):v=s[10];let y;return s[11]!==h||s[12]!==v?(y=(0,r.jsx)(i.Provider,{value:h,children:v}),s[11]=h,s[12]=v,s[13]=y):y=s[13],y}function o(e){return!e}function s(){let e=(0,t.useContext)(i);if(!e)throw Error(`useTheme must be used inside <ThemeProvider>`);return e}exports.ThemeProvider=a,exports.useTheme=s;
1
+ require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../theme.cjs`);let t=require(`react`),n=require(`react/compiler-runtime`),r=require(`react/jsx-runtime`);var i=(0,t.createContext)(null);function a(a){let s=(0,n.c)(17),{children:c,themeOverrides:l}=a,[u,d]=(0,t.useState)(!0),f,p;s[0]!==u||s[1]!==l?.dark||s[2]!==l?.light?(p=u?{...e.darkTheme,...l?.dark}:{...e.lightTheme,...l?.light},f=e.themeToCssVars(p),s[0]=u,s[1]=l?.dark,s[2]=l?.light,s[3]=f,s[4]=p):(f=s[3],p=s[4]);let m=f,h;s[5]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>d(o),s[5]=h):h=s[5];let g;s[6]!==u||s[7]!==p?(g={isDark:u,toggleTheme:h,theme:p},s[6]=u,s[7]=p,s[8]=g):g=s[8];let _=m,v;s[9]===_?v=s[10]:(v={..._,height:`100%`,width:`100%`},s[9]=_,s[10]=v);let y;s[11]!==c||s[12]!==v?(y=(0,r.jsx)(`div`,{style:v,children:c}),s[11]=c,s[12]=v,s[13]=y):y=s[13];let b;return s[14]!==g||s[15]!==y?(b=(0,r.jsx)(i.Provider,{value:g,children:y}),s[14]=g,s[15]=y,s[16]=b):b=s[16],b}function o(e){return!e}function s(){let e=(0,t.useContext)(i);if(!e)throw Error(`useTheme must be used inside <ThemeProvider>`);return e}exports.ThemeProvider=a,exports.useTheme=s;
@@ -1 +1 @@
1
- const e=require(`../_virtual/_rolldown/runtime.cjs`);;/* empty css */let t=require(`react`),n=require(`pdfjs-dist`);n=e.__toESM(n,1);let r=require(`react/compiler-runtime`);function i(e){let i=(0,r.c)(8),{pdf:a,zoom:o,rotation:s,numPages:c,canvasRefs:l}=e,u;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],i[0]=u):u=i[0];let d=(0,t.useRef)(u),f,p;return i[1]!==l||i[2]!==c||i[3]!==a||i[4]!==s||i[5]!==o?(f=()=>{if(!a)return;let e=!1;return(async()=>{for(let t=1;t<=c&&!e;t++){let r=d.current[t-1],i=l.current[t-1];if(!r||!i)continue;r.replaceChildren();let c=await a.getPage(t),u=c.getViewport({scale:o,rotation:s}),f=await c.getTextContent();if(e)break;r.style.width=`${u.width}px`,r.style.height=`${u.height}px`,await new n.TextLayer({textContentSource:f,container:r,viewport:u}).render()}})(),()=>{e=!0}},p=[a,o,s,c,l],i[1]=l,i[2]=c,i[3]=a,i[4]=s,i[5]=o,i[6]=f,i[7]=p):(f=i[6],p=i[7]),(0,t.useEffect)(f,p),d}exports.useTextLayer=i;
1
+ const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`react`),n=require(`pdfjs-dist`);n=e.__toESM(n,1);let r=require(`react/compiler-runtime`);function i(e){let i=(0,r.c)(8),{pdf:a,zoom:o,rotation:s,numPages:c,canvasRefs:l}=e,u;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[],i[0]=u):u=i[0];let d=(0,t.useRef)(u),f,p;return i[1]!==l||i[2]!==c||i[3]!==a||i[4]!==s||i[5]!==o?(f=()=>{if(!a)return;let e=!1;return(async()=>{for(let t=1;t<=c&&!e;t++){let r=d.current[t-1],i=l.current[t-1];if(!r||!i)continue;r.replaceChildren();let c=await a.getPage(t),u=c.getViewport({scale:o,rotation:s}),f=await c.getTextContent();if(e)break;r.style.width=`${u.width}px`,r.style.height=`${u.height}px`,await new n.TextLayer({textContentSource:f,container:r,viewport:u}).render()}})(),()=>{e=!0}},p=[a,o,s,c,l],i[1]=l,i[2]=c,i[3]=a,i[4]=s,i[5]=o,i[6]=f,i[7]=p):(f=i[6],p=i[7]),(0,t.useEffect)(f,p),d}exports.useTextLayer=i;