pdfjs-reader-core 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +678 -423
- package/dist/index.cjs +3478 -590
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +745 -2
- package/dist/index.d.ts +745 -2
- package/dist/index.js +3423 -568
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,244 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
8
8
|
import * as pdfjs_dist_types_src_display_api from 'pdfjs-dist/types/src/display/api';
|
|
9
9
|
import { ClassValue } from 'clsx';
|
|
10
10
|
import * as pdfjs_dist_types_src_display_metadata from 'pdfjs-dist/types/src/display/metadata';
|
|
11
|
+
import { StoreApi } from 'zustand/vanilla';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Context provided by an external AI agent during interaction
|
|
15
|
+
*/
|
|
16
|
+
interface AgentContext {
|
|
17
|
+
/** The last statement or response from the agent */
|
|
18
|
+
lastStatement?: string;
|
|
19
|
+
/** Unique identifier for the conversation session */
|
|
20
|
+
conversationId?: string;
|
|
21
|
+
/** Timestamp of the context */
|
|
22
|
+
timestamp: Date;
|
|
23
|
+
/** Additional metadata from the agent */
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Context passed when user triggers "Ask About This" feature
|
|
28
|
+
*/
|
|
29
|
+
interface AskAboutContext {
|
|
30
|
+
/** Type of content being asked about */
|
|
31
|
+
type: 'text' | 'region';
|
|
32
|
+
/** Page number where the selection is made */
|
|
33
|
+
pageNumber: number;
|
|
34
|
+
/** Selected text content (for text type) */
|
|
35
|
+
selectedText?: string;
|
|
36
|
+
/** Selected region coordinates (for region type) */
|
|
37
|
+
region?: PDFRegion;
|
|
38
|
+
/** Current agent context when asking */
|
|
39
|
+
agentContext?: AgentContext;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents a rectangular region on a PDF page
|
|
43
|
+
*/
|
|
44
|
+
interface PDFRegion {
|
|
45
|
+
/** X coordinate (from left) */
|
|
46
|
+
x: number;
|
|
47
|
+
/** Y coordinate (from top) */
|
|
48
|
+
y: number;
|
|
49
|
+
/** Width of the region */
|
|
50
|
+
width: number;
|
|
51
|
+
/** Height of the region */
|
|
52
|
+
height: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A focused region with visual styling, typically used by AI agent
|
|
56
|
+
* to highlight content being discussed
|
|
57
|
+
*/
|
|
58
|
+
interface FocusedRegion extends PDFRegion {
|
|
59
|
+
/** Unique identifier for this focus region */
|
|
60
|
+
id: string;
|
|
61
|
+
/** Page number where the region is located */
|
|
62
|
+
pageNumber: number;
|
|
63
|
+
/** Visual style for the focus indicator */
|
|
64
|
+
style?: 'pulse' | 'glow' | 'border';
|
|
65
|
+
/** Color of the focus indicator */
|
|
66
|
+
color?: string;
|
|
67
|
+
/** Auto-clear timeout in milliseconds (0 = no auto-clear) */
|
|
68
|
+
autoClearTimeout?: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A bookmark saved by the student
|
|
72
|
+
*/
|
|
73
|
+
interface Bookmark {
|
|
74
|
+
/** Unique identifier */
|
|
75
|
+
id: string;
|
|
76
|
+
/** Page number of the bookmark */
|
|
77
|
+
pageNumber: number;
|
|
78
|
+
/** When the bookmark was created */
|
|
79
|
+
timestamp: Date;
|
|
80
|
+
/** Agent's last statement when bookmarking (captured from context) */
|
|
81
|
+
agentContext?: string;
|
|
82
|
+
/** User's personal note about the bookmark */
|
|
83
|
+
userNote?: string;
|
|
84
|
+
/** Optional label for the bookmark */
|
|
85
|
+
label?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A quick note added by the student
|
|
89
|
+
*/
|
|
90
|
+
interface QuickNote {
|
|
91
|
+
/** Unique identifier */
|
|
92
|
+
id: string;
|
|
93
|
+
/** Page number where the note is placed */
|
|
94
|
+
pageNumber: number;
|
|
95
|
+
/** X coordinate on the page */
|
|
96
|
+
x: number;
|
|
97
|
+
/** Y coordinate on the page */
|
|
98
|
+
y: number;
|
|
99
|
+
/** Note content */
|
|
100
|
+
content: string;
|
|
101
|
+
/** When the note was created */
|
|
102
|
+
timestamp: Date;
|
|
103
|
+
/** Agent's last statement when creating note */
|
|
104
|
+
agentLastStatement?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A key takeaway or summary, typically from the AI agent
|
|
108
|
+
*/
|
|
109
|
+
interface Takeaway {
|
|
110
|
+
/** Unique identifier */
|
|
111
|
+
id: string;
|
|
112
|
+
/** Page number associated with this takeaway */
|
|
113
|
+
pageNumber: number;
|
|
114
|
+
/** Summary content */
|
|
115
|
+
summary: string;
|
|
116
|
+
/** When the takeaway was added */
|
|
117
|
+
timestamp: Date;
|
|
118
|
+
/** Source of the takeaway */
|
|
119
|
+
source: 'agent' | 'user';
|
|
120
|
+
/** Additional metadata */
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Parameters for creating an agent-sourced highlight
|
|
125
|
+
*/
|
|
126
|
+
interface AgentHighlightParams {
|
|
127
|
+
/** Page number for the highlight */
|
|
128
|
+
pageNumber: number;
|
|
129
|
+
/** Rectangles defining the highlight area */
|
|
130
|
+
rects: HighlightRect[];
|
|
131
|
+
/** Text content being highlighted */
|
|
132
|
+
text: string;
|
|
133
|
+
/** Highlight color */
|
|
134
|
+
color?: HighlightColor;
|
|
135
|
+
/** Optional comment */
|
|
136
|
+
comment?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* API exposed to external AI agents for interacting with the PDF viewer
|
|
140
|
+
*/
|
|
141
|
+
interface AgentAPI {
|
|
142
|
+
/**
|
|
143
|
+
* Focus a region on the page (visual indicator of what agent is discussing)
|
|
144
|
+
* @returns The ID of the focused region
|
|
145
|
+
*/
|
|
146
|
+
focusRegion: (region: Omit<FocusedRegion, 'id'>) => string;
|
|
147
|
+
/**
|
|
148
|
+
* Clear a focused region by ID, or all if no ID provided
|
|
149
|
+
*/
|
|
150
|
+
clearFocusedRegion: (id?: string) => void;
|
|
151
|
+
/**
|
|
152
|
+
* Add a key takeaway for a page
|
|
153
|
+
*/
|
|
154
|
+
addTakeaway: (pageNumber: number, summary: string, metadata?: Record<string, unknown>) => Takeaway;
|
|
155
|
+
/**
|
|
156
|
+
* Set the current agent context
|
|
157
|
+
*/
|
|
158
|
+
setAgentContext: (context: Partial<AgentContext>) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Add a highlight from the agent (marked with source: 'agent')
|
|
161
|
+
*/
|
|
162
|
+
addAgentHighlight: (params: AgentHighlightParams) => string;
|
|
163
|
+
/**
|
|
164
|
+
* Navigate to a specific page
|
|
165
|
+
*/
|
|
166
|
+
goToPage: (pageNumber: number) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Get current page number
|
|
169
|
+
*/
|
|
170
|
+
getCurrentPage: () => number;
|
|
171
|
+
/**
|
|
172
|
+
* Get current agent context
|
|
173
|
+
*/
|
|
174
|
+
getAgentContext: () => AgentContext | null;
|
|
175
|
+
}
|
|
176
|
+
interface StudentState {
|
|
177
|
+
/** User's bookmarks */
|
|
178
|
+
bookmarks: Bookmark[];
|
|
179
|
+
/** User's quick notes */
|
|
180
|
+
quickNotes: QuickNote[];
|
|
181
|
+
/** Key takeaways (from agent or user) */
|
|
182
|
+
takeaways: Takeaway[];
|
|
183
|
+
/** Pages the user has visited */
|
|
184
|
+
visitedPages: Set<number>;
|
|
185
|
+
/** Reading progress (0-1) */
|
|
186
|
+
progress: number;
|
|
187
|
+
}
|
|
188
|
+
interface StudentActions {
|
|
189
|
+
addBookmark: (bookmark: Omit<Bookmark, 'id' | 'timestamp'>) => Bookmark;
|
|
190
|
+
updateBookmark: (id: string, updates: Partial<Omit<Bookmark, 'id'>>) => void;
|
|
191
|
+
removeBookmark: (id: string) => void;
|
|
192
|
+
addQuickNote: (note: Omit<QuickNote, 'id' | 'timestamp'>) => QuickNote;
|
|
193
|
+
updateQuickNote: (id: string, updates: Partial<Omit<QuickNote, 'id'>>) => void;
|
|
194
|
+
removeQuickNote: (id: string) => void;
|
|
195
|
+
addTakeaway: (takeaway: Omit<Takeaway, 'id' | 'timestamp'>) => Takeaway;
|
|
196
|
+
removeTakeaway: (id: string) => void;
|
|
197
|
+
markPageVisited: (pageNumber: number) => void;
|
|
198
|
+
setProgress: (progress: number) => void;
|
|
199
|
+
persistToStorage: (documentId: string) => void;
|
|
200
|
+
loadFromStorage: (documentId: string) => void;
|
|
201
|
+
reset: () => void;
|
|
202
|
+
}
|
|
203
|
+
interface AgentState {
|
|
204
|
+
/** Current agent context */
|
|
205
|
+
currentContext: AgentContext | null;
|
|
206
|
+
/** Currently focused regions */
|
|
207
|
+
focusedRegions: FocusedRegion[];
|
|
208
|
+
}
|
|
209
|
+
interface AgentActions {
|
|
210
|
+
/** Set the current agent context */
|
|
211
|
+
setAgentContext: (context: Partial<AgentContext>) => void;
|
|
212
|
+
/** Clear the agent context */
|
|
213
|
+
clearAgentContext: () => void;
|
|
214
|
+
/** Add a focused region */
|
|
215
|
+
addFocusedRegion: (region: Omit<FocusedRegion, 'id'>) => string;
|
|
216
|
+
/** Remove a focused region by ID */
|
|
217
|
+
removeFocusedRegion: (id: string) => void;
|
|
218
|
+
/** Clear all focused regions */
|
|
219
|
+
clearAllFocusedRegions: () => void;
|
|
220
|
+
/** Reset agent state */
|
|
221
|
+
reset: () => void;
|
|
222
|
+
}
|
|
223
|
+
interface StudentModeCallbacks {
|
|
224
|
+
/** Callback when user triggers "Ask About This" */
|
|
225
|
+
onAskAbout?: (context: AskAboutContext) => void;
|
|
226
|
+
/** Callback when a bookmark is added */
|
|
227
|
+
onBookmarkAdd?: (bookmark: Bookmark) => void;
|
|
228
|
+
/** Callback when a quick note is added */
|
|
229
|
+
onQuickNoteAdd?: (note: QuickNote) => void;
|
|
230
|
+
}
|
|
231
|
+
interface StudentModeProps {
|
|
232
|
+
/** Enable student learning mode features */
|
|
233
|
+
studentMode?: boolean;
|
|
234
|
+
/** Callbacks for agent integration */
|
|
235
|
+
agentCallbacks?: StudentModeCallbacks;
|
|
236
|
+
/** Initial agent context */
|
|
237
|
+
initialAgentContext?: AgentContext;
|
|
238
|
+
/** Show quick note buttons on pages */
|
|
239
|
+
showQuickNoteButtons?: boolean;
|
|
240
|
+
/** Show the minimap */
|
|
241
|
+
showMinimap?: boolean;
|
|
242
|
+
/** Position of the minimap */
|
|
243
|
+
minimapPosition?: 'sidebar' | 'floating';
|
|
244
|
+
/** Enable "Ask About This" feature */
|
|
245
|
+
enableAskAbout?: boolean;
|
|
246
|
+
/** Long press duration for ask about trigger (ms) */
|
|
247
|
+
askAboutLongPressDuration?: number;
|
|
248
|
+
}
|
|
11
249
|
|
|
12
250
|
interface PDFViewerProps {
|
|
13
251
|
/** URL or ArrayBuffer of the PDF file */
|
|
@@ -121,6 +359,8 @@ interface Highlight {
|
|
|
121
359
|
comment?: string;
|
|
122
360
|
createdAt: Date;
|
|
123
361
|
updatedAt: Date;
|
|
362
|
+
/** Source of the highlight: user-created or agent-created */
|
|
363
|
+
source?: 'user' | 'agent';
|
|
124
364
|
}
|
|
125
365
|
interface HighlightRect {
|
|
126
366
|
x: number;
|
|
@@ -277,6 +517,16 @@ interface VirtualizedDocumentContainerProps {
|
|
|
277
517
|
enableTouchGestures?: boolean;
|
|
278
518
|
className?: string;
|
|
279
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* VirtualizedDocumentContainer efficiently renders only visible pages.
|
|
522
|
+
*
|
|
523
|
+
* Mobile optimizations:
|
|
524
|
+
* - Only pages in/near viewport are rendered (virtualization)
|
|
525
|
+
* - Smooth scrolling with -webkit-overflow-scrolling
|
|
526
|
+
* - Touch gestures for pinch-zoom and swipe navigation
|
|
527
|
+
* - Passive event listeners for scroll performance
|
|
528
|
+
* - Smart page caching to avoid re-fetching
|
|
529
|
+
*/
|
|
280
530
|
declare const VirtualizedDocumentContainer: react.NamedExoticComponent<VirtualizedDocumentContainerProps>;
|
|
281
531
|
|
|
282
532
|
interface ContinuousScrollContainerProps extends VirtualizedDocumentContainerProps {
|
|
@@ -338,7 +588,18 @@ interface CanvasLayerProps {
|
|
|
338
588
|
onRenderStart?: () => void;
|
|
339
589
|
onRenderComplete?: () => void;
|
|
340
590
|
onRenderError?: (error: Error) => void;
|
|
591
|
+
/** Priority for rendering (lower = higher priority) - used for render ordering */
|
|
592
|
+
priority?: number;
|
|
341
593
|
}
|
|
594
|
+
/**
|
|
595
|
+
* CanvasLayer renders a PDF page at full quality.
|
|
596
|
+
*
|
|
597
|
+
* Optimizations for mobile:
|
|
598
|
+
* - Uses requestAnimationFrame for render timing
|
|
599
|
+
* - Cancels pending renders on unmount/update
|
|
600
|
+
* - Uses 'display' intent for faster rendering
|
|
601
|
+
* - Disables alpha channel for better performance
|
|
602
|
+
*/
|
|
342
603
|
declare const CanvasLayer: react.NamedExoticComponent<CanvasLayerProps>;
|
|
343
604
|
|
|
344
605
|
interface TextLayerProps {
|
|
@@ -355,6 +616,8 @@ interface HighlightLayerProps {
|
|
|
355
616
|
selectedId?: string | null;
|
|
356
617
|
onHighlightClick?: (highlight: Highlight) => void;
|
|
357
618
|
className?: string;
|
|
619
|
+
/** Filter by source type */
|
|
620
|
+
sourceFilter?: 'all' | 'user' | 'agent';
|
|
358
621
|
}
|
|
359
622
|
declare const HighlightLayer: react.NamedExoticComponent<HighlightLayerProps>;
|
|
360
623
|
|
|
@@ -390,6 +653,14 @@ interface AnnotationLayerProps {
|
|
|
390
653
|
}
|
|
391
654
|
declare const AnnotationLayer: react.NamedExoticComponent<AnnotationLayerProps>;
|
|
392
655
|
|
|
656
|
+
interface FocusRegionLayerProps {
|
|
657
|
+
focusedRegions: FocusedRegion[];
|
|
658
|
+
scale: number;
|
|
659
|
+
pageNumber: number;
|
|
660
|
+
className?: string;
|
|
661
|
+
}
|
|
662
|
+
declare const FocusRegionLayer: react.NamedExoticComponent<FocusRegionLayerProps>;
|
|
663
|
+
|
|
393
664
|
interface ToolbarProps {
|
|
394
665
|
className?: string;
|
|
395
666
|
showNavigation?: boolean;
|
|
@@ -458,6 +729,22 @@ interface HighlightsPanelProps {
|
|
|
458
729
|
}
|
|
459
730
|
declare const HighlightsPanel: react.NamedExoticComponent<HighlightsPanelProps>;
|
|
460
731
|
|
|
732
|
+
interface BookmarksPanelProps {
|
|
733
|
+
className?: string;
|
|
734
|
+
/** Callback when a bookmark item is clicked */
|
|
735
|
+
onBookmarkClick?: (bookmark: Bookmark) => void;
|
|
736
|
+
}
|
|
737
|
+
declare const BookmarksPanel: react.NamedExoticComponent<BookmarksPanelProps>;
|
|
738
|
+
|
|
739
|
+
interface TakeawaysPanelProps {
|
|
740
|
+
className?: string;
|
|
741
|
+
/** Callback when a takeaway item is clicked */
|
|
742
|
+
onTakeawayClick?: (takeaway: Takeaway) => void;
|
|
743
|
+
/** Filter by source */
|
|
744
|
+
sourceFilter?: 'all' | 'agent' | 'user';
|
|
745
|
+
}
|
|
746
|
+
declare const TakeawaysPanel: react.NamedExoticComponent<TakeawaysPanelProps>;
|
|
747
|
+
|
|
461
748
|
interface SelectionToolbarProps {
|
|
462
749
|
/** Current text selection */
|
|
463
750
|
selection: TextSelection | null;
|
|
@@ -627,6 +914,112 @@ interface ShapePreviewProps {
|
|
|
627
914
|
}
|
|
628
915
|
declare const ShapePreview: react.NamedExoticComponent<ShapePreviewProps>;
|
|
629
916
|
|
|
917
|
+
interface QuickNoteButtonProps {
|
|
918
|
+
/** Page number this button is for */
|
|
919
|
+
pageNumber: number;
|
|
920
|
+
/** Scale of the page */
|
|
921
|
+
scale: number;
|
|
922
|
+
/** Position of the button (relative to page) */
|
|
923
|
+
position?: 'top-right' | 'bottom-right';
|
|
924
|
+
/** Callback when button is clicked */
|
|
925
|
+
onClick: (pageNumber: number, x: number, y: number) => void;
|
|
926
|
+
/** Custom className */
|
|
927
|
+
className?: string;
|
|
928
|
+
/** Whether the button is visible */
|
|
929
|
+
visible?: boolean;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Floating button on each page to quickly add a note.
|
|
933
|
+
*/
|
|
934
|
+
declare const QuickNoteButton: react.NamedExoticComponent<QuickNoteButtonProps>;
|
|
935
|
+
|
|
936
|
+
interface QuickNotePopoverProps {
|
|
937
|
+
/** Whether the popover is visible */
|
|
938
|
+
visible: boolean;
|
|
939
|
+
/** Position of the popover */
|
|
940
|
+
position: {
|
|
941
|
+
x: number;
|
|
942
|
+
y: number;
|
|
943
|
+
};
|
|
944
|
+
/** Initial content */
|
|
945
|
+
initialContent?: string;
|
|
946
|
+
/** Agent's last statement to display */
|
|
947
|
+
agentLastStatement?: string;
|
|
948
|
+
/** Callback when note is saved */
|
|
949
|
+
onSave: (content: string) => void;
|
|
950
|
+
/** Callback when cancelled */
|
|
951
|
+
onCancel: () => void;
|
|
952
|
+
/** Custom className */
|
|
953
|
+
className?: string;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Popover for entering quick note content.
|
|
957
|
+
*/
|
|
958
|
+
declare const QuickNotePopover: react.NamedExoticComponent<QuickNotePopoverProps>;
|
|
959
|
+
|
|
960
|
+
interface AskAboutOverlayProps {
|
|
961
|
+
/** Whether the overlay is visible */
|
|
962
|
+
visible: boolean;
|
|
963
|
+
/** Progress of the long press (0-1) */
|
|
964
|
+
progress: number;
|
|
965
|
+
/** Position of the overlay */
|
|
966
|
+
position: {
|
|
967
|
+
x: number;
|
|
968
|
+
y: number;
|
|
969
|
+
} | null;
|
|
970
|
+
/** Size of the progress indicator */
|
|
971
|
+
size?: number;
|
|
972
|
+
/** Custom className */
|
|
973
|
+
className?: string;
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Visual feedback overlay shown during long-press for "Ask About This" feature.
|
|
977
|
+
* Displays a circular progress indicator.
|
|
978
|
+
*/
|
|
979
|
+
declare const AskAboutOverlay: react.NamedExoticComponent<AskAboutOverlayProps>;
|
|
980
|
+
|
|
981
|
+
interface AskAboutTriggerProps {
|
|
982
|
+
/** Position to display the trigger */
|
|
983
|
+
position: {
|
|
984
|
+
x: number;
|
|
985
|
+
y: number;
|
|
986
|
+
};
|
|
987
|
+
/** Callback when ask about is confirmed */
|
|
988
|
+
onConfirm: () => void;
|
|
989
|
+
/** Callback when cancelled */
|
|
990
|
+
onCancel: () => void;
|
|
991
|
+
/** Whether to show the trigger */
|
|
992
|
+
visible: boolean;
|
|
993
|
+
/** Auto-hide delay in ms (0 = no auto-hide) */
|
|
994
|
+
autoHideDelay?: number;
|
|
995
|
+
/** Custom className */
|
|
996
|
+
className?: string;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Confirmation UI shown after long-press completes.
|
|
1000
|
+
* Provides buttons to confirm or cancel the "Ask About This" action.
|
|
1001
|
+
*/
|
|
1002
|
+
declare const AskAboutTrigger: react.NamedExoticComponent<AskAboutTriggerProps>;
|
|
1003
|
+
|
|
1004
|
+
interface MinimapProps {
|
|
1005
|
+
/** Display variant */
|
|
1006
|
+
variant?: 'sidebar' | 'floating';
|
|
1007
|
+
/** Position for floating variant */
|
|
1008
|
+
floatingPosition?: 'left' | 'right';
|
|
1009
|
+
/** Maximum height in pixels */
|
|
1010
|
+
maxHeight?: number;
|
|
1011
|
+
/** Whether to show page numbers */
|
|
1012
|
+
showPageNumbers?: boolean;
|
|
1013
|
+
/** Callback when a page is clicked */
|
|
1014
|
+
onPageClick?: (pageNumber: number) => void;
|
|
1015
|
+
/** Custom className */
|
|
1016
|
+
className?: string;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Visual minimap showing reading progress and navigation.
|
|
1020
|
+
*/
|
|
1021
|
+
declare const Minimap: react.NamedExoticComponent<MinimapProps>;
|
|
1022
|
+
|
|
630
1023
|
interface PDFErrorBoundaryProps {
|
|
631
1024
|
/** Child components to render */
|
|
632
1025
|
children: ReactNode;
|
|
@@ -673,10 +1066,20 @@ type SearchStore = SearchState & SearchActions;
|
|
|
673
1066
|
declare function createSearchStore(initialOverrides?: Partial<SearchState>): zustand.StoreApi<SearchStore>;
|
|
674
1067
|
type SearchStoreApi = ReturnType<typeof createSearchStore>;
|
|
675
1068
|
|
|
1069
|
+
type AgentStore = AgentState & AgentActions;
|
|
1070
|
+
declare function createAgentStore(initialOverrides?: Partial<AgentState>): zustand.StoreApi<AgentStore>;
|
|
1071
|
+
type AgentStoreApi = ReturnType<typeof createAgentStore>;
|
|
1072
|
+
|
|
1073
|
+
type StudentStore = StudentState & StudentActions;
|
|
1074
|
+
declare function createStudentStore(initialOverrides?: Partial<StudentState>): zustand.StoreApi<StudentStore>;
|
|
1075
|
+
type StudentStoreApi = ReturnType<typeof createStudentStore>;
|
|
1076
|
+
|
|
676
1077
|
interface PDFViewerContextValue {
|
|
677
1078
|
viewerStore: ViewerStoreApi;
|
|
678
1079
|
annotationStore: AnnotationStoreApi;
|
|
679
1080
|
searchStore: SearchStoreApi;
|
|
1081
|
+
agentStore: AgentStoreApi;
|
|
1082
|
+
studentStore: StudentStoreApi;
|
|
680
1083
|
}
|
|
681
1084
|
interface PDFViewerProviderProps {
|
|
682
1085
|
children: ReactNode;
|
|
@@ -684,12 +1087,16 @@ interface PDFViewerProviderProps {
|
|
|
684
1087
|
viewer?: Partial<ViewerState>;
|
|
685
1088
|
annotation?: Partial<AnnotationState>;
|
|
686
1089
|
search?: Partial<SearchState>;
|
|
1090
|
+
agent?: Partial<AgentState>;
|
|
1091
|
+
student?: Partial<StudentState>;
|
|
687
1092
|
};
|
|
688
1093
|
theme?: Theme;
|
|
689
1094
|
defaultSidebarPanel?: SidebarPanel;
|
|
1095
|
+
/** Enable student learning mode features */
|
|
1096
|
+
studentMode?: boolean;
|
|
690
1097
|
}
|
|
691
1098
|
declare const PDFViewerContext: react.Context<PDFViewerContextValue | null>;
|
|
692
|
-
declare function PDFViewerProvider({ children, initialState, theme, defaultSidebarPanel, }: PDFViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
1099
|
+
declare function PDFViewerProvider({ children, initialState, theme, defaultSidebarPanel, studentMode: _studentMode, }: PDFViewerProviderProps): react_jsx_runtime.JSX.Element;
|
|
693
1100
|
/**
|
|
694
1101
|
* Hook to access the viewer store.
|
|
695
1102
|
* Optionally pass a selector to subscribe to specific state.
|
|
@@ -705,6 +1112,16 @@ declare function useAnnotationStore<T>(selector: (state: AnnotationStore) => T):
|
|
|
705
1112
|
* Optionally pass a selector to subscribe to specific state.
|
|
706
1113
|
*/
|
|
707
1114
|
declare function useSearchStore<T>(selector: (state: SearchStore) => T): T;
|
|
1115
|
+
/**
|
|
1116
|
+
* Hook to access the agent store.
|
|
1117
|
+
* Optionally pass a selector to subscribe to specific state.
|
|
1118
|
+
*/
|
|
1119
|
+
declare function useAgentStore<T>(selector: (state: AgentStore) => T): T;
|
|
1120
|
+
/**
|
|
1121
|
+
* Hook to access the student store.
|
|
1122
|
+
* Optionally pass a selector to subscribe to specific state.
|
|
1123
|
+
*/
|
|
1124
|
+
declare function useStudentStore<T>(selector: (state: StudentStore) => T): T;
|
|
708
1125
|
/**
|
|
709
1126
|
* Hook to access all stores directly (for actions).
|
|
710
1127
|
*/
|
|
@@ -760,6 +1177,28 @@ declare function usePDFViewer(): {
|
|
|
760
1177
|
clearSearch: () => void;
|
|
761
1178
|
nextSearchResult: () => void;
|
|
762
1179
|
previousSearchResult: () => void;
|
|
1180
|
+
agentContext: AgentContext | null;
|
|
1181
|
+
setAgentContext: (context: Partial<AgentContext>) => void;
|
|
1182
|
+
clearAgentContext: () => void;
|
|
1183
|
+
focusedRegions: FocusedRegion[];
|
|
1184
|
+
focusRegion: (region: Omit<FocusedRegion, "id">) => string;
|
|
1185
|
+
clearFocusedRegion: (id: string) => void;
|
|
1186
|
+
clearAllFocusedRegions: () => void;
|
|
1187
|
+
getAgentAPI: () => AgentAPI;
|
|
1188
|
+
bookmarks: Bookmark[];
|
|
1189
|
+
addBookmark: (data: Omit<Bookmark, "id" | "timestamp">) => Bookmark;
|
|
1190
|
+
updateBookmark: (id: string, updates: Partial<Omit<Bookmark, "id">>) => void;
|
|
1191
|
+
removeBookmark: (id: string) => void;
|
|
1192
|
+
quickNotes: QuickNote[];
|
|
1193
|
+
addQuickNote: (data: Omit<QuickNote, "id" | "timestamp">) => QuickNote;
|
|
1194
|
+
updateQuickNote: (id: string, updates: Partial<Omit<QuickNote, "id">>) => void;
|
|
1195
|
+
removeQuickNote: (id: string) => void;
|
|
1196
|
+
takeaways: Takeaway[];
|
|
1197
|
+
addTakeaway: (data: Omit<Takeaway, "id" | "timestamp">) => Takeaway;
|
|
1198
|
+
removeTakeaway: (id: string) => void;
|
|
1199
|
+
visitedPages: Set<number>;
|
|
1200
|
+
progress: number;
|
|
1201
|
+
markPageVisited: (pageNumber: number) => void;
|
|
763
1202
|
};
|
|
764
1203
|
|
|
765
1204
|
interface UsePageNavigationOptions {
|
|
@@ -1079,6 +1518,190 @@ interface UsePluginsReturn {
|
|
|
1079
1518
|
}
|
|
1080
1519
|
declare function usePlugins(options?: UsePluginsOptions): UsePluginsReturn;
|
|
1081
1520
|
|
|
1521
|
+
interface UseAgentContextOptions {
|
|
1522
|
+
/** Default focus region style */
|
|
1523
|
+
defaultFocusStyle?: 'pulse' | 'glow' | 'border';
|
|
1524
|
+
/** Default focus region color */
|
|
1525
|
+
defaultFocusColor?: string;
|
|
1526
|
+
/** Default auto-clear timeout for focus regions (ms) */
|
|
1527
|
+
defaultAutoClearTimeout?: number;
|
|
1528
|
+
}
|
|
1529
|
+
interface UseAgentContextReturn {
|
|
1530
|
+
/** Current agent context */
|
|
1531
|
+
agentContext: AgentContext | null;
|
|
1532
|
+
/** Set or update agent context */
|
|
1533
|
+
setAgentContext: (context: Partial<AgentContext>) => void;
|
|
1534
|
+
/** Clear agent context */
|
|
1535
|
+
clearAgentContext: () => void;
|
|
1536
|
+
/** Currently focused regions */
|
|
1537
|
+
focusedRegions: FocusedRegion[];
|
|
1538
|
+
/** Add a focus region and return its ID */
|
|
1539
|
+
focusRegion: (region: Omit<FocusedRegion, 'id'>) => string;
|
|
1540
|
+
/** Remove a focus region by ID */
|
|
1541
|
+
clearFocusedRegion: (id: string) => void;
|
|
1542
|
+
/** Clear all focus regions */
|
|
1543
|
+
clearAllFocusedRegions: () => void;
|
|
1544
|
+
/** Add a takeaway for a page */
|
|
1545
|
+
addTakeaway: (pageNumber: number, summary: string, metadata?: Record<string, unknown>) => Takeaway;
|
|
1546
|
+
/** Add a highlight from the agent */
|
|
1547
|
+
addAgentHighlight: (params: AgentHighlightParams) => string;
|
|
1548
|
+
/** Get the agent API for external integration */
|
|
1549
|
+
getAgentAPI: () => AgentAPI;
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Hook for agent context management and AI agent integration.
|
|
1553
|
+
* Provides methods for agents to interact with the PDF viewer.
|
|
1554
|
+
*/
|
|
1555
|
+
declare function useAgentContext(options?: UseAgentContextOptions): UseAgentContextReturn;
|
|
1556
|
+
|
|
1557
|
+
interface UseAskAboutOptions {
|
|
1558
|
+
/** Whether the feature is enabled */
|
|
1559
|
+
enabled?: boolean;
|
|
1560
|
+
/** Long press duration to trigger ask about (ms) */
|
|
1561
|
+
longPressDuration?: number;
|
|
1562
|
+
/** Callback when ask about is triggered */
|
|
1563
|
+
onAskAbout?: (context: AskAboutContext) => void;
|
|
1564
|
+
/** Minimum selection length to enable ask about for text */
|
|
1565
|
+
minSelectionLength?: number;
|
|
1566
|
+
}
|
|
1567
|
+
interface UseAskAboutReturn {
|
|
1568
|
+
/** Whether ask about is currently in progress (long press active) */
|
|
1569
|
+
isLongPressing: boolean;
|
|
1570
|
+
/** Progress of the long press (0-1) */
|
|
1571
|
+
longPressProgress: number;
|
|
1572
|
+
/** Position of the long press */
|
|
1573
|
+
longPressPosition: {
|
|
1574
|
+
x: number;
|
|
1575
|
+
y: number;
|
|
1576
|
+
} | null;
|
|
1577
|
+
/** Trigger ask about for selected text */
|
|
1578
|
+
askAboutSelection: (text: string, pageNumber: number) => void;
|
|
1579
|
+
/** Trigger ask about for a region (diagram, image) */
|
|
1580
|
+
askAboutRegion: (region: PDFRegion, pageNumber: number) => void;
|
|
1581
|
+
/** Start long press tracking (for custom implementations) */
|
|
1582
|
+
startLongPress: (x: number, y: number) => void;
|
|
1583
|
+
/** Cancel long press */
|
|
1584
|
+
cancelLongPress: () => void;
|
|
1585
|
+
/** Complete long press and trigger callback */
|
|
1586
|
+
completeLongPress: (type: 'text' | 'region', pageNumber: number, text?: string, region?: PDFRegion) => void;
|
|
1587
|
+
/** Handlers for attaching to elements */
|
|
1588
|
+
handlers: {
|
|
1589
|
+
onMouseDown: (e: React.MouseEvent) => void;
|
|
1590
|
+
onMouseUp: () => void;
|
|
1591
|
+
onMouseLeave: () => void;
|
|
1592
|
+
onTouchStart: (e: React.TouchEvent) => void;
|
|
1593
|
+
onTouchEnd: () => void;
|
|
1594
|
+
onTouchCancel: () => void;
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Hook for implementing the "Ask About This" feature.
|
|
1599
|
+
* Provides long-press detection and callbacks for asking about text or regions.
|
|
1600
|
+
*/
|
|
1601
|
+
declare function useAskAbout(options?: UseAskAboutOptions): UseAskAboutReturn;
|
|
1602
|
+
|
|
1603
|
+
interface UseBookmarksOptions {
|
|
1604
|
+
/** Callback when bookmark is added */
|
|
1605
|
+
onBookmarkAdd?: (bookmark: Bookmark) => void;
|
|
1606
|
+
/** Callback when bookmark is removed */
|
|
1607
|
+
onBookmarkRemove?: (id: string) => void;
|
|
1608
|
+
/** Automatically capture agent context when bookmarking */
|
|
1609
|
+
captureAgentContext?: boolean;
|
|
1610
|
+
}
|
|
1611
|
+
interface UseBookmarksReturn {
|
|
1612
|
+
/** All bookmarks */
|
|
1613
|
+
bookmarks: Bookmark[];
|
|
1614
|
+
/** Bookmarks for the current page */
|
|
1615
|
+
currentPageBookmarks: Bookmark[];
|
|
1616
|
+
/** Check if current page is bookmarked */
|
|
1617
|
+
isCurrentPageBookmarked: boolean;
|
|
1618
|
+
/** Add a bookmark */
|
|
1619
|
+
addBookmark: (data?: Partial<Omit<Bookmark, 'id' | 'timestamp'>>) => Bookmark;
|
|
1620
|
+
/** Update a bookmark */
|
|
1621
|
+
updateBookmark: (id: string, updates: Partial<Omit<Bookmark, 'id'>>) => void;
|
|
1622
|
+
/** Remove a bookmark */
|
|
1623
|
+
removeBookmark: (id: string) => void;
|
|
1624
|
+
/** Toggle bookmark on current page */
|
|
1625
|
+
toggleBookmark: () => void;
|
|
1626
|
+
/** Navigate to a bookmarked page */
|
|
1627
|
+
goToBookmark: (bookmark: Bookmark) => void;
|
|
1628
|
+
/** Get bookmarks for a specific page */
|
|
1629
|
+
getBookmarksForPage: (pageNumber: number) => Bookmark[];
|
|
1630
|
+
/** Get bookmarks grouped by page */
|
|
1631
|
+
bookmarksByPage: Map<number, Bookmark[]>;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Hook for managing bookmarks with agent context capture.
|
|
1635
|
+
*/
|
|
1636
|
+
declare function useBookmarks(options?: UseBookmarksOptions): UseBookmarksReturn;
|
|
1637
|
+
|
|
1638
|
+
interface UseQuickNotesOptions {
|
|
1639
|
+
/** Callback when note is added */
|
|
1640
|
+
onNoteAdd?: (note: QuickNote) => void;
|
|
1641
|
+
/** Callback when note is removed */
|
|
1642
|
+
onNoteRemove?: (id: string) => void;
|
|
1643
|
+
/** Automatically capture agent's last statement when creating notes */
|
|
1644
|
+
captureAgentContext?: boolean;
|
|
1645
|
+
}
|
|
1646
|
+
interface UseQuickNotesReturn {
|
|
1647
|
+
/** All quick notes */
|
|
1648
|
+
quickNotes: QuickNote[];
|
|
1649
|
+
/** Quick notes for the current page */
|
|
1650
|
+
currentPageNotes: QuickNote[];
|
|
1651
|
+
/** Add a quick note */
|
|
1652
|
+
addQuickNote: (data: {
|
|
1653
|
+
content: string;
|
|
1654
|
+
x: number;
|
|
1655
|
+
y: number;
|
|
1656
|
+
pageNumber?: number;
|
|
1657
|
+
}) => QuickNote;
|
|
1658
|
+
/** Update a quick note */
|
|
1659
|
+
updateQuickNote: (id: string, updates: Partial<Omit<QuickNote, 'id'>>) => void;
|
|
1660
|
+
/** Remove a quick note */
|
|
1661
|
+
removeQuickNote: (id: string) => void;
|
|
1662
|
+
/** Get notes for a specific page */
|
|
1663
|
+
getNotesForPage: (pageNumber: number) => QuickNote[];
|
|
1664
|
+
/** Notes grouped by page */
|
|
1665
|
+
notesByPage: Map<number, QuickNote[]>;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Hook for managing quick notes with agent context capture.
|
|
1669
|
+
*/
|
|
1670
|
+
declare function useQuickNotes(options?: UseQuickNotesOptions): UseQuickNotesReturn;
|
|
1671
|
+
|
|
1672
|
+
interface UseStudentProgressOptions {
|
|
1673
|
+
/** Automatically track page visits */
|
|
1674
|
+
autoTrack?: boolean;
|
|
1675
|
+
/** Debounce time for page tracking (ms) */
|
|
1676
|
+
trackDebounce?: number;
|
|
1677
|
+
}
|
|
1678
|
+
interface UseStudentProgressReturn {
|
|
1679
|
+
/** Set of visited page numbers */
|
|
1680
|
+
visitedPages: Set<number>;
|
|
1681
|
+
/** Array of visited page numbers (for easier iteration) */
|
|
1682
|
+
visitedPagesArray: number[];
|
|
1683
|
+
/** Current reading progress (0-1) */
|
|
1684
|
+
progress: number;
|
|
1685
|
+
/** Percentage of pages visited */
|
|
1686
|
+
visitedPercentage: number;
|
|
1687
|
+
/** Number of pages visited */
|
|
1688
|
+
visitedCount: number;
|
|
1689
|
+
/** Total number of pages */
|
|
1690
|
+
totalPages: number;
|
|
1691
|
+
/** Current page number */
|
|
1692
|
+
currentPage: number;
|
|
1693
|
+
/** Mark a page as visited */
|
|
1694
|
+
markPageVisited: (pageNumber: number) => void;
|
|
1695
|
+
/** Check if a page has been visited */
|
|
1696
|
+
isPageVisited: (pageNumber: number) => boolean;
|
|
1697
|
+
/** Get page visit status for minimap rendering */
|
|
1698
|
+
getPageStatus: (pageNumber: number) => 'current' | 'visited' | 'unvisited';
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Hook for tracking student reading progress.
|
|
1702
|
+
*/
|
|
1703
|
+
declare function useStudentProgress(options?: UseStudentProgressOptions): UseStudentProgressReturn;
|
|
1704
|
+
|
|
1082
1705
|
/**
|
|
1083
1706
|
* Utility for merging class names with support for conditionals.
|
|
1084
1707
|
* Uses clsx under the hood.
|
|
@@ -1113,6 +1736,12 @@ interface LoadDocumentOptions {
|
|
|
1113
1736
|
loaded: number;
|
|
1114
1737
|
total: number;
|
|
1115
1738
|
}) => void;
|
|
1739
|
+
/** Enable range requests for faster loading (default: true) */
|
|
1740
|
+
enableRangeRequests?: boolean;
|
|
1741
|
+
/** Enable streaming for progressive display (default: true) */
|
|
1742
|
+
enableStreaming?: boolean;
|
|
1743
|
+
/** Cache the document data (default: true) */
|
|
1744
|
+
cacheDocument?: boolean;
|
|
1116
1745
|
}
|
|
1117
1746
|
interface LoadDocumentResult {
|
|
1118
1747
|
document: PDFDocumentProxy;
|
|
@@ -1120,6 +1749,12 @@ interface LoadDocumentResult {
|
|
|
1120
1749
|
}
|
|
1121
1750
|
/**
|
|
1122
1751
|
* Load a PDF document from a URL or data buffer.
|
|
1752
|
+
*
|
|
1753
|
+
* Optimizations:
|
|
1754
|
+
* - Range requests allow loading only the parts needed (faster initial load)
|
|
1755
|
+
* - Streaming allows pages to render as data arrives
|
|
1756
|
+
* - Document caching prevents duplicate fetches
|
|
1757
|
+
* - Worker handles parsing off the main thread
|
|
1123
1758
|
*/
|
|
1124
1759
|
declare function loadDocument(options: LoadDocumentOptions): Promise<LoadDocumentResult>;
|
|
1125
1760
|
/**
|
|
@@ -1289,4 +1924,112 @@ declare function createPDFViewer(container: HTMLElement, options?: PDFViewerCont
|
|
|
1289
1924
|
*/
|
|
1290
1925
|
declare function quickViewer(container: HTMLElement | string, src: string | ArrayBuffer | Uint8Array, options?: Partial<PDFViewerControllerOptions>): Promise<PDFViewerController>;
|
|
1291
1926
|
|
|
1292
|
-
|
|
1927
|
+
interface ExportData {
|
|
1928
|
+
highlights?: Highlight[];
|
|
1929
|
+
bookmarks?: Bookmark[];
|
|
1930
|
+
quickNotes?: QuickNote[];
|
|
1931
|
+
takeaways?: Takeaway[];
|
|
1932
|
+
documentTitle?: string;
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* Export all annotations as a comprehensive Markdown document.
|
|
1936
|
+
* Organizes content by page with highlights, notes, bookmarks, and takeaways.
|
|
1937
|
+
*/
|
|
1938
|
+
declare function exportAnnotationsAsMarkdown(data: ExportData): string;
|
|
1939
|
+
/**
|
|
1940
|
+
* Export all annotations as JSON.
|
|
1941
|
+
*/
|
|
1942
|
+
declare function exportAnnotationsAsJSON(data: ExportData): string;
|
|
1943
|
+
/**
|
|
1944
|
+
* Download content as a file.
|
|
1945
|
+
*/
|
|
1946
|
+
declare function downloadFile(content: string, filename: string, mimeType: string): void;
|
|
1947
|
+
/**
|
|
1948
|
+
* Export annotations as Markdown and trigger download.
|
|
1949
|
+
*/
|
|
1950
|
+
declare function downloadAnnotationsAsMarkdown(data: ExportData, filename?: string): void;
|
|
1951
|
+
/**
|
|
1952
|
+
* Export annotations as JSON and trigger download.
|
|
1953
|
+
*/
|
|
1954
|
+
declare function downloadAnnotationsAsJSON(data: ExportData, filename?: string): void;
|
|
1955
|
+
|
|
1956
|
+
interface StoredBookmark extends Omit<Bookmark, 'timestamp'> {
|
|
1957
|
+
timestamp: string;
|
|
1958
|
+
}
|
|
1959
|
+
interface StoredQuickNote extends Omit<QuickNote, 'timestamp'> {
|
|
1960
|
+
timestamp: string;
|
|
1961
|
+
}
|
|
1962
|
+
interface StoredTakeaway extends Omit<Takeaway, 'timestamp'> {
|
|
1963
|
+
timestamp: string;
|
|
1964
|
+
}
|
|
1965
|
+
interface StoredStudentData {
|
|
1966
|
+
bookmarks: StoredBookmark[];
|
|
1967
|
+
quickNotes: StoredQuickNote[];
|
|
1968
|
+
takeaways: StoredTakeaway[];
|
|
1969
|
+
visitedPages: number[];
|
|
1970
|
+
progress: number;
|
|
1971
|
+
lastAccessed: string;
|
|
1972
|
+
}
|
|
1973
|
+
interface StudentData {
|
|
1974
|
+
bookmarks: Bookmark[];
|
|
1975
|
+
quickNotes: QuickNote[];
|
|
1976
|
+
takeaways: Takeaway[];
|
|
1977
|
+
visitedPages: Set<number>;
|
|
1978
|
+
progress: number;
|
|
1979
|
+
lastAccessed: Date;
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Save student data to localStorage.
|
|
1983
|
+
*/
|
|
1984
|
+
declare function saveStudentData(documentId: string, data: StudentData): boolean;
|
|
1985
|
+
/**
|
|
1986
|
+
* Load student data from localStorage.
|
|
1987
|
+
*/
|
|
1988
|
+
declare function loadStudentData(documentId: string): StudentData | null;
|
|
1989
|
+
/**
|
|
1990
|
+
* Clear student data for a specific document.
|
|
1991
|
+
*/
|
|
1992
|
+
declare function clearStudentData(documentId: string): boolean;
|
|
1993
|
+
/**
|
|
1994
|
+
* Get all document IDs that have stored student data.
|
|
1995
|
+
*/
|
|
1996
|
+
declare function getAllStudentDataDocumentIds(): string[];
|
|
1997
|
+
/**
|
|
1998
|
+
* Get storage usage statistics.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function getStorageStats(): {
|
|
2001
|
+
usedBytes: number;
|
|
2002
|
+
itemCount: number;
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
interface AgentAPIStores {
|
|
2006
|
+
agentStore: StoreApi<AgentStore>;
|
|
2007
|
+
studentStore: StoreApi<StudentStore>;
|
|
2008
|
+
viewerStore: StoreApi<ViewerStore>;
|
|
2009
|
+
annotationStore: StoreApi<AnnotationStore>;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Create a standalone Agent API for external AI agent integration.
|
|
2013
|
+
* This allows external agents to interact with the PDF viewer without
|
|
2014
|
+
* needing direct access to React hooks.
|
|
2015
|
+
*
|
|
2016
|
+
* @example
|
|
2017
|
+
* ```typescript
|
|
2018
|
+
* import { createAgentAPI } from 'pdfjs-reader-core';
|
|
2019
|
+
*
|
|
2020
|
+
* // Get stores from the context (this would typically be done in a React component)
|
|
2021
|
+
* const api = createAgentAPI(stores);
|
|
2022
|
+
*
|
|
2023
|
+
* // Now the external agent can use the API
|
|
2024
|
+
* api.setAgentContext({ lastStatement: "The mitochondria is the powerhouse of the cell" });
|
|
2025
|
+
* api.focusRegion({ pageNumber: 1, x: 100, y: 200, width: 300, height: 50, style: 'pulse' });
|
|
2026
|
+
* api.addTakeaway(1, "Key concept: Cell energy production");
|
|
2027
|
+
* ```
|
|
2028
|
+
*/
|
|
2029
|
+
declare function createAgentAPI(stores: AgentAPIStores): AgentAPI;
|
|
2030
|
+
/**
|
|
2031
|
+
* Convenience type for the return value of createAgentAPI
|
|
2032
|
+
*/
|
|
2033
|
+
type AgentAPIInstance = ReturnType<typeof createAgentAPI>;
|
|
2034
|
+
|
|
2035
|
+
export { type AgentAPI, type AgentAPIInstance, type AgentAPIStores, type AgentActions, type AgentContext, type AgentHighlightParams, type AgentState, type AgentStore, type AgentStoreApi, type Annotation, type AnnotationActions, AnnotationLayer, type AnnotationLayerProps, type AnnotationState, type AnnotationStore, type AnnotationStoreApi, type AnnotationTool, AnnotationToolbar, type AnnotationToolbarProps, type AnnotationType, type AskAboutContext, AskAboutOverlay, type AskAboutOverlayProps, AskAboutTrigger, type AskAboutTriggerProps, type Bookmark, BookmarksPanel, type BookmarksPanelProps, CanvasLayer, type CanvasLayerProps, type ContextMenuItem, ContinuousScrollContainer, type ContinuousScrollContainerProps, DocumentContainer, type DocumentContainerProps, type DrawingAnnotation, DrawingCanvas, type DrawingCanvasProps, type DrawingPath, DualPageContainer, type DualPageContainerProps, type ExportData, FocusRegionLayer, type FocusRegionLayerProps, type FocusedRegion, type Highlight, type HighlightColor, HighlightLayer, type HighlightLayerProps, HighlightPopover, type HighlightPopoverProps, type HighlightRect, HighlightsPanel, type HighlightsPanelProps, type LoadDocumentOptions, type LoadDocumentResult, Minimap, type MinimapProps, MobileSidebar, type MobileSidebarProps, MobileToolbar, type MobileToolbarProps, type NoteAnnotation, type OutlineItem, OutlinePanel, type OutlinePanelProps, type PDFDocumentLoadedEvent, PDFErrorBoundary, type PDFErrorBoundaryProps, PDFPage, type PDFPageProps, type PDFPageState, type PDFRegion, PDFViewer, PDFViewerClient, PDFViewerContext, type PDFViewerContextValue, type PDFViewerController, type PDFViewerControllerOptions, type PDFViewerEventMap, type PDFViewerProps, PDFViewerProvider, type PDFViewerProviderProps, type PageDimensions, type Plugin, type PluginAPI, PluginManager, type PluginManagerOptions, type QuickNote, QuickNoteButton, type QuickNoteButtonProps, QuickNotePopover, type QuickNotePopoverProps, type ScrollMode, type SearchActions, SearchPanel, type SearchPanelProps, type SearchResult, type SearchState, type SearchStore, type SearchStoreApi, SelectionToolbar, type SelectionToolbarProps, type ShapeAnnotation, ShapePreview, type ShapePreviewProps, ShapeRenderer, type ShapeRendererProps, type ShapeType, Sidebar, type SidebarPanel, type SidebarPanelConfig, type SidebarProps, StickyNote, type StickyNoteProps, type StoredStudentData, type StudentActions, type StudentData, type StudentModeCallbacks, type StudentModeProps, type StudentState, type StudentStore, type StudentStoreApi, type Takeaway, TakeawaysPanel, type TakeawaysPanelProps, TextLayer, type TextLayerProps, type TextSelection, type Theme, ThumbnailPanel, type ThumbnailPanelProps, Toolbar, type ToolbarItem, type ToolbarProps, type UseAgentContextOptions, type UseAgentContextReturn, type UseAnnotationsOptions, type UseAnnotationsReturn, type UseAskAboutOptions, type UseAskAboutReturn, type UseBookmarksOptions, type UseBookmarksReturn, type UseHighlightsOptions, type UseHighlightsReturn, type UsePageNavigationOptions, type UsePluginsOptions, type UsePluginsReturn, type UseQuickNotesOptions, type UseQuickNotesReturn, type UseStudentProgressOptions, type UseStudentProgressReturn, type UseTextSelectionOptions, type UseTouchGesturesOptions, type UseZoomOptions, type ViewMode, type ViewerActions, type ViewerState, type ViewerStore, type ViewerStoreApi, VirtualizedDocumentContainer, type VirtualizedDocumentContainerProps, type WithErrorBoundaryProps, clearHighlights, clearStudentData, cn, createAgentAPI, createAgentStore, createAnnotationStore, createPDFViewer, createPluginManager, createSearchStore, createStudentStore, createViewerStore, downloadAnnotationsAsJSON, downloadAnnotationsAsMarkdown, downloadFile, exportAnnotationsAsJSON, exportAnnotationsAsMarkdown, exportHighlightsAsJSON, exportHighlightsAsMarkdown, generateDocumentId, getAllDocumentIds, getAllStudentDataDocumentIds, getMetadata, getOutline, getPage, getPageTextContent, getPluginManager, getStorageStats, importHighlightsFromJSON, initializePDFJS, isPDFJSInitialized, loadDocument, loadHighlights, loadStudentData, quickViewer, saveHighlights, saveStudentData, useAgentContext, useAgentStore, useAnnotationStore, useAnnotations, useAskAbout, useBookmarks, useHighlights, useIsMobile, useIsTouchDevice, usePDFViewer, usePDFViewerStores, usePageNavigation, usePlugins, useQuickNotes, useSearchStore, useStudentProgress, useStudentStore, useTextSelection, useTouchGestures, useViewerStore, useZoom, withErrorBoundary };
|