Add bridge debug info to options page

This commit is contained in:
hensm
2018-12-11 23:11:01 +00:00
parent c555d72a0d
commit c24c6412c0
6 changed files with 281 additions and 130 deletions

View File

@@ -0,0 +1,37 @@
import semver from "semver";
export default async function getBridgeInfo () {
let applicationVersion;
try {
const response = await browser.runtime.sendNativeMessage(
APPLICATION_NAME
, { subject: "bridge:getInfo"
, data: EXTENSION_VERSION });
applicationVersion = response.data;
} catch (err) {
return null;
}
/**
* Compare installed bridge version to the version the
* extension was built alongside and is known to be
* compatible with.
*
* TODO: Determine compatibility with semver and enforce/notify
* user.
*/
if (applicationVersion !== APPLICATION_VERSION) {
console.error(`Expecting ${APPLICATION_NAME} v${APPLICATION_VERSION}, found v${applicationVersion}.`
, semver.lt(applicationVersion, APPLICATION_VERSION)
? "Try updating the native app to the latest version."
: "Try updating the extension to the latest version");
}
return {
version: applicationVersion
, isVersionCompatible: applicationVersion === APPLICATION_VERSION
, isVersionOlder: semver.lt(applicationVersion, APPLICATION_VERSION)
, isVersionNewer: semver.gt(applicationVersion, APPLICATION_VERSION)
};
}