summaryrefslogtreecommitdiff
path: root/packages/webapi/src/lib/Window.ts
blob: ac3312c93b86c0874e96f12a211362ea35f8b0ad (plain) (blame)
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
import * as _ from './utils'

export class Window extends EventTarget {
	get self(): this {
		return this
	}

	get top(): this {
		return this
	}

	get window(): this {
		return this
	}

	get innerHeight(): number {
		return 0
	}

	get innerWidth(): number {
		return 0
	}

	get scrollX(): number {
		return 0
	}

	get scrollY(): number {
		return 0
	}
}

_.allowStringTag(Window)

export const initWindow = (target: Target, exclude: Set<string>) => {
	if (exclude.has('Window') || exclude.has('window')) return

	target.window = target
}

export interface WindowInternals {
	document: null
	location: URL
	window: this
}

interface Target extends Record<any, any> {
	window: this
}