diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 276d56e2698436..a1e461324fb69f 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -6276,96 +6276,86 @@ declare namespace chrome { * @platform ChromeOS only */ export namespace input.ime { - /** See http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent */ + /** See https://www.w3.org/TR/uievents/#events-KeyboardEvent */ export interface KeyboardEvent { - /** - * Optional. - * Whether or not the SHIFT key is pressed. - */ + /** Whether or not the SHIFT key is pressed. */ shiftKey?: boolean | undefined; - /** - * Optional. - * Whether or not the ALT key is pressed. - */ + /** Whether or not the ALT key is pressed. */ altKey?: boolean | undefined; /** - * Optional. * Whether or not the ALTGR key is pressed. * @since Chrome 79 */ altgrKey?: boolean | undefined; /** - * Optional. - * The ID of the request. Use the requestId param from the onKeyEvent event instead. - * @deprecated since Chrome 79. + * The ID of the request + * @deprecated Use the `requestId` param from the `onKeyEvent` event instead. */ requestId?: string | undefined; - /** Value of the key being pressed */ + /** Value of the key being pressed. */ key: string; - /** - * Optional. - * Whether or not the CTRL key is pressed. - */ + /** Whether or not the CTRL key is pressed. */ ctrlKey?: boolean | undefined; /** One of keyup or keydown. */ - type: string; - /** - * Optional. - * The extension ID of the sender of this keyevent. - * @since Chrome 34 - */ + type: `${KeyboardEventType}`; + /** The extension ID of the sender of this keyevent. */ extensionId?: string | undefined; - /** - * Optional. - * Value of the physical key being pressed. The value is not affected by current keyboard layout or modifier state. - * @since Chrome 26 - */ + /** Value of the physical key being pressed. The value is not affected by current keyboard layout or modifier state. */ code: string; - /** - * Optional. - * The deprecated HTML keyCode, which is system- and implementation-dependent numerical code signifying the unmodified identifier associated with the key pressed. - * @since Chrome 37 - */ + /** The deprecated HTML keyCode, which is system- and implementation-dependent numerical code signifying the unmodified identifier associated with the key pressed. */ keyCode?: number | undefined; - /** - * Optional. - * Whether or not the CAPS_LOCK is enabled. - * @since Chrome 29 - */ + /** Whether or not the CAPS_LOCK is enabled. */ capsLock?: boolean | undefined; } + /** @since Chrome 44 */ + export enum KeyboardEventType { + KEYUP = "keyup", + KEYDOWN = "keydown", + } + /** * The auto-capitalize type of the text field. * @since Chrome 69 */ - export type AutoCapitalizeType = "characters" | "words" | "sentences"; + export enum AutoCapitalizeType { + CHARACTERS = "characters", + WORDS = "words", + SENTENCES = "sentences", + } + + /** + * Type of value this text field edits, (Text, Number, URL, etc) + * @since Chrome 44 + */ + export enum InputContextType { + TEXT = "text", + SEARCH = "search", + TEL = "tel", + URL = "url", + EMAIL = "email", + NUMBER = "number", + PASSWORD = "password", + NULL = "null", + } + /** Describes an input Context */ export interface InputContext { /** This is used to specify targets of text field operations. This ID becomes invalid as soon as onBlur is called. */ contextID: number; /** Type of value this text field edits, (Text, Number, URL, etc) */ - type: string; - /** - * Whether the text field wants auto-correct. - * @since Chrome 40 - */ + type: `${InputContextType}`; + /** Whether the text field wants auto-correct. */ autoCorrect: boolean; - /** - * Whether the text field wants auto-complete. - * @since Chrome 40 - */ + /** Whether the text field wants auto-complete. */ autoComplete: boolean; - /** - * Whether the text field wants spell-check. - * @since Chrome 40 - */ + /** Whether the text field wants spell-check. */ spellCheck: boolean; /** * The auto-capitalize type of the text field. * @since Chrome 69 */ - autoCapitalize: AutoCapitalizeType; + autoCapitalize: `${AutoCapitalizeType}`; /** * Whether text entered into the text field should be used to improve typing suggestions for the user. * @since Chrome 68 @@ -6373,18 +6363,15 @@ declare namespace chrome { shouldDoLearning: boolean; } - /** - * A menu item used by an input method to interact with the user from the language menu. - * @since Chrome 30 - */ + /** A menu item used by an input method to interact with the user from the language menu. */ export interface MenuItem { /** String that will be passed to callbacks referencing this MenuItem. */ id: string; - /** Optional. Text displayed in the menu for this item. */ + /** Text displayed in the menu for this item. */ label?: string | undefined; - /** Optional. The type of menu item. */ - style?: string | undefined; - /** Optional. Indicates this item is visible. */ + /** The type of menu item. */ + style?: `${MenuItemStyle}` | undefined; + /** Indicates this item is visible. */ visible?: boolean | undefined; /** Indicates this item should be drawn with a check. */ checked?: boolean | undefined; @@ -6392,11 +6379,14 @@ declare namespace chrome { enabled?: boolean | undefined; } - export interface ImeParameters { - /** MenuItems to use. */ - items: MenuItem[]; - /** ID of the engine to use */ - engineID: string; + /** + * The type of menu item. Radio buttons between separators are considered grouped. + * @since Chrome 44 + */ + export enum MenuItemStyle { + CHECK = "check", + RADIO = "radio", + SEPARATOR = "separator", } export interface CommitTextParameters { @@ -6418,25 +6408,13 @@ declare namespace chrome { candidate: string; /** The candidate's id */ id: number; - /** - * Optional. - * The id to add these candidates under - */ + /** The id to add these candidates under */ parentId?: number | undefined; - /** - * Optional. - * Short string displayed to next to the candidate, often the shortcut key or index - */ + /** Short string displayed to next to the candidate, often the shortcut key or index */ label?: string | undefined; - /** - * Optional. - * Additional text describing the candidate - */ + /** Additional text describing the candidate */ annotation?: string | undefined; - /** - * Optional. - * The usage or detail description of word. - */ + /** The usage or detail description of word. */ usage?: CandidateUsage | undefined; } @@ -6453,7 +6431,7 @@ declare namespace chrome { /** Index of the character to end this segment after. */ end: number; /** The type of the underline to modify this segment. */ - style: string; + style: `${UnderlineStyle}`; } export interface CompositionParameters { @@ -6461,79 +6439,111 @@ declare namespace chrome { contextID: number; /** Text to set */ text: string; - /** Optional. List of segments and their associated types. */ + /** List of segments and their associated types. */ segments?: CompositionParameterSegment[] | undefined; /** Position in the text of the cursor. */ cursor: number; - /** Optional. Position in the text that the selection starts at. */ + /** Position in the text that the selection starts at. */ selectionStart?: number | undefined; - /** Optional. Position in the text that the selection ends at. */ + /** Position in the text that the selection ends at. */ selectionEnd?: number | undefined; } - export interface MenuItemParameters { + /** @since Chrome 88 */ + export interface MenuParameters { + /** MenuItems to add or update. They will be added in the order they exist in the array. */ items: MenuItem[]; - engineId: string; + /** ID of the engine to use. */ + engineID: string; + } + + /** + * Which mouse buttons was clicked. + * @since Chrome 44 + */ + export enum MouseButton { + LEFT = "left", + MIDDLE = "middle", + RIGHT = "right", } - /** Type of the assistive window. */ - export type AssistiveWindowType = "undo"; + /** + * The screen type under which the IME is activated. + * @since Chrome 44 + */ + export enum ScreenType { + NORMAL = "normal", + LOGIN = "login", + LOCK = "lock", + SECONDARY_LOGIN = "secondary-login", + } - /** ID of a button in an assistive window. */ - export type AssistiveWindowButton = "undo" | "addToDictionary"; + /** + * The type of the underline to modify this segment. + * @since Chrome 44 + */ + export enum UnderlineStyle { + UNDERLINE = "underline", + DOUBLE_UNDERLINE = "doubleUnderline", + NO_UNDERLINE = "noUnderline", + } - /** Properties of an assistive window. */ + /** + * Where to display the candidate window. If set to 'cursor', the window follows the cursor. If set to 'composition', the window is locked to the beginning of the composition. + * @since Chrome 44 + */ + export enum WindowPosition { + CURSOR = "cursor", + COMPOSITION = "composition", + } + + /** Type of assistive window. */ + export enum AssistiveWindowType { + UNDO = "undo", + } + + /** + * ID of a button in an assistive window. + * @since Chrome 85 + */ + export enum AssistiveWindowButton { + UNDO = "undo", + ADD_TO_DICTIONARY = "addToDictionary", + } + + /** + * Properties of the assistive window. + * @since Chrome 85 + */ export interface AssistiveWindowProperties { - type: AssistiveWindowType; + type: `${AssistiveWindowType}`; + /** Sets true to show AssistiveWindow, sets false to hide. */ visible: boolean; + /** Strings for ChromeVox to announce */ announceString?: string | undefined; } export interface CandidateWindowParameterProperties { - /** - * Optional. - * True to show the cursor, false to hide it. - */ + /** True to show the cursor, false to hide it. */ cursorVisible?: boolean | undefined; - /** - * Optional. - * True if the candidate window should be rendered vertical, false to make it horizontal. - */ + /** True if the candidate window should be rendered vertical, false to make it horizontal. */ vertical?: boolean | undefined; - /** - * Optional. - * The number of candidates to display per page. - */ + /** The number of candidates to display per page. */ pageSize?: number | undefined; - /** - * Optional. - * True to display the auxiliary text, false to hide it. - */ + /** True to display the auxiliary text, false to hide it. */ auxiliaryTextVisible?: boolean | undefined; - /** - * Optional. - * Text that is shown at the bottom of the candidate window. - */ + /** Text that is shown at the bottom of the candidate window. */ auxiliaryText?: string | undefined; - /** - * Optional. - * True to show the Candidate window, false to hide it. - */ + /** True to show the Candidate window, false to hide it. */ visible?: boolean | undefined; + /** Where to display the candidate window. */ + windowPosition?: `${WindowPosition}` | undefined; /** - * Optional. - * Where to display the candidate window. - * @since Chrome 28 - */ - windowPosition?: string | undefined; - /** - * Optional. * The index of the current chosen candidate out of total candidates. * @since Chrome 84 */ currentCandidateIndex?: number | undefined; /** - * Optional. * The total number of candidates for the candidate window. * @since Chrome 84 */ @@ -6576,179 +6586,215 @@ declare namespace chrome { length: number; } + export interface AssistiveWindowButtonHighlightedParameters { + /** The text for the screenreader to announce. */ + announceString?: string | undefined; + /** The ID of the button */ + buttonID: `${AssistiveWindowButton}`; + /** ID of the context owning the assistive window. */ + contextID: number; + /** Whether the button should be highlighted. */ + highlighted: boolean; + /** The window type the button belongs to. */ + windowType: `${AssistiveWindowType}`; + } + + export interface AssistiveWindowPropertiesParameters { + /** ID of the context owning the assistive window. */ + contextID: number; + /** Properties of the assistive window. */ + properties: AssistiveWindowProperties; + } + export interface SurroundingTextInfo { - /** The text around cursor. */ + /** The text around the cursor. This is only a subset of all text in the input field. */ text: string; /** The ending position of the selection. This value indicates caret position if there is no selection. */ focus: number; - /** The beginning position of the selection. This value indicates caret position if is no selection. */ + /** + * The offset position of `text`. Since `text` only includes a subset of text around the cursor, offset indicates the absolute position of the first character of `text`. + * @since Chrome 46 + */ + offset: number; + /** The beginning position of the selection. This value indicates caret position if there is no selection. */ anchor: number; } export interface AssistiveWindowButtonClickedDetails { /** The ID of the button clicked. */ - buttonID: AssistiveWindowButton; + buttonID: `${AssistiveWindowButton}`; /** The type of the assistive window. */ - windowType: AssistiveWindowType; + windowType: `${AssistiveWindowType}`; } - export interface BlurEvent extends chrome.events.Event<(contextID: number) => void> {} - - export interface AssistiveWindowButtonClickedEvent - extends chrome.events.Event<(details: AssistiveWindowButtonClickedDetails) => void> - {} - - export interface CandidateClickedEvent - extends chrome.events.Event<(engineID: string, candidateID: number, button: string) => void> - {} - - export interface KeyEventEvent - extends chrome.events.Event<(engineID: string, keyData: KeyboardEvent, requestId: string) => void> - {} - - export interface DeactivatedEvent extends chrome.events.Event<(engineID: string) => void> {} - - export interface InputContextUpdateEvent extends chrome.events.Event<(context: InputContext) => void> {} - - export interface ActivateEvent extends chrome.events.Event<(engineID: string, screen: string) => void> {} - - export interface FocusEvent extends chrome.events.Event<(context: InputContext) => void> {} - - export interface MenuItemActivatedEvent extends chrome.events.Event<(engineID: string, name: string) => void> {} - - export interface SurroundingTextChangedEvent - extends chrome.events.Event<(engineID: string, surroundingInfo: SurroundingTextInfo) => void> - {} - - export interface InputResetEvent extends chrome.events.Event<(engineID: string) => void> {} - /** * Adds the provided menu items to the language menu when this IME is active. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ - export function setMenuItems(parameters: ImeParameters, callback?: () => void): void; + export function setMenuItems(parameters: MenuParameters): Promise; + export function setMenuItems(parameters: MenuParameters, callback: () => void): void; + /** * Commits the provided text to the current input. - * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ - export function commitText(parameters: CommitTextParameters, callback?: (success: boolean) => void): void; + export function commitText(parameters: CommitTextParameters): Promise; + export function commitText(parameters: CommitTextParameters, callback: (success: boolean) => void): void; + /** * Sets the current candidate list. This fails if this extension doesn't own the active IME - * @param callback Called when the operation completes. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ - export function setCandidates(parameters: CandidatesParameters, callback?: (success: boolean) => void): void; + export function setCandidates(parameters: CandidatesParameters): Promise; + export function setCandidates(parameters: CandidatesParameters, callback: (success: boolean) => void): void; + /** * Set the current composition. If this extension does not own the active IME, this fails. - * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ - export function setComposition(parameters: CompositionParameters, callback?: (success: boolean) => void): void; + export function setComposition(parameters: CompositionParameters): Promise; + export function setComposition(parameters: CompositionParameters, callback: (success: boolean) => void): void; + /** * Updates the state of the MenuItems specified - * @param callback Called when the operation completes + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ - export function updateMenuItems(parameters: MenuItemParameters, callback?: () => void): void; + export function updateMenuItems(parameters: MenuParameters): Promise; + export function updateMenuItems(parameters: MenuParameters, callback: () => void): void; + /** * Shows/Hides an assistive window with the given properties. - * @param parameters - * @param callback Called when the operation completes. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ export function setAssistiveWindowProperties( - parameters: { - contextID: number; - properties: chrome.input.ime.AssistiveWindowProperties; - }, - callback?: (success: boolean) => void, + parameters: AssistiveWindowPropertiesParameters, + ): Promise; + export function setAssistiveWindowProperties( + parameters: AssistiveWindowPropertiesParameters, + callback: (success: boolean) => void, ): void; + /** * Highlights/Unhighlights a button in an assistive window. - * @param parameters - * @param callback Called when the operation completes. On failure, chrome.runtime.lastError is set. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ export function setAssistiveWindowButtonHighlighted( - parameters: { - contextID: number; - buttonID: chrome.input.ime.AssistiveWindowButton; - windowType: chrome.input.ime.AssistiveWindowType; - announceString?: string | undefined; - highlighted: boolean; - }, - callback?: () => void, + parameters: AssistiveWindowButtonHighlightedParameters, + ): Promise; + export function setAssistiveWindowButtonHighlighted( + parameters: AssistiveWindowButtonHighlightedParameters, + callback: () => void, ): void; + /** * Sets the properties of the candidate window. This fails if the extension doesn't own the active IME - * @param callback Called when the operation completes. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ + export function setCandidateWindowProperties(parameters: CandidateWindowParameter): Promise; export function setCandidateWindowProperties( parameters: CandidateWindowParameter, - callback?: (success: boolean) => void, + callback: (success: boolean) => void, ): void; + /** * Clear the current composition. If this extension does not own the active IME, this fails. - * @param callback Called when the operation completes with a boolean indicating if the text was accepted or not. On failure, chrome.runtime.lastError is set. + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ + export function clearComposition(parameters: ClearCompositionParameters): Promise; export function clearComposition( parameters: ClearCompositionParameters, - callback?: (success: boolean) => void, + callback: (success: boolean) => void, ): void; + /** * Set the position of the cursor in the candidate window. This is a no-op if this extension does not own the active IME. - * @param callback Called when the operation completes + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ export function setCursorPosition( parameters: CursorPositionParameters, - callback?: (success: boolean) => void, + ): Promise; + export function setCursorPosition( + parameters: CursorPositionParameters, + callback: (success: boolean) => void, ): void; + /** * Sends the key events. This function is expected to be used by virtual keyboards. When key(s) on a virtual keyboard is pressed by a user, this function is used to propagate that event to the system. - * @since Chrome 33 - * @param callback Called when the operation completes. - */ - export function sendKeyEvents(parameters: SendKeyEventParameters, callback?: () => void): void; - /** - * Hides the input view window, which is popped up automatically by system. If the input view window is already hidden, this function will do nothing. - * @since Chrome 34 + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ + export function sendKeyEvents(parameters: SendKeyEventParameters): Promise; + export function sendKeyEvents(parameters: SendKeyEventParameters, callback: () => void): void; + + /** Hides the input view window, which is popped up automatically by system. If the input view window is already hidden, this function will do nothing. */ export function hideInputView(): void; + /** * Deletes the text around the caret. - * @since Chrome 27 + * + * Can return its result via Promise in Manifest V3 or later since Chrome 111. */ - export function deleteSurroundingText(parameters: DeleteSurroundingTextParameters, callback?: () => void): void; + export function deleteSurroundingText(parameters: DeleteSurroundingTextParameters): Promise; + export function deleteSurroundingText(parameters: DeleteSurroundingTextParameters, callback: () => void): void; + /** * Indicates that the key event received by onKeyEvent is handled. This should only be called if the onKeyEvent listener is asynchronous. - * @since Chrome 25 * @param requestId Request id of the event that was handled. This should come from keyEvent.requestId * @param response True if the keystroke was handled, false if not */ export function keyEventHandled(requestId: string, response: boolean): void; /** This event is sent when focus leaves a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ - export var onBlur: BlurEvent; - /** This event is sent when a button in an assistive window is clicked. */ - export var onAssistiveWindowButtonClicked: AssistiveWindowButtonClickedEvent; - /** This event is sent if this extension owns the active IME. */ - export var onCandidateClicked: CandidateClickedEvent; + export const onBlur: events.Event<(contextID: number) => void>; + + /** + * This event is sent when a button in an assistive window is clicked. + * @since Chrome 85 + */ + export const onAssistiveWindowButtonClicked: events.Event< + (details: AssistiveWindowButtonClickedDetails) => void + >; + /** This event is sent if this extension owns the active IME. */ - export var onKeyEvent: KeyEventEvent; + export const onCandidateClicked: events.Event< + (engineID: string, candidateID: number, button: `${MouseButton}`) => void + >; + + /** Fired when a key event is sent from the operating system. The event will be sent to the extension if this extension owns the active IME. The listener function should return true if the event was handled false if it was not. If the event will be evaluated asynchronously, this function must return undefined and the IME must later call keyEventHandled() with the result. */ + export const onKeyEvent: events.Event<(engineID: string, keyData: KeyboardEvent, requestId: string) => void>; + /** This event is sent when an IME is deactivated. It signals that the IME will no longer be receiving onKeyPress events. */ - export var onDeactivated: DeactivatedEvent; - /** This event is sent when the properties of the current InputContext change, such as the type. It is sent to all extensions that are listening to this event, and enabled by the user. */ - export var onInputContextUpdate: InputContextUpdateEvent; + export const onDeactivated: events.Event<(engineID: string) => void>; + + /** This event is sent when the properties of the current InputContext change, such as the the type. It is sent to all extensions that are listening to this event, and enabled by the user. */ + export const onInputContextUpdate: events.Event<(context: InputContext) => void>; + /** This event is sent when an IME is activated. It signals that the IME will be receiving onKeyPress events. */ - export var onActivate: ActivateEvent; - /** This event is sent when focus enters a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ - export var onFocus: FocusEvent; + export const onActivate: events.Event<(engineID: string, screen: `${ScreenType}`) => void>; + + // /** This event is sent when focus enters a text box. It is sent to all extensions that are listening to this event, and enabled by the user. */ + export const onFocus: events.Event<(context: InputContext) => void>; + /** Called when the user selects a menu item */ - export var onMenuItemActivated: MenuItemActivatedEvent; - /** - * Called when the editable string around caret is changed or when the caret position is moved. The text length is limited to 100 characters for each back and forth direction. - * @since Chrome 27 - */ - export var onSurroundingTextChanged: SurroundingTextChangedEvent; - /** - * This event is sent when chrome terminates ongoing text input session. - * @since Chrome 29 - */ - export var onReset: InputResetEvent; + export const onMenuItemActivated: events.Event<(engineID: string, name: string) => void>; + + /** Called when the editable string around caret is changed or when the caret position is moved. The text length is limited to 100 characters for each back and forth direction. */ + export const onSurroundingTextChanged: events.Event< + (engineID: string, surroundingInfo: SurroundingTextInfo) => void + >; + + /** This event is sent when chrome terminates ongoing text input session. */ + export const onReset: events.Event<(engineID: string) => void>; } //////////////////// @@ -10069,14 +10115,13 @@ declare namespace chrome { availableCapacity: number; } - /** Get physical memory information. */ - export function getInfo(callback: (info: MemoryInfo) => void): void; - /** * Get physical memory information. - * @return The `getInfo` method provides its result via callback or returned as a `Promise` (MV3 only). + * + * Can return its result via Promise in Manifest V3 or later since Chrome 91. */ export function getInfo(): Promise; + export function getInfo(callback: (info: MemoryInfo) => void): void; } //////////////////// diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index e00fecb4a8d12e..36ef816789d1d3 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -1535,36 +1535,321 @@ function testDevtoolsNetwork() { }); } -function testAssistiveWindow() { - chrome.input.ime.setAssistiveWindowProperties({ - contextID: 0, +// https://developer.chrome.com/docs/extensions/reference/api/input/ime +function testInputIme() { + chrome.input.ime.AssistiveWindowButton.ADD_TO_DICTIONARY === "addToDictionary"; + chrome.input.ime.AssistiveWindowButton.UNDO === "undo"; + + chrome.input.ime.AssistiveWindowType.UNDO === "undo"; + + chrome.input.ime.AutoCapitalizeType.CHARACTERS === "characters"; + chrome.input.ime.AutoCapitalizeType.SENTENCES === "sentences"; + chrome.input.ime.AutoCapitalizeType.WORDS === "words"; + + chrome.input.ime.InputContextType.EMAIL === "email"; + chrome.input.ime.InputContextType.NULL === "null"; + chrome.input.ime.InputContextType.NUMBER === "number"; + chrome.input.ime.InputContextType.PASSWORD === "password"; + chrome.input.ime.InputContextType.SEARCH === "search"; + chrome.input.ime.InputContextType.TEL === "tel"; + chrome.input.ime.InputContextType.TEXT === "text"; + chrome.input.ime.InputContextType.URL === "url"; + + chrome.input.ime.KeyboardEventType.KEYDOWN === "keydown"; + chrome.input.ime.KeyboardEventType.KEYUP === "keyup"; + + chrome.input.ime.MenuItemStyle.CHECK === "check"; + chrome.input.ime.MenuItemStyle.RADIO === "radio"; + chrome.input.ime.MenuItemStyle.SEPARATOR === "separator"; + + chrome.input.ime.MouseButton.LEFT === "left"; + chrome.input.ime.MouseButton.MIDDLE === "middle"; + chrome.input.ime.MouseButton.RIGHT === "right"; + + chrome.input.ime.ScreenType.LOCK === "lock"; + chrome.input.ime.ScreenType.LOGIN === "login"; + chrome.input.ime.ScreenType.NORMAL === "normal"; + chrome.input.ime.ScreenType.SECONDARY_LOGIN === "secondary-login"; + + chrome.input.ime.UnderlineStyle.DOUBLE_UNDERLINE === "doubleUnderline"; + chrome.input.ime.UnderlineStyle.NO_UNDERLINE === "noUnderline"; + chrome.input.ime.UnderlineStyle.UNDERLINE === "underline"; + + chrome.input.ime.WindowPosition.COMPOSITION === "composition"; + chrome.input.ime.WindowPosition.CURSOR === "cursor"; + + const contextID = 0; + + const clearCompositionParameters: chrome.input.ime.ClearCompositionParameters = { + contextID, + }; + + chrome.input.ime.clearComposition(clearCompositionParameters); // $ExpectType Promise + chrome.input.ime.clearComposition(clearCompositionParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean + }); + // @ts-expect-error + chrome.input.ime.clearComposition(clearCompositionParameters, () => {}).then(() => {}); + + const commitTextParameters: chrome.input.ime.CommitTextParameters = { + contextID, + text: "text", + }; + + chrome.input.ime.commitText(commitTextParameters); // $ExpectType Promise + chrome.input.ime.commitText(commitTextParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean + }); + // @ts-expect-error + chrome.input.ime.commitText(commitTextParameters, () => {}).then(() => {}); + + const deleteSurroundingTextParameters: chrome.input.ime.DeleteSurroundingTextParameters = { + contextID, + engineID: "engineID", + length: 1, + offset: 1, + }; + + chrome.input.ime.deleteSurroundingText(deleteSurroundingTextParameters); // $ExpectType Promise + chrome.input.ime.deleteSurroundingText(deleteSurroundingTextParameters, () => void 0); // $ExpectType void + // @ts-expect-error + chrome.input.ime.deleteSurroundingText(deleteSurroundingTextParameters, () => {}).then(() => {}); + + chrome.input.ime.hideInputView(); // $ExpectType void + + chrome.input.ime.keyEventHandled("requestId", true); // $ExpectType void + + const sendKeyEventsParameters: chrome.input.ime.SendKeyEventParameters = { + contextID, + keyData: [ + { + altKey: false, + altgrKey: false, + capsLock: false, + code: "KeyA", + ctrlKey: false, + extensionId: "extensionId", + key: "a", + keyCode: 65, + requestId: "requestId", + shiftKey: false, + type: "keyup", + }, + ], + }; + + chrome.input.ime.sendKeyEvents(sendKeyEventsParameters); // $ExpectType Promise + chrome.input.ime.sendKeyEvents(sendKeyEventsParameters, () => void 0); // $ExpectType void + // @ts-expect-error + chrome.input.ime.sendKeyEvents(sendKeyEventsParameters, () => {}).then(() => {}); + + const setAssistiveWindowButtonHighlightedParameters: chrome.input.ime.AssistiveWindowButtonHighlightedParameters = { + announceString: "announceString", + contextID, + buttonID: "undo", + highlighted: true, + windowType: "undo", + }; + + chrome.input.ime.setAssistiveWindowButtonHighlighted(setAssistiveWindowButtonHighlightedParameters); // $ExpectType Promise + chrome.input.ime.setAssistiveWindowButtonHighlighted(setAssistiveWindowButtonHighlightedParameters, () => void 0); // $ExpectType void + // @ts-expect-error + chrome.input.ime.setAssistiveWindowButtonHighlighted(setAssistiveWindowButtonHighlightedParameters, () => {}).then( + () => {}, + ); + + const setAssistiveWindowPropertiesParameters: chrome.input.ime.AssistiveWindowPropertiesParameters = { + contextID, properties: { + announceString: "announceString", type: "undo", visible: true, }, - }); + }; - chrome.input.ime.setAssistiveWindowButtonHighlighted({ - contextID: 0, - buttonID: "undo", - windowType: "undo", - announceString: "Undo button highlighted", - highlighted: true, + chrome.input.ime.setAssistiveWindowProperties(setAssistiveWindowPropertiesParameters); // $ExpectType Promise + chrome.input.ime.setAssistiveWindowProperties(setAssistiveWindowPropertiesParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean }); + // @ts-expect-error + chrome.input.ime.setAssistiveWindowProperties(setAssistiveWindowPropertiesParameters, () => {}).then(() => {}); - chrome.input.ime.setAssistiveWindowButtonHighlighted({ - contextID: 0, - buttonID: "undo", - windowType: "undo", - highlighted: false, + const setCandidatesParameters: chrome.input.ime.CandidatesParameters = { + contextID, + candidates: [ + { + annotation: "annotation", + candidate: "candidate", + id: 0, + label: "label", + parentId: 0, + usage: { + body: "body", + title: "title", + }, + }, + ], + }; + + chrome.input.ime.setCandidates(setCandidatesParameters); // $ExpectType Promise + chrome.input.ime.setCandidates(setCandidatesParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean }); + // @ts-expect-error + chrome.input.ime.setCandidates(setCandidatesParameters, () => {}).then(() => {}); - chrome.input.ime.onAssistiveWindowButtonClicked.addListener( - (details: chrome.input.ime.AssistiveWindowButtonClickedDetails) => { - details; - console.log(`${details.buttonID} button in ${details.windowType} window clicked`); + const setCandidateWindowPropertiesParameters: chrome.input.ime.CandidateWindowParameter = { + engineID: "engineID", + properties: { + auxiliaryText: "auxiliaryText", + auxiliaryTextVisible: true, + currentCandidateIndex: 0, + cursorVisible: true, + pageSize: 5, + totalCandidates: 10, + vertical: true, + visible: true, + windowPosition: "composition", }, - ); + }; + + chrome.input.ime.setCandidateWindowProperties(setCandidateWindowPropertiesParameters); // $ExpectType Promise + chrome.input.ime.setCandidateWindowProperties(setCandidateWindowPropertiesParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean + }); + // @ts-expect-error + chrome.input.ime.setCandidateWindowProperties(setCandidateWindowPropertiesParameters, () => {}).then(() => {}); + + const setCompositionParameters: chrome.input.ime.CompositionParameters = { + contextID, + cursor: 1, + segments: [{ + end: 1, + start: 2, + style: "underline", + }], + selectionEnd: 2, + selectionStart: 1, + text: "text", + }; + + chrome.input.ime.setComposition(setCompositionParameters); // $ExpectType Promise + chrome.input.ime.setComposition(setCompositionParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean + }); + // @ts-expect-error + chrome.input.ime.setComposition(setCompositionParameters, () => {}).then(() => {}); + + const setCursorPositionParameters: chrome.input.ime.CursorPositionParameters = { + candidateID: 1, + contextID, + }; + + chrome.input.ime.setCursorPosition(setCursorPositionParameters); // $ExpectType Promise + chrome.input.ime.setCursorPosition(setCursorPositionParameters, (success) => { // $ExpectType void + success; // $ExpectType boolean + }); + // @ts-expect-error + chrome.input.ime.setCursorPosition(setCursorPositionParameters, () => {}).then(() => {}); + + const menuParameters: chrome.input.ime.MenuParameters = { + engineID: "engineID", + items: [{ + checked: true, + enabled: true, + id: "id", + label: "label", + style: "check", + visible: true, + }], + }; + + chrome.input.ime.setMenuItems(menuParameters); // $ExpectType Promise + chrome.input.ime.setMenuItems(menuParameters, () => void 0); // $ExpectType void + // @ts-expect-error + chrome.input.ime.setMenuItems(menuParameters, () => {}).then(() => {}); + + chrome.input.ime.updateMenuItems(menuParameters); // $ExpectType Promise + chrome.input.ime.updateMenuItems(menuParameters, () => void 0); // $ExpectType void + // @ts-expect-error + chrome.input.ime.updateMenuItems(menuParameters, () => {}).then(() => {}); + + checkChromeEvent(chrome.input.ime.onActivate, (engineID, screen) => { + engineID; // $ExpectType string + screen; // $ExpectType "normal" | "login" | "lock" | "secondary-login" + }); + + checkChromeEvent(chrome.input.ime.onAssistiveWindowButtonClicked, (details) => { + details.buttonID; // $ExpectType "undo" | "addToDictionary" + details.windowType; // $ExpectType "undo" + }); + + checkChromeEvent(chrome.input.ime.onBlur, (contextID) => { + contextID; // $ExpectType number + }); + + checkChromeEvent(chrome.input.ime.onCandidateClicked, (engineID, candidateID, button) => { + engineID; // $ExpectType string + candidateID; // $ExpectType number + button; // $ExpectType "left" | "middle" | "right" + }); + + checkChromeEvent(chrome.input.ime.onDeactivated, (engineID) => { + engineID; // $ExpectType string + }); + + checkChromeEvent(chrome.input.ime.onFocus, (context) => { + context.autoCapitalize; // $ExpectType "characters" | "words" | "sentences" + context.autoComplete; // $ExpectType boolean + context.autoCorrect; // $ExpectType boolean + context.contextID; // $ExpectType number + context.shouldDoLearning; // $ExpectType boolean + context.spellCheck; // $ExpectType boolean + context.type; // $ExpectType "text" | "search" | "tel" | "url" | "email" | "number" | "password" | "null" + }); + + checkChromeEvent(chrome.input.ime.onInputContextUpdate, (context) => { + context.autoCapitalize; // $ExpectType "characters" | "words" | "sentences" + context.autoComplete; // $ExpectType boolean + context.autoCorrect; // $ExpectType boolean + context.contextID; // $ExpectType number + context.shouldDoLearning; // $ExpectType boolean + context.spellCheck; // $ExpectType boolean + context.type; // $ExpectType "text" | "search" | "tel" | "url" | "email" | "number" | "password" | "null" + }); + + checkChromeEvent(chrome.input.ime.onKeyEvent, (engineID, keyData, requestId) => { + engineID; // $ExpectType string + keyData.altKey; // $ExpectType boolean | undefined + keyData.altgrKey; // $ExpectType boolean | undefined + keyData.capsLock; // $ExpectType boolean | undefined + keyData.code; // $ExpectType string + keyData.ctrlKey; // $ExpectType boolean | undefined + keyData.extensionId; // $ExpectType string | undefined + keyData.key; // $ExpectType string + keyData.keyCode; // $ExpectType number | undefined + keyData.shiftKey; // $ExpectType boolean | undefined + keyData.type; // $ExpectType "keydown" | "keyup" + requestId; // $ExpectType string + return true; + }); + + checkChromeEvent(chrome.input.ime.onMenuItemActivated, (engineID, name) => { + engineID; // $ExpectType string + name; // $ExpectType string + }); + + checkChromeEvent(chrome.input.ime.onReset, (engineID) => { + engineID; // $ExpectType string + }); + + checkChromeEvent(chrome.input.ime.onSurroundingTextChanged, (engineID, surroundingInfo) => { + engineID; // $ExpectType string + surroundingInfo.anchor; // $ExpectType number + surroundingInfo.focus; // $ExpectType number + surroundingInfo.offset; // $ExpectType number + surroundingInfo.text; // $ExpectType string + }); } // https://developer.chrome.com/docs/extensions/reference/api/omnibox @@ -2654,6 +2939,17 @@ async function testSystemDisplay() { checkChromeEvent(chrome.system.display.onDisplayChanged, () => void 0); } +// https://developer.chrome.com/docs/extensions/reference/api/system/memory +function testSystemMemory() { + chrome.system.memory.getInfo(); // $ExpectType Promise + chrome.system.memory.getInfo((info) => { // $ExpectType void + info.availableCapacity; // $ExpectType number + info.capacity; // $ExpectType number + }); + // @ts-expect-error + chrome.system.memory.getInfo(() => {}).then(() => {}); +} + // https://developer.chrome.com/docs/extensions/reference/api/systemLog function testSystemLog() { chrome.systemLog.add({ message: "" }); // $ExpectType Promise