import TinyServiceWorker from '../TinyServiceWorker.mjs'; export type DebuggerConstructor = import('../../../tools/TinyDebugger.mjs').DebuggerConstructor; export type ExtraDataFn = (() => any); export type ConstructorOptions = { /** * - Whether to track tab focus status. */ trackFocus?: boolean; /** * - Whether the tab allows the SW to request tab closure. */ allowTabClosing?: boolean; /** * - Optional function that returns custom data to be cached in the SW. */ getExtraData?: ExtraDataFn; /** * - Debugger configuration. */ lgConfig?: Partial; }; export type TabFocusPayload = { /** * - Whether the tab is currently active and focused. */ isFocused: boolean; }; export type TabInfo = { /** * - The unique Client ID. */ id: string; /** * - The current URL. */ url: string; /** * - The document title. */ title: string; /** * - Whether the tab currently has window focus. */ isFocused: boolean; /** * - Custom data provided by the client. */ data?: any; }; export type TabList = { /** * - Total number of open tabs. */ count: number; /** * - Array of tab information. */ tabs: TabInfo[]; }; /** @typedef {import('../../../tools/TinyDebugger.mjs').DebuggerConstructor} DebuggerConstructor - The constructor function for a debugger instance. */ /** * @typedef {(() => any)} ExtraDataFn - A function that returns custom data. */ /** * Options of the new instance. * @typedef {Object} ConstructorOptions - Configuration options. * @property {boolean} [trackFocus=true] - Whether to track tab focus status. * @property {boolean} [allowTabClosing=true] - Whether the tab allows the SW to request tab closure. * @property {ExtraDataFn} [getExtraData] - Optional function that returns custom data to be cached in the SW. * @property {Partial} [lgConfig] - Debugger configuration. */ /** * @typedef {Object} TabFocusPayload * @property {boolean} isFocused - Whether the tab is currently active and focused. */ /** * @typedef {Object} TabInfo * @property {string} id - The unique Client ID. * @property {string} url - The current URL. * @property {string} title - The document title. * @property {boolean} isFocused - Whether the tab currently has window focus. * @property {any} [data] - Custom data provided by the client. */ /** * @typedef {Object} TabList * @property {number} count - Total number of open tabs. * @property {TabInfo[]} tabs - Array of tab information. */ /** * Controller to be used in the main thread to communicate with the TabManagerPlugin. */ declare class TinySwTabsLayer extends TinyServiceWorker.TinyPluginLayer { #private; /** * Gets the current status of the focus tracking configuration. * @returns {boolean} - Whether the tab focus tracking is enabled. */ get trackFocus(): boolean; /** * Gets whether the tab allows closure requests from the Service Worker. * @returns {boolean} - Whether the tab allows closure requests. */ get allowTabClosing(): boolean; /** * Updates the tab's permissions and synchronizes with the Service Worker. * @param {Object} options - The new permission configuration. * @param {boolean} [options.trackFocus] - New focus tracking permission. * @param {boolean} [options.allowTabClosing] - New tab closing permission. * @returns {Promise} - A promise that resolves when the status report is complete. * @throws {TypeError} If options is not an object or properties are not booleans. */ setPermissions(options?: { trackFocus?: boolean; allowTabClosing?: boolean; }): Promise; /** * Initializes a new instance of the TinySwTabsLayer. * @param {TinyServiceWorker} sw - The TinyServiceWorker instance used for communication. * @param {ConstructorOptions} [options] - Configuration options. * @throws {TypeError} If sw is not an instance of TinyServiceWorker or options are invalid. */ constructor(sw: TinyServiceWorker, options?: ConstructorOptions); /** * Registers this tab in the manager. * @returns {Promise} - A promise that resolves when the registration is complete. */ register(): Promise; /** * Explicitly requests the current list of all open tabs. * @returns {Promise} - A promise that resolves with the current list of tabs. */ getTabList(): Promise; /** * Retrieves the information for a specific tab by its unique ID. * @param {string} id - The unique identifier of the tab. * @returns {Promise} - The tab information if found, or null if the tab does not exist. * @throws {TypeError} If the provided id is not a string. */ getTab(id: string): Promise; /** * Closes a specific tab by its ID. * @param {string} id - The ID of the tab to close. * @returns {Promise<{ closed: boolean }>} - A promise that resolves with the result of the close request. */ closeTab(id: string): Promise<{ closed: boolean; }>; /** * Closes multiple tabs by their IDs. * @param {string[]} ids - Array of tab IDs. * @returns {Promise<{ closed: (-1|0|1)[] }>} (-1: no permission | 0: no closed | 1: closed) */ closeTabs(ids: string[]): Promise<{ closed: (-1 | 0 | 1)[]; }>; /** * Closes all registered tabs. * @returns {Promise} - A promise that resolves when all tabs have been requested to close. */ closeAllTabs(): Promise; /** * Sets a callback to be executed whenever the tab list changes. * @param {(list: TabList) => void} callback - The function to execute when the tab list changes. */ onUpdate(callback: (list: TabList) => void): void; /** * Removes a callback from tab list change events. * @param {(list: TabList) => void} callback - The callback function to remove. */ offUpdate(callback: (list: TabList) => void): void; } /** * A plugin for TinyServiceWorker that manages a centralized registry of all open website tabs. * @type {import('../TinyServiceWorker.mjs').SwPluginInstaller} */ declare const TinyTabManagerPlugin: import('../TinyServiceWorker.mjs').SwPluginInstaller; export default TinyTabManagerPlugin; //# sourceMappingURL=TabManager.d.mts.map