diff --git a/extension/.flowconfig b/extension/.flowconfig index 4995da2..ccd1f48 100644 --- a/extension/.flowconfig +++ b/extension/.flowconfig @@ -2,10 +2,10 @@ .*/node_modules/.* [include] +src/ [libs] node_modules/flow-interfaces-chrome/interfaces/ -src/js/browser_types.js [lints] diff --git a/extension/src/js/browser_types.js b/extension/flow-typed/webextension-polyfill.js similarity index 90% rename from extension/src/js/browser_types.js rename to extension/flow-typed/webextension-polyfill.js index f343edb..3bd7ad2 100644 --- a/extension/src/js/browser_types.js +++ b/extension/flow-typed/webextension-polyfill.js @@ -91,3 +91,11 @@ declare var browser: { tabs: browser$tabs, scripting: browser$scripting, } + + +declare module "webextension-polyfill" { + declare var storage: browser$storage; + declare var permissions: browser$permissions; + declare var tabs: browser$tabs; + declare var scripting: browser$scripting; +} diff --git a/extension/src/js/background.js b/extension/src/js/background.js index 16740e2..26f16bc 100644 --- a/extension/src/js/background.js +++ b/extension/src/js/background.js @@ -1,5 +1,4 @@ /* @flow */ -// TODO do I really need to annotate all files with @flow?? // hmm this works if you declare type: module in manifest @@ -7,16 +6,19 @@ // I assume this is only processed with webpack // import * as browser from "./browser-polyfill" -const manifestVersion = chrome.runtime.getManifest().manifest_version -if (manifestVersion == 3) { - // for v3 it's provided via manifest - try { - /* eslint-disable no-undef */ - importScripts('./browser-polyfill.js') - } catch (e) { - console.error(e) - } -} +// this works with v3 if you need to +// const manifestVersion = chrome.runtime.getManifest().manifest_version +// if (manifestVersion == 3) { +// // for v3 it's provided via manifest +// try { +// /* eslint-disable no-undef */ +// importScripts('./browser-polyfill.js') +// } catch (e) { +// console.error(e) +// } +// } + +import * as browser from "webextension-polyfill" import {COMMAND_CAPTURE_SIMPLE, METHOD_CAPTURE_WITH_EXTRAS, showNotification} from './common' diff --git a/extension/src/js/options.js b/extension/src/js/options.js index caa8b02..ced9f0d 100644 --- a/extension/src/js/options.js +++ b/extension/src/js/options.js @@ -1,4 +1,6 @@ /* @flow */ +import browser from "webextension-polyfill" + export type Options = { endpoint: string; diff --git a/extension/src/js/permissions.js b/extension/src/js/permissions.js index cbdf0c6..12956b8 100644 --- a/extension/src/js/permissions.js +++ b/extension/src/js/permissions.js @@ -1,4 +1,6 @@ /* @flow */ +import browser from "webextension-polyfill" + function urlForPermissionsCheck(url: string): string { var u = new URL(url); diff --git a/extension/src/options.html b/extension/src/options.html index 3c28a6e..c4b0b52 100644 --- a/extension/src/options.html +++ b/extension/src/options.html @@ -2,7 +2,7 @@
- +