webext-messenger 0.15.0 → 0.15.1-0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,20 +28,22 @@ function onMessageListener(message, sender) {
28
28
  async function handleMessage(message, sender,
29
29
  // Once messages reach this function they cannot be "ignored", they're already being handled
30
30
  action) {
31
- const { type, target, args, options: { trace } = {} } = message;
32
- debug(type, "↘️ received", { sender, args });
31
+ const { type, target, args, options = {} } = message;
32
+ const { trace = [] } = options;
33
+ trace.push(sender);
34
+ const meta = { trace };
35
+ debug(type, "↘️ received", { sender, args, wasForwarded: trace.length > 1 });
33
36
  let handleMessage;
34
37
  if (action === "forward") {
35
38
  debug(type, "🔀 forwarded", { sender, target });
36
- handleMessage = async () => messenger(type, { trace }, target, ...args);
39
+ handleMessage = async () => messenger(type, meta, target, ...args);
37
40
  }
38
41
  else {
39
42
  const localHandler = handlers.get(type);
40
43
  if (!localHandler) {
41
44
  throw new MessengerError(`No handler registered for ${type} in ${getContextName()}`);
42
45
  }
43
- debug(type, "➡️ will be handled here");
44
- const meta = { trace: [sender] };
46
+ debug(type, "➡️ will be handled here,", getContextName());
45
47
  handleMessage = async () => localHandler.apply(meta, args);
46
48
  }
47
49
  const response = await handleMessage().then((value) => ({ value }), (error) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webext-messenger",
3
- "version": "0.15.0",
3
+ "version": "0.15.1-0",
4
4
  "description": "Browser Extension component messaging framework",
5
5
  "keywords": [],
6
6
  "repository": "pixiebrix/webext-messenger",