-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
135 lines (134 loc) · 3.51 KB
/
index.d.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
export interface ClipboardOptions {
/**
* Specify an interval (in ms) for how frequently a changes from the clipboard are watched.
*
* @default 500 .5 seconds
*/
interval?: number
}
export class Clipboard {
constructor(options?: ClipboardOptions)
/**
* Read the data in the clipboard.
*
* Note: if files have been copied, an empty string is returned.
*
* @returns clipboard text
*/
read(): string
/**
* Write text to the clipboard.
*
* @param text data to write
*/
write(text: string): void
/**
* Read the file paths in the clipboard.
*
* Note: if no files have been copied, an empty array is returned.
*
* @returns file paths
*/
readFiles(): string[]
/**
* Write file paths to the clipboard.
*
* @param paths file paths
*/
writeFiles(paths: string[]): void
/**
* Clear the clipboard.
*/
clear(): void
/**
* Stop the watcher from listening to clipboard changes.
*/
stop(): void
/**
* Listen for text changes on the clipboard.
*
* @param event clipboard text change event
* @param listener callback
*/
on(event: 'text-changed', listener: (text: string) => void): this
/**
* Listen for file changes on the clipboard.
*
* @param event clipboard file change event
* @param listener callback
*/
on(event: 'file-changed', listener: (paths: string[]) => void): this
/**
* Listen for text changes on the clipboard.
*
* @param event clipboard text change event
* @param listener callback
*/
once(event: 'text-changed', listener: (text: string) => void): this
/**
* Listen for file changes on the clipboard only once.
*
* @param event clipboard file change event
* @param listener callback
*/
once(event: 'file-changed', listener: (paths: string[]) => void): this
/**
* Add a listener for text changes on the clipboard.
*
* @param event clipboard text change event
* @param listener callback
*/
addListener(event: 'text-changed', listener: (text: string) => void): this
/**
* Add a listener for file changes on the clipboard.
*
* @param event clipboard file change event
* @param listener callback
*/
addListener(event: 'file-changed', listener: (paths: string[]) => void): this
/**
* Remove a listener for text changes on the clipboard.
*
* @param event clipboard text change event
* @param listener callback
*/
removeListener(event: 'text-changed', listener: (text: string) => void): this
/**
* Remove a listener for file changes on the clipboard.
*
* @param event clipboard file change event
* @param listener callback
*/
removeListener(event: 'file-changed', listener: (paths: string[]) => void): this
/**
* Remove all listeners from a clipboard change event.
*
* @param event clipboard change event
*/
removeAllListeners(event?: 'text-changed' | 'file-changed'): this
/**
* Get all listeners from a clipboard change event.
*
* @param event clipboard change event
* @returns all event listeners
*/
listeners(event: 'text-changed' | 'file-changed'): ((text: string) => void)[] | ((paths: string[]) => void)[]
/**
* Emit an event for a clipboard text change.
*
* Note: avoid using as this may not reflect the clipboard.
*
* @param event clipboard text change event
* @param text data
*/
emit(event: 'text-changed', text: string): boolean
/**
* Emit an event for a clipboard file change.
*
* Note: avoid using as this may not reflect the clipboard.
*
* @param event clipboard file change event
* @param paths file paths
*/
emit(event: 'file-changed', paths: string[]): boolean
}