2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 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" />
|
2021-03-01 05:31:13 -05:00
|
|
|
/// <reference lib="deno.webgpu" />
|
2020-01-29 12:54:23 -05:00
|
|
|
/// <reference lib="esnext" />
|
|
|
|
|
2021-06-14 21:16:06 -04:00
|
|
|
interface WorkerGlobalScopeEventMap {
|
|
|
|
"error": ErrorEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare class WorkerGlobalScope extends EventTarget {
|
|
|
|
readonly location: WorkerLocation;
|
|
|
|
readonly navigator: WorkerNavigator;
|
|
|
|
onerror: ((this: WorkerGlobalScope, ev: ErrorEvent) => any) | null;
|
|
|
|
|
|
|
|
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;
|
2021-03-01 05:31:13 -05:00
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:49 -05:00
|
|
|
declare class WorkerNavigator {
|
|
|
|
constructor();
|
2021-03-01 05:31:13 -05:00
|
|
|
readonly gpu: GPU;
|
2021-07-29 15:45:11 -04:00
|
|
|
readonly hardwareConcurrency: number;
|
2020-01-29 12:54:23 -05:00
|
|
|
}
|
|
|
|
|
2021-03-08 07:27:49 -05:00
|
|
|
declare var navigator: WorkerNavigator;
|
|
|
|
|
2021-06-14 21:16:06 -04:00
|
|
|
interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
|
|
|
"message": MessageEvent;
|
|
|
|
"messageerror": MessageEvent;
|
|
|
|
}
|
|
|
|
|
2020-10-11 18:04:43 -04:00
|
|
|
declare class 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;
|
|
|
|
postMessage(message: any, options?: PostMessageOptions): 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
|
|
|
}
|
|
|
|
|
2021-06-14 21:16:06 -04:00
|
|
|
declare var name: string;
|
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;
|
|
|
|
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;
|
2021-06-14 21:16:06 -04:00
|
|
|
declare function close(): void;
|
2021-06-22 10:30:16 -04:00
|
|
|
declare function postMessage(message: any, transfer: Transferable[]): void;
|
|
|
|
declare function postMessage(message: any, options?: PostMessageOptions): void;
|
2021-06-14 21:16:06 -04:00
|
|
|
declare var navigator: WorkerNavigator;
|
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;
|
2021-06-14 21:16:06 -04:00
|
|
|
declare var self: WorkerGlobalScope & typeof globalThis;
|
|
|
|
declare function addEventListener<
|
|
|
|
K extends keyof DedicatedWorkerGlobalScopeEventMap,
|
|
|
|
>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: DedicatedWorkerGlobalScope,
|
|
|
|
ev: DedicatedWorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
declare function addEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
declare function removeEventListener<
|
|
|
|
K extends keyof DedicatedWorkerGlobalScopeEventMap,
|
|
|
|
>(
|
|
|
|
type: K,
|
|
|
|
listener: (
|
|
|
|
this: DedicatedWorkerGlobalScope,
|
|
|
|
ev: DedicatedWorkerGlobalScopeEventMap[K],
|
|
|
|
) => any,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
|
|
|
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
|
|
|
|
* WorkerGlobalScope.location property obtained by calling self.location. */
|
|
|
|
declare class WorkerLocation {
|
|
|
|
constructor();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
declare var location: WorkerLocation;
|