@webext-core/messaging 1.2.0 → 1.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@webext-core/messaging`
2
2
 
3
- A light-weight, type-safe wrapper around the `browser.runtime` messaging APIs.
3
+ A light-weight, type-safe wrapper around the `browser.runtime` messaging APIs. Supports all browsers (Chrome, Firefox, Safari).
4
4
 
5
5
  ```ts
6
6
  // ./messaging.ts
package/lib/index.d.ts CHANGED
@@ -35,13 +35,13 @@ declare type ProtocolWithReturn<TData, TReturn> = {
35
35
  RrhVseLgZW: TReturn;
36
36
  };
37
37
  /**
38
- * Given a `ProtocolWithReturn` or a value, return the message's data type.
38
+ * Given a function declaration, `ProtocolWithReturn`, or a value, return the message's data type.
39
39
  */
40
- declare type GetDataType<T> = T extends ProtocolWithReturn<any, any> ? T['BtVgCTPYZu'] : T;
40
+ declare type GetDataType<T> = T extends (...args: infer Args) => any ? Args['length'] extends 0 | 1 ? Args[0] : never : T extends ProtocolWithReturn<any, any> ? T['BtVgCTPYZu'] : T;
41
41
  /**
42
- * Given a `ProtocolWithReturn` or a value, return the message's return type.
42
+ * Given a function declaration, `ProtocolWithReturn`, or a value, return the message's return type.
43
43
  */
44
- declare type GetReturnType<T> = T extends ProtocolWithReturn<any, any> ? T['RrhVseLgZW'] : void;
44
+ declare type GetReturnType<T> = T extends (...args: any[]) => infer R ? R : T extends ProtocolWithReturn<any, any> ? T['RrhVseLgZW'] : void;
45
45
  /**
46
46
  * Either a Promise of a type, or that type directly. Used to indicate that a method can by sync or
47
47
  * async.
@@ -113,6 +113,6 @@ interface Message<TProtocolMap, TType extends keyof TProtocolMap> {
113
113
  *
114
114
  * @param config Configure the behavior of the messenger.
115
115
  */
116
- declare function defineExtensionMessaging<TProtocolMap>(config?: ExtensionMessagingConfig): Messenger<TProtocolMap>;
116
+ declare function defineExtensionMessaging<TProtocolMap = Record<string, ProtocolWithReturn<any, any>>>(config?: ExtensionMessagingConfig): Messenger<TProtocolMap>;
117
117
 
118
118
  export { ExtensionMessagingConfig, GetDataType, GetReturnType, Logger, MaybePromise, Messenger, ProtocolWithReturn, RemoveListenerCallback, defineExtensionMessaging };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webext-core/messaging",
3
- "version": "1.2.0",
4
- "description": "Light weight, type-safe wrapper around the extension messaging APIs",
3
+ "version": "1.3.0",
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": [
7
7
  "web-extension",
@@ -9,13 +9,13 @@
9
9
  "chrome-extension",
10
10
  "webext",
11
11
  "web-ext",
12
- "web",
13
12
  "chrome",
13
+ "firefox",
14
+ "safari",
14
15
  "browser",
15
16
  "extension",
16
17
  "message",
17
- "messaging",
18
- "webextension-polyfill"
18
+ "messaging"
19
19
  ],
20
20
  "homepage": "https://github.com/aklinker1/webext-core/tree/main/packages/messaging",
21
21
  "repository": {
@@ -47,8 +47,8 @@
47
47
  "@vitest/coverage-c8": "^0.24.5",
48
48
  "tsup": "^6.4.0",
49
49
  "typescript": "^4.8.4",
50
- "vitest": "^0.24.5",
51
- "@webext-core/fake-browser": "1.0.4",
50
+ "vitest": "^0.28.5",
51
+ "@webext-core/fake-browser": "1.2.1",
52
52
  "tsconfig": "0.0.0"
53
53
  },
54
54
  "scripts": {
@@ -56,6 +56,6 @@
56
56
  "build:dependencies": "cd ../.. && turbo run build --filter=@webext-core/messaging^...",
57
57
  "test": "vitest -r src",
58
58
  "test:coverage": "vitest run -r src --coverage",
59
- "compile": "tsc --noEmit"
59
+ "compile": "vitest typecheck"
60
60
  }
61
61
  }