@open-file-viewer/core 0.1.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.
- package/dist/index.cjs +12476 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +125 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.js +12422 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +2482 -0
- package/package.json +76 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as pdfjs_dist from 'pdfjs-dist';
|
|
2
|
+
|
|
3
|
+
type PreviewSource = File | Blob | string | ArrayBuffer;
|
|
4
|
+
type PreviewFit = "contain" | "cover" | "width" | "height" | "actual" | "scale-down";
|
|
5
|
+
type PreviewFallback = "inline" | "download" | "custom";
|
|
6
|
+
type PreviewTheme = "light" | "dark" | "auto";
|
|
7
|
+
interface PreviewFile {
|
|
8
|
+
source: PreviewSource;
|
|
9
|
+
name: string;
|
|
10
|
+
extension: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
url?: string;
|
|
14
|
+
blob?: Blob;
|
|
15
|
+
}
|
|
16
|
+
interface PreviewItem {
|
|
17
|
+
file: PreviewSource;
|
|
18
|
+
fileName?: string;
|
|
19
|
+
mimeType?: string;
|
|
20
|
+
}
|
|
21
|
+
interface PreviewSize {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}
|
|
25
|
+
interface PreviewToolbarOptions {
|
|
26
|
+
zoom?: boolean;
|
|
27
|
+
rotate?: boolean;
|
|
28
|
+
download?: boolean;
|
|
29
|
+
fullscreen?: boolean;
|
|
30
|
+
print?: boolean;
|
|
31
|
+
search?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface PreviewOptions {
|
|
34
|
+
container: HTMLElement | string;
|
|
35
|
+
file?: PreviewSource;
|
|
36
|
+
files?: Array<PreviewSource | PreviewItem>;
|
|
37
|
+
initialIndex?: number;
|
|
38
|
+
fileName?: string;
|
|
39
|
+
mimeType?: string;
|
|
40
|
+
width?: number | string;
|
|
41
|
+
height?: number | string;
|
|
42
|
+
fit?: PreviewFit;
|
|
43
|
+
plugins?: PreviewPlugin[];
|
|
44
|
+
fallback?: PreviewFallback;
|
|
45
|
+
renderFallback?: (ctx: PreviewContext) => Promise<PreviewInstance> | PreviewInstance;
|
|
46
|
+
toolbar?: boolean | PreviewToolbarOptions;
|
|
47
|
+
theme?: PreviewTheme;
|
|
48
|
+
className?: string;
|
|
49
|
+
onLoad?: (file: PreviewFile) => void;
|
|
50
|
+
onError?: (error: Error, file?: PreviewFile) => void;
|
|
51
|
+
onUnsupported?: (file: PreviewFile) => void;
|
|
52
|
+
}
|
|
53
|
+
interface PreviewContext {
|
|
54
|
+
host: HTMLElement;
|
|
55
|
+
viewport: HTMLElement;
|
|
56
|
+
file: PreviewFile;
|
|
57
|
+
size: PreviewSize;
|
|
58
|
+
options: Required<Pick<PreviewOptions, "fit" | "fallback">> & PreviewOptions;
|
|
59
|
+
setLoading: (loading: boolean) => void;
|
|
60
|
+
setError: (error: Error | string) => void;
|
|
61
|
+
}
|
|
62
|
+
interface PreviewInstance {
|
|
63
|
+
resize?: (size: PreviewSize) => void;
|
|
64
|
+
command?: (command: PreviewCommand) => void | boolean;
|
|
65
|
+
canCommand?: (command: PreviewCommand) => boolean;
|
|
66
|
+
destroy: () => void;
|
|
67
|
+
}
|
|
68
|
+
type PreviewCommand = "zoom-in" | "zoom-out" | "zoom-reset" | "rotate-right" | "rotate-left";
|
|
69
|
+
interface PreviewPlugin {
|
|
70
|
+
name: string;
|
|
71
|
+
match: (file: PreviewFile) => boolean | Promise<boolean>;
|
|
72
|
+
render: (ctx: PreviewContext) => Promise<PreviewInstance> | PreviewInstance;
|
|
73
|
+
}
|
|
74
|
+
interface FileViewer {
|
|
75
|
+
reload: (file?: PreviewSource) => Promise<void>;
|
|
76
|
+
next: () => Promise<void>;
|
|
77
|
+
previous: () => Promise<void>;
|
|
78
|
+
goTo: (index: number) => Promise<void>;
|
|
79
|
+
getCurrentIndex: () => number;
|
|
80
|
+
resize: () => void;
|
|
81
|
+
destroy: () => void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare function createViewer(options: PreviewOptions): FileViewer;
|
|
85
|
+
|
|
86
|
+
declare function imagePlugin(): PreviewPlugin;
|
|
87
|
+
|
|
88
|
+
declare function videoPlugin(): PreviewPlugin;
|
|
89
|
+
|
|
90
|
+
declare function audioPlugin(): PreviewPlugin;
|
|
91
|
+
|
|
92
|
+
declare function textPlugin(): PreviewPlugin;
|
|
93
|
+
|
|
94
|
+
type PdfJsModule = typeof pdfjs_dist;
|
|
95
|
+
interface PdfPluginOptions {
|
|
96
|
+
pdfjs?: PdfJsModule;
|
|
97
|
+
workerSrc?: string;
|
|
98
|
+
}
|
|
99
|
+
declare function pdfPlugin(options?: PdfJsModule | PdfPluginOptions): PreviewPlugin;
|
|
100
|
+
|
|
101
|
+
declare function epubPlugin(): PreviewPlugin;
|
|
102
|
+
|
|
103
|
+
declare function xpsPlugin(): PreviewPlugin;
|
|
104
|
+
|
|
105
|
+
declare function officePlugin(): PreviewPlugin;
|
|
106
|
+
|
|
107
|
+
declare function ofdPlugin(): PreviewPlugin;
|
|
108
|
+
|
|
109
|
+
declare function archivePlugin(): PreviewPlugin;
|
|
110
|
+
|
|
111
|
+
declare function emailPlugin(): PreviewPlugin;
|
|
112
|
+
|
|
113
|
+
declare function drawingPlugin(): PreviewPlugin;
|
|
114
|
+
|
|
115
|
+
declare function cadPlugin(): PreviewPlugin;
|
|
116
|
+
|
|
117
|
+
declare function model3dPlugin(): PreviewPlugin;
|
|
118
|
+
|
|
119
|
+
declare function gisPlugin(): PreviewPlugin;
|
|
120
|
+
|
|
121
|
+
declare function assetPlugin(): PreviewPlugin;
|
|
122
|
+
|
|
123
|
+
declare function fallbackPlugin(): PreviewPlugin;
|
|
124
|
+
|
|
125
|
+
export { type FileViewer, type PreviewCommand, type PreviewContext, type PreviewFallback, type PreviewFile, type PreviewFit, type PreviewInstance, type PreviewItem, type PreviewOptions, type PreviewPlugin, type PreviewSize, type PreviewSource, type PreviewTheme, type PreviewToolbarOptions, archivePlugin, assetPlugin, audioPlugin, cadPlugin, createViewer, drawingPlugin, emailPlugin, epubPlugin, fallbackPlugin, gisPlugin, imagePlugin, model3dPlugin, ofdPlugin, officePlugin, pdfPlugin, textPlugin, videoPlugin, xpsPlugin };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as pdfjs_dist from 'pdfjs-dist';
|
|
2
|
+
|
|
3
|
+
type PreviewSource = File | Blob | string | ArrayBuffer;
|
|
4
|
+
type PreviewFit = "contain" | "cover" | "width" | "height" | "actual" | "scale-down";
|
|
5
|
+
type PreviewFallback = "inline" | "download" | "custom";
|
|
6
|
+
type PreviewTheme = "light" | "dark" | "auto";
|
|
7
|
+
interface PreviewFile {
|
|
8
|
+
source: PreviewSource;
|
|
9
|
+
name: string;
|
|
10
|
+
extension: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
url?: string;
|
|
14
|
+
blob?: Blob;
|
|
15
|
+
}
|
|
16
|
+
interface PreviewItem {
|
|
17
|
+
file: PreviewSource;
|
|
18
|
+
fileName?: string;
|
|
19
|
+
mimeType?: string;
|
|
20
|
+
}
|
|
21
|
+
interface PreviewSize {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}
|
|
25
|
+
interface PreviewToolbarOptions {
|
|
26
|
+
zoom?: boolean;
|
|
27
|
+
rotate?: boolean;
|
|
28
|
+
download?: boolean;
|
|
29
|
+
fullscreen?: boolean;
|
|
30
|
+
print?: boolean;
|
|
31
|
+
search?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface PreviewOptions {
|
|
34
|
+
container: HTMLElement | string;
|
|
35
|
+
file?: PreviewSource;
|
|
36
|
+
files?: Array<PreviewSource | PreviewItem>;
|
|
37
|
+
initialIndex?: number;
|
|
38
|
+
fileName?: string;
|
|
39
|
+
mimeType?: string;
|
|
40
|
+
width?: number | string;
|
|
41
|
+
height?: number | string;
|
|
42
|
+
fit?: PreviewFit;
|
|
43
|
+
plugins?: PreviewPlugin[];
|
|
44
|
+
fallback?: PreviewFallback;
|
|
45
|
+
renderFallback?: (ctx: PreviewContext) => Promise<PreviewInstance> | PreviewInstance;
|
|
46
|
+
toolbar?: boolean | PreviewToolbarOptions;
|
|
47
|
+
theme?: PreviewTheme;
|
|
48
|
+
className?: string;
|
|
49
|
+
onLoad?: (file: PreviewFile) => void;
|
|
50
|
+
onError?: (error: Error, file?: PreviewFile) => void;
|
|
51
|
+
onUnsupported?: (file: PreviewFile) => void;
|
|
52
|
+
}
|
|
53
|
+
interface PreviewContext {
|
|
54
|
+
host: HTMLElement;
|
|
55
|
+
viewport: HTMLElement;
|
|
56
|
+
file: PreviewFile;
|
|
57
|
+
size: PreviewSize;
|
|
58
|
+
options: Required<Pick<PreviewOptions, "fit" | "fallback">> & PreviewOptions;
|
|
59
|
+
setLoading: (loading: boolean) => void;
|
|
60
|
+
setError: (error: Error | string) => void;
|
|
61
|
+
}
|
|
62
|
+
interface PreviewInstance {
|
|
63
|
+
resize?: (size: PreviewSize) => void;
|
|
64
|
+
command?: (command: PreviewCommand) => void | boolean;
|
|
65
|
+
canCommand?: (command: PreviewCommand) => boolean;
|
|
66
|
+
destroy: () => void;
|
|
67
|
+
}
|
|
68
|
+
type PreviewCommand = "zoom-in" | "zoom-out" | "zoom-reset" | "rotate-right" | "rotate-left";
|
|
69
|
+
interface PreviewPlugin {
|
|
70
|
+
name: string;
|
|
71
|
+
match: (file: PreviewFile) => boolean | Promise<boolean>;
|
|
72
|
+
render: (ctx: PreviewContext) => Promise<PreviewInstance> | PreviewInstance;
|
|
73
|
+
}
|
|
74
|
+
interface FileViewer {
|
|
75
|
+
reload: (file?: PreviewSource) => Promise<void>;
|
|
76
|
+
next: () => Promise<void>;
|
|
77
|
+
previous: () => Promise<void>;
|
|
78
|
+
goTo: (index: number) => Promise<void>;
|
|
79
|
+
getCurrentIndex: () => number;
|
|
80
|
+
resize: () => void;
|
|
81
|
+
destroy: () => void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare function createViewer(options: PreviewOptions): FileViewer;
|
|
85
|
+
|
|
86
|
+
declare function imagePlugin(): PreviewPlugin;
|
|
87
|
+
|
|
88
|
+
declare function videoPlugin(): PreviewPlugin;
|
|
89
|
+
|
|
90
|
+
declare function audioPlugin(): PreviewPlugin;
|
|
91
|
+
|
|
92
|
+
declare function textPlugin(): PreviewPlugin;
|
|
93
|
+
|
|
94
|
+
type PdfJsModule = typeof pdfjs_dist;
|
|
95
|
+
interface PdfPluginOptions {
|
|
96
|
+
pdfjs?: PdfJsModule;
|
|
97
|
+
workerSrc?: string;
|
|
98
|
+
}
|
|
99
|
+
declare function pdfPlugin(options?: PdfJsModule | PdfPluginOptions): PreviewPlugin;
|
|
100
|
+
|
|
101
|
+
declare function epubPlugin(): PreviewPlugin;
|
|
102
|
+
|
|
103
|
+
declare function xpsPlugin(): PreviewPlugin;
|
|
104
|
+
|
|
105
|
+
declare function officePlugin(): PreviewPlugin;
|
|
106
|
+
|
|
107
|
+
declare function ofdPlugin(): PreviewPlugin;
|
|
108
|
+
|
|
109
|
+
declare function archivePlugin(): PreviewPlugin;
|
|
110
|
+
|
|
111
|
+
declare function emailPlugin(): PreviewPlugin;
|
|
112
|
+
|
|
113
|
+
declare function drawingPlugin(): PreviewPlugin;
|
|
114
|
+
|
|
115
|
+
declare function cadPlugin(): PreviewPlugin;
|
|
116
|
+
|
|
117
|
+
declare function model3dPlugin(): PreviewPlugin;
|
|
118
|
+
|
|
119
|
+
declare function gisPlugin(): PreviewPlugin;
|
|
120
|
+
|
|
121
|
+
declare function assetPlugin(): PreviewPlugin;
|
|
122
|
+
|
|
123
|
+
declare function fallbackPlugin(): PreviewPlugin;
|
|
124
|
+
|
|
125
|
+
export { type FileViewer, type PreviewCommand, type PreviewContext, type PreviewFallback, type PreviewFile, type PreviewFit, type PreviewInstance, type PreviewItem, type PreviewOptions, type PreviewPlugin, type PreviewSize, type PreviewSource, type PreviewTheme, type PreviewToolbarOptions, archivePlugin, assetPlugin, audioPlugin, cadPlugin, createViewer, drawingPlugin, emailPlugin, epubPlugin, fallbackPlugin, gisPlugin, imagePlugin, model3dPlugin, ofdPlugin, officePlugin, pdfPlugin, textPlugin, videoPlugin, xpsPlugin };
|