-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate methods to arrow function
- Loading branch information
1 parent
20483dd
commit 4907c74
Showing
8 changed files
with
56 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline' 'unsafe-eval';" /> | ||
<script> | ||
global.isBackground = true; | ||
(function () { | ||
const script = document.createElement('script'); | ||
script.async = true; | ||
script.src = (process.env.NODE_ENV) | ||
? 'http://localhost:3000/dist/background.bundle.js' | ||
: '../dist/background.bundle.js'; | ||
document.write(script.outerHTML); | ||
}()); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-inline' 'unsafe-eval';" /> | ||
<script> | ||
global.isBackground = true; | ||
(function () { | ||
const script = document.createElement('script'); | ||
script.async = true; | ||
script.src = (process.env.NODE_ENV) | ||
? 'http://localhost:3000/dist/background.bundle.js' | ||
: '../dist/background.bundle.js'; | ||
document.write(script.outerHTML); | ||
}()); | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import { on } from 'lib/rpc' | ||
import PluginsService from 'plugins' | ||
import plugins from 'plugins' | ||
import initPlugin from './initPlugin' | ||
|
||
function listenToAsyncMessages() { | ||
on('plugin.message', ({ name, data }) => { | ||
const plugin = PluginsService.getAllPlugins()[name] | ||
if (plugin.onMessage) plugin.onMessage(data) | ||
}) | ||
} | ||
|
||
/** | ||
* Initialize all plugins and start listening for replies from plugin async initializers | ||
*/ | ||
export default () => { | ||
const initializePlugins = () => { | ||
// Start listening for replies from plugin async initializers | ||
listenToAsyncMessages() | ||
on('plugin.message', ({ name, data }) => { | ||
const plugin = plugins.getAllPlugins()[name] | ||
if (plugin.onMessage) plugin.onMessage(data) | ||
}) | ||
|
||
const allPlugins = PluginsService.getAllPlugins() | ||
const allPlugins = plugins.getAllPlugins() | ||
|
||
Object.keys(allPlugins).forEach((name) => initPlugin(allPlugins[name], name)) | ||
} | ||
|
||
export default initializePlugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
import core from './core' | ||
import getExternalPlugins from './externalPlugins' | ||
|
||
class PluginsService { | ||
getCorePlugins() { | ||
return core | ||
} | ||
const getCorePlugins = () => core | ||
|
||
getExternalPlugins() { | ||
return getExternalPlugins() | ||
} | ||
const getAllPlugins = () => ({ ...core, ...getExternalPlugins() }) | ||
|
||
getAllPlugins() { | ||
return { ...core, ...getExternalPlugins() } | ||
} | ||
const pluginsService = { | ||
getExternalPlugins, | ||
getCorePlugins, | ||
getAllPlugins, | ||
} | ||
|
||
export default new PluginsService() | ||
export default pluginsService |