// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. // deno-lint-ignore-file no-explicit-any no-var /// /// /** @category Broadcast Channel */ interface BroadcastChannelEventMap { "message": MessageEvent; "messageerror": MessageEvent; } /** @category Broadcast Channel */ interface BroadcastChannel extends EventTarget { /** * 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( type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | AddEventListenerOptions, ): void; addEventListener( type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, ): void; removeEventListener( type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, options?: boolean | EventListenerOptions, ): void; removeEventListener( type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions, ): void; } /** @category Broadcast Channel */ declare var BroadcastChannel: { prototype: BroadcastChannel; new (name: string): BroadcastChannel; };