* docs: add jsdoc * feat: change enums to as const objects * chore(test): add themeColors.test.ts * fix: fix tests and bugs with strings.ts util * fix: path alias imports and tsconfig file bug * fix: remove --max-warnings 0
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import type { BACKGROUND_MESSAGES } from '@shared/messages';
|
|
import { MessageListener } from 'chrome-extension-toolkit';
|
|
|
|
import onInstall from './events/onInstall';
|
|
import onServiceWorkerAlive from './events/onServiceWorkerAlive';
|
|
import onUpdate from './events/onUpdate';
|
|
import browserActionHandler from './handler/browserActionHandler';
|
|
import tabManagementHandler from './handler/tabManagementHandler';
|
|
import userScheduleHandler from './handler/userScheduleHandler';
|
|
|
|
onServiceWorkerAlive();
|
|
|
|
/**
|
|
* will be triggered on either install or update
|
|
* (will also be triggered on a user's sync'd browsers (on other devices)))
|
|
*/
|
|
chrome.runtime.onInstalled.addListener(details => {
|
|
switch (details.reason) {
|
|
case 'install':
|
|
onInstall();
|
|
break;
|
|
case 'update':
|
|
onUpdate();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
|
|
// initialize the message listener that will listen for messages from the content script
|
|
const messageListener = new MessageListener<BACKGROUND_MESSAGES>({
|
|
...browserActionHandler,
|
|
...tabManagementHandler,
|
|
...userScheduleHandler,
|
|
});
|
|
|
|
messageListener.listen();
|