@types/chrome 0.1.9 → 0.1.10

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.
Files changed (3) hide show
  1. chrome/README.md +1 -1
  2. chrome/index.d.ts +164 -218
  3. chrome/package.json +2 -2
chrome/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for chrome (https://developer.chrome.com/
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Mon, 08 Sep 2025 17:34:26 GMT
11
+ * Last updated: Fri, 12 Sep 2025 19:02:26 GMT
12
12
  * Dependencies: [@types/filesystem](https://npmjs.com/package/@types/filesystem), [@types/har-format](https://npmjs.com/package/@types/har-format)
13
13
 
14
14
  # Credits
chrome/index.d.ts CHANGED
@@ -377,120 +377,76 @@ declare namespace chrome {
377
377
  */
378
378
  export namespace alarms {
379
379
  export interface AlarmCreateInfo {
380
- /** Optional. Length of time in minutes after which the onAlarm event should fire. */
380
+ /** Length of time in minutes after which the {@link onAlarm} event should fire. */
381
381
  delayInMinutes?: number | undefined;
382
- /** Optional. If set, the onAlarm event should fire every periodInMinutes minutes after the initial event specified by when or delayInMinutes. If not set, the alarm will only fire once. */
382
+ /** If set, the onAlarm event should fire every `periodInMinutes` minutes after the initial event specified by `when` or `delayInMinutes`. If not set, the alarm will only fire once. */
383
383
  periodInMinutes?: number | undefined;
384
- /** Optional. Time at which the alarm should fire, in milliseconds past the epoch (e.g. Date.now() + n). */
384
+ /** Time at which the alarm should fire, in milliseconds past the epoch (e.g. `Date.now() + n`). */
385
385
  when?: number | undefined;
386
386
  }
387
387
 
388
388
  export interface Alarm {
389
- /** Optional. If not null, the alarm is a repeating alarm and will fire again in periodInMinutes minutes. */
390
- periodInMinutes?: number | undefined;
391
- /** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. Date.now() + n). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */
389
+ /** If not null, the alarm is a repeating alarm and will fire again in `periodInMinutes` minutes. */
390
+ periodInMinutes?: number;
391
+ /** Time at which this alarm was scheduled to fire, in milliseconds past the epoch (e.g. `Date.now() + n`). For performance reasons, the alarm may have been delayed an arbitrary amount beyond this. */
392
392
  scheduledTime: number;
393
393
  /** Name of this alarm. */
394
394
  name: string;
395
395
  }
396
396
 
397
- export interface AlarmEvent extends chrome.events.Event<(alarm: Alarm) => void> {}
398
-
399
- /**
400
- * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
401
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
402
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
403
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
404
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only).
405
- */
406
- export function create(alarmInfo: AlarmCreateInfo): Promise<void>;
407
397
  /**
408
- * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
409
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
398
+ * Creates an alarm. Near the time(s) specified by `alarmInfo`, the {@link onAlarm} event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
399
+ *
400
+ * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 30 seconds but may delay them an arbitrary amount more. That is, setting `delayInMinutes` or `periodInMinutes` to less than `0.5` will not be honored and will cause a warning. `when` can be set to less than 30 seconds after "now" without warning but won't actually cause the alarm to fire for at least 30 seconds.
401
+ *
410
402
  * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
411
403
  * @param name Optional name to identify this alarm. Defaults to the empty string.
412
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
413
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only).
414
- */
415
- export function create(name: string, alarmInfo: AlarmCreateInfo): Promise<void>;
416
- /**
417
- * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
418
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
419
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
420
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
404
+ * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either `when` or `delayInMinutes` (but not both). If `periodInMinutes` is set, the alarm will repeat every `periodInMinutes` minutes after the initial event. If neither `when` or `delayInMinutes` is set for a repeating alarm, `periodInMinutes` is used as the default for `delayInMinutes`.
405
+ *
406
+ * Can return its result via Promise in Manifest V3 or later since Chrome 111.
421
407
  */
408
+ export function create(alarmInfo: AlarmCreateInfo): Promise<void>;
409
+ export function create(name: string | undefined, alarmInfo: AlarmCreateInfo): Promise<void>;
422
410
  export function create(alarmInfo: AlarmCreateInfo, callback: () => void): void;
423
- /**
424
- * Creates an alarm. Near the time(s) specified by alarmInfo, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.
425
- * In order to reduce the load on the user's machine, Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more. That is, setting delayInMinutes or periodInMinutes to less than 1 will not be honored and will cause a warning. when can be set to less than 1 minute after "now" without warning but won't actually cause the alarm to fire for at least 1 minute.
426
- * To help you debug your app or extension, when you've loaded it unpacked, there's no limit to how often the alarm can fire.
427
- * @param name Optional name to identify this alarm. Defaults to the empty string.
428
- * @param alarmInfo Describes when the alarm should fire. The initial time must be specified by either when or delayInMinutes (but not both). If periodInMinutes is set, the alarm will repeat every periodInMinutes minutes after the initial event. If neither when or delayInMinutes is set for a repeating alarm, periodInMinutes is used as the default for delayInMinutes.
429
- */
430
- export function create(name: string, alarmInfo: AlarmCreateInfo, callback: () => void): void;
431
- /**
432
- * Gets an array of all the alarms.
433
- */
434
- export function getAll(callback: (alarms: Alarm[]) => void): void;
411
+ export function create(name: string | undefined, alarmInfo: AlarmCreateInfo, callback: () => void): void;
412
+
435
413
  /**
436
414
  * Gets an array of all the alarms.
437
- * @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only).
415
+ *
416
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
438
417
  */
439
418
  export function getAll(): Promise<Alarm[]>;
419
+ export function getAll(callback: (alarms: Alarm[]) => void): void;
420
+
440
421
  /**
441
422
  * Clears all alarms.
442
- * function(boolean wasCleared) {...};
443
- * @return The `clearAll` method provides its result via callback or returned as a `Promise` (MV3 only).
423
+ *
424
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
444
425
  */
445
426
  export function clearAll(): Promise<boolean>;
446
- /**
447
- * Clears all alarms.
448
- */
449
427
  export function clearAll(callback: (wasCleared: boolean) => void): void;
428
+
450
429
  /**
451
430
  * Clears the alarm with the given name.
452
- * @param name The name of the alarm to clear. Defaults to the empty string.
453
- * @return The `clear` method provides its result via callback or returned as a `Promise` (MV3 only).
431
+ *
432
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
454
433
  */
455
434
  export function clear(name?: string): Promise<boolean>;
456
- /**
457
- * Clears the alarm with the given name.
458
- * @param name The name of the alarm to clear. Defaults to the empty string.
459
- */
460
- export function clear(callback: (wasCleared: boolean) => void): void;
461
- export function clear(name: string, callback: (wasCleared: boolean) => void): void;
462
- /**
463
- * Clears the alarm without a name.
464
- */
465
435
  export function clear(callback: (wasCleared: boolean) => void): void;
466
- /**
467
- * Clears the alarm without a name.
468
- * @return The `clear` method provides its result via callback or returned as a `Promise` (MV3 only).
469
- */
470
- export function clear(): Promise<void>;
471
- /**
472
- * Retrieves details about the specified alarm.
473
- */
474
- export function get(callback: (alarm?: Alarm) => void): void;
475
- /**
476
- * Retrieves details about the specified alarm.
477
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
478
- */
479
- export function get(): Promise<Alarm | undefined>;
480
- /**
481
- * Retrieves details about the specified alarm.
482
- * @param name The name of the alarm to get. Defaults to the empty string.
483
- */
484
- export function get(name: string, callback: (alarm?: Alarm) => void): void;
436
+ export function clear(name: string | undefined, callback: (wasCleared: boolean) => void): void;
437
+
485
438
  /**
486
439
  * Retrieves details about the specified alarm.
487
440
  * @param name The name of the alarm to get. Defaults to the empty string.
488
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
441
+ *
442
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
489
443
  */
490
- export function get(name: string): Promise<Alarm | undefined>;
444
+ export function get(name?: string): Promise<Alarm | undefined>;
445
+ export function get(callback: (alarm?: Alarm) => void): void;
446
+ export function get(name: string | undefined, callback: (alarm?: Alarm) => void): void;
491
447
 
492
448
  /** Fired when an alarm has elapsed. Useful for event pages. */
493
- export var onAlarm: AlarmEvent;
449
+ export const onAlarm: events.Event<(alarm: Alarm) => void>;
494
450
  }
495
451
 
496
452
  ////////////////////
@@ -2450,45 +2406,70 @@ declare namespace chrome {
2450
2406
  * Permissions: "declarativeContent"
2451
2407
  */
2452
2408
  export namespace declarativeContent {
2453
- export class PageStateMatcherProperties {
2454
- /** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */
2409
+ interface PageStateMatcherProperties {
2410
+ /** Matches if the conditions of the `UrlFilter` are fulfilled for the top-level URL of the page. */
2455
2411
  pageUrl?: events.UrlFilter | undefined;
2456
- /** Optional. Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites. */
2412
+ /** Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note: Listing hundreds of CSS selectors or listing CSS selectors that match hundreds of times per page can slow down web sites. */
2457
2413
  css?: string[] | undefined;
2458
2414
  /**
2459
- * Optional.
2460
- * @since Chrome 45
2461
2415
  * Matches if the bookmarked state of the page is equal to the specified value. Requires the bookmarks permission.
2416
+ * @since Chrome 45
2462
2417
  */
2463
2418
  isBookmarked?: boolean | undefined;
2464
2419
  }
2465
2420
 
2466
- /** Matches the state of a web page by various criteria. */
2421
+ /** Matches the state of a web page based on various criteria. */
2467
2422
  export class PageStateMatcher {
2468
- constructor(options: PageStateMatcherProperties);
2423
+ constructor(arg: PageStateMatcherProperties);
2424
+ }
2425
+
2426
+ export interface RequestContentScriptProperties {
2427
+ /** Whether the content script runs in all frames of the matching page, or in only the top frame. Default is `false`. */
2428
+ allFrames?: boolean | undefined;
2429
+
2430
+ /** Names of CSS files to be injected as a part of the content script. */
2431
+ css?: string[] | undefined;
2432
+
2433
+ /** Names of JavaScript files to be injected as a part of the content script. */
2434
+ js?: string[] | undefined;
2435
+
2436
+ /** Whether to insert the content script on `about:blank` and `about:srcdoc`. Default is `false`. */
2437
+ matchAboutBlank?: boolean | undefined;
2438
+ }
2439
+
2440
+ /** Declarative event action that injects a content script. */
2441
+ export class RequestContentScript {
2442
+ constructor(arg: RequestContentScriptProperties);
2469
2443
  }
2470
2444
 
2471
2445
  /**
2472
- * Declarative event action that enables the extension's action while the corresponding conditions are met.
2473
- * Manifest v3.
2446
+ * A declarative event action that sets the extension's toolbar {@link action} to an enabled state while the corresponding conditions are met. This action can be used without host permissions. If the extension has the `activeTab` permission, clicking the page action grants access to the active tab.
2447
+ *
2448
+ * On pages where the conditions are not met the extension's toolbar action will be grey-scale, and clicking it will open the context menu, instead of triggering the action.
2449
+ * @since MV3
2474
2450
  */
2475
2451
  export class ShowAction {}
2476
2452
 
2477
2453
  /**
2478
- * Declarative event action that shows the extension's page action while the corresponding conditions are met.
2479
- * Manifest v2.
2454
+ * A declarative event action that sets the extension's {@link pageAction} to an enabled state while the corresponding conditions are met. This action can be used without host permissions, but the extension must have a page action. If the extension has the `activeTab` permission, clicking the page action grants access to the active tab.
2455
+ *
2456
+ * On pages where the conditions are not met the extension's toolbar action will be grey-scale, and clicking it will open the context menu, instead of triggering the action.
2457
+ *
2458
+ * MV2 only
2480
2459
  */
2481
2460
  export class ShowPageAction {}
2482
2461
 
2483
- /** Declarative event action that changes the icon of the page action while the corresponding conditions are met. */
2462
+ /**
2463
+ * Declarative event action that sets the n-dip square icon for the extension's {@link pageAction} or {@link browserAction} while the corresponding conditions are met. This action can be used without host permissions, but the extension must have a page or browser action.
2464
+ *
2465
+ * Exactly one of `imageData` or `path` must be specified. Both are dictionaries mapping a number of pixels to an image representation. The image representation in `imageData` is an `ImageData` object; for example, from a `canvas` element, while the image representation in `path` is the path to an image file relative to the extension's manifest. If `scale` screen pixels fit into a device-independent pixel, the `scale * n` icon is used. If that scale is missing, another image is resized to the required size.
2466
+ */
2484
2467
  export class SetIcon {
2485
2468
  constructor(options?: { imageData?: ImageData | { [size: string]: ImageData } | undefined });
2486
2469
  }
2487
2470
 
2488
- /** Provides the Declarative Event API consisting of addRules, removeRules, and getRules. */
2489
- export interface PageChangedEvent extends chrome.events.Event<() => void> {}
2490
-
2491
- export var onPageChanged: PageChangedEvent;
2471
+ /** Provides the Declarative Event API consisting of {@link events.Event.addRules addRules}, {@link events.Event.removeRules removeRules}, and {@link events.Event.getRules getRules}. */
2472
+ export const onPageChanged: events.Event<() => void>;
2492
2473
  }
2493
2474
 
2494
2475
  ////////////////////
@@ -4331,7 +4312,8 @@ declare namespace chrome {
4331
4312
  * Unregisters currently registered rules.
4332
4313
  * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are unregistered.
4333
4314
  */
4334
- removeRules(ruleIdentifiers?: string[] | undefined, callback?: () => void): void;
4315
+ removeRules(ruleIdentifiers: string[] | undefined, callback?: () => void): void;
4316
+ removeRules(callback?: () => void): void;
4335
4317
 
4336
4318
  /**
4337
4319
  * Registers rules to handle events.
@@ -4376,117 +4358,114 @@ declare namespace chrome {
4376
4358
  * The `chrome.extension` API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing.
4377
4359
  */
4378
4360
  export namespace extension {
4361
+ /**
4362
+ * The type of extension view.
4363
+ * @since Chrome 44
4364
+ */
4365
+ export enum ViewType {
4366
+ TAB = "tab",
4367
+ POPUP = "popup",
4368
+ }
4369
+
4379
4370
  export interface FetchProperties {
4380
4371
  /**
4381
- * Optional.
4382
- * Chrome 54+
4383
4372
  * Find a view according to a tab id. If this field is omitted, returns all views.
4373
+ * @since Chrome 54
4384
4374
  */
4385
4375
  tabId?: number | undefined;
4386
- /** Optional. The window to restrict the search to. If omitted, returns all views. */
4376
+ /** The window to restrict the search to. If omitted, returns all views. */
4387
4377
  windowId?: number | undefined;
4388
- /** Optional. The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'notification', 'popup'. */
4389
- type?: string | undefined;
4378
+ /** The type of view to get. If omitted, returns all views (including background pages and tabs). */
4379
+ type?: `${ViewType}` | undefined;
4390
4380
  }
4391
4381
 
4392
- export interface LastError {
4393
- /** Description of the error that has taken place. */
4394
- message: string;
4395
- }
4396
-
4397
- export interface OnRequestEvent extends
4398
- chrome.events.Event<
4399
- | ((request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)
4400
- | ((sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)
4401
- >
4402
- {}
4382
+ /** True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior. */
4383
+ export const inIncognitoContext: boolean;
4403
4384
 
4404
4385
  /**
4405
- * @since Chrome 7
4406
- * True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior.
4386
+ * Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occurred lastError will be `undefined`.
4387
+ * @deprecated since Chrome 58. Please use {@link runtime.lastError}
4407
4388
  */
4408
- export var inIncognitoContext: boolean;
4409
- /** Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occurred lastError will be undefined. */
4410
- export var lastError: LastError;
4389
+ export const lastError: runtime.LastError | undefined;
4411
4390
 
4412
4391
  /** Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page. */
4413
4392
  export function getBackgroundPage(): Window | null;
4393
+
4414
4394
  /**
4415
4395
  * Converts a relative path within an extension install directory to a fully-qualified URL.
4416
4396
  * @param path A path to a resource within an extension expressed relative to its install directory.
4397
+ * @deprecated since Chrome 58. Please use {@link runtime.getURL}
4417
4398
  */
4418
4399
  export function getURL(path: string): string;
4419
- /**
4420
- * Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery.
4421
- * @since Chrome 9
4422
- */
4400
+
4401
+ /** Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery. */
4423
4402
  export function setUpdateUrlData(data: string): void;
4403
+
4424
4404
  /** Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension. */
4425
4405
  export function getViews(fetchProperties?: FetchProperties): Window[];
4406
+
4426
4407
  /**
4427
- * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox.
4428
- * @since Chrome 12
4429
- * @return The `isAllowedFileSchemeAccess` method provides its result via callback or returned as a `Promise` (MV3 only).
4408
+ * Retrieves the state of the extension's access to the 'file://' scheme. This corresponds to the user-controlled per-extension 'Allow access to File URLs' setting accessible via the `chrome://extensions` page.
4409
+ *
4410
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
4430
4411
  */
4431
4412
  export function isAllowedFileSchemeAccess(): Promise<boolean>;
4432
- /**
4433
- * Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox.
4434
- * @since Chrome 12
4435
- * Parameter isAllowedAccess: True if the extension can access the 'file://' scheme, false otherwise.
4436
- */
4437
4413
  export function isAllowedFileSchemeAccess(callback: (isAllowedAccess: boolean) => void): void;
4414
+
4438
4415
  /**
4439
- * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox.
4440
- * @since Chrome 12
4441
- * @return The `isAllowedIncognitoAccess` method provides its result via callback or returned as a `Promise` (MV3 only).
4416
+ * Retrieves the state of the extension's access to Incognito-mode. This corresponds to the user-controlled per-extension 'Allowed in Incognito' setting accessible via the `chrome://extensions` page.
4417
+ *
4418
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
4442
4419
  */
4443
4420
  export function isAllowedIncognitoAccess(): Promise<boolean>;
4444
- /**
4445
- * Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox.
4446
- * @since Chrome 12
4447
- * Parameter isAllowedAccess: True if the extension has access to Incognito mode, false otherwise.
4448
- */
4449
4421
  export function isAllowedIncognitoAccess(callback: (isAllowedAccess: boolean) => void): void;
4422
+
4450
4423
  /**
4451
- * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension.
4452
- * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage.
4424
+ * Sends a single request to other listeners within the extension. Similar to {@link runtime.connect}, but only sends a single request with an optional response. The {@link extension.onRequest} event is fired in each page of the extension.
4425
+ *
4426
+ * MV2 only
4453
4427
  * @param extensionId The extension ID of the extension you want to connect to. If omitted, default is your own extension.
4454
- * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this:
4455
- * function(any response) {...};
4456
- * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.
4428
+ * @deprecated Please use {@link runtime.sendMessage}
4457
4429
  */
4458
4430
  export function sendRequest<Request = any, Response = any>(
4459
- extensionId: string,
4431
+ extensionId: string | undefined,
4460
4432
  request: Request,
4461
- responseCallback?: (response: Response) => void,
4433
+ callback?: (response: Response) => void,
4462
4434
  ): void;
4463
- /**
4464
- * Sends a single request to other listeners within the extension. Similar to runtime.connect, but only sends a single request with an optional response. The extension.onRequest event is fired in each page of the extension.
4465
- * @deprecated Deprecated since Chrome 33. Please use runtime.sendMessage.
4466
- * @param responseCallback If you specify the responseCallback parameter, it should be a function that looks like this:
4467
- * function(any response) {...};
4468
- * Parameter response: The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.
4469
- */
4470
4435
  export function sendRequest<Request = any, Response = any>(
4471
4436
  request: Request,
4472
- responseCallback?: (response: Response) => void,
4437
+ callback?: (response: Response) => void,
4473
4438
  ): void;
4439
+
4474
4440
  /**
4475
- * Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window.
4476
- * @deprecated Deprecated since Chrome 33. Please use extension.getViews {type: "tab"}.
4441
+ * Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If `windowId` is specified, returns only the 'window' objects of tabs attached to the specified window.
4442
+ *
4443
+ * MV2 only
4444
+ * @deprecated Please use {@link extension.getViews} `{type: "tab"}`.
4477
4445
  */
4478
4446
  export function getExtensionTabs(windowId?: number): Window[];
4479
4447
 
4480
4448
  /**
4481
4449
  * Fired when a request is sent from either an extension process or a content script.
4482
- * @deprecated Deprecated since Chrome 33. Please use runtime.onMessage.
4450
+ *
4451
+ * MV2 only
4452
+ * @deprecated Please use {@link runtime.onMessage}.
4483
4453
  */
4484
- export var onRequest: OnRequestEvent;
4454
+ export const onRequest: chrome.events.Event<
4455
+ | ((request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)
4456
+ | ((sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)
4457
+ >;
4458
+
4485
4459
  /**
4486
4460
  * Fired when a request is sent from another extension.
4487
- * @deprecated Deprecated since Chrome 33. Please use runtime.onMessageExternal.
4461
+ *
4462
+ * MV2 only
4463
+ * @deprecated Please use {@link runtime.onMessageExternal}.
4488
4464
  */
4489
- export var onRequestExternal: OnRequestEvent;
4465
+ export const onRequestExternal: chrome.events.Event<
4466
+ | ((request: any, sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)
4467
+ | ((sender: runtime.MessageSender, sendResponse: (response: any) => void) => void)
4468
+ >;
4490
4469
  }
4491
4470
 
4492
4471
  ////////////////////
@@ -4577,47 +4556,16 @@ declare namespace chrome {
4577
4556
  * @platform ChromeOS only
4578
4557
  */
4579
4558
  export namespace fileBrowserHandler {
4580
- export interface SelectionParams {
4581
- /**
4582
- * Optional.
4583
- * List of file extensions that the selected file can have. The list is also used to specify what files to be shown in the select file dialog. Files with the listed extensions are only shown in the dialog. Extensions should not include the leading '.'. Example: ['jpg', 'png']
4584
- * @since Chrome 23
4585
- */
4586
- allowedFileExtensions?: string[] | undefined;
4587
- /** Suggested name for the file. */
4588
- suggestedName: string;
4589
- }
4590
-
4591
- export interface SelectionResult {
4592
- /** Optional. Selected file entry. It will be null if a file hasn't been selected. */
4593
- entry?: object | null | undefined;
4594
- /** Whether the file has been selected. */
4595
- success: boolean;
4596
- }
4597
-
4598
4559
  /** Event details payload for fileBrowserHandler.onExecute event. */
4599
4560
  export interface FileHandlerExecuteEventDetails {
4600
- /** Optional. The ID of the tab that raised this event. Tab IDs are unique within a browser session. */
4601
- tab_id?: number | undefined;
4561
+ /** The ID of the tab that raised this event. Tab IDs are unique within a browser session. */
4562
+ tab_id?: number;
4602
4563
  /** Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser). */
4603
4564
  entries: any[];
4604
4565
  }
4605
4566
 
4606
- export interface FileBrowserHandlerExecuteEvent
4607
- extends chrome.events.Event<(id: string, details: FileHandlerExecuteEventDetails) => void>
4608
- {}
4609
-
4610
- /**
4611
- * Prompts user to select file path under which file should be saved. When the file is selected, file access permission required to use the file (read, write and create) are granted to the caller. The file will not actually get created during the function call, so function caller must ensure its existence before using it. The function has to be invoked with a user gesture.
4612
- * @since Chrome 21
4613
- * @param selectionParams Parameters that will be used while selecting the file.
4614
- * @param callback Function called upon completion.
4615
- * Parameter result: Result of the method.
4616
- */
4617
- export function selectFile(selectionParams: SelectionParams, callback: (result: SelectionResult) => void): void;
4618
-
4619
4567
  /** Fired when file system action is executed from ChromeOS file browser. */
4620
- export var onExecute: FileBrowserHandlerExecuteEvent;
4568
+ export const onExecute: events.Event<(id: string, details: FileHandlerExecuteEventDetails) => void>;
4621
4569
  }
4622
4570
 
4623
4571
  ////////////////////
@@ -5828,58 +5776,56 @@ declare namespace chrome {
5828
5776
  * Manifest: "default_locale"
5829
5777
  */
5830
5778
  export namespace i18n {
5831
- /** Holds detected ISO language code and its percentage in the input string */
5832
5779
  export interface DetectedLanguage {
5833
- /** An ISO language code such as 'en' or 'fr'.
5834
- * For a complete list of languages supported by this method, see [kLanguageInfoTable]{@link https://src.chromium.org/viewvc/chrome/trunk/src/third_party/cld/languages/internal/languages.cc}.
5835
- * For an unknown language, 'und' will be returned, which means that [percentage] of the text is unknown to CLD */
5836
5780
  language: string;
5837
-
5838
5781
  /** The percentage of the detected language */
5839
5782
  percentage: number;
5840
5783
  }
5841
5784
 
5842
- /** Holds detected language reliability and array of DetectedLanguage */
5785
+ /** Holds detected language reliability and array of {@link DetectedLanguage} */
5843
5786
  export interface LanguageDetectionResult {
5844
5787
  /** CLD detected language reliability */
5845
5788
  isReliable: boolean;
5846
-
5847
5789
  /** Array of detectedLanguage */
5848
5790
  languages: DetectedLanguage[];
5849
5791
  }
5850
5792
 
5793
+ /** @since Chrome 79 */
5794
+ export interface GetMessageOptions {
5795
+ /** Escape `<` in translation to `&lt;`. This applies only to the message itself, not to the placeholders. Developers might want to use this if the translation is used in an HTML context. Closure Templates used with Closure Compiler generate this automatically. */
5796
+ escapeLt?: boolean | undefined;
5797
+ }
5798
+
5851
5799
  /**
5852
- * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use i18n.getUILanguage.
5853
- * @return The `getAcceptLanguages` method provides its result via callback or returned as a `Promise` (MV3 only).
5854
- * @since MV3
5800
+ * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use {@link i18n.getUILanguage}.
5801
+ *
5802
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
5855
5803
  */
5856
5804
  export function getAcceptLanguages(): Promise<string[]>;
5857
- /**
5858
- * Gets the accept-languages of the browser. This is different from the locale used by the browser; to get the locale, use i18n.getUILanguage.
5859
- * Parameter languages: Array of the accept languages of the browser, such as en-US,en,zh-CN
5860
- */
5861
5805
  export function getAcceptLanguages(callback: (languages: string[]) => void): void;
5806
+
5862
5807
  /**
5863
- * Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the getMessage() call is wrong — for example, messageName is not a string or the substitutions array has more than 9 elements — this method returns undefined.
5864
- * @param messageName The name of the message, as specified in the messages.json file.
5865
- * @param substitutions Optional. Up to 9 substitution strings, if the message requires any.
5866
- */
5867
- export function getMessage(messageName: string, substitutions?: string | string[]): string;
5868
- /**
5869
- * Gets the browser UI language of the browser. This is different from i18n.getAcceptLanguages which returns the preferred user languages.
5870
- * @since Chrome 35
5808
+ * Gets the localized string for the specified message. If the message is missing, this method returns an empty string (''). If the format of the `getMessage()` call is wrong — for example, messageName is not a string or the substitutions array has more than 9 elements — this method returns `undefined`.
5809
+ * @param messageName The name of the message, as specified in the `messages.json` file.
5810
+ * @param substitutions Up to 9 substitution strings, if the message requires any.
5871
5811
  */
5812
+ export function getMessage(messageName: string, substitutions?: string | Array<string | number>): string;
5813
+ export function getMessage(
5814
+ messageName: string,
5815
+ substitutions: string | Array<string | number> | undefined,
5816
+ options?: GetMessageOptions,
5817
+ ): string;
5818
+
5819
+ /** Gets the browser UI language of the browser. This is different from {@link i18n.getAcceptLanguages} which returns the preferred user languages. */
5872
5820
  export function getUILanguage(): string;
5873
5821
 
5874
5822
  /** Detects the language of the provided text using CLD.
5875
5823
  * @param text User input string to be translated.
5876
- * @return The `detectLanguage` method provides its result via callback or returned as a `Promise` (MV3 only).
5877
- * @since MV3
5824
+ *
5825
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
5826
+ * @since Chrome 47
5878
5827
  */
5879
5828
  export function detectLanguage(text: string): Promise<LanguageDetectionResult>;
5880
- /** Detects the language of the provided text using CLD.
5881
- * @param text User input string to be translated.
5882
- */
5883
5829
  export function detectLanguage(text: string, callback: (result: LanguageDetectionResult) => void): void;
5884
5830
  }
5885
5831
 
chrome/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/chrome",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "TypeScript definitions for chrome",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome",
6
6
  "license": "MIT",
@@ -94,6 +94,6 @@
94
94
  "@types/har-format": "*"
95
95
  },
96
96
  "peerDependencies": {},
97
- "typesPublisherContentHash": "e1847839136a21eca4a5e3d9983e414a4cc25f314b870dc6c424dbeacdcb8b35",
97
+ "typesPublisherContentHash": "a46e6689297c50bba1d7cc23508d14acdbf293bafc846406f96238879a6c46de",
98
98
  "typeScriptVersion": "5.2"
99
99
  }