2021-01-11 17:13:41 +00:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-01-29 17:54:23 +00:00
|
|
|
|
|
|
|
/// <reference no-default-lib="true" />
|
2020-04-16 21:40:29 +00:00
|
|
|
/// <reference lib="deno.ns" />
|
2020-02-19 05:34:11 +00:00
|
|
|
/// <reference lib="deno.shared_globals" />
|
2021-03-01 10:31:13 +00:00
|
|
|
/// <reference lib="deno.webgpu" />
|
2020-01-29 17:54:23 +00:00
|
|
|
/// <reference lib="esnext" />
|
|
|
|
|
2021-06-15 01:16:06 +00: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 21:40:29 +00:00
|
|
|
Deno: typeof Deno;
|
2021-03-01 10:31:13 +00:00
|
|
|
}
|
|
|
|
|
2021-03-08 12:27:49 +00:00
|
|
|
declare class WorkerNavigator {
|
|
|
|
constructor();
|
2021-03-01 10:31:13 +00:00
|
|
|
readonly gpu: GPU;
|
2020-01-29 17:54:23 +00:00
|
|
|
}
|
|
|
|
|
2021-03-08 12:27:49 +00:00
|
|
|
declare var navigator: WorkerNavigator;
|
|
|
|
|
2021-06-15 01:16:06 +00:00
|
|
|
interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
|
|
|
"message": MessageEvent;
|
|
|
|
"messageerror": MessageEvent;
|
|
|
|
}
|
|
|
|
|
2020-10-11 22:04:43 +00:00
|
|
|
declare class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
2021-06-15 01:16:06 +00:00
|
|
|
readonly name: string;
|
|
|
|
onmessage:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
|
|
|
| null;
|
|
|
|
onmessageerror:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
|
|
|
| null;
|
|
|
|
close(): void;
|
|
|
|
postMessage(message: any): void;
|
|
|
|
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 22:04:43 +00:00
|
|
|
}
|
|
|
|
|
2021-06-15 01:16:06 +00:00
|
|
|
declare var name: string;
|
2020-10-08 09:43:26 +00:00
|
|
|
declare var onmessage:
|
2021-06-15 01:16:06 +00:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
2020-10-08 09:43:26 +00:00
|
|
|
| null;
|
|
|
|
declare var onmessageerror:
|
2021-06-15 01:16:06 +00:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
2020-10-08 09:43:26 +00:00
|
|
|
| null;
|
2021-06-15 01:16:06 +00:00
|
|
|
declare function close(): void;
|
|
|
|
declare function postMessage(message: any): void;
|
|
|
|
declare var navigator: WorkerNavigator;
|
2020-09-25 21:23:35 +00:00
|
|
|
declare var onerror:
|
2021-06-15 01:16:06 +00:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any)
|
2020-10-08 09:43:26 +00:00
|
|
|
| null;
|
2021-06-15 01:16:06 +00: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 15:28:54 +00:00
|
|
|
|
2021-04-30 19:51:48 +00:00
|
|
|
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.
|
2021-01-17 15:28:54 +00: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 19:51:48 +00:00
|
|
|
// TODO(nayeemrmn): Move this to `extensions/web` where its implementation is.
|
2021-01-17 15:28:54 +00:00
|
|
|
// The types there must first be split into window, worker and global types.
|
|
|
|
declare var location: WorkerLocation;
|