forked from qq15725/modern-screenshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.ts
151 lines (129 loc) · 3.41 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
export interface Options {
/**
* Width in pixels to be applied to node before rendering.
*/
width?: number
/**
* Height in pixels to be applied to node before rendering.
*/
height?: number
/**
* A number between `0` and `1` indicating image quality (e.g. 0.92 => 92%) of the JPEG image.
*/
quality?: number
/**
* A string indicating the image format. The default type is image/png; that type is also used if the given type isn't supported.
*/
type?: string
/**
* The pixel ratio of captured image.
*
* DPI = 96 * scale
*
* default: 1
*/
scale?: number
/**
* A string value for the background color, any valid CSS color value.
*/
backgroundColor?: string | null
/**
* An object whose properties to be copied to node's style before rendering.
*/
style?: Partial<CSSStyleDeclaration> | null
/**
* A function taking DOM node as argument. Should return `true` if passed
* node should be included in the output. Excluding node means excluding
* it's children as well.
*/
filter?: ((el: Node) => boolean) | null
/**
* Maximum canvas size (pixels).
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas#maximum_canvas_size
*/
maximumCanvasSize?: number
/**
* Load media timeout and fetch remote asset timeout (millisecond).
*
* default: 30000
*/
timeout?: number
/**
* Embed assets progress.
*/
progress?: ((current: number, total: number) => void) | null
/**
* Enable debug mode to view the execution time log.
*/
debug?: boolean
/**
* The options of fetch resources.
*/
fetch?: {
/**
* The second parameter of `window.fetch` RequestInit
*
* default: {
* cache: 'force-cache',
* }
*/
requestInit?: RequestInit
/**
* Set to `true` to append the current time as a query string to URL
* requests to enable cache busting.
*
* default: false
*/
bypassingCache?: boolean
/**
* A data URL for a placeholder image that will be used when fetching
* an image fails. Defaults to an empty string and will render empty
* areas for failed images.
*
* default: data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
*/
placeholderImage?: string | ((cloned: HTMLImageElement | SVGImageElement) => string | Promise<string>)
}
/**
* The options of fonts download and embed.
*/
font?: false | {
/**
* The preferred font format. If specified all other font formats are ignored.
*/
preferredFormat?: 'woff' | 'woff2' | 'truetype' | 'opentype' | 'embedded-opentype' | 'svg' | string
/**
* A CSS string to specify for font embeds. If specified only this CSS will
* be present in the resulting image.
*/
cssText?: string
}
/**
* Canvas `drawImage` interval
* is used to fix errors in decoding images in safari/webkit
*
* default: 100
*/
drawImageInterval?: number
/**
* Web Worker script url
*/
workerUrl?: string | null
/**
* Web Worker number
*/
workerNumber?: number
/**
* Triggered after a node is cloned
*/
onCloneNode?: ((cloend: Node) => void) | null
/**
* Triggered after a node is embed
*/
onEmbedNode?: ((cloend: Node) => void) | null
/**
* Triggered after a ForeignObjectSvg is created
*/
onCreateForeignObjectSvg?: ((svg: SVGSVGElement) => void) | null
}