Skip to content

Commit

Permalink
update name
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazyzh committed Jan 10, 2022
1 parent 2c25d3b commit 979ac9d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
10 changes: 5 additions & 5 deletions dev/client.ts
Original file line number Diff line number Diff line change
@@ -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();
4 changes: 2 additions & 2 deletions dev/worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TabManagerWorkerServer } from '../src/worker';
import { TabsManagerWorkerServer } from '../src/worker';

const server = new TabManagerWorkerServer();
const server = new TabsManagerWorkerServer();
server.init();
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions src/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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') {
Expand Down Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -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;
14 changes: 7 additions & 7 deletions src/helper.ts
Original file line number Diff line number Diff line change
@@ -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',
};
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface TabManagerWorkerCallerParams {
export interface TabsManagerWorkerCallerParams {
workerPath: string
workerName?: string
}
Expand Down
4 changes: 2 additions & 2 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,4 +57,4 @@ export class TabManagerWorkerServer {
};
}

export default TabManagerWorkerServer;
export default TabsManagerWorkerServer;
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
filename: 'tabManager.html',
filename: 'index.html',
chunks: ['client'],
template: './dev/index.html'
})
Expand Down

0 comments on commit 979ac9d

Please sign in to comment.