@webext-core/messaging 1.2.0 → 1.3.1
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 +1 -1
- package/lib/index.cjs +0 -5
- package/lib/index.d.ts +5 -5
- package/lib/index.global.js +0 -5
- package/lib/index.js +0 -5
- package/package.json +8 -8
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.cjs
CHANGED
|
@@ -106,11 +106,6 @@ function defineExtensionMessaging(config) {
|
|
|
106
106
|
return { err: errMessage };
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
return Promise.resolve({
|
|
110
|
-
err: `Listener not found for message.type="${message.type}".
|
|
111
|
-
|
|
112
|
-
Did you forget to call \`onMessage("getLength", ...)\`?`
|
|
113
|
-
});
|
|
114
109
|
};
|
|
115
110
|
import_webextension_polyfill.default.runtime.onMessage.addListener(rootListener);
|
|
116
111
|
}
|
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
|
|
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
|
|
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
|
|
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/lib/index.global.js
CHANGED
|
@@ -1104,11 +1104,6 @@ var webExtCoreMessaging = (() => {
|
|
|
1104
1104
|
return { err: errMessage };
|
|
1105
1105
|
});
|
|
1106
1106
|
}
|
|
1107
|
-
return Promise.resolve({
|
|
1108
|
-
err: `Listener not found for message.type="${message.type}".
|
|
1109
|
-
|
|
1110
|
-
Did you forget to call \`onMessage("getLength", ...)\`?`
|
|
1111
|
-
});
|
|
1112
1107
|
};
|
|
1113
1108
|
import_webextension_polyfill.default.runtime.onMessage.addListener(rootListener);
|
|
1114
1109
|
}
|
package/lib/index.js
CHANGED
|
@@ -77,11 +77,6 @@ function defineExtensionMessaging(config) {
|
|
|
77
77
|
return { err: errMessage };
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
return Promise.resolve({
|
|
81
|
-
err: `Listener not found for message.type="${message.type}".
|
|
82
|
-
|
|
83
|
-
Did you forget to call \`onMessage("getLength", ...)\`?`
|
|
84
|
-
});
|
|
85
80
|
};
|
|
86
81
|
Browser.runtime.onMessage.addListener(rootListener);
|
|
87
82
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webext-core/messaging",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Light weight, type-safe wrapper around the extension messaging APIs",
|
|
3
|
+
"version": "1.3.1",
|
|
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.
|
|
51
|
-
"@webext-core/fake-browser": "1.
|
|
50
|
+
"vitest": "^0.28.5",
|
|
51
|
+
"@webext-core/fake-browser": "1.2.2",
|
|
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": "
|
|
59
|
+
"compile": "vitest typecheck"
|
|
60
60
|
}
|
|
61
61
|
}
|