forked from feross/whiteboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
definitions.d.ts
86 lines (74 loc) · 2.15 KB
/
definitions.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
/** @type {import('webtorrent').WebTorrent} */
declare module 'videostream' {
type VideoStream = (
file: File | WebTorrent.TorrentFile,
media: HTMLVideoElement | HTMLAudioElement,
) => void
let videoStream: VideoStream
export default videoStream
}
declare module 'cat-names' {
class CatNames {
static random(): string
}
export default CatNames
}
declare module 'thunky' {
type ThunkCallback<T extends unknown, ErrorType = Error> = (
err: ErrorType | null,
val: T,
) => void
type ThunkyReturn<T extends unknown, ErrorType = Error> = (
cb: ThunkCallback<T, ErrorType>,
) => void
type ThunkyArgument<T extends unknown, ErrorType = Error> = (
cb: ThunkCallback<T, ErrorType>,
) => void
export default function thunky<T extends unknown, ErrorType = Error>(
arg: ThunkyReturn<T, ErrorType>,
): ThunkyArgument<T, ErrorType>
}
declare module 'bittorrent-tracker/client' {
type TrackerOptions = {
peerId: string | Buffer
announce: string[]
infoHash: Buffer
}
type PeerOnEvents = 'data' | 'close' | 'error' | 'end'
type PeerOnFunctionCallback<T extends PeerOnEvents> = T extends 'data'
? (data: string) => void
: () => void
export class Peer {
id: string
connected: boolean
username?: string
color?: string
once<T extends 'connect'>(event: T, callback: () => void): void
on<T extends PeerOnEvents>(
event: T,
callback: PeerOnFunctionCallback<T>,
): void
removeListener<T extends PeerOnEvents>(
event: T,
callback: PeerOnFunctionCallback<T>,
): void
send(data: string): void
}
type TrackerOnFunctionCallback<T extends PeerOnEvents> = T extends 'peer'
? (peer: Peer) => void
: () => void
class Tracker {
constructor(options: TrackerOptions)
start(): void
on<T extends 'peer'>(event: T, callback: TrackerOnFunctionCallback<T>): void
}
export default Tracker
}
declare module 'drag-drop' {
type Position = { x: number; y: number }
type DragDropCallback = (files: File[], pos: Position) => void
export default function (
qualifiedName: keyof HTMLElementTagNameMap,
callback: DragDropCallback,
): void
}