2023-01-02 16:00:42 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
2020-01-29 12:54:23 -05:00
|
|
|
|
|
|
|
/// <reference no-default-lib="true" />
|
2020-04-16 17:40:29 -04:00
|
|
|
/// <reference lib="deno.ns" />
|
2020-02-19 00:34:11 -05:00
|
|
|
/// <reference lib="deno.shared_globals" />
|
2020-01-29 12:54:23 -05:00
|
|
|
/// <reference lib="esnext" />
|
2022-09-28 08:11:12 -04:00
|
|
|
/// <reference lib="deno.cache" />
|
2020-01-29 12:54:23 -05:00
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface WorkerGlobalScopeEventMap {
|
2021-06-14 21:16:06 -04:00
|
|
|
"error": ErrorEvent;
|
2022-07-21 17:54:53 -04:00
|
|
|
"unhandledrejection": PromiseRejectionEvent;
|
2021-06-14 21:16:06 -04:00
|
|
|
}
|
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface WorkerGlobalScope extends EventTarget {
|
2021-06-14 21:16:06 -04:00
|
|
|
readonly location: WorkerLocation;
|
|
|
|
readonly navigator: WorkerNavigator;
|
|
|
|
onerror: ((this: WorkerGlobalScope, ev: ErrorEvent) => any) | null;
|
2022-07-21 17:54:53 -04:00
|
|
|
onunhandledrejection:
|
|
|
|
| ((this: WorkerGlobalScope, ev: PromiseRejectionEvent) => any)
|
|
|
|
| null;
|
2021-06-14 21:16:06 -04:00
|
|
|
|
|
|
|
readonly self: WorkerGlobalScope & typeof globalThis;
|
|
|
|
|
|
|
|
addEventListener<K extends keyof WorkerGlobalScopeEventMap>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: WorkerGlobalScope,
|
|
|
|
ev: WorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
addEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
removeEventListener<K extends keyof WorkerGlobalScopeEventMap>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: WorkerGlobalScope,
|
|
|
|
ev: WorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
|
|
|
removeEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
|
|
|
|
2020-04-16 17:40:29 -04:00
|
|
|
Deno: typeof Deno;
|
2022-09-28 08:11:12 -04:00
|
|
|
caches: CacheStorage;
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
2023-07-03 14:36:55 -04:00
|
|
|
/** @category Web Workers */
|
|
|
|
declare var WorkerGlobalScope: {
|
|
|
|
readonly prototype: WorkerGlobalScope;
|
|
|
|
new (): never;
|
|
|
|
};
|
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web APIs */
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface WorkerNavigator {
|
2023-12-08 19:19:16 -05:00
|
|
|
readonly gpu: GPU;
|
2021-07-29 15:45:11 -04:00
|
|
|
readonly hardwareConcurrency: number;
|
2022-05-14 06:00:02 -04:00
|
|
|
readonly userAgent: string;
|
2022-10-18 09:33:35 -04:00
|
|
|
readonly language: string;
|
|
|
|
readonly languages: string[];
|
2020-01-29 12:54:23 -05:00
|
|
|
}
|
|
|
|
|
2023-07-03 14:36:55 -04:00
|
|
|
/** @category Web APIs */
|
|
|
|
declare var WorkerNavigator: {
|
|
|
|
readonly prototype: WorkerNavigator;
|
|
|
|
new (): never;
|
|
|
|
};
|
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web APIs */
|
2021-03-08 07:27:49 -05:00
|
|
|
declare var navigator: WorkerNavigator;
|
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface DedicatedWorkerGlobalScopeEventMap
|
|
|
|
extends WorkerGlobalScopeEventMap {
|
2021-06-14 21:16:06 -04:00
|
|
|
"message": MessageEvent;
|
|
|
|
"messageerror": MessageEvent;
|
|
|
|
}
|
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web APIs */
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
2021-06-14 21:16:06 -04:00
|
|
|
readonly name: string;
|
|
|
|
onmessage:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
|
|
|
| null;
|
|
|
|
onmessageerror:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
|
|
|
| null;
|
|
|
|
close(): void;
|
2021-06-22 10:30:16 -04:00
|
|
|
postMessage(message: any, transfer: Transferable[]): void;
|
2021-08-09 04:39:00 -04:00
|
|
|
postMessage(message: any, options?: StructuredSerializeOptions): void;
|
2021-06-14 21:16:06 -04:00
|
|
|
addEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: DedicatedWorkerGlobalScope,
|
|
|
|
ev: DedicatedWorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
addEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
removeEventListener<K extends keyof DedicatedWorkerGlobalScopeEventMap>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: DedicatedWorkerGlobalScope,
|
|
|
|
ev: DedicatedWorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
|
|
|
removeEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
2020-10-11 18:04:43 -04:00
|
|
|
}
|
|
|
|
|
2023-07-03 14:36:55 -04:00
|
|
|
/** @category Web APIs */
|
|
|
|
declare var DedicatedWorkerGlobalScope: {
|
|
|
|
readonly prototype: DedicatedWorkerGlobalScope;
|
|
|
|
new (): never;
|
|
|
|
};
|
|
|
|
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare var name: string;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2020-10-08 05:43:26 -04:00
|
|
|
declare var onmessage:
|
2021-06-14 21:16:06 -04:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
2020-10-08 05:43:26 -04:00
|
|
|
| null;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2020-10-08 05:43:26 -04:00
|
|
|
declare var onmessageerror:
|
2021-06-14 21:16:06 -04:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
2020-10-08 05:43:26 -04:00
|
|
|
| null;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare function close(): void;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2021-06-22 10:30:16 -04:00
|
|
|
declare function postMessage(message: any, transfer: Transferable[]): void;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2021-08-09 04:39:00 -04:00
|
|
|
declare function postMessage(
|
|
|
|
message: any,
|
|
|
|
options?: StructuredSerializeOptions,
|
|
|
|
): void;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web APIs */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare var navigator: WorkerNavigator;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web APIs */
|
2020-09-25 17:23:35 -04:00
|
|
|
declare var onerror:
|
2021-06-14 21:16:06 -04:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any)
|
2020-10-08 05:43:26 -04:00
|
|
|
| null;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Observability */
|
2022-07-21 17:54:53 -04:00
|
|
|
declare var onunhandledrejection:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: PromiseRejectionEvent) => any)
|
|
|
|
| null;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web Workers */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare var self: WorkerGlobalScope & typeof globalThis;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category DOM Events */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare function addEventListener<
|
|
|
|
K extends keyof DedicatedWorkerGlobalScopeEventMap,
|
|
|
|
>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: DedicatedWorkerGlobalScope,
|
|
|
|
ev: DedicatedWorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category DOM Events */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare function addEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category DOM Events */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare function removeEventListener<
|
|
|
|
K extends keyof DedicatedWorkerGlobalScopeEventMap,
|
|
|
|
>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: DedicatedWorkerGlobalScope,
|
|
|
|
ev: DedicatedWorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category DOM Events */
|
2021-06-14 21:16:06 -04:00
|
|
|
declare function removeEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
2021-01-17 10:28:54 -05:00
|
|
|
|
2021-04-30 15:51:48 -04:00
|
|
|
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.
|
2021-01-17 10:28:54 -05:00
|
|
|
// The types there must first be split into window, worker and global types.
|
|
|
|
/** The absolute location of the script executed by the Worker. Such an object
|
|
|
|
* is initialized for each worker and is available via the
|
2022-08-16 23:12:24 -04:00
|
|
|
* WorkerGlobalScope.location property obtained by calling self.location.
|
|
|
|
*
|
|
|
|
* @category Web APIs
|
|
|
|
*/
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface WorkerLocation {
|
2021-01-17 10:28:54 -05:00
|
|
|
readonly hash: string;
|
|
|
|
readonly host: string;
|
|
|
|
readonly hostname: string;
|
|
|
|
readonly href: string;
|
|
|
|
toString(): string;
|
|
|
|
readonly origin: string;
|
|
|
|
readonly pathname: string;
|
|
|
|
readonly port: string;
|
|
|
|
readonly protocol: string;
|
|
|
|
readonly search: string;
|
|
|
|
}
|
|
|
|
|
2023-07-03 14:36:55 -04:00
|
|
|
// 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 absolute location of the script executed by the Worker. Such an object
|
|
|
|
* is initialized for each worker and is available via the
|
|
|
|
* WorkerGlobalScope.location property obtained by calling self.location.
|
|
|
|
*
|
|
|
|
* @category Web APIs
|
|
|
|
*/
|
|
|
|
declare var WorkerLocation: {
|
|
|
|
readonly prototype: WorkerLocation;
|
|
|
|
new (): never;
|
|
|
|
};
|
|
|
|
|
2021-04-30 15:51:48 -04:00
|
|
|
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.
|
2021-01-17 10:28:54 -05:00
|
|
|
// The types there must first be split into window, worker and global types.
|
2022-08-16 23:12:24 -04:00
|
|
|
/** @category Web APIs */
|
2021-01-17 10:28:54 -05:00
|
|
|
declare var location: WorkerLocation;
|