2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2021-05-22 12:08:24 -04:00
|
|
|
|
2021-12-09 17:12:21 -05:00
|
|
|
// deno-lint-ignore-file no-explicit-any no-var
|
2021-05-22 12:08:24 -04:00
|
|
|
|
|
|
|
/// <reference no-default-lib="true" />
|
|
|
|
/// <reference lib="esnext" />
|
|
|
|
|
2024-04-26 12:04:29 -04:00
|
|
|
/**
|
|
|
|
* @category Broadcast Channel
|
|
|
|
* @tags unstable
|
|
|
|
*/
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface BroadcastChannelEventMap {
|
2021-05-22 12:08:24 -04:00
|
|
|
"message": MessageEvent;
|
|
|
|
"messageerror": MessageEvent;
|
|
|
|
}
|
|
|
|
|
2024-04-26 12:04:29 -04:00
|
|
|
/**
|
|
|
|
* @category Broadcast Channel
|
|
|
|
* @tags unstable
|
|
|
|
*/
|
2023-07-03 14:36:55 -04:00
|
|
|
declare interface BroadcastChannel extends EventTarget {
|
2021-05-22 12:08:24 -04:00
|
|
|
/**
|
|
|
|
* Returns the channel name (as passed to the constructor).
|
|
|
|
*/
|
|
|
|
readonly name: string;
|
|
|
|
onmessage: ((this: BroadcastChannel, ev: MessageEvent) => any) | null;
|
|
|
|
onmessageerror: ((this: BroadcastChannel, ev: MessageEvent) => any) | null;
|
|
|
|
/**
|
|
|
|
* Closes the BroadcastChannel object, opening it up to garbage collection.
|
|
|
|
*/
|
|
|
|
close(): void;
|
|
|
|
/**
|
|
|
|
* Sends the given message to other BroadcastChannel objects set up for
|
|
|
|
* this channel. Messages can be structured objects, e.g. nested objects
|
|
|
|
* and arrays.
|
|
|
|
*/
|
|
|
|
postMessage(message: any): void;
|
|
|
|
addEventListener<K extends keyof BroadcastChannelEventMap>(
|
|
|
|
type: K,
|
|
|
|
listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
addEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | AddEventListenerOptions,
|
|
|
|
): void;
|
|
|
|
removeEventListener<K extends keyof BroadcastChannelEventMap>(
|
|
|
|
type: K,
|
|
|
|
listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
|
|
|
removeEventListener(
|
|
|
|
type: string,
|
|
|
|
listener: EventListenerOrEventListenerObject,
|
|
|
|
options?: boolean | EventListenerOptions,
|
|
|
|
): void;
|
|
|
|
}
|
|
|
|
|
2024-04-26 12:04:29 -04:00
|
|
|
/**
|
|
|
|
* @category Broadcast Channel
|
|
|
|
* @tags unstable
|
|
|
|
*/
|
2021-05-22 12:08:24 -04:00
|
|
|
declare var BroadcastChannel: {
|
2023-07-03 14:36:55 -04:00
|
|
|
readonly prototype: BroadcastChannel;
|
2021-05-22 12:08:24 -04:00
|
|
|
new (name: string): BroadcastChannel;
|
|
|
|
};
|