@files-preview-app/preview-file 1.3.0 → 1.3.2
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 +69 -0
- package/dist/angular.cjs +1477 -482
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.d.cts +1 -1
- package/dist/angular.d.ts +1 -1
- package/dist/angular.js +1477 -482
- package/dist/angular.js.map +1 -1
- package/dist/index.cjs +1477 -482
- package/dist/index.cjs.map +1 -1
- package/dist/index.d-B79v0jxi.d.cts +570 -0
- package/dist/index.d-B79v0jxi.d.ts +570 -0
- package/dist/index.d.cts +3227 -19
- package/dist/index.d.ts +3227 -19
- package/dist/index.js +1477 -482
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +1477 -482
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -16
- package/dist/react.d.ts +1 -16
- package/dist/react.js +1477 -482
- package/dist/react.js.map +1 -1
- package/dist/styles.css +195 -14
- package/dist/vue.cjs +1477 -482
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +1477 -482
- package/dist/vue.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported file input sources.
|
|
3
|
+
* Accepts URL strings, File objects, Blobs, ArrayBuffers, or Uint8Arrays.
|
|
4
|
+
*/
|
|
5
|
+
type FileSource = string | File | Blob | ArrayBuffer | Uint8Array;
|
|
6
|
+
/** Metadata extracted from a file source */
|
|
7
|
+
interface FileMetadata {
|
|
8
|
+
/** Original filename (if available) */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** File size in bytes */
|
|
11
|
+
size?: number;
|
|
12
|
+
/** Detected MIME type */
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
/** File extension (lowercase, with dot, e.g. '.pdf') */
|
|
15
|
+
extension?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Information about a resolved file, ready for plugin matching */
|
|
18
|
+
interface FileInfo {
|
|
19
|
+
metadata: FileMetadata;
|
|
20
|
+
buffer: ArrayBuffer;
|
|
21
|
+
}
|
|
22
|
+
/** Toolbar action types */
|
|
23
|
+
type ToolbarActionType = 'button' | 'toggle' | 'range' | 'input' | 'separator' | 'page-nav';
|
|
24
|
+
/** Toolbar action group names for visual grouping */
|
|
25
|
+
type ToolbarGroup = 'navigation' | 'zoom' | 'view' | 'actions';
|
|
26
|
+
/** Represents a single toolbar action/control */
|
|
27
|
+
interface ToolbarAction {
|
|
28
|
+
/** Unique action identifier */
|
|
29
|
+
id: string;
|
|
30
|
+
/** SVG icon markup string */
|
|
31
|
+
icon: string;
|
|
32
|
+
/** Accessible label */
|
|
33
|
+
label: string;
|
|
34
|
+
/** Type of control to render */
|
|
35
|
+
type: ToolbarActionType;
|
|
36
|
+
/** Visual group placement */
|
|
37
|
+
group: ToolbarGroup;
|
|
38
|
+
/** Whether the action is currently enabled */
|
|
39
|
+
enabled?: boolean;
|
|
40
|
+
/** Whether a toggle is currently active */
|
|
41
|
+
active?: boolean;
|
|
42
|
+
/** Execute the action */
|
|
43
|
+
execute: (...args: unknown[]) => void;
|
|
44
|
+
/** For 'range' type: min/max/step/value */
|
|
45
|
+
min?: number;
|
|
46
|
+
max?: number;
|
|
47
|
+
step?: number;
|
|
48
|
+
value?: number;
|
|
49
|
+
}
|
|
50
|
+
/** Represents a thumbnail in the sidebar */
|
|
51
|
+
interface Thumbnail {
|
|
52
|
+
/** Page/sheet/frame index */
|
|
53
|
+
index: number;
|
|
54
|
+
/** Display label (e.g., "Page 1", "Sheet: Revenue") */
|
|
55
|
+
label: string;
|
|
56
|
+
/** Renders the thumbnail into a canvas element */
|
|
57
|
+
render: (canvas: HTMLCanvasElement) => Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/** Instance returned after a file is rendered — exposes controls */
|
|
60
|
+
interface PreviewInstance {
|
|
61
|
+
/** Clean up all resources */
|
|
62
|
+
destroy(): void;
|
|
63
|
+
zoomIn?(): void;
|
|
64
|
+
zoomOut?(): void;
|
|
65
|
+
getZoom?(): number;
|
|
66
|
+
setZoom?(level: number): void;
|
|
67
|
+
fitToPage?(): void;
|
|
68
|
+
fitToWidth?(): void;
|
|
69
|
+
goToPage?(page: number): void;
|
|
70
|
+
getPageCount?(): number;
|
|
71
|
+
getCurrentPage?(): number;
|
|
72
|
+
rotateCW?(): void;
|
|
73
|
+
rotateCCW?(): void;
|
|
74
|
+
getRotation?(): number;
|
|
75
|
+
play?(): void;
|
|
76
|
+
pause?(): void;
|
|
77
|
+
isPlaying?(): boolean;
|
|
78
|
+
fastForward?(seconds?: number): void;
|
|
79
|
+
rewind?(seconds?: number): void;
|
|
80
|
+
setPlaybackRate?(rate: number): void;
|
|
81
|
+
getPlaybackRate?(): number;
|
|
82
|
+
getThumbnails?(): Thumbnail[] | Promise<Thumbnail[]>;
|
|
83
|
+
toggleThumbnails?(): void;
|
|
84
|
+
download?(): void;
|
|
85
|
+
print?(): void;
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
/** Context passed to a plugin's render function */
|
|
89
|
+
interface RenderContext {
|
|
90
|
+
/** The container DOM element to render into */
|
|
91
|
+
container: HTMLElement;
|
|
92
|
+
/** Original file source */
|
|
93
|
+
source: FileSource;
|
|
94
|
+
/** Resolved file metadata */
|
|
95
|
+
metadata: FileMetadata;
|
|
96
|
+
/** File content as ArrayBuffer */
|
|
97
|
+
buffer: ArrayBuffer;
|
|
98
|
+
/** Viewer options */
|
|
99
|
+
options: PreviewViewerOptions;
|
|
100
|
+
/** AbortSignal for cancellation */
|
|
101
|
+
signal: AbortSignal;
|
|
102
|
+
/** Emit an event to the viewer */
|
|
103
|
+
emit: (event: string, payload?: unknown) => void;
|
|
104
|
+
}
|
|
105
|
+
/** Plugin interface — each file format renderer implements this */
|
|
106
|
+
interface PreviewPlugin {
|
|
107
|
+
/** Unique plugin identifier */
|
|
108
|
+
id: string;
|
|
109
|
+
/** Human-readable plugin name */
|
|
110
|
+
name: string;
|
|
111
|
+
/** File extensions this plugin handles (e.g., ['.pdf']) */
|
|
112
|
+
extensions: string[];
|
|
113
|
+
/** MIME types this plugin handles */
|
|
114
|
+
mimeTypes: string[];
|
|
115
|
+
/** Priority when multiple plugins match (higher = preferred) */
|
|
116
|
+
weight?: number;
|
|
117
|
+
/** Check if this plugin can handle the given file */
|
|
118
|
+
supports(file: FileInfo): boolean | Promise<boolean>;
|
|
119
|
+
/** Return toolbar actions for the rendered instance */
|
|
120
|
+
getToolbarActions(instance: PreviewInstance): ToolbarAction[];
|
|
121
|
+
/** Render the file into the container */
|
|
122
|
+
render(ctx: RenderContext): Promise<PreviewInstance>;
|
|
123
|
+
}
|
|
124
|
+
/** Configuration to selectively enable or disable individual toolbar functions/buttons */
|
|
125
|
+
interface ToolbarConfig {
|
|
126
|
+
/** Page navigation (< [1] / N >) */
|
|
127
|
+
pageNav?: boolean;
|
|
128
|
+
pagination?: boolean;
|
|
129
|
+
prevPage?: boolean;
|
|
130
|
+
nextPage?: boolean;
|
|
131
|
+
/** Zoom controls */
|
|
132
|
+
zoomIn?: boolean;
|
|
133
|
+
zoomOut?: boolean;
|
|
134
|
+
fitPage?: boolean;
|
|
135
|
+
fitToPage?: boolean;
|
|
136
|
+
fitWidth?: boolean;
|
|
137
|
+
zoomReset?: boolean;
|
|
138
|
+
/** View controls */
|
|
139
|
+
rotate?: boolean;
|
|
140
|
+
rotateCW?: boolean;
|
|
141
|
+
rotateCCW?: boolean;
|
|
142
|
+
fullscreen?: boolean;
|
|
143
|
+
thumbnails?: boolean;
|
|
144
|
+
/** Action controls */
|
|
145
|
+
download?: boolean;
|
|
146
|
+
print?: boolean;
|
|
147
|
+
openWindow?: boolean;
|
|
148
|
+
openSeparateWindow?: boolean;
|
|
149
|
+
copy?: boolean;
|
|
150
|
+
/** Media controls */
|
|
151
|
+
play?: boolean;
|
|
152
|
+
pause?: boolean;
|
|
153
|
+
fastForward?: boolean;
|
|
154
|
+
rewind?: boolean;
|
|
155
|
+
speed?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** Viewer configuration options */
|
|
158
|
+
interface PreviewViewerOptions extends ToolbarConfig {
|
|
159
|
+
/** Color theme */
|
|
160
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
161
|
+
/** Locale for UI labels */
|
|
162
|
+
locale?: string;
|
|
163
|
+
/** Initial zoom level (1.0 = 100%) */
|
|
164
|
+
zoom?: number;
|
|
165
|
+
/** Initial page number (1-based) */
|
|
166
|
+
page?: number;
|
|
167
|
+
/** Show the toolbar */
|
|
168
|
+
showToolbar?: boolean;
|
|
169
|
+
/** Detailed toolbar configuration (or boolean to show/hide entire toolbar) */
|
|
170
|
+
toolbar?: boolean | (ToolbarConfig & Record<string, boolean | undefined>);
|
|
171
|
+
/** Toolbar position */
|
|
172
|
+
toolbarPosition?: 'top' | 'bottom';
|
|
173
|
+
/** Fit mode: 'page' (fill frame width with minimal margins) or 'width' */
|
|
174
|
+
fitMode?: 'page' | 'width';
|
|
175
|
+
/** Show thumbnail sidebar initially */
|
|
176
|
+
showThumbnails?: boolean;
|
|
177
|
+
/** Whether to display the file name / title bar above the toolbar in the preview panel (defaults to true) */
|
|
178
|
+
showFileName?: boolean;
|
|
179
|
+
/** Custom file name / title override to display */
|
|
180
|
+
fileName?: string;
|
|
181
|
+
/** Custom CSS class for the container */
|
|
182
|
+
className?: string;
|
|
183
|
+
/** Plugin-specific options */
|
|
184
|
+
pluginOptions?: Record<string, unknown>;
|
|
185
|
+
/** Optional file metadata overrides (name, extension, mimeType, etc.) */
|
|
186
|
+
metadata?: FileMetadata;
|
|
187
|
+
/** Custom URL to navigate when "Open in Separate Full Window" is clicked */
|
|
188
|
+
standaloneViewerUrl?: string;
|
|
189
|
+
/** Custom handler for opening preview in a separate window */
|
|
190
|
+
onOpenSeparateWindow?: (payload: {
|
|
191
|
+
buffer: ArrayBuffer;
|
|
192
|
+
metadata: FileMetadata;
|
|
193
|
+
options: PreviewViewerOptions;
|
|
194
|
+
}) => Window | null;
|
|
195
|
+
/** Internal flag: true when viewer is rendered inside separate full window */
|
|
196
|
+
_isSeparateWindow?: boolean;
|
|
197
|
+
/** Allow custom/plugin-specific options */
|
|
198
|
+
[key: string]: unknown;
|
|
199
|
+
}
|
|
200
|
+
/** Events emitted by the viewer */
|
|
201
|
+
type PreviewEvent = 'loading' | 'loaded' | 'error' | 'page-change' | 'zoom-change' | 'rotate' | 'destroy';
|
|
202
|
+
/** Event handler function */
|
|
203
|
+
type EventHandler<T = unknown> = (data: T) => void;
|
|
204
|
+
/** Unsubscribe function returned by on() */
|
|
205
|
+
type Unsubscribe = () => void;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Main file preview viewer engine.
|
|
209
|
+
* Manages plugins, rendering lifecycle, toolbar, and thumbnails.
|
|
210
|
+
*/
|
|
211
|
+
declare class FilePreviewViewer {
|
|
212
|
+
private plugins;
|
|
213
|
+
private activeInstance;
|
|
214
|
+
private abortController;
|
|
215
|
+
private eventEmitter;
|
|
216
|
+
private toolbar;
|
|
217
|
+
private thumbnailPanel;
|
|
218
|
+
private wrapperEl;
|
|
219
|
+
private contentEl;
|
|
220
|
+
private currentBuffer;
|
|
221
|
+
private currentMetadata;
|
|
222
|
+
private keyHandler;
|
|
223
|
+
private currentContainer;
|
|
224
|
+
private currentOptions;
|
|
225
|
+
private resizeObserver;
|
|
226
|
+
private fullscreenHandler;
|
|
227
|
+
private titleBarEl;
|
|
228
|
+
/**
|
|
229
|
+
* Register a preview plugin.
|
|
230
|
+
*/
|
|
231
|
+
registerPlugin(plugin: PreviewPlugin): this;
|
|
232
|
+
/**
|
|
233
|
+
* Register multiple plugins at once.
|
|
234
|
+
*/
|
|
235
|
+
registerPlugins(plugins: PreviewPlugin[]): this;
|
|
236
|
+
/**
|
|
237
|
+
* Preview a file in the given container element.
|
|
238
|
+
*/
|
|
239
|
+
preview(container: HTMLElement, source: FileSource, options?: PreviewViewerOptions): Promise<PreviewInstance>;
|
|
240
|
+
/**
|
|
241
|
+
* Opens the current file preview in a separate full browser window.
|
|
242
|
+
*/
|
|
243
|
+
openInSeparateWindow(): Window | null;
|
|
244
|
+
/**
|
|
245
|
+
* Subscribe to viewer events.
|
|
246
|
+
*/
|
|
247
|
+
on(event: string, handler: EventHandler): Unsubscribe;
|
|
248
|
+
/**
|
|
249
|
+
* Destroy the viewer and clean up all resources.
|
|
250
|
+
*/
|
|
251
|
+
destroy(): void;
|
|
252
|
+
/**
|
|
253
|
+
* Get the currently active preview instance.
|
|
254
|
+
*/
|
|
255
|
+
getInstance(): PreviewInstance | null;
|
|
256
|
+
/**
|
|
257
|
+
* Configure toolbar features dynamically through options or methods.
|
|
258
|
+
* e.g. viewer.setToolbarConfig({ zoomIn: false, print: false })
|
|
259
|
+
*/
|
|
260
|
+
setToolbarConfig(config: ToolbarConfig): void;
|
|
261
|
+
/**
|
|
262
|
+
* Get current toolbar configuration.
|
|
263
|
+
*/
|
|
264
|
+
getToolbarConfig(): ToolbarConfig;
|
|
265
|
+
/**
|
|
266
|
+
* Hide a specific toolbar action by ID or alias (e.g. 'zoom-in', 'print', 'download').
|
|
267
|
+
*/
|
|
268
|
+
hideToolbarAction(actionId: string): void;
|
|
269
|
+
/**
|
|
270
|
+
* Show a specific toolbar action by ID or alias.
|
|
271
|
+
*/
|
|
272
|
+
showToolbarAction(actionId: string): void;
|
|
273
|
+
/**
|
|
274
|
+
* Enable a specific toolbar action button.
|
|
275
|
+
*/
|
|
276
|
+
enableToolbarAction(actionId: string): void;
|
|
277
|
+
/**
|
|
278
|
+
* Disable a specific toolbar action button.
|
|
279
|
+
*/
|
|
280
|
+
disableToolbarAction(actionId: string): void;
|
|
281
|
+
/**
|
|
282
|
+
* Fit document to page so it fills the frame width with minimal margins.
|
|
283
|
+
*/
|
|
284
|
+
fitToPage(): void;
|
|
285
|
+
/**
|
|
286
|
+
* Zoom in.
|
|
287
|
+
*/
|
|
288
|
+
zoomIn(): void;
|
|
289
|
+
/**
|
|
290
|
+
* Zoom out.
|
|
291
|
+
*/
|
|
292
|
+
zoomOut(): void;
|
|
293
|
+
/**
|
|
294
|
+
* Set specific zoom level.
|
|
295
|
+
*/
|
|
296
|
+
setZoom(level: number): void;
|
|
297
|
+
/**
|
|
298
|
+
* Get current zoom level.
|
|
299
|
+
*/
|
|
300
|
+
getZoom(): number;
|
|
301
|
+
/**
|
|
302
|
+
* Rotate 90 degrees clockwise.
|
|
303
|
+
*/
|
|
304
|
+
rotateCW(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Rotate 90 degrees counter-clockwise.
|
|
307
|
+
*/
|
|
308
|
+
rotateCCW(): void;
|
|
309
|
+
/**
|
|
310
|
+
* Navigate to a specific page number.
|
|
311
|
+
*/
|
|
312
|
+
goToPage(page: number): void;
|
|
313
|
+
/**
|
|
314
|
+
* Navigate to next page.
|
|
315
|
+
*/
|
|
316
|
+
nextPage(): void;
|
|
317
|
+
/**
|
|
318
|
+
* Navigate to previous page.
|
|
319
|
+
*/
|
|
320
|
+
prevPage(): void;
|
|
321
|
+
/**
|
|
322
|
+
* Get total page count.
|
|
323
|
+
*/
|
|
324
|
+
getPageCount(): number;
|
|
325
|
+
/**
|
|
326
|
+
* Get current page number.
|
|
327
|
+
*/
|
|
328
|
+
getCurrentPage(): number;
|
|
329
|
+
/**
|
|
330
|
+
* Download the current document.
|
|
331
|
+
*/
|
|
332
|
+
download(): void;
|
|
333
|
+
/**
|
|
334
|
+
* Print the current document.
|
|
335
|
+
*/
|
|
336
|
+
print(): void;
|
|
337
|
+
/**
|
|
338
|
+
* Toggle fullscreen mode.
|
|
339
|
+
*/
|
|
340
|
+
toggleFullscreen(): void;
|
|
341
|
+
/**
|
|
342
|
+
* Toggle thumbnails sidebar panel.
|
|
343
|
+
*/
|
|
344
|
+
toggleThumbnails(): void;
|
|
345
|
+
/**
|
|
346
|
+
* Set whether to display the file name / title bar above the toolbar.
|
|
347
|
+
*/
|
|
348
|
+
setShowFileName(show: boolean): void;
|
|
349
|
+
/**
|
|
350
|
+
* Set or override the displayed file name in the preview panel.
|
|
351
|
+
*/
|
|
352
|
+
setFileName(name: string): void;
|
|
353
|
+
private updateTitleBar;
|
|
354
|
+
private extractToolbarConfig;
|
|
355
|
+
private abort;
|
|
356
|
+
private destroyInstance;
|
|
357
|
+
private findPlugin;
|
|
358
|
+
private setupDOM;
|
|
359
|
+
private setupResizeAndFullscreenListeners;
|
|
360
|
+
private setupKeyboardShortcuts;
|
|
361
|
+
private setupDragAndDrop;
|
|
362
|
+
private showLoading;
|
|
363
|
+
private hideLoading;
|
|
364
|
+
private showError;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Lightweight typed event emitter for the file preview system.
|
|
369
|
+
* Supports on/off/emit with automatic cleanup.
|
|
370
|
+
*/
|
|
371
|
+
declare class EventEmitter {
|
|
372
|
+
private listeners;
|
|
373
|
+
/**
|
|
374
|
+
* Subscribe to an event.
|
|
375
|
+
* @returns An unsubscribe function.
|
|
376
|
+
*/
|
|
377
|
+
on(event: string, handler: EventHandler): Unsubscribe;
|
|
378
|
+
/**
|
|
379
|
+
* Unsubscribe from an event.
|
|
380
|
+
*/
|
|
381
|
+
off(event: string, handler: EventHandler): void;
|
|
382
|
+
/**
|
|
383
|
+
* Emit an event with optional payload.
|
|
384
|
+
*/
|
|
385
|
+
emit(event: string, data?: unknown): void;
|
|
386
|
+
/**
|
|
387
|
+
* Remove all listeners, optionally for a specific event.
|
|
388
|
+
*/
|
|
389
|
+
removeAll(event?: string): void;
|
|
390
|
+
/**
|
|
391
|
+
* Get the count of listeners for a specific event.
|
|
392
|
+
*/
|
|
393
|
+
listenerCount(event: string): number;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Detect MIME type from file buffer magic bytes.
|
|
398
|
+
*/
|
|
399
|
+
declare function detectMagicBytes(buffer: ArrayBuffer): string | null;
|
|
400
|
+
/**
|
|
401
|
+
* Detect ZIP sub-type (OOXML or OpenDocument) by checking ZIP entry names.
|
|
402
|
+
* All OOXML formats use ZIP container with PK header.
|
|
403
|
+
* OpenDocument formats also use ZIP with a 'mimetype' entry at offset 0.
|
|
404
|
+
*/
|
|
405
|
+
declare function detectOoxmlType(buffer: ArrayBuffer): string | null;
|
|
406
|
+
/**
|
|
407
|
+
* Extract file extension from a filename or URL.
|
|
408
|
+
*/
|
|
409
|
+
declare function extractExtension(nameOrUrl: string): string | undefined;
|
|
410
|
+
/**
|
|
411
|
+
* Get MIME type from file extension.
|
|
412
|
+
*/
|
|
413
|
+
declare function mimeFromExtension(extension: string): string | undefined;
|
|
414
|
+
/**
|
|
415
|
+
* Convert any FileSource to ArrayBuffer.
|
|
416
|
+
*/
|
|
417
|
+
declare function sourceToArrayBuffer(source: FileSource, signal?: AbortSignal): Promise<{
|
|
418
|
+
buffer: ArrayBuffer;
|
|
419
|
+
metadata: FileMetadata;
|
|
420
|
+
}>;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Sanitize HTML string using DOMPurify to prevent XSS.
|
|
424
|
+
*/
|
|
425
|
+
declare function sanitizeHTML(html: string): string;
|
|
426
|
+
/**
|
|
427
|
+
* Sanitize SVG string using DOMPurify.
|
|
428
|
+
*/
|
|
429
|
+
declare function sanitizeSVG(svg: string): string;
|
|
430
|
+
/**
|
|
431
|
+
* Download a file from an ArrayBuffer.
|
|
432
|
+
*/
|
|
433
|
+
declare function downloadFile(buffer: ArrayBuffer, filename: string, mimeType?: string): void;
|
|
434
|
+
/**
|
|
435
|
+
* Print an HTML element by opening a print window.
|
|
436
|
+
*/
|
|
437
|
+
declare function printElement(element: HTMLElement, title?: string): void;
|
|
438
|
+
/**
|
|
439
|
+
* Format file size in human-readable format.
|
|
440
|
+
*/
|
|
441
|
+
declare function formatFileSize(bytes: number): string;
|
|
442
|
+
/**
|
|
443
|
+
* Debounce a function call.
|
|
444
|
+
*/
|
|
445
|
+
declare function debounce<T extends (...args: unknown[]) => void>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
446
|
+
/**
|
|
447
|
+
* Clamp a number between min and max.
|
|
448
|
+
*/
|
|
449
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
450
|
+
/**
|
|
451
|
+
* Create a DOM element with optional attributes and children.
|
|
452
|
+
*/
|
|
453
|
+
declare function createElement<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Record<string, string>, ...children: (string | Node)[]): HTMLElementTagNameMap[K];
|
|
454
|
+
|
|
455
|
+
declare class ToolbarController {
|
|
456
|
+
private el;
|
|
457
|
+
private toolbarEl;
|
|
458
|
+
private actions;
|
|
459
|
+
private config;
|
|
460
|
+
private pageInputEl;
|
|
461
|
+
private pageLabelEl;
|
|
462
|
+
private prevPageBtn;
|
|
463
|
+
private nextPageBtn;
|
|
464
|
+
constructor(container: HTMLElement, config?: ToolbarConfig);
|
|
465
|
+
setConfig(config: ToolbarConfig): void;
|
|
466
|
+
getConfig(): ToolbarConfig;
|
|
467
|
+
hideAction(actionId: string): void;
|
|
468
|
+
showAction(actionId: string): void;
|
|
469
|
+
private normalizeActionId;
|
|
470
|
+
enableAction(actionId: string): void;
|
|
471
|
+
disableAction(actionId: string): void;
|
|
472
|
+
setActionActive(actionId: string, active: boolean): void;
|
|
473
|
+
isActionEnabled(action: ToolbarAction): boolean;
|
|
474
|
+
setPage(page: number, max?: number): void;
|
|
475
|
+
update(actions: ToolbarAction[]): void;
|
|
476
|
+
show(): void;
|
|
477
|
+
hide(): void;
|
|
478
|
+
destroy(): void;
|
|
479
|
+
private render;
|
|
480
|
+
private createButton;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
declare class ThumbnailPanel {
|
|
484
|
+
private el;
|
|
485
|
+
private panelEl;
|
|
486
|
+
private listEl;
|
|
487
|
+
private headerEl;
|
|
488
|
+
private thumbnails;
|
|
489
|
+
private onSelect?;
|
|
490
|
+
private onToggleCallback?;
|
|
491
|
+
private activeIndex;
|
|
492
|
+
private observer?;
|
|
493
|
+
private renderedIndices;
|
|
494
|
+
constructor(container: HTMLElement, onToggle?: (isOpen: boolean) => void);
|
|
495
|
+
isOpen(): boolean;
|
|
496
|
+
update(thumbnails: Thumbnail[], onSelect: (index: number) => void): void;
|
|
497
|
+
setActive(index: number): void;
|
|
498
|
+
show(): void;
|
|
499
|
+
hide(): void;
|
|
500
|
+
toggle(): void;
|
|
501
|
+
destroy(): void;
|
|
502
|
+
renderAllVisible(): void;
|
|
503
|
+
private renderThumbnailItem;
|
|
504
|
+
private render;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* IndexedDB and in-memory document transfer utility for cross-window preview opening.
|
|
509
|
+
*/
|
|
510
|
+
interface TransferPayload {
|
|
511
|
+
buffer: ArrayBuffer;
|
|
512
|
+
metadata?: {
|
|
513
|
+
name?: string;
|
|
514
|
+
extension?: string;
|
|
515
|
+
mimeType?: string;
|
|
516
|
+
size?: number;
|
|
517
|
+
};
|
|
518
|
+
options?: Record<string, any>;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Save file payload to IndexedDB and window storage for cross-window retrieval.
|
|
522
|
+
*/
|
|
523
|
+
declare function saveTransferPayload(id: string, payload: TransferPayload): Promise<void>;
|
|
524
|
+
/**
|
|
525
|
+
* Retrieve transferred file payload from opener window or IndexedDB.
|
|
526
|
+
*/
|
|
527
|
+
declare function getTransferPayload(id: string): Promise<TransferPayload | null>;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Compound File Binary Format (CFBF / OLE2) parser.
|
|
531
|
+
* Implements Microsoft [MS-CFB] specification for legacy Office formats (.doc, .ppt, .xls).
|
|
532
|
+
* Zero external dependencies, client-side browser and Node.js compatible.
|
|
533
|
+
*/
|
|
534
|
+
interface CfbfEntry {
|
|
535
|
+
name: string;
|
|
536
|
+
type: number;
|
|
537
|
+
size: number;
|
|
538
|
+
startSector: number;
|
|
539
|
+
}
|
|
540
|
+
declare class CfbfReader {
|
|
541
|
+
private view;
|
|
542
|
+
private u8;
|
|
543
|
+
private sectorSize;
|
|
544
|
+
private miniSectorSize;
|
|
545
|
+
private miniStreamCutoff;
|
|
546
|
+
private fat;
|
|
547
|
+
private miniFat;
|
|
548
|
+
private entries;
|
|
549
|
+
private miniStream;
|
|
550
|
+
constructor(buffer: ArrayBuffer);
|
|
551
|
+
/** Check if the magic 8-byte signature matches [MS-CFB] */
|
|
552
|
+
isValid(): boolean;
|
|
553
|
+
/** Return all directory stream/storage entries found in the file */
|
|
554
|
+
listEntries(): CfbfEntry[];
|
|
555
|
+
/** Check if a stream exists */
|
|
556
|
+
hasStream(name: string): boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Read raw bytes of a named stream (e.g. "WordDocument", "PowerPoint Document", "Workbook")
|
|
559
|
+
*/
|
|
560
|
+
readStream(name: string): Uint8Array | null;
|
|
561
|
+
private findEntryCaseInsensitive;
|
|
562
|
+
private getSectorOffset;
|
|
563
|
+
private parseFat;
|
|
564
|
+
private parseDirectory;
|
|
565
|
+
private parseMiniFat;
|
|
566
|
+
private readRegularStream;
|
|
567
|
+
private readMiniStream;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
export { sanitizeHTML as A, sanitizeSVG as B, type CfbfEntry as C, saveTransferPayload as D, EventEmitter as E, type FileSource as F, sourceToArrayBuffer as G, type PreviewPlugin as P, type RenderContext as R, type Thumbnail as T, type Unsubscribe as U, type PreviewViewerOptions as a, type PreviewInstance as b, FilePreviewViewer as c, CfbfReader as d, type EventHandler as e, type FileInfo as f, type FileMetadata as g, type PreviewEvent as h, ThumbnailPanel as i, type ToolbarAction as j, type ToolbarActionType as k, type ToolbarConfig as l, ToolbarController as m, type ToolbarGroup as n, type TransferPayload as o, clamp as p, createElement as q, debounce as r, detectMagicBytes as s, detectOoxmlType as t, downloadFile as u, extractExtension as v, formatFileSize as w, getTransferPayload as x, mimeFromExtension as y, printElement as z };
|