1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00
denoland-deno/cli/tsc/dts/lib.deno.window.d.ts
Leo Kettmeir 35196eab27
BREAKING(unstable): remove WebGPU (#18094)
This PR _**temporarily**_ removes WebGPU (which has behind the
`--unstable` flag in Deno), due to performance complications due to its
presence.

It will be brought back in the future; as a point of reference, Chrome
will ship WebGPU to stable on 26/04/2023.

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-03-17 00:29:32 +01:00

268 lines
7.6 KiB
TypeScript

// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
/// <reference no-default-lib="true" />
/// <reference lib="deno.ns" />
/// <reference lib="deno.shared_globals" />
/// <reference lib="deno.webstorage" />
/// <reference lib="esnext" />
/// <reference lib="deno.cache" />
/** @category Web APIs */
interface WindowEventMap {
"error": ErrorEvent;
"unhandledrejection": PromiseRejectionEvent;
}
/** @category Web APIs */
declare class Window extends EventTarget {
new(): Window;
readonly window: Window & typeof globalThis;
readonly self: Window & typeof globalThis;
onerror: ((this: Window, ev: ErrorEvent) => any) | null;
onload: ((this: Window, ev: Event) => any) | null;
onbeforeunload: ((this: Window, ev: Event) => any) | null;
onunload: ((this: Window, ev: Event) => any) | null;
onunhandledrejection:
| ((this: Window, ev: PromiseRejectionEvent) => any)
| null;
close: () => void;
readonly closed: boolean;
alert: (message?: string) => void;
confirm: (message?: string) => boolean;
prompt: (message?: string, defaultValue?: string) => string | null;
Deno: typeof Deno;
Navigator: typeof Navigator;
navigator: Navigator;
Location: typeof Location;
location: Location;
localStorage: Storage;
sessionStorage: Storage;
caches: CacheStorage;
addEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (
this: Window,
ev: WindowEventMap[K],
) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
removeEventListener<K extends keyof WindowEventMap>(
type: K,
listener: (
this: Window,
ev: WindowEventMap[K],
) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
}
/** @category Web APIs */
declare var window: Window & typeof globalThis;
/** @category Web APIs */
declare var self: Window & typeof globalThis;
/** @category DOM Events */
declare var onerror: ((this: Window, ev: ErrorEvent) => any) | null;
/** @category DOM Events */
declare var onload: ((this: Window, ev: Event) => any) | null;
/** @category DOM Events */
declare var onbeforeunload: ((this: Window, ev: Event) => any) | null;
/** @category DOM Events */
declare var onunload: ((this: Window, ev: Event) => any) | null;
/** @category Observability */
declare var onunhandledrejection:
| ((this: Window, ev: PromiseRejectionEvent) => any)
| null;
/** @category Web Storage API */
declare var localStorage: Storage;
/** @category Web Storage API */
declare var sessionStorage: Storage;
/** @category Cache API */
declare var caches: CacheStorage;
/** @category Web APIs */
declare class Navigator {
constructor();
readonly hardwareConcurrency: number;
readonly userAgent: string;
readonly language: string;
readonly languages: string[];
}
/** @category Web APIs */
declare var navigator: Navigator;
/**
* Shows the given message and waits for the enter key pressed.
*
* If the stdin is not interactive, it does nothing.
*
* @category Web APIs
*
* @param message
*/
declare function alert(message?: string): void;
/**
* Shows the given message and waits for the answer. Returns the user's answer as boolean.
*
* Only `y` and `Y` are considered as true.
*
* If the stdin is not interactive, it returns false.
*
* @category Web APIs
*
* @param message
*/
declare function confirm(message?: string): boolean;
/**
* Shows the given message and waits for the user's input. Returns the user's input as string.
*
* If the default value is given and the user inputs the empty string, then it returns the given
* default value.
*
* If the default value is not given and the user inputs the empty string, it returns null.
*
* If the stdin is not interactive, it returns null.
*
* @category Web APIs
*
* @param message
* @param defaultValue
*/
declare function prompt(message?: string, defaultValue?: string): string | null;
/** Registers an event listener in the global scope, which will be called
* synchronously whenever the event `type` is dispatched.
*
* ```ts
* addEventListener('unload', () => { console.log('All finished!'); });
* ...
* dispatchEvent(new Event('unload'));
* ```
*
* @category DOM Events
*/
declare function addEventListener<
K extends keyof WindowEventMap,
>(
type: K,
listener: (this: Window, ev: WindowEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
/** @category DOM Events */
declare function addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
/** Remove a previously registered event listener from the global scope
*
* ```ts
* const listener = () => { console.log('hello'); };
* addEventListener('load', listener);
* removeEventListener('load', listener);
* ```
*
* @category DOM Events
*/
declare function removeEventListener<
K extends keyof WindowEventMap,
>(
type: K,
listener: (this: Window, ev: WindowEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
declare function removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.
// The types there must first be split into window, worker and global types.
/** The location (URL) of the object it is linked to. Changes done on it are
* reflected on the object it relates to. Accessible via
* `globalThis.location`.
*
* @category Web APIs
*/
declare class Location {
constructor();
/** Returns a DOMStringList object listing the origins of the ancestor
* browsing contexts, from the parent browsing context to the top-level
* browsing context.
*
* Always empty in Deno. */
readonly ancestorOrigins: DOMStringList;
/** Returns the Location object's URL's fragment (includes leading "#" if
* non-empty).
*
* Cannot be set in Deno. */
hash: string;
/** Returns the Location object's URL's host and port (if different from the
* default port for the scheme).
*
* Cannot be set in Deno. */
host: string;
/** Returns the Location object's URL's host.
*
* Cannot be set in Deno. */
hostname: string;
/** Returns the Location object's URL.
*
* Cannot be set in Deno. */
href: string;
toString(): string;
/** Returns the Location object's URL's origin. */
readonly origin: string;
/** Returns the Location object's URL's path.
*
* Cannot be set in Deno. */
pathname: string;
/** Returns the Location object's URL's port.
*
* Cannot be set in Deno. */
port: string;
/** Returns the Location object's URL's scheme.
*
* Cannot be set in Deno. */
protocol: string;
/** Returns the Location object's URL's query (includes leading "?" if
* non-empty).
*
* Cannot be set in Deno. */
search: string;
/** Navigates to the given URL.
*
* Cannot be set in Deno. */
assign(url: string): void;
/** Reloads the current page.
*
* Disabled in Deno. */
reload(): void;
/** @deprecated */
reload(forcedReload: boolean): void;
/** Removes the current page from the session history and navigates to the
* given URL.
*
* Disabled in Deno. */
replace(url: string): void;
}
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.
// The types there must first be split into window, worker and global types.
/** @category Web APIs */
declare var location: Location;