tabs-manager
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,11 +0,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(); |
@@ -1,4 +0,4 @@ | ||
import { TabManagerWorkerServer } from '../src/worker'; | ||
import { TabsManagerWorkerServer } from '../src/worker'; | ||
const server = new TabManagerWorkerServer(); | ||
const server = new TabsManagerWorkerServer(); | ||
server.init(); |
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { TabManagerWorkerCallerParams } from './interface'; | ||
export declare class TabManagerWorkerCaller extends EventEmitter { | ||
import { TabsManagerWorkerCallerParams } from './interface'; | ||
export declare class TabsManagerWorkerCaller extends EventEmitter { | ||
private readonly workerPath; | ||
@@ -10,3 +10,3 @@ private readonly workerName; | ||
isActive: boolean; | ||
constructor(options: TabManagerWorkerCallerParams); | ||
constructor(options: TabsManagerWorkerCallerParams); | ||
init(): void; | ||
@@ -22,2 +22,2 @@ private initWorker; | ||
} | ||
export default TabManagerWorkerCaller; | ||
export default TabsManagerWorkerCaller; |
@@ -18,9 +18,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TabManagerWorkerCaller = void 0; | ||
exports.TabsManagerWorkerCaller = void 0; | ||
var events_1 = require("events"); | ||
var uuid_1 = require("uuid"); | ||
var helper_1 = require("./helper"); | ||
var TabManagerWorkerCaller = /** @class */ (function (_super) { | ||
__extends(TabManagerWorkerCaller, _super); | ||
function TabManagerWorkerCaller(options) { | ||
var TabsManagerWorkerCaller = /** @class */ (function (_super) { | ||
__extends(TabsManagerWorkerCaller, _super); | ||
function TabsManagerWorkerCaller(options) { | ||
var _a; | ||
@@ -55,3 +55,3 @@ var _this = _super.call(this) || this; | ||
} | ||
TabManagerWorkerCaller.prototype.init = function () { | ||
TabsManagerWorkerCaller.prototype.init = function () { | ||
this.initWorker(); | ||
@@ -61,3 +61,3 @@ this.initWorkerListener(); | ||
}; | ||
TabManagerWorkerCaller.prototype.initWorker = function () { | ||
TabsManagerWorkerCaller.prototype.initWorker = function () { | ||
if (!window.SharedWorker) { | ||
@@ -69,3 +69,3 @@ this.error('ShareWorker not support!'); | ||
}; | ||
TabManagerWorkerCaller.prototype.initWorkerListener = function () { | ||
TabsManagerWorkerCaller.prototype.initWorkerListener = function () { | ||
var _this = this; | ||
@@ -78,3 +78,3 @@ this.workerInstance.port.addEventListener('message', function (e) { | ||
_this.isActive = isActive; | ||
_this.emit(helper_1.tabManagerEvents.activeTab, isActive); | ||
_this.emit(helper_1.TabsManagerEvents.activeTab, isActive); | ||
} | ||
@@ -88,3 +88,3 @@ }); | ||
}; | ||
TabManagerWorkerCaller.prototype.initDomListener = function () { | ||
TabsManagerWorkerCaller.prototype.initDomListener = function () { | ||
if (!this.workerInstance) | ||
@@ -102,11 +102,11 @@ return; | ||
}; | ||
TabManagerWorkerCaller.prototype.sendMessage = function (data) { | ||
TabsManagerWorkerCaller.prototype.sendMessage = function (data) { | ||
this.workerInstance.port.postMessage(data); | ||
}; | ||
TabManagerWorkerCaller.prototype.error = function (message) { | ||
this.emit(helper_1.tabManagerEvents.error, message); | ||
TabsManagerWorkerCaller.prototype.error = function (message) { | ||
this.emit(helper_1.TabsManagerEvents.error, message); | ||
}; | ||
return TabManagerWorkerCaller; | ||
return TabsManagerWorkerCaller; | ||
}(events_1.EventEmitter)); | ||
exports.TabManagerWorkerCaller = TabManagerWorkerCaller; | ||
exports.default = TabManagerWorkerCaller; | ||
exports.TabsManagerWorkerCaller = TabsManagerWorkerCaller; | ||
exports.default = TabsManagerWorkerCaller; |
@@ -7,5 +7,5 @@ export declare const workerEvents: { | ||
}; | ||
export declare const tabManagerEvents: { | ||
export declare const TabsManagerEvents: { | ||
error: string; | ||
activeTab: string; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tabManagerEvents = exports.workerEvents = void 0; | ||
exports.TabsManagerEvents = exports.workerEvents = void 0; | ||
exports.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', | ||
}; | ||
exports.tabManagerEvents = { | ||
error: 'tab-manager-error', | ||
activeTab: 'tab-manager-active-tab', | ||
exports.TabsManagerEvents = { | ||
error: 'tabs-manager-error', | ||
activeTab: 'tabs-manager-active-tab', | ||
}; |
@@ -1,2 +0,2 @@ | ||
export interface TabManagerWorkerCallerParams { | ||
export interface TabsManagerWorkerCallerParams { | ||
workerPath: string; | ||
@@ -3,0 +3,0 @@ workerName?: string; |
@@ -1,2 +0,2 @@ | ||
export declare class TabManagerWorkerServer { | ||
export declare class TabsManagerWorkerServer { | ||
private connections; | ||
@@ -9,2 +9,2 @@ private activeId; | ||
} | ||
export default TabManagerWorkerServer; | ||
export default TabsManagerWorkerServer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TabManagerWorkerServer = void 0; | ||
exports.TabsManagerWorkerServer = void 0; | ||
var helper_1 = require("./helper"); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,no-restricted-globals | ||
var globalSelf = self; | ||
var TabManagerWorkerServer = /** @class */ (function () { | ||
function TabManagerWorkerServer() { | ||
var TabsManagerWorkerServer = /** @class */ (function () { | ||
function TabsManagerWorkerServer() { | ||
var _this = this; | ||
@@ -45,3 +45,3 @@ this.connections = []; | ||
} | ||
TabManagerWorkerServer.prototype.init = function () { | ||
TabsManagerWorkerServer.prototype.init = function () { | ||
var _this = this; | ||
@@ -56,5 +56,5 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
}; | ||
return TabManagerWorkerServer; | ||
return TabsManagerWorkerServer; | ||
}()); | ||
exports.TabManagerWorkerServer = TabManagerWorkerServer; | ||
exports.default = TabManagerWorkerServer; | ||
exports.TabsManagerWorkerServer = TabsManagerWorkerServer; | ||
exports.default = TabsManagerWorkerServer; |
{ | ||
"name": "tabs-manager", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Definition one active tab on multiple tabs scenarios. ", | ||
@@ -12,3 +12,3 @@ "main": "./lib/index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/Hazyzh/tab-manager.git" | ||
"url": "git+https://github.com/Hazyzh/tabs-manager.git" | ||
}, | ||
@@ -24,5 +24,5 @@ "keywords": [ | ||
"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": { | ||
@@ -29,0 +29,0 @@ "@types/node": "^17.0.8", |
@@ -5,3 +5,3 @@ import { EventEmitter } from 'events'; | ||
import { | ||
tabManagerEvents, | ||
TabsManagerEvents, | ||
workerEvents, | ||
@@ -11,6 +11,6 @@ } from './helper'; | ||
IWorkerMessageData, | ||
TabManagerWorkerCallerParams, | ||
TabsManagerWorkerCallerParams, | ||
} from './interface'; | ||
export class TabManagerWorkerCaller extends EventEmitter { | ||
export class TabsManagerWorkerCaller extends EventEmitter { | ||
private readonly workerPath: string; | ||
@@ -26,3 +26,3 @@ | ||
constructor(options: TabManagerWorkerCallerParams) { | ||
constructor(options: TabsManagerWorkerCallerParams) { | ||
super(); | ||
@@ -58,3 +58,3 @@ this.workerPath = options.workerPath; | ||
this.isActive = isActive; | ||
this.emit(tabManagerEvents.activeTab, isActive); | ||
this.emit(TabsManagerEvents.activeTab, isActive); | ||
} | ||
@@ -111,6 +111,6 @@ }); | ||
private error(message: string) { | ||
this.emit(tabManagerEvents.error, message); | ||
this.emit(TabsManagerEvents.error, message); | ||
} | ||
} | ||
export default TabManagerWorkerCaller; | ||
export default TabsManagerWorkerCaller; |
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', | ||
}; |
@@ -1,2 +0,2 @@ | ||
export interface TabManagerWorkerCallerParams { | ||
export interface TabsManagerWorkerCallerParams { | ||
workerPath: string | ||
@@ -3,0 +3,0 @@ workerName?: string |
@@ -7,3 +7,3 @@ import { workerEvents } from './helper'; | ||
export class TabManagerWorkerServer { | ||
export class TabsManagerWorkerServer { | ||
private connections: MessagePort[] = []; | ||
@@ -61,2 +61,2 @@ | ||
export default TabManagerWorkerServer; | ||
export default TabsManagerWorkerServer; |
@@ -39,3 +39,3 @@ const path = require('path'); | ||
new HtmlWebpackPlugin({ | ||
filename: 'tabManager.html', | ||
filename: 'index.html', | ||
chunks: ['client'], | ||
@@ -42,0 +42,0 @@ template: './dev/index.html' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24933
27