From 4e50ab486659afc6018f9d88cd6ef6982fe3f417 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 1 May 2021 14:20:05 +0200 Subject: [PATCH] Use definitely typed management types --- src/lib/extension_info.ts | 4 +- src/tridactyl.d.ts | 96 --------------------------------------- 2 files changed, 2 insertions(+), 98 deletions(-) diff --git a/src/lib/extension_info.ts b/src/lib/extension_info.ts index 4e79e426..316490ee 100644 --- a/src/lib/extension_info.ts +++ b/src/lib/extension_info.ts @@ -16,11 +16,11 @@ export const KNOWN_EXTENSIONS: { [name: string]: string } = { /** List of currently installed extensions. */ const installedExtensions: { - [id: string]: browser.management.IExtensionInfo + [id: string]: browser.management.ExtensionInfo } = {} function updateExtensionInfo( - extension: browser.management.IExtensionInfo, + extension: browser.management.ExtensionInfo, ): void { installedExtensions[extension.id] = extension } diff --git a/src/tridactyl.d.ts b/src/tridactyl.d.ts index a4e2338e..e2a06664 100644 --- a/src/tridactyl.d.ts +++ b/src/tridactyl.d.ts @@ -89,102 +89,6 @@ interface WebExtEventBase< hasListener(cb: TCallback): boolean } -type WebExtEvent any> = WebExtEventBase< - (callback: TCallback) => void, - TCallback -> -declare namespace browser.management { - /* management types */ - - /** Information about an icon belonging to an extension. */ - interface IconInfo { - /** - * A number representing the width and height of the icon. Likely values include (but are not limited to) 128, - * 48, 24, and 16. - */ - size: number - /** - * The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is - * disabled, for example), append `?grayscale=true` to the URL. - */ - url: string - } - - /** A reason the item is disabled. */ - type ExtensionDisabledReason = "unknown" | "permissions_increase" - - /** The type of this extension. Will always be 'extension'. */ - type ExtensionType = "extension" | "theme" - - /** - * How the extension was installed. One of - * `development`: The extension was loaded unpacked in developer mode, - * `normal`: The extension was installed normally via an .xpi file, - * `sideload`: The extension was installed by other software on the machine, - * `other`: The extension was installed by other means. - */ - type ExtensionInstallType = "development" | "normal" | "sideload" | "other" - - /** Information about an installed extension. */ - interface IExtensionInfo { - /** The extension's unique identifier. */ - id: string - /** The name of this extension. */ - name: string - /** A short version of the name of this extension. */ - shortName?: string - /** The description of this extension. */ - description: string - /** The version of this extension. */ - version: string - /** The version name of this extension if the manifest specified one. */ - versionName?: string - /** Whether this extension can be disabled or uninstalled by the user. */ - mayDisable: boolean - /** Whether it is currently enabled or disabled. */ - enabled: boolean - /** A reason the item is disabled. */ - disabledReason?: ExtensionDisabledReason - /** The type of this extension. Will always return 'extension'. */ - type: ExtensionType - /** The URL of the homepage of this extension. */ - homepageUrl?: string - /** The update URL of this extension. */ - updateUrl?: string - /** The url for the item's options page, if it has one. */ - optionsUrl: string - /** - * A list of icon information. Note that this just reflects what was declared in the manifest, and the actual - * image at that url may be larger or smaller than what was declared, so you might consider using explicit - * width and height attributes on img tags referencing these images. See the manifest documentation on icons - * for more details. - */ - icons?: IconInfo[] - /** Returns a list of API based permissions. */ - permissions?: string[] - /** Returns a list of host based permissions. */ - hostPermissions?: string[] - /** How the extension was installed. */ - installType: ExtensionInstallType - } - - /* management functions */ - /** Returns a list of information about installed extensions. */ - function getAll(): Promise - - /* management events */ - /** Fired when an addon has been disabled. */ - const onDisabled: WebExtEvent<(info: IExtensionInfo) => void> - - /** Fired when an addon has been enabled. */ - const onEnabled: WebExtEvent<(info: IExtensionInfo) => void> - - /** Fired when an addon has been installed. */ - const onInstalled: WebExtEvent<(info: IExtensionInfo) => void> - - /** Fired when an addon has been uninstalled. */ - const onUninstalled: WebExtEvent<(info: IExtensionInfo) => void> -} // html-tagged-template.js declare function html(