parent
c7803e7c29
commit
cdfd54ed99
37 changed files with 212 additions and 202 deletions
@ -0,0 +1,35 @@ |
||||
import { injectable } from 'tsyringe'; |
||||
import ContentMessageListener from './infrastructures/ContentMessageListener'; |
||||
import SettingController from './controllers/SettingController'; |
||||
import VersionController from './controllers/VersionController'; |
||||
|
||||
@injectable() |
||||
export default class Application { |
||||
constructor( |
||||
private contentMessageListener: ContentMessageListener, |
||||
private settingController: SettingController, |
||||
private versionController: VersionController, |
||||
) { |
||||
} |
||||
|
||||
run() { |
||||
this.settingController.reload(); |
||||
|
||||
browser.runtime.onInstalled.addListener((details) => { |
||||
if (details.reason !== 'install' && details.reason !== 'update') { |
||||
return; |
||||
} |
||||
this.versionController.notify(); |
||||
}); |
||||
|
||||
this.contentMessageListener.run(); |
||||
browser.storage.onChanged.addListener((changes, area) => { |
||||
if (area !== 'local') { |
||||
return; |
||||
} |
||||
if (changes.settings) { |
||||
this.settingController.reload(); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1,23 +1,6 @@ |
||||
import ContentMessageListener from './infrastructures/ContentMessageListener'; |
||||
import SettingController from './controllers/SettingController'; |
||||
import VersionController from './controllers/VersionController'; |
||||
import 'reflect-metadata'; |
||||
import { container } from 'tsyringe'; |
||||
import Application from './Application'; |
||||
|
||||
let settingController = new SettingController(); |
||||
settingController.reload(); |
||||
|
||||
browser.runtime.onInstalled.addListener((details) => { |
||||
if (details.reason !== 'install' && details.reason !== 'update') { |
||||
return; |
||||
} |
||||
new VersionController().notify(); |
||||
}); |
||||
|
||||
new ContentMessageListener().run(); |
||||
browser.storage.onChanged.addListener((changes, area) => { |
||||
if (area !== 'local') { |
||||
return; |
||||
} |
||||
if (changes.settings) { |
||||
settingController.reload(); |
||||
} |
||||
}); |
||||
let app = container.resolve(Application); |
||||
app.run(); |
||||
|
@ -1,6 +1,8 @@ |
||||
import chai from 'chai'; |
||||
import 'reflect-metadata'; |
||||
import { expect } from 'chai'; |
||||
|
||||
const browserFake = require('webextensions-api-fake'); |
||||
const browser = browserFake(); |
||||
|
||||
global.expect = chai.expect; |
||||
global.expect = expect; |
||||
global.browser = browser; |
||||
|
Reference in new issue