@wxt-dev/browser 0.0.310 → 0.0.315

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,7 +43,7 @@ Types are generated based on the `@types/chrome` package, and with modifications
43
43
 
44
44
  ### Updating `@types/chrome` Version
45
45
 
46
- You don't need to do anything! A github action is ran every day to generate and publish this package using the latest `@types/chrome` version.
46
+ You don't need to do anything! [A github action](https://github.com/wxt-dev/wxt/actions/workflows/update-browser-package.yml) is ran every day to generate and publish this package using the latest `@types/chrome` version.
47
47
 
48
48
  You can manually generate types via:
49
49
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wxt-dev/browser",
3
3
  "description": "Provides a cross-browser API for using extension APIs and types based on @types/chrome",
4
- "version": "0.0.310",
4
+ "version": "0.0.315",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
7
7
  "types": "src/index.d.ts",
@@ -19,11 +19,12 @@
19
19
  "src"
20
20
  ],
21
21
  "devDependencies": {
22
- "@types/chrome": "0.0.310",
23
- "fs-extra": "^11.2.0",
22
+ "@types/chrome": "0.0.315",
23
+ "fs-extra": "^11.3.0",
24
24
  "nano-spawn": "^0.2.0",
25
25
  "tsx": "4.19.3",
26
- "vitest": "^3.0.7"
26
+ "typescript": "^5.8.3",
27
+ "vitest": "^3.1.1"
27
28
  },
28
29
  "dependencies": {
29
30
  "@types/filesystem": "*",
@@ -31,6 +32,7 @@
31
32
  },
32
33
  "peerDependencies": {},
33
34
  "scripts": {
35
+ "check": "check",
34
36
  "gen": "tsx scripts/generate.ts"
35
37
  }
36
38
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="chrome" />
2
2
  import { describe, expectTypeOf, it } from 'vitest';
3
- import { browser, Browser } from '../index';
3
+ import { browser, type Browser } from '../index';
4
4
 
5
5
  describe('browser', () => {
6
6
  describe('types', () => {
@@ -1867,198 +1867,146 @@ export namespace Browser {
1867
1867
  * Permissions: "contextMenus"
1868
1868
  */
1869
1869
  export namespace contextMenus {
1870
- export interface OnClickData {
1871
- /**
1872
- * Optional.
1873
- * @since Chrome 35
1874
- * The text for the context selection, if any.
1875
- */
1876
- selectionText?: string | undefined;
1877
- /**
1878
- * Optional.
1879
- * @since Chrome 35
1880
- * A flag indicating the state of a checkbox or radio item after it is clicked.
1881
- */
1882
- checked?: boolean | undefined;
1883
- /**
1884
- * @since Chrome 35
1885
- * The ID of the menu item that was clicked.
1886
- */
1887
- menuItemId: number | string;
1888
- /**
1889
- * Optional.
1890
- * @since Chrome 35
1891
- * The ID of the frame of the element where the context menu was
1892
- * clicked, if it was in a frame.
1893
- */
1894
- frameId?: number | undefined;
1895
- /**
1896
- * Optional.
1897
- * @since Chrome 35
1898
- * The URL of the frame of the element where the context menu was clicked, if it was in a frame.
1899
- */
1900
- frameUrl?: string | undefined;
1901
- /**
1902
- * @since Chrome 35
1903
- * A flag indicating whether the element is editable (text input, textarea, etc.).
1904
- */
1905
- editable: boolean;
1906
- /**
1907
- * Optional.
1908
- * @since Chrome 35
1909
- * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
1910
- */
1911
- mediaType?: "image" | "video" | "audio" | undefined;
1912
- /**
1913
- * Optional.
1914
- * @since Chrome 35
1915
- * A flag indicating the state of a checkbox or radio item before it was clicked.
1916
- */
1917
- wasChecked?: boolean | undefined;
1918
- /**
1919
- * @since Chrome 35
1920
- * The URL of the page where the menu item was clicked. This property is not set if the click occurred in a context where there is no current page, such as in a launcher context menu.
1921
- */
1922
- pageUrl: string;
1923
- /**
1924
- * Optional.
1925
- * @since Chrome 35
1926
- * If the element is a link, the URL it points to.
1927
- */
1928
- linkUrl?: string | undefined;
1929
- /**
1930
- * Optional.
1931
- * @since Chrome 35
1932
- * The parent ID, if any, for the item clicked.
1933
- */
1934
- parentMenuItemId?: number | string;
1935
- /**
1936
- * Optional.
1937
- * @since Chrome 35
1938
- * Will be present for elements with a 'src' URL.
1939
- */
1940
- srcUrl?: string | undefined;
1870
+ /**
1871
+ * The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all other contexts except for 'launcher'. The 'launcher' context is only supported by apps and is used to add menu items to the context menu that appears when clicking the app icon in the launcher/taskbar/dock/etc. Different platforms might put limitations on what is actually supported in a launcher context menu.
1872
+ * @since Chrome 44
1873
+ */
1874
+ export enum ContextType {
1875
+ ALL = "all",
1876
+ PAGE = "page",
1877
+ FRAME = "frame",
1878
+ SELECTION = "selection",
1879
+ LINK = "link",
1880
+ EDITABLE = "editable",
1881
+ IMAGE = "image",
1882
+ VIDEO = "video",
1883
+ AUDIO = "audio",
1884
+ LAUNCHER = "launcher",
1885
+ BROWSER_ACTION = "browser_action",
1886
+ PAGE_ACTION = "page_action",
1887
+ ACTION = "action",
1941
1888
  }
1942
1889
 
1943
- type ContextType =
1944
- | "all"
1945
- | "page"
1946
- | "frame"
1947
- | "selection"
1948
- | "link"
1949
- | "editable"
1950
- | "image"
1951
- | "video"
1952
- | "audio"
1953
- | "launcher"
1954
- | "browser_action"
1955
- | "page_action"
1956
- | "action";
1957
-
1958
- type ContextItemType = "normal" | "checkbox" | "radio" | "separator";
1959
-
1890
+ /**
1891
+ * Properties of the new context menu item.
1892
+ * @since Chrome 123
1893
+ */
1960
1894
  export interface CreateProperties {
1961
- /** Optional. Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns. */
1962
- documentUrlPatterns?: string[] | undefined;
1963
- /** Optional. The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items. */
1964
- checked?: boolean | undefined;
1965
- /** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */
1966
- title?: string | undefined;
1967
- /** Optional. List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */
1968
- contexts?: ContextType | ContextType[] | undefined;
1969
- /**
1970
- * Optional.
1971
- * @since Chrome 20
1972
- * Whether this context menu item is enabled or disabled. Defaults to true.
1973
- */
1974
- enabled?: boolean | undefined;
1975
- /** Optional. Similar to documentUrlPatterns, but lets you filter based on the src attribute of img/audio/video tags and the href of anchor tags. */
1976
- targetUrlPatterns?: string[] | undefined;
1977
- /**
1978
- * Optional.
1979
- * A function that will be called back when the menu item is clicked. Event pages cannot use this; instead, they should register a listener for Browser.contextMenus.onClicked.
1980
- * @param info Information sent when a context menu item is clicked.
1981
- * @param tab The details of the tab where the click took place. Note: this parameter only present for extensions.
1982
- */
1983
- onclick?: ((info: OnClickData, tab: Browser.tabs.Tab) => void) | undefined;
1984
- /** Optional. The ID of a parent menu item; this makes the item a child of a previously added item. */
1985
- parentId?: number | string | undefined;
1986
- /** Optional. The type of menu item. Defaults to 'normal' if not specified. */
1987
- type?: ContextItemType | undefined;
1988
- /**
1989
- * Optional.
1990
- * @since Chrome 21
1991
- * The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension.
1992
- */
1993
- id?: string | undefined;
1895
+ /** The initial state of a checkbox or radio button: `true` for selected, `false` for unselected. Only one radio button can be selected at a time in a given group. */
1896
+ checked?: boolean;
1897
+ /** List of contexts this menu item will appear in. Defaults to `['page']`. */
1898
+ contexts?: [`${ContextType}`, ...`${ContextType}`[]];
1899
+ /** Restricts the item to apply only to documents or frames whose URL matches one of the given patterns. For details on pattern formats, see Match Patterns. */
1900
+ documentUrlPatterns?: string[];
1901
+ /** Whether this context menu item is enabled or disabled. Defaults to `true`. */
1902
+ enabled?: boolean;
1903
+ /** The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension. */
1904
+ id?: string;
1905
+ /** The ID of a parent menu item; this makes the item a child of a previously added item. */
1906
+ parentId?: number | string;
1907
+ /** Similar to `documentUrlPatterns`, filters based on the `src` attribute of `img`, `audio`, and `video` tags and the `href` attribute of `a` tags. */
1908
+ targetUrlPatterns?: string[];
1909
+ /** The text to display in the item; this is _required_ unless `type` is `separator`. When the context is `selection`, use `%s` within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */
1910
+ title?: string;
1911
+ /** The type of menu item. Defaults to `normal`. */
1912
+ type?: `${ItemType}`;
1913
+ /** Whether the item is visible in the menu. */
1914
+ visible?: boolean;
1994
1915
  /**
1995
- * Optional.
1996
- * @since Chrome 62
1997
- * Whether the item is visible in the menu.
1916
+ * A function that is called back when the menu item is clicked. This is not available inside of a service worker; instead, you should register a listener for {@link contextMenus.onClicked}.
1917
+ * @param info Information about the item clicked and the context where the click happened.
1918
+ * @param tab The details of the tab where the click took place. This parameter is not present for platform apps.
1998
1919
  */
1999
- visible?: boolean | undefined;
1920
+ onclick?: (
1921
+ info: OnClickData,
1922
+ tab: tabs.Tab,
1923
+ ) => void;
2000
1924
  }
2001
1925
 
2002
- export interface UpdateProperties extends Omit<CreateProperties, "id"> {}
2003
-
2004
- export interface MenuClickedEvent
2005
- extends Browser.events.Event<(info: OnClickData, tab?: Browser.tabs.Tab) => void>
2006
- {}
2007
-
2008
1926
  /**
2009
- * @since Chrome 38
2010
- * The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored.
1927
+ * The type of menu item.
1928
+ * @since Chrome 44
2011
1929
  */
2012
- export var ACTION_MENU_TOP_LEVEL_LIMIT: number;
1930
+ export enum ItemType {
1931
+ NORMAL = "normal",
1932
+ CHECKBOX = "checkbox",
1933
+ RADIO = "radio",
1934
+ SEPARATOR = "separator",
1935
+ }
1936
+
1937
+ /** Information sent when a context menu item is clicked. */
1938
+ export interface OnClickData {
1939
+ /** A flag indicating the state of a checkbox or radio item after it is clicked. */
1940
+ checked?: boolean;
1941
+ /** A flag indicating whether the element is editable (text input, textarea, etc.). */
1942
+ editable: boolean;
1943
+ /**
1944
+ * The ID of the frame of the element where the context menu was clicked, if it was in a frame.
1945
+ * @since Chrome 51
1946
+ */
1947
+ frameId?: number;
1948
+ /** The URL of the frame of the element where the context menu was clicked, if it was in a frame. */
1949
+ frameUrl?: string;
1950
+ /** If the element is a link, the URL it points to. */
1951
+ linkUrl?: string;
1952
+ /** One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements. */
1953
+ mediaType?: `${ContextType.IMAGE}` | `${ContextType.VIDEO}` | `${ContextType.AUDIO}`;
1954
+ /** The ID of the menu item that was clicked. */
1955
+ menuItemId: number | string;
1956
+ /** The URL of the page where the menu item was clicked. This property is not set if the click occurred in a context where there is no current page, such as in a launcher context menu. */
1957
+ pageUrl?: string;
1958
+ /** The parent ID, if any, for the item clicked.*/
1959
+ parentMenuItemId?: number | string;
1960
+ /** The text for the context selection, if any. */
1961
+ selectionText?: string | undefined;
1962
+ /** Will be present for elements with a 'src' URL. */
1963
+ srcUrl?: string | undefined;
1964
+ /** A flag indicating the state of a checkbox or radio item before it was clicked. */
1965
+ wasChecked?: boolean | undefined;
1966
+ }
1967
+
1968
+ /** The maximum number of top level extension items that can be added to an extension action context menu. Any items beyond this limit will be ignored. */
1969
+ export const ACTION_MENU_TOP_LEVEL_LIMIT: 6;
2013
1970
 
2014
1971
  /**
2015
- * Removes all context menu items added by this extension.
2016
- * @since Chrome 123
2017
- */
2018
- export function removeAll(): Promise<void>;
2019
- /**
2020
- * Removes all context menu items added by this extension.
2021
- * @param callback Called when removal is complete.
2022
- */
2023
- export function removeAll(callback: () => void): void;
2024
- /**
2025
- * Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in Browser.runtime.lastError).
2026
- * @param callback Called when the item has been created in the browser. If there were any problems creating the item, details will be available in Browser.runtime.lastError.
1972
+ * Creates a new context menu item. If an error occurs during creation, it may not be detected until the creation callback fires; details will be in {@link Browser.runtime.lastError}.
2027
1973
  * @return The ID of the newly created item.
2028
1974
  */
2029
1975
  export function create(createProperties: CreateProperties, callback?: () => void): number | string;
2030
- /**
2031
- * Updates a previously created context menu item.
2032
- * @param id The ID of the item to update.
2033
- * @param updateProperties The properties to update. Accepts the same values as the create function.
2034
- * @since Chrome 123
2035
- */
2036
- export function update(id: string | number, updateProperties: UpdateProperties): Promise<void>;
2037
- /**
2038
- * Updates a previously created context menu item.
2039
- * @param id The ID of the item to update.
2040
- * @param updateProperties The properties to update. Accepts the same values as the create function.
2041
- * @param callback Called when the context menu has been updated.
2042
- */
2043
- export function update(id: string | number, updateProperties: UpdateProperties, callback: () => void): void;
1976
+
2044
1977
  /**
2045
1978
  * Removes a context menu item.
2046
1979
  * @param menuItemId The ID of the context menu item to remove.
2047
- * @since Chrome 123
1980
+ *
1981
+ * Can return its result via Promise since Chrome 123.
2048
1982
  */
2049
1983
  export function remove(menuItemId: string | number): Promise<void>;
1984
+ export function remove(menuItemId: string | number, callback: () => void): void;
1985
+
2050
1986
  /**
2051
- * Removes a context menu item.
2052
- * @param menuItemId The ID of the context menu item to remove.
2053
- * @param callback Called when the context menu has been removed.
1987
+ * Removes all context menu items added by this extension.
1988
+ *
1989
+ * Can return its result via Promise since Chrome 123.
2054
1990
  */
2055
- export function remove(menuItemId: string | number, callback: () => void): void;
1991
+ export function removeAll(): Promise<void>;
1992
+ export function removeAll(callback: () => void): void;
2056
1993
 
2057
1994
  /**
2058
- * @since Chrome 21
2059
- * Fired when a context menu item is clicked.
1995
+ * Updates a previously created context menu item.
1996
+ * @param id The ID of the item to update.
1997
+ * @param updateProperties The properties to update. Accepts the same values as the {@link contextMenus.create} function.
1998
+ *
1999
+ * Can return its result via Promise since Chrome 123.
2060
2000
  */
2061
- export var onClicked: MenuClickedEvent;
2001
+ export function update(id: string | number, updateProperties: Omit<CreateProperties, "id">): Promise<void>;
2002
+ export function update(
2003
+ id: string | number,
2004
+ updateProperties: Omit<CreateProperties, "id">,
2005
+ callback: () => void,
2006
+ ): void;
2007
+
2008
+ /** Fired when a context menu item is clicked. */
2009
+ export const onClicked: events.Event<(info: OnClickData, tab?: tabs.Tab) => void>;
2062
2010
  }
2063
2011
 
2064
2012
  ////////////////////
@@ -3073,6 +3021,71 @@ export namespace Browser {
3073
3021
  export var themeName: "default" | "dark";
3074
3022
  }
3075
3023
 
3024
+ ////////////////////
3025
+ // Dev Tools - Recorder
3026
+ ////////////////////
3027
+ /**
3028
+ * Use the `Browser.devtools.recorder` API to customize the Recorder panel in DevTools.
3029
+ * @since Chrome 105
3030
+ */
3031
+ export namespace devtools.recorder {
3032
+ /** A plugin interface that the Recorder panel invokes to customize the Recorder panel. */
3033
+ export interface RecorderExtensionPlugin {
3034
+ /**
3035
+ * Allows the extension to implement custom replay functionality.
3036
+ *
3037
+ * @param recording A recording of the user interaction with the page. This should match [Puppeteer's recording schema](https://github.com/puppeteer/replay/blob/main/docs/api/interfaces/Schema.UserFlow.md).
3038
+ * @since Chrome 112
3039
+ */
3040
+ replay?(recording: object): void;
3041
+
3042
+ /**
3043
+ * Converts a recording from the Recorder panel format into a string.
3044
+ * @param recording A recording of the user interaction with the page. This should match [Puppeteer's recording schema](https://github.com/puppeteer/replay/blob/main/docs/api/interfaces/Schema.UserFlow.md).
3045
+ */
3046
+ stringify?(recording: object): void;
3047
+
3048
+ /**
3049
+ * Converts a step of the recording from the Recorder panel format into a string.
3050
+ * @param step A step of the recording of a user interaction with the page. This should match [Puppeteer's step schema](https://github.com/puppeteer/replay/blob/main/docs/api/modules/Schema.md#step).
3051
+ */
3052
+ stringifyStep?(step: object): void;
3053
+ }
3054
+
3055
+ /**
3056
+ * Represents a view created by extension to be embedded inside the Recorder panel.
3057
+ * @since Chrome 112
3058
+ */
3059
+ export interface RecorderView {
3060
+ /** Fired when the view is hidden. */
3061
+ onHidden: events.Event<() => void>;
3062
+ /** Fired when the view is shown. */
3063
+ onShown: events.Event<() => void>;
3064
+ /** Indicates that the extension wants to show this view in the Recorder panel. */
3065
+ show(): void;
3066
+ }
3067
+
3068
+ /**
3069
+ * Creates a view that can handle the replay. This view will be embedded inside the Recorder panel.
3070
+ * @param title Title that is displayed next to the extension icon in the Developer Tools toolbar.
3071
+ * @param pagePath Path of the panel's HTML page relative to the extension directory.
3072
+ * @since Chrome 112
3073
+ */
3074
+ export function createView(title: string, pagePath: string): RecorderView;
3075
+
3076
+ /**
3077
+ * Registers a Recorder extension plugin.
3078
+ * @param plugin An instance implementing the RecorderExtensionPlugin interface.
3079
+ * @param name The name of the plugin.
3080
+ * @param mediaType The media type of the string content that the plugin produces.
3081
+ */
3082
+ export function registerRecorderExtensionPlugin(
3083
+ plugin: RecorderExtensionPlugin,
3084
+ name: string,
3085
+ mediaType: string,
3086
+ ): void;
3087
+ }
3088
+
3076
3089
  ////////////////////
3077
3090
  // Document Scan
3078
3091
  ////////////////////
@@ -9798,32 +9811,6 @@ export namespace Browser {
9798
9811
  export function updateContentScripts(scripts: RegisteredContentScript[], callback: () => void): void;
9799
9812
  }
9800
9813
 
9801
- ////////////////////
9802
- // Script Badge
9803
- ////////////////////
9804
- export namespace scriptBadge {
9805
- export interface GetPopupDetails {
9806
- tabId: number;
9807
- }
9808
-
9809
- export interface AttentionDetails {
9810
- tabId: number;
9811
- }
9812
-
9813
- export interface SetPopupDetails {
9814
- tabId: number;
9815
- popup: string;
9816
- }
9817
-
9818
- export interface ScriptBadgeClickedEvent extends Browser.events.Event<(tab: Browser.tabs.Tab) => void> {}
9819
-
9820
- export function getPopup(details: GetPopupDetails, callback: Function): void;
9821
- export function getAttention(details: AttentionDetails): void;
9822
- export function setPopup(details: SetPopupDetails): void;
9823
-
9824
- export var onClicked: ScriptBadgeClickedEvent;
9825
- }
9826
-
9827
9814
  ////////////////////
9828
9815
  // Sessions
9829
9816
  ////////////////////
@@ -12382,133 +12369,143 @@ export namespace Browser {
12382
12369
  // Text to Speech
12383
12370
  ////////////////////
12384
12371
  /**
12385
- * Use the `Browser.tts` API to play synthesized text-to-speech (TTS). See also the related ttsEngine API, which allows an extension to implement a speech engine.
12372
+ * Use the `Browser.tts` API to play synthesized text-to-speech (TTS). See also the related {@link ttsEngine} API, which allows an extension to implement a speech engine.
12386
12373
  *
12387
12374
  * Permissions: "tts"
12388
12375
  */
12389
12376
  export namespace tts {
12377
+ /** @since Chrome 54 */
12378
+ export enum EventType {
12379
+ START = "start",
12380
+ END = "end",
12381
+ WORD = "word",
12382
+ SENTENCE = "sentence",
12383
+ MARKER = "marker",
12384
+ INTERRUPTED = "interrupted",
12385
+ CANCELLED = "cancelled",
12386
+ ERROR = "error",
12387
+ PAUSE = "pause",
12388
+ RESUME = "resume",
12389
+ }
12390
+
12390
12391
  /** An event from the TTS engine to communicate the status of an utterance. */
12391
12392
  export interface TtsEvent {
12392
- /** Optional. The index of the current character in the utterance. */
12393
- charIndex?: number | undefined;
12394
- /** Optional. The error description, if the event type is 'error'. */
12395
- errorMessage?: string | undefined;
12393
+ /** The index of the current character in the utterance. For word events, the event fires at the end of one word and before the beginning of the next. The `charIndex` represents a point in the text at the beginning of the next word to be spoken. */
12394
+ charIndex?: number;
12395
+ /** The error description, if the event type is `error`. */
12396
+ errorMessage?: string;
12396
12397
  /**
12397
- * The length of the next part of the utterance.
12398
- * For example, in a word event, this is the length of the word which will be spoken next.
12399
- * It will be set to -1 if not set by the speech engine.
12398
+ * The length of the next part of the utterance. For example, in a `word` event, this is the length of the word which will be spoken next. It will be set to -1 if not set by the speech engine.
12399
+ * @since Chrome 74
12400
12400
  */
12401
- length?: number | undefined;
12401
+ length?: number;
12402
+ /** The type can be `start` as soon as speech has started, `word` when a word boundary is reached, `sentence` when a sentence boundary is reached, `marker` when an SSML mark element is reached, `end` when the end of the utterance is reached, `interrupted` when the utterance is stopped or interrupted before reaching the end, `cancelled` when it's removed from the queue before ever being synthesized, or `error` when any other error occurs. When pausing speech, a `pause` event is fired if a particular utterance is paused in the middle, and `resume` if an utterance resumes speech. Note that pause and resume events may not fire if speech is paused in-between utterances. */
12403
+ type: `${EventType}`;
12404
+ }
12405
+
12406
+ /**
12407
+ * The speech options for the TTS engine.
12408
+ * @since Chrome 77
12409
+ */
12410
+ export interface TtsOptions {
12411
+ /** The TTS event types that you are interested in listening to. If missing, all event types may be sent. */
12412
+ desiredEventTypes?: string[];
12413
+ /** If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance. */
12414
+ enqueue?: boolean;
12415
+ /** The extension ID of the speech engine to use, if known. */
12416
+ extensionId?: string;
12417
+ /**
12418
+ * Gender of voice for synthesized speech.
12419
+ * @deprecated since Chrome 77. Gender is deprecated and will be ignored.
12420
+ */
12421
+ gender?: `${VoiceGender}`;
12422
+ /** The language to be used for synthesis, in the form _language_\-_region_. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */
12423
+ lang?: string;
12424
+ /** Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch. */
12425
+ pitch?: number;
12426
+ /** Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further—for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0. */
12427
+ rate?: number;
12428
+ /** The TTS event types the voice must support. */
12429
+ requiredEventTypes?: string[];
12430
+ /** The name of the voice to use for synthesis. If empty, uses any available voice. */
12431
+ voiceName?: string;
12432
+ /** Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0. */
12433
+ volume?: number;
12402
12434
  /**
12403
- * The type can be 'start' as soon as speech has started, 'word' when a word boundary is reached, 'sentence' when a sentence boundary is reached, 'marker' when an SSML mark element is reached, 'end' when the end of the utterance is reached, 'interrupted' when the utterance is stopped or interrupted before reaching the end, 'cancelled' when it's removed from the queue before ever being synthesized, or 'error' when any other error occurs. When pausing speech, a 'pause' event is fired if a particular utterance is paused in the middle, and 'resume' if an utterance resumes speech. Note that pause and resume events may not fire if speech is paused in-between utterances.
12404
- * One of: "start", "end", "word", "sentence", "marker", "interrupted", "cancelled", "error", "pause", or "resume"
12435
+ * This function is called with events that occur in the process of speaking the utterance.
12436
+ * @param event The update event from the text-to-speech engine indicating the status of this utterance.
12405
12437
  */
12406
- type:
12407
- | "start"
12408
- | "end"
12409
- | "word"
12410
- | "sentence"
12411
- | "marker"
12412
- | "interrupted"
12413
- | "cancelled"
12414
- | "error"
12415
- | "pause"
12416
- | "resume";
12438
+ onEvent?: (
12439
+ event: TtsEvent,
12440
+ ) => void;
12417
12441
  }
12418
12442
 
12419
12443
  /** A description of a voice available for speech synthesis. */
12420
12444
  export interface TtsVoice {
12421
- /** Optional. The language that this voice supports, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */
12422
- lang?: string | undefined;
12445
+ /** All of the callback event types that this voice is capable of sending. */
12446
+ eventTypes?: `${EventType}`[];
12447
+ /** The ID of the extension providing this voice. */
12448
+ extensionId?: string;
12423
12449
  /**
12424
- * Optional. This voice's gender.
12425
- * One of: "male", or "female"
12450
+ * This voice's gender.
12426
12451
  * @deprecated since Chrome 70. Gender is deprecated and will be ignored.
12427
12452
  */
12428
- gender?: string | undefined;
12429
- /** Optional. The name of the voice. */
12430
- voiceName?: string | undefined;
12431
- /** Optional. The ID of the extension providing this voice. */
12432
- extensionId?: string | undefined;
12433
- /** Optional. All of the callback event types that this voice is capable of sending. */
12434
- eventTypes?: string[] | undefined;
12435
- /**
12436
- * Optional. If true, the synthesis engine is a remote network resource. It may be higher latency and may incur bandwidth costs.
12437
- * @since Chrome 33
12438
- */
12439
- remote?: boolean | undefined;
12453
+ gender?: `${VoiceGender}`;
12454
+ /** The language that this voice supports, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */
12455
+ lang?: string;
12456
+ /** If true, the synthesis engine is a remote network resource. It may be higher latency and may incur bandwidth costs. */
12457
+ remote?: boolean;
12458
+ /** The name of the voice. */
12459
+ voiceName?: string;
12440
12460
  }
12441
12461
 
12442
- export interface SpeakOptions {
12443
- /** Optional. Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0. */
12444
- volume?: number | undefined;
12445
- /**
12446
- * Optional.
12447
- * If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance.
12448
- */
12449
- enqueue?: boolean | undefined;
12450
- /**
12451
- * Optional.
12452
- * Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further—for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0.
12453
- */
12454
- rate?: number | undefined;
12455
- /**
12456
- * Optional. This function is called with events that occur in the process of speaking the utterance.
12457
- * @param event The update event from the text-to-speech engine indicating the status of this utterance.
12458
- */
12459
- onEvent?: ((event: TtsEvent) => void) | undefined;
12460
- /**
12461
- * Optional.
12462
- * Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch.
12463
- */
12464
- pitch?: number | undefined;
12465
- /** Optional. The language to be used for synthesis, in the form language-region. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'. */
12466
- lang?: string | undefined;
12467
- /** Optional. The name of the voice to use for synthesis. If empty, uses any available voice. */
12468
- voiceName?: string | undefined;
12469
- /** Optional. The extension ID of the speech engine to use, if known. */
12470
- extensionId?: string | undefined;
12471
- /**
12472
- * Optional. Gender of voice for synthesized speech.
12473
- * One of: "male", or "female"
12474
- */
12475
- gender?: string | undefined;
12476
- /** Optional. The TTS event types the voice must support. */
12477
- requiredEventTypes?: string[] | undefined;
12478
- /** Optional. The TTS event types that you are interested in listening to. If missing, all event types may be sent. */
12479
- desiredEventTypes?: string[] | undefined;
12462
+ /** @deprecated since Chrome 70. Gender is deprecated and is ignored.*/
12463
+ export enum VoiceGender {
12464
+ FEMALE = "female",
12465
+ MALE = "male",
12480
12466
  }
12481
12467
 
12482
- /** Checks whether the engine is currently speaking. On Mac OS X, the result is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome. */
12483
- export function isSpeaking(callback?: (speaking: boolean) => void): void;
12484
- /** Stops any current speech and flushes the queue of any pending utterances. In addition, if speech was paused, it will now be un-paused for the next call to speak. */
12485
- export function stop(): void;
12486
- /** Gets an array of all available voices. */
12468
+ /**
12469
+ * Gets an array of all available voices.
12470
+ *
12471
+ * Can return its result via Promise since Chrome Chrome 101
12472
+ */
12487
12473
  export function getVoices(): Promise<TtsVoice[]>;
12488
- export function getVoices(callback?: (voices: TtsVoice[]) => void): void;
12474
+ export function getVoices(callback: (voices: TtsVoice[]) => void): void;
12475
+
12489
12476
  /**
12490
- * Speaks text using a text-to-speech engine.
12491
- * @param utterance The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters.
12492
- * @param callback Optional. Called right away, before speech finishes. Check Browser.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback.
12477
+ * Checks whether the engine is currently speaking. On Mac OS X, the result is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome.
12478
+ *
12479
+ * Can return its result via Promise since Chrome Chrome 101
12493
12480
  */
12494
- export function speak(utterance: string, callback?: Function): void;
12481
+ export function isSpeaking(): Promise<boolean>;
12482
+ export function isSpeaking(callback: (speaking: boolean) => void): void;
12483
+
12484
+ /** Pauses speech synthesis, potentially in the middle of an utterance. A call to resume or stop will un-pause speech. */
12485
+ export function pause(): void;
12486
+
12487
+ /** If speech was paused, resumes speaking where it left off. */
12488
+ export function resume(): void;
12489
+
12495
12490
  /**
12496
12491
  * Speaks text using a text-to-speech engine.
12497
12492
  * @param utterance The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters.
12498
12493
  * @param options Optional. The speech options.
12499
- * @param callback Optional. Called right away, before speech finishes. Check Browser.runtime.lastError to make sure there were no errors. Use options.onEvent to get more detailed feedback.
12500
- */
12501
- export function speak(utterance: string, options: SpeakOptions, callback?: Function): void;
12502
- /**
12503
- * Pauses speech synthesis, potentially in the middle of an utterance. A call to resume or stop will un-pause speech.
12504
- * @since Chrome 29
12494
+
12495
+ * Can return its result via Promise since Chrome Chrome 101
12505
12496
  */
12506
- export function pause(): void;
12497
+ export function speak(utterance: string, options?: TtsOptions): Promise<void>;
12498
+ export function speak(utterance: string, callback: () => void): void;
12499
+ export function speak(utterance: string, options: TtsOptions, callback: () => void): void;
12500
+
12501
+ /** Stops any current speech and flushes the queue of any pending utterances. In addition, if speech was paused, it will now be un-paused for the next call to speak. */
12502
+ export function stop(): void;
12503
+
12507
12504
  /**
12508
- * If speech was paused, resumes speaking where it left off.
12509
- * @since Chrome 29
12505
+ * Called when the list of {@link TtsVoice} that would be returned by getVoices has changed.
12506
+ * @since Chrome 124
12510
12507
  */
12511
- export function resume(): void;
12508
+ const onVoicesChanged: Browser.events.Event<() => void>;
12512
12509
  }
12513
12510
 
12514
12511
  ////////////////////
@@ -13445,113 +13442,6 @@ export namespace Browser {
13445
13442
  export const onErrorOccurred: WebResponseErrorEvent;
13446
13443
  }
13447
13444
 
13448
- ////////////////////
13449
- // Web Store
13450
- ////////////////////
13451
- /**
13452
- * Use the Browser.webstore API to initiate app and extension installations "inline" from your site.
13453
- * @since Chrome 15
13454
- */
13455
- export namespace webstore {
13456
- /**
13457
- * @param url Optional. If you have more than one <link> tag on your page with the chrome-webstore-item relation, you can choose which item you'd like to install by passing in its URL here. If it is omitted, then the first (or only) link will be used. An exception will be thrown if the passed in URL does not exist on the page.
13458
- * @param successCallback Optional. This function is invoked when inline installation successfully completes (after the dialog is shown and the user agrees to add the item to Chrome). You may wish to use this to hide the user interface element that prompted the user to install the app or extension.
13459
- * @param failureCallback Optional. This function is invoked when inline installation does not successfully complete. Possible reasons for this include the user canceling the dialog, the linked item not being found in the store, or the install being initiated from a non-verified site.
13460
- * Parameter error: The failure detail. You may wish to inspect or log this for debugging purposes, but you should not rely on specific strings being passed back.
13461
- * Optional parameter errorCode: The error code from the stable set of possible errors.
13462
- * * Enum of the possible install results, including error codes sent back in the event that an inline installation has failed.
13463
- * * * "otherError": An uncommon, unrecognized, or unexpected error. In some cases, the readable error string can provide more information.
13464
- * * * "aborted": The operation was aborted as the requestor is no longer alive.
13465
- * * * "installInProgress": An installation of the same extension is in progress.
13466
- * * * "notPermitted": The installation is not permitted.
13467
- * * * "invalidId": Invalid Chrome Web Store item ID.
13468
- * * * "webstoreRequestError": Failed to retrieve extension metadata from the Web Store.
13469
- * * * "invalidWebstoreResponse": The extension metadata retrieved from the Web Store was invalid.
13470
- * * * "invalidManifest": An error occurred while parsing the extension manifest retrieved from the Web Store.
13471
- * * * "iconError": Failed to retrieve the extension's icon from the Web Store, or the icon was invalid.
13472
- * * * "userCanceled": The user canceled the operation.
13473
- * * * "blacklisted": The extension is blacklisted.
13474
- * * * "missingDependencies": Unsatisfied dependencies, such as shared modules.
13475
- * * * "requirementViolations": Unsatisfied requirements, such as webgl.
13476
- * * * "blockedByPolicy": The extension is blocked by management policies.
13477
- * * * "launchFeatureDisabled": The launch feature is not available.
13478
- * * * "launchUnsupportedExtensionType": The launch feature is not supported for the extension type.
13479
- * * * "launchInProgress": A launch of the same extension is in progress.
13480
- */
13481
- export function install(
13482
- url: string,
13483
- successCallback?: Function,
13484
- failureCallback?: (error: string, errorCode?: string) => void,
13485
- ): void;
13486
- /**
13487
- * @param successCallback Optional. This function is invoked when inline installation successfully completes (after the dialog is shown and the user agrees to add the item to Chrome). You may wish to use this to hide the user interface element that prompted the user to install the app or extension.
13488
- * @param failureCallback Optional. This function is invoked when inline installation does not successfully complete. Possible reasons for this include the user canceling the dialog, the linked item not being found in the store, or the install being initiated from a non-verified site.
13489
- * Parameter error: The failure detail. You may wish to inspect or log this for debugging purposes, but you should not rely on specific strings being passed back.
13490
- * Optional parameter errorCode: The error code from the stable set of possible errors.
13491
- * * Enum of the possible install results, including error codes sent back in the event that an inline installation has failed.
13492
- * * * "otherError": An uncommon, unrecognized, or unexpected error. In some cases, the readable error string can provide more information.
13493
- * * * "aborted": The operation was aborted as the requestor is no longer alive.
13494
- * * * "installInProgress": An installation of the same extension is in progress.
13495
- * * * "notPermitted": The installation is not permitted.
13496
- * * * "invalidId": Invalid Chrome Web Store item ID.
13497
- * * * "webstoreRequestError": Failed to retrieve extension metadata from the Web Store.
13498
- * * * "invalidWebstoreResponse": The extension metadata retrieved from the Web Store was invalid.
13499
- * * * "invalidManifest": An error occurred while parsing the extension manifest retrieved from the Web Store.
13500
- * * * "iconError": Failed to retrieve the extension's icon from the Web Store, or the icon was invalid.
13501
- * * * "userCanceled": The user canceled the operation.
13502
- * * * "blacklisted": The extension is blacklisted.
13503
- * * * "missingDependencies": Unsatisfied dependencies, such as shared modules.
13504
- * * * "requirementViolations": Unsatisfied requirements, such as webgl.
13505
- * * * "blockedByPolicy": The extension is blocked by management policies.
13506
- * * * "launchFeatureDisabled": The launch feature is not available.
13507
- * * * "launchUnsupportedExtensionType": The launch feature is not supported for the extension type.
13508
- * * * "launchInProgress": A launch of the same extension is in progress.
13509
- */
13510
- export function install(
13511
- successCallback: Function,
13512
- failureCallback?: (error: string, errorCode?: string) => void,
13513
- ): void;
13514
- /**
13515
- * @param failureCallback Optional. This function is invoked when inline installation does not successfully complete. Possible reasons for this include the user canceling the dialog, the linked item not being found in the store, or the install being initiated from a non-verified site.
13516
- * Parameter error: The failure detail. You may wish to inspect or log this for debugging purposes, but you should not rely on specific strings being passed back.
13517
- * Optional parameter errorCode: The error code from the stable set of possible errors.
13518
- * * Enum of the possible install results, including error codes sent back in the event that an inline installation has failed.
13519
- * * * "otherError": An uncommon, unrecognized, or unexpected error. In some cases, the readable error string can provide more information.
13520
- * * * "aborted": The operation was aborted as the requestor is no longer alive.
13521
- * * * "installInProgress": An installation of the same extension is in progress.
13522
- * * * "notPermitted": The installation is not permitted.
13523
- * * * "invalidId": Invalid Chrome Web Store item ID.
13524
- * * * "webstoreRequestError": Failed to retrieve extension metadata from the Web Store.
13525
- * * * "invalidWebstoreResponse": The extension metadata retrieved from the Web Store was invalid.
13526
- * * * "invalidManifest": An error occurred while parsing the extension manifest retrieved from the Web Store.
13527
- * * * "iconError": Failed to retrieve the extension's icon from the Web Store, or the icon was invalid.
13528
- * * * "userCanceled": The user canceled the operation.
13529
- * * * "blacklisted": The extension is blacklisted.
13530
- * * * "missingDependencies": Unsatisfied dependencies, such as shared modules.
13531
- * * * "requirementViolations": Unsatisfied requirements, such as webgl.
13532
- * * * "blockedByPolicy": The extension is blocked by management policies.
13533
- * * * "launchFeatureDisabled": The launch feature is not available.
13534
- * * * "launchUnsupportedExtensionType": The launch feature is not supported for the extension type.
13535
- * * * "launchInProgress": A launch of the same extension is in progress.
13536
- */
13537
- export function install(failureCallback?: (error: string, errorCode?: string) => void): void;
13538
-
13539
- export interface InstallationStageEvent extends Browser.events.Event<(stage: string) => void> {}
13540
-
13541
- export interface DownloadProgressEvent extends Browser.events.Event<(percentDownloaded: number) => void> {}
13542
-
13543
- /**
13544
- * Fired when an inline installation enters a new InstallStage. In order to receive notifications about this event, listeners must be registered before the inline installation begins.
13545
- * @since Chrome 35
13546
- */
13547
- export var onInstallStageChanged: InstallationStageEvent;
13548
- /**
13549
- * Fired periodically with the download progress of an inline install. In order to receive notifications about this event, listeners must be registered before the inline installation begins.
13550
- * @since Chrome 35
13551
- */
13552
- export var onDownloadProgress: DownloadProgressEvent;
13553
- }
13554
-
13555
13445
  ////////////////////
13556
13446
  // Windows
13557
13447
  ////////////////////