README
Workspace API for Chrome
How to use
Install the package:
npm add -D workspace-api-for-chrome
Create a new window as the new workspace,
import { WindowsService } from 'workspace-api-for-chrome';
const winId = await WindowsService.create('https://github.com/');
Initialize the workspace with a specified windowId,
import { Workspace } from 'workspace-api-for-chrome';
const workspace = new Workspace(winId);
Serialize the workspace,
const jsonFormatString: string = await workspace.read();
De-serialize the workspace,
workspace.write(jsonFormatString).then();
The structure of the JSON data,
type IMessage = {
tabs: string[]; // the array of tab information
activeIndex: number; // the index of the active tab
};
Furthermore, some helpful tools are available. For instance, to register browser listeners for tab events in a batch way,
import { ListenersService } from 'workspace-api-for-chrome';
const listenersService = new ListenersService(() => {
// do something here
});