summaryrefslogtreecommitdiff
path: root/packages/webapi/src/lib/Window.ts
diff options
context:
space:
mode:
authorGravatar Nate Moore <natemoo-re@users.noreply.github.com> 2022-03-07 15:36:22 -0600
committerGravatar GitHub <noreply@github.com> 2022-03-07 15:36:22 -0600
commitf18ee36dc0abdc5c8ec87734de7962966d16fe65 (patch)
treec01a7034186cb0bbe5e1d042f4a5dd09bad21ed5 /packages/webapi/src/lib/Window.ts
parent10a9c3412b4f6e8607687a74eafdb150d3222047 (diff)
downloadastro-f18ee36dc0abdc5c8ec87734de7962966d16fe65.tar.gz
astro-f18ee36dc0abdc5c8ec87734de7962966d16fe65.tar.zst
astro-f18ee36dc0abdc5c8ec87734de7962966d16fe65.zip
Add `@astrojs/webapi` package (#2729)@astrojs/webapi@0.11.0
* chore: add @astrojs/webapi * chore: update package.json * fix: update file case * fix: remove lowercase file * chore: update tests to use mocha * chore: update LICENSE
Diffstat (limited to 'packages/webapi/src/lib/Window.ts')
-rw-r--r--packages/webapi/src/lib/Window.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/packages/webapi/src/lib/Window.ts b/packages/webapi/src/lib/Window.ts
new file mode 100644
index 000000000..ac3312c93
--- /dev/null
+++ b/packages/webapi/src/lib/Window.ts
@@ -0,0 +1,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
+}