feat: shim browser

This commit is contained in:
EnixCoda 2019-11-03 20:26:45 +08:00
parent 85a40fbe9b
commit aebc62a7b2
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
5 changed files with 24 additions and 16 deletions

View file

@ -17,6 +17,7 @@
"@primer/octicons": "^9.1.1",
"@primer/octicons-react": "^9.2.0",
"@sentry/browser": "^5.5.0",
"@types/firefox-webext-browser": "^70.0.1",
"@types/react-window": "^1.8.1",
"ini": "^1.3.5",
"js-base64": "^2.5.1",
@ -24,7 +25,8 @@
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-window": "^1.8.5",
"safe-touch": "^0.2.2"
"safe-touch": "^0.2.2",
"webextension-polyfill": "^0.5.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
@ -35,7 +37,6 @@
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@sentry/cli": "^1.47.1",
"@types/chrome": "^0.0.87",
"@types/ini": "^1.3.30",
"@types/js-base64": "^2.3.1",
"@types/node": "^11.10.4",

View file

@ -8,18 +8,11 @@
"128": "icons/Gitako-128x128.png"
},
"homepage_url": "https://github.com/EnixCoda/Gitako",
"permissions": [
"storage",
"*://github.com/*"
],
"permissions": ["storage", "*://*.github.com/*", "*://*.sentry.io/*"],
"content_scripts": [
{
"matches": [
"https://github.com/*"
],
"js": [
"content.js"
]
"matches": ["https://github.com/*"],
"js": ["browser-polyfill.js", "content.js"]
}
]
}
}

View file

@ -1,11 +1,11 @@
const localStorage = chrome.storage.local
const localStorage = browser.storage.local
function get(mapping: string[] | null): Promise<any> {
return new Promise(resolve => localStorage.get(mapping, resolve))
return localStorage.get(mapping || undefined)
}
function set(value: any): Promise<void> {
return new Promise(resolve => localStorage.set(value, resolve))
return localStorage.set(value)
}
export default {

View file

@ -18,6 +18,10 @@ const plugins = [
from: './src/assets/icons/*',
to: 'icons/[name].[ext]',
},
{
from: 'node_modules/webextension-polyfill/dist/browser-polyfill.js',
to: 'browser-polyfill.js',
},
]),
new ForkTsCheckerWebpackPlugin(),
new Dotenv(),

View file

@ -861,6 +861,11 @@
resolved "https://registry.yarnpkg.com/@types/filewriter/-/filewriter-0.0.28.tgz#c054e8af4d9dd75db4e63abc76f885168714d4b3"
integrity sha1-wFTor02d11205jq8dviFFocU1LM=
"@types/firefox-webext-browser@^70.0.1":
version "70.0.1"
resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-70.0.1.tgz#53a3915bfbe25e2c5ec439dbdbe6e303610012bb"
integrity sha512-hjHsTR9vKs+yikWbNS/s7TVCx15M/MEn+VYx47wtT/W/wORsIZDD75gfUfP7lkzi+IxRvKMQBB/5/wMFlfgvgQ==
"@types/ini@^1.3.30":
version "1.3.30"
resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.30.tgz#d1485459c9fad84e937414b832a2adb649eab379"
@ -5110,6 +5115,11 @@ watchpack@^1.6.0:
graceful-fs "^4.1.2"
neo-async "^2.5.0"
webextension-polyfill@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/webextension-polyfill/-/webextension-polyfill-0.5.0.tgz#795e0bf6a2b8eadcdb6edaecd169e9228c747519"
integrity sha512-aFrl38x43t1bTboX/paCT8I97+idzX/TY0+fuM52hrIkCpYfROEF9kSn0BXuEIi3J9LTYt2ZZKkhx9NB1qF3nA==
webpack-bundle-analyzer@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.6.0.tgz#39b3a8f829ca044682bc6f9e011c95deb554aefd"