diff --git a/dev/client.ts b/dev/client.ts index ffda968..87cb8a7 100644 --- a/dev/client.ts +++ b/dev/client.ts @@ -1,11 +1,11 @@ -import { TabManagerWorkerCaller } from '../src/caller'; -import { tabManagerEvents } from '../src/helper'; +import { TabsManagerWorkerCaller } from '../src/caller'; +import { TabsManagerEvents } from '../src/helper'; -const tabManager = new TabManagerWorkerCaller({ +const tabManager = new TabsManagerWorkerCaller({ workerPath: 'worker.js', }); -tabManager.addListener(tabManagerEvents.activeTab, (isActive: boolean) => { - document.title = isActive ? '🧐 active' : 'inactive'; +tabManager.addListener(TabsManagerEvents.activeTab, (isActive: boolean) => { + document.title = isActive ? '✅ active' : 'inactive'; }); tabManager.init(); diff --git a/dev/worker.ts b/dev/worker.ts index a4a7207..a4fffbb 100644 --- a/dev/worker.ts +++ b/dev/worker.ts @@ -1,4 +1,4 @@ -import { TabManagerWorkerServer } from '../src/worker'; +import { TabsManagerWorkerServer } from '../src/worker'; -const server = new TabManagerWorkerServer(); +const server = new TabsManagerWorkerServer(); server.init(); \ No newline at end of file diff --git a/package.json b/package.json index 08742f4..223fc15 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Hazyzh/tab-manager.git" + "url": "git+https://github.com/Hazyzh/tabs-manager.git" }, "keywords": [ "multiple tabs", @@ -20,9 +20,9 @@ "author": "Harry Hou", "license": "MIT", "bugs": { - "url": "https://github.com/Hazyzh/tab-manager/issues" + "url": "https://github.com/Hazyzh/tabs-manager/issues" }, - "homepage": "https://github.com/Hazyzh/tab-manager#readme", + "homepage": "https://github.com/Hazyzh/tabs-manager#readme", "devDependencies": { "@types/node": "^17.0.8", "@types/uuid": "^8.3.4", diff --git a/src/caller.ts b/src/caller.ts index 46694ed..6a38d45 100644 --- a/src/caller.ts +++ b/src/caller.ts @@ -2,15 +2,15 @@ import { EventEmitter } from 'events'; import { v4 as uuid } from 'uuid'; import { - tabManagerEvents, + TabsManagerEvents, workerEvents, } from './helper'; import { IWorkerMessageData, - TabManagerWorkerCallerParams, + TabsManagerWorkerCallerParams, } from './interface'; -export class TabManagerWorkerCaller extends EventEmitter { +export class TabsManagerWorkerCaller extends EventEmitter { private readonly workerPath: string; private readonly workerName: string; @@ -21,7 +21,7 @@ export class TabManagerWorkerCaller extends EventEmitter { isActive = true; - constructor(options: TabManagerWorkerCallerParams) { + constructor(options: TabsManagerWorkerCallerParams) { super(); this.workerPath = options.workerPath; if (!this.workerPath || typeof this.workerPath !== 'string') { @@ -52,7 +52,7 @@ export class TabManagerWorkerCaller extends EventEmitter { if (type === workerEvents.activeTabId) { const isActive = id === this.id; this.isActive = isActive; - this.emit(tabManagerEvents.activeTab, isActive); + this.emit(TabsManagerEvents.activeTab, isActive); } }); @@ -104,8 +104,8 @@ export class TabManagerWorkerCaller extends EventEmitter { }; private error(message: string) { - this.emit(tabManagerEvents.error, message); + this.emit(TabsManagerEvents.error, message); } } -export default TabManagerWorkerCaller; +export default TabsManagerWorkerCaller; diff --git a/src/helper.ts b/src/helper.ts index c17c0b9..64c69fc 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -1,11 +1,11 @@ export const workerEvents = { - activeTabId: 'tab-manager-active-tab-id', - setActiveTab: 'tab-manager-set-active-tab', - checkActiveTab: 'tab-manager-check-active-tab', - closeWindow: 'tab-manager-close-window', + activeTabId: 'tabs-manager-active-tab-id', + setActiveTab: 'tabs-manager-set-active-tab', + checkActiveTab: 'tabs-manager-check-active-tab', + closeWindow: 'tabs-manager-close-window', }; -export const tabManagerEvents = { - error: 'tab-manager-error', - activeTab: 'tab-manager-active-tab', +export const TabsManagerEvents = { + error: 'tabs-manager-error', + activeTab: 'tabs-manager-active-tab', }; diff --git a/src/interface.ts b/src/interface.ts index dccef57..d49ec2c 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -1,4 +1,4 @@ -export interface TabManagerWorkerCallerParams { +export interface TabsManagerWorkerCallerParams { workerPath: string workerName?: string } diff --git a/src/worker.ts b/src/worker.ts index 15e6e48..b0626be 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -4,7 +4,7 @@ import { IWorkerMessageData } from './interface'; // eslint-disable-next-line @typescript-eslint/no-explicit-any,no-restricted-globals const globalSelf = self as any; -export class TabManagerWorkerServer { +export class TabsManagerWorkerServer { private connections: MessagePort[] = []; private activeId: string; @@ -57,4 +57,4 @@ export class TabManagerWorkerServer { }; } -export default TabManagerWorkerServer; +export default TabsManagerWorkerServer; diff --git a/webpack.config.js b/webpack.config.js index 88d3ae6..16f8b28 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -36,7 +36,7 @@ module.exports = { }, plugins: [ new HtmlWebpackPlugin({ - filename: 'tabManager.html', + filename: 'index.html', chunks: ['client'], template: './dev/index.html' })