webext-messenger 0.15.0-5 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ function onMessageListener(message, sender) {
16
16
  // TODO: Add test for this eventuality: ignore unrelated messages
17
17
  return;
18
18
  }
19
- // Target check must be synchronous (`await` means we're handing the message)
19
+ // Target check must be synchronous (`await` means we're handling the message)
20
20
  const action = getActionForMessage(sender, message.target);
21
21
  if (action === "ignore") {
22
22
  return;
@@ -26,7 +26,7 @@ function onMessageListener(message, sender) {
26
26
  // This function can only be called when the message *will* be handled locally.
27
27
  // Returning "undefined" or throwing an error will still handle it.
28
28
  async function handleMessage(message, sender,
29
- // Once messages reach handleMessage they cannot be "ignored", they're already being handled
29
+ // Once messages reach this function they cannot be "ignored", they're already being handled
30
30
  action) {
31
31
  const { type, target, args, options: { trace } = {} } = message;
32
32
  debug(type, "↘️ received", { sender, args });
@@ -44,16 +44,13 @@ action) {
44
44
  const meta = { trace: [sender] };
45
45
  handleMessage = async () => localHandler.apply(meta, args);
46
46
  }
47
- return handleMessage()
48
- .then((value) => ({ value }), (error) => ({
49
- // Errors must be serialized because the stacktraces are currently lost on Chrome
47
+ const response = await handleMessage().then((value) => ({ value }), (error) => ({
48
+ // Errors must be serialized because the stack traces are currently lost on Chrome
50
49
  // and https://github.com/mozilla/webextension-polyfill/issues/210
51
50
  error: serializeError(error),
52
- }))
53
- .then((response) => {
54
- debug(type, "↗️ responding", response);
55
- return { ...response, __webextMessenger };
56
- });
51
+ }));
52
+ debug(type, "↗️ responding", response);
53
+ return { ...response, __webextMessenger };
57
54
  }
58
55
  export function registerMethods(methods) {
59
56
  if (!isBackgroundPage()) {
@@ -26,7 +26,7 @@ export function getActionForMessage(from, { ...to } // Clone object because we'r
26
26
  // If this *was* the target, then probably no one else answered
27
27
  return "ignore";
28
28
  }
29
- // If requests "this" tab, then set it to allow the next condition
29
+ // Set "this" tab to the current tabId
30
30
  if (to.tabId === "this" && thisTarget.tabId === ((_a = from.tab) === null || _a === void 0 ? void 0 : _a.id)) {
31
31
  to.tabId = thisTarget.tabId;
32
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webext-messenger",
3
- "version": "0.15.0-5",
3
+ "version": "0.15.0",
4
4
  "description": "Browser Extension component messaging framework",
5
5
  "keywords": [],
6
6
  "repository": "pixiebrix/webext-messenger",