2021-01-12 02:13:41 +09:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-01-29 18:54:23 +01:00
|
|
|
|
|
|
|
/// <reference no-default-lib="true" />
|
2020-04-16 23:40:29 +02:00
|
|
|
/// <reference lib="deno.ns" />
|
2020-02-19 16:34:11 +11:00
|
|
|
/// <reference lib="deno.shared_globals" />
|
2021-03-01 11:31:13 +01:00
|
|
|
/// <reference lib="deno.webgpu" />
|
2020-01-29 18:54:23 +01:00
|
|
|
/// <reference lib="esnext" />
|
|
|
|
|
2021-06-15 11:16:06 +10: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 23:40:29 +02:00
|
|
|
Deno: typeof Deno;
|
2021-03-01 11:31:13 +01:00
|
|
|
}
|
|
|
|
|
2021-03-08 12:27:49 +00:00
|
|
|
declare class WorkerNavigator {
|
|
|
|
constructor();
|
2021-03-01 11:31:13 +01:00
|
|
|
readonly gpu: GPU;
|
2020-01-29 18:54:23 +01:00
|
|
|
}
|
|
|
|
|
2021-03-08 12:27:49 +00:00
|
|
|
declare var navigator: WorkerNavigator;
|
|
|
|
|
2021-06-15 11:16:06 +10:00
|
|
|
interface DedicatedWorkerGlobalScopeEventMap extends WorkerGlobalScopeEventMap {
|
|
|
|
"message": MessageEvent;
|
|
|
|
"messageerror": MessageEvent;
|
|
|
|
}
|
|
|
|
|
2020-10-11 23:04:43 +01:00
|
|
|
declare class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
2021-06-15 11:16:06 +10:00
|
|
|
readonly name: string;
|
|
|
|
onmessage:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
|
|
|
| null;
|
|
|
|
onmessageerror:
|
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
|
|
|
| null;
|
|
|
|
close(): void;
|
2021-06-22 16:30:16 +02:00
|
|
|
postMessage(message: any, transfer: Transferable[]): void;
|
|
|
|
postMessage(message: any, options?: PostMessageOptions): void;
|
2021-06-15 11:16:06 +10: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 23:04:43 +01:00
|
|
|
}
|
|
|
|
|
2021-06-15 11:16:06 +10:00
|
|
|
declare var name: string;
|
2020-10-08 20:43:26 +11:00
|
|
|
declare var onmessage:
|
2021-06-15 11:16:06 +10:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
2020-10-08 20:43:26 +11:00
|
|
|
| null;
|
|
|
|
declare var onmessageerror:
|
2021-06-15 11:16:06 +10:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any)
|
2020-10-08 20:43:26 +11:00
|
|
|
| null;
|
2021-06-15 11:16:06 +10:00
|
|
|
declare function close(): void;
|
2021-06-22 16:30:16 +02:00
|
|
|
declare function postMessage(message: any, transfer: Transferable[]): void;
|
|
|
|
declare function postMessage(message: any, options?: PostMessageOptions): void;
|
2021-06-15 11:16:06 +10:00
|
|
|
declare var navigator: WorkerNavigator;
|
2020-09-25 22:23:35 +01:00
|
|
|
declare var onerror:
|
2021-06-15 11:16:06 +10:00
|
|
|
| ((this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any)
|
2020-10-08 20:43:26 +11:00
|
|
|
| null;
|
2021-06-15 11:16:06 +10: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 12:51:48 -07: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 12:51:48 -07: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;
|