webext-messenger
Advanced tools
Comparing version 0.17.0-0 to 0.17.0
@@ -35,3 +35,2 @@ import browser from "webextension-polyfill"; | ||
const meta = { trace }; | ||
debug(type, "↘️ received", { sender, args, wasForwarded: trace.length > 1 }); | ||
let handleMessage; | ||
@@ -43,2 +42,7 @@ if (action === "forward") { | ||
else { | ||
debug(type, "↘️ received in", getContextName(), { | ||
sender, | ||
args, | ||
wasForwarded: trace.length > 1, | ||
}); | ||
const localHandler = handlers.get(type); | ||
@@ -48,3 +52,2 @@ if (!localHandler) { | ||
} | ||
debug(type, "➡️ will be handled here,", getContextName()); | ||
handleMessage = async () => localHandler.apply(meta, args); | ||
@@ -68,3 +71,3 @@ } | ||
} | ||
console.debug("Messenger: Registered", type); | ||
debug("Registered", type); | ||
handlers.set(type, method); | ||
@@ -71,0 +74,0 @@ } |
@@ -0,1 +1,13 @@ | ||
const logging = (() => { | ||
try { | ||
// @ts-expect-error it would break Webpack | ||
return process.env.WEBEXT_MESSENGER_LOGGING === "true"; | ||
} | ||
catch { | ||
return false; | ||
} | ||
})(); | ||
function noop() { | ||
/* */ | ||
} | ||
export const __webextMessenger = true; | ||
@@ -18,4 +30,4 @@ export function isObject(value) { | ||
// .bind preserves the call location in the console | ||
export const debug = console.debug.bind(console, "Messenger:"); | ||
export const warn = console.warn.bind(console, "Messenger:"); | ||
export const debug = logging ? console.debug.bind(console, "Messenger:") : noop; | ||
export const warn = logging ? console.warn.bind(console, "Messenger:") : noop; | ||
export function isErrorObject(error) { | ||
@@ -22,0 +34,0 @@ var _a; |
{ | ||
"name": "webext-messenger", | ||
"version": "0.17.0-0", | ||
"version": "0.17.0", | ||
"description": "Browser Extension component messaging framework", | ||
@@ -21,3 +21,3 @@ "keywords": [], | ||
"build": "tsc", | ||
"demo:watch": "parcel watch --no-cache --no-hmr", | ||
"demo:watch": "WEBEXT_MESSENGER_LOGGING=true parcel watch --no-cache --no-hmr", | ||
"demo:build": "parcel build --no-cache", | ||
@@ -24,0 +24,0 @@ "prepack": "tsc --sourceMap false", |
23150
425