@webext-core/messaging 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ import { a as Logger, c as NamespaceMessagingConfig, i as GetReturnType, l as ProtocolWithReturn, n as BaseMessagingConfig, o as MaybePromise, r as GetDataType, s as Message, t as GenericMessenger, u as RemoveListenerCallback } from "./generic-B-kFbyP9.cjs";
2
+ import { Runtime } from "webextension-polyfill";
3
+
4
+ //#region src/extension.d.ts
5
+ /** Configuration passed into `defineExtensionMessaging`. */
6
+ interface ExtensionMessagingConfig extends BaseMessagingConfig {}
7
+ /** Additional fields available on the `Message` from an `ExtensionMessenger`. */
8
+ interface ExtensionMessage {
9
+ /**
10
+ * Information about where the message came from. See
11
+ * [`Runtime.MessageSender`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/MessageSender).
12
+ */
13
+ sender: Runtime.MessageSender;
14
+ }
15
+ /** Options for sending a message to a specific tab/frame */
16
+ interface SendMessageOptions {
17
+ /** The tab to send a message to */
18
+ tabId: number;
19
+ /** The frame to send a message to. 0 represents the main frame. */
20
+ frameId?: number;
21
+ }
22
+ /**
23
+ * Send message accepts either:
24
+ *
25
+ * - No arguments to send to background
26
+ * - A tabId number to send to a specific tab
27
+ * - A SendMessageOptions object to target a specific tab and frame
28
+ *
29
+ * You cannot message between tabs directly. It must go through the background script.
30
+ */
31
+ type ExtensionSendMessageArgs = [arg?: number | SendMessageOptions];
32
+ /** Messenger returned by `defineExtensionMessaging`. */
33
+ type ExtensionMessenger<TProtocolMap extends Record<string, any>> = GenericMessenger<TProtocolMap, ExtensionMessage, ExtensionSendMessageArgs>;
34
+ /**
35
+ * Returns an `ExtensionMessenger` that is backed by the `browser.runtime.sendMessage` and
36
+ * `browser.tabs.sendMessage` APIs.
37
+ *
38
+ * It can be used to send messages to and from the background page/service worker.
39
+ */
40
+ declare function defineExtensionMessaging<TProtocolMap extends Record<string, any> = Record<string, any>>(config?: ExtensionMessagingConfig): ExtensionMessenger<TProtocolMap>;
41
+ //#endregion
42
+ export { BaseMessagingConfig, ExtensionMessage, ExtensionMessagingConfig, ExtensionMessenger, ExtensionSendMessageArgs, GetDataType, GetReturnType, Logger, MaybePromise, Message, NamespaceMessagingConfig, ProtocolWithReturn, RemoveListenerCallback, SendMessageOptions, defineExtensionMessaging };
@@ -0,0 +1,42 @@
1
+ import { a as Logger, c as NamespaceMessagingConfig, i as GetReturnType, l as ProtocolWithReturn, n as BaseMessagingConfig, o as MaybePromise, r as GetDataType, s as Message, t as GenericMessenger, u as RemoveListenerCallback } from "./generic-B-kFbyP9.mjs";
2
+ import { Runtime } from "webextension-polyfill";
3
+
4
+ //#region src/extension.d.ts
5
+ /** Configuration passed into `defineExtensionMessaging`. */
6
+ interface ExtensionMessagingConfig extends BaseMessagingConfig {}
7
+ /** Additional fields available on the `Message` from an `ExtensionMessenger`. */
8
+ interface ExtensionMessage {
9
+ /**
10
+ * Information about where the message came from. See
11
+ * [`Runtime.MessageSender`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/MessageSender).
12
+ */
13
+ sender: Runtime.MessageSender;
14
+ }
15
+ /** Options for sending a message to a specific tab/frame */
16
+ interface SendMessageOptions {
17
+ /** The tab to send a message to */
18
+ tabId: number;
19
+ /** The frame to send a message to. 0 represents the main frame. */
20
+ frameId?: number;
21
+ }
22
+ /**
23
+ * Send message accepts either:
24
+ *
25
+ * - No arguments to send to background
26
+ * - A tabId number to send to a specific tab
27
+ * - A SendMessageOptions object to target a specific tab and frame
28
+ *
29
+ * You cannot message between tabs directly. It must go through the background script.
30
+ */
31
+ type ExtensionSendMessageArgs = [arg?: number | SendMessageOptions];
32
+ /** Messenger returned by `defineExtensionMessaging`. */
33
+ type ExtensionMessenger<TProtocolMap extends Record<string, any>> = GenericMessenger<TProtocolMap, ExtensionMessage, ExtensionSendMessageArgs>;
34
+ /**
35
+ * Returns an `ExtensionMessenger` that is backed by the `browser.runtime.sendMessage` and
36
+ * `browser.tabs.sendMessage` APIs.
37
+ *
38
+ * It can be used to send messages to and from the background page/service worker.
39
+ */
40
+ declare function defineExtensionMessaging<TProtocolMap extends Record<string, any> = Record<string, any>>(config?: ExtensionMessagingConfig): ExtensionMessenger<TProtocolMap>;
41
+ //#endregion
42
+ export { BaseMessagingConfig, ExtensionMessage, ExtensionMessagingConfig, ExtensionMessenger, ExtensionSendMessageArgs, GetDataType, GetReturnType, Logger, MaybePromise, Message, NamespaceMessagingConfig, ProtocolWithReturn, RemoveListenerCallback, SendMessageOptions, defineExtensionMessaging };