add firefox extension template

This commit is contained in:
2025-08-07 16:03:16 -05:00
parent 6cbb29fed1
commit 5df289ffcb
586 changed files with 13636 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
package webextension_polyfill.management;
/**
A reason the item is disabled.
**/
typedef ExtensionDisabledReason = String;

View File

@@ -0,0 +1,94 @@
package webextension_polyfill.management;
/**
Information about an installed extension.
**/
typedef ExtensionInfo = {
/**
The extension's unique identifier.
**/
var id : String;
/**
The name of this extension.
**/
var name : String;
/**
A short version of the name of this extension.
Optional.
**/
@:optional
var shortName : String;
/**
The description of this extension.
**/
var description : String;
/**
The <a href='manifest/version'>version</a> of this extension.
**/
var version : String;
/**
The <a href='manifest/version#version_name'>version name</a> of this extension if the manifest specified one.
Optional.
**/
@:optional
var versionName : String;
/**
Whether this extension can be disabled or uninstalled by the user.
**/
var mayDisable : Bool;
/**
Whether it is currently enabled or disabled.
**/
var enabled : Bool;
/**
A reason the item is disabled.
Optional.
**/
@:optional
var disabledReason : ExtensionDisabledReason;
/**
The type of this extension, 'extension' or 'theme'.
**/
var type : ExtensionType;
/**
The URL of the homepage of this extension.
Optional.
**/
@:optional
var homepageUrl : String;
/**
The update URL of this extension.
Optional.
**/
@:optional
var updateUrl : String;
/**
The url for the item's options page, if it has one.
**/
var 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 <a href='manifest/icons'>manifest documentation on icons</a> for more details.
Optional.
**/
@:optional
var icons : Array<IconInfo>;
/**
Returns a list of API based permissions.
Optional.
**/
@:optional
var permissions : Array<String>;
/**
Returns a list of host based permissions.
Optional.
**/
@:optional
var hostPermissions : Array<String>;
/**
How the extension was installed.
**/
var installType : ExtensionInstallType;
};

View File

@@ -0,0 +1,9 @@
package webextension_polyfill.management;
/**
How the extension was installed. One of<br><var>development</var>: The extension was loaded unpacked in developer mode,
<br><var>normal</var>: The extension was installed normally via an .xpi file,<br><var>sideload</var>
: The extension was installed by other software on the machine,<br><var>other</var>
: The extension was installed by other means.
**/
typedef ExtensionInstallType = String;

View File

@@ -0,0 +1,6 @@
package webextension_polyfill.management;
/**
The type of this extension, 'extension' or 'theme'.
**/
typedef ExtensionType = String;

View File

@@ -0,0 +1,17 @@
package webextension_polyfill.management;
/**
Information about an icon belonging to an extension.
**/
typedef IconInfo = {
/**
A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24,
and 16.
**/
var size : Float;
/**
The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is disabled,
for example), append <code>?grayscale=true</code> to the URL.
**/
var url : String;
};

View File

@@ -0,0 +1,5 @@
package webextension_polyfill.management;
typedef InstallCallbackResultType = {
var id : String;
};

View File

@@ -0,0 +1,14 @@
package webextension_polyfill.management;
typedef InstallOptionsType = {
/**
URL pointing to the XPI file on addons.mozilla.org or similar.
**/
var url : String;
/**
A hash of the XPI file, using sha256 or stronger.
Optional.
**/
@:optional
var hash : String;
};

View File

@@ -0,0 +1,46 @@
package webextension_polyfill.management;
typedef Static = {
/**
Returns a list of information about installed extensions.
**/
function getAll():js.lib.Promise<Array<ExtensionInfo>>;
/**
Returns information about the installed extension that has the given ID.
**/
function get(id:String):js.lib.Promise<ExtensionInfo>;
/**
Installs and enables a theme extension from the given url.
**/
function install(options:InstallOptionsType):js.lib.Promise<InstallCallbackResultType>;
/**
Returns information about the calling extension. Note: This function can be used without requesting the 'management'
permission in the manifest.
**/
function getSelf():js.lib.Promise<ExtensionInfo>;
/**
Uninstalls the calling extension. Note: This function can be used without requesting the 'management' permission in the
manifest.
**/
function uninstallSelf(?options:UninstallSelfOptionsType):js.lib.Promise<ts.Undefined>;
/**
Enables or disables the given add-on.
**/
function setEnabled(id:String, enabled:Bool):js.lib.Promise<ts.Undefined>;
/**
Fired when an addon has been disabled.
**/
var onDisabled : webextension_polyfill.events.Event<(info:ExtensionInfo) -> Void>;
/**
Fired when an addon has been enabled.
**/
var onEnabled : webextension_polyfill.events.Event<(info:ExtensionInfo) -> Void>;
/**
Fired when an addon has been installed.
**/
var onInstalled : webextension_polyfill.events.Event<(info:ExtensionInfo) -> Void>;
/**
Fired when an addon has been uninstalled.
**/
var onUninstalled : webextension_polyfill.events.Event<(info:ExtensionInfo) -> Void>;
};

View File

@@ -0,0 +1,16 @@
package webextension_polyfill.management;
typedef UninstallSelfOptionsType = {
/**
Whether or not a confirm-uninstall dialog should prompt the user. Defaults to false.
Optional.
**/
@:optional
var showConfirmDialog : Bool;
/**
The message to display to a user when being asked to confirm removal of the extension.
Optional.
**/
@:optional
var dialogMessage : String;
};