@mirawision/chrome-api
Version:
A comprehensive TypeScript library for Chrome Extension API, providing type-safe wrappers and utilities for bookmarks, commands, context menus, cookies, downloads, storage, notifications, runtime, scripting, and side panel functionalities.
22 lines (21 loc) • 910 B
TypeScript
/// <reference types="chrome" />
/**
* A class that provides a type-safe wrapper around Chrome's commands API.
* This class allows you to retrieve registered commands and listen for command triggers.
* Commands are keyboard shortcuts that can be used to trigger actions in your extension.
*/
declare class Commands {
/**
* Retrieves all registered commands for the extension.
* @returns A promise that resolves to an array of Command objects
* @throws {Error} If there's an error retrieving the commands
*/
static getAll(): Promise<chrome.commands.Command[]>;
/**
* Adds a listener for command events.
* @param callback - Function called when a command is triggered via keyboard shortcut
* @returns A function that removes the listener when called
*/
static addCommandListener(callback: (command: string) => void): () => void;
}
export { Commands };