@webext-core/messaging 2.2.0 → 2.3.0

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Interface used to log text to the console when sending and recieving messages.
2
+ * Interface used to log text to the console when sending and receiving messages.
3
3
  */
4
4
  interface Logger {
5
5
  debug(...args: any[]): void;
@@ -76,7 +76,7 @@ interface NamespaceMessagingConfig extends BaseMessagingConfig {
76
76
  namespace: string;
77
77
  }
78
78
  /**
79
- * Contains information about the message recieved.
79
+ * Contains information about the message received.
80
80
  */
81
81
  interface Message<TProtocolMap extends Record<string, any>, TType extends keyof TProtocolMap> {
82
82
  /**
@@ -114,15 +114,16 @@ interface GenericMessenger<TProtocolMap extends Record<string, any>, TMessageExt
114
114
  * @param data The data to send with the message.
115
115
  * @param args Different messengers will have additional arguments to configure how a message gets sent.
116
116
  */
117
+ sendMessage<TType extends keyof TProtocolMap>(type: TType, ...args: GetDataType<TProtocolMap[TType]> extends undefined ? [data?: undefined, ...args: TSendMessageArgs] : never): Promise<GetReturnType<TProtocolMap[TType]>>;
117
118
  sendMessage<TType extends keyof TProtocolMap>(type: TType, data: GetDataType<TProtocolMap[TType]>, ...args: TSendMessageArgs): Promise<GetReturnType<TProtocolMap[TType]>>;
118
119
  /**
119
- * Trigger a callback when a message of the requested type is recieved. You cannot setup multiple
120
+ * Trigger a callback when a message of the requested type is received. You cannot setup multiple
120
121
  * listeners for the same message type in the same JS context.
121
122
  *
122
123
  * To remove the listener, call the returned message.
123
124
  *
124
- * @param type The message type to listen for. Call `sendMessage` with the same type to triggern this listener.
125
- * @param onReceived The callback executed when a message is recieved.
125
+ * @param type The message type to listen for. Call `sendMessage` with the same type to trigger this listener.
126
+ * @param onReceived The callback executed when a message is received.
126
127
  */
127
128
  onMessage<TType extends keyof TProtocolMap>(type: TType, onReceived: (message: Message<TProtocolMap, TType> & TMessageExtension) => void | MaybePromise<GetReturnType<TProtocolMap[TType]>>): RemoveListenerCallback;
128
129
  /**
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BaseMessagingConfig, G as GenericMessenger } from './generic-ad5087a0.js';
2
- export { a as GetDataType, b as GetReturnType, L as Logger, M as MaybePromise, c as Message, N as NamespaceMessagingConfig, P as ProtocolWithReturn, R as RemoveListenerCallback } from './generic-ad5087a0.js';
1
+ import { B as BaseMessagingConfig, G as GenericMessenger } from './generic-683db69b.js';
2
+ export { a as GetDataType, b as GetReturnType, L as Logger, M as MaybePromise, c as Message, N as NamespaceMessagingConfig, P as ProtocolWithReturn, R as RemoveListenerCallback } from './generic-683db69b.js';
3
3
  import { Runtime } from 'webextension-polyfill';
4
4
 
5
5
  /**
package/lib/page.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { N as NamespaceMessagingConfig, G as GenericMessenger } from './generic-ad5087a0.js';
1
+ import { N as NamespaceMessagingConfig, G as GenericMessenger } from './generic-683db69b.js';
2
2
 
3
3
  /**
4
4
  * Configuration passed into `defineWindowMessaging`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webext-core/messaging",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Light weight, type-safe wrapper around the web extension messaging APIs. Supports all browsers (Chrome, Firefox, Safari)",
5
5
  "license": "MIT",
6
6
  "keywords": [