@wxt-dev/browser 0.0.327 → 0.0.329

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/gen/index.d.ts +808 -956
@@ -2555,52 +2555,9 @@ export namespace Browser {
2555
2555
  * Permissions: "declarativeContent"
2556
2556
  */
2557
2557
  export namespace declarativeContent {
2558
- export interface PageStateUrlDetails {
2559
- /** Optional. Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */
2560
- hostContains?: string | undefined;
2561
- /** Optional. Matches if the host name of the URL is equal to a specified string. */
2562
- hostEquals?: string | undefined;
2563
- /** Optional. Matches if the host name of the URL starts with a specified string. */
2564
- hostPrefix?: string | undefined;
2565
- /** Optional. Matches if the host name of the URL ends with a specified string. */
2566
- hostSuffix?: string | undefined;
2567
- /** Optional. Matches if the path segment of the URL contains a specified string. */
2568
- pathContains?: string | undefined;
2569
- /** Optional. Matches if the path segment of the URL is equal to a specified string. */
2570
- pathEquals?: string | undefined;
2571
- /** Optional. Matches if the path segment of the URL starts with a specified string. */
2572
- pathPrefix?: string | undefined;
2573
- /** Optional. Matches if the path segment of the URL ends with a specified string. */
2574
- pathSuffix?: string | undefined;
2575
- /** Optional. Matches if the query segment of the URL contains a specified string. */
2576
- queryContains?: string | undefined;
2577
- /** Optional. Matches if the query segment of the URL is equal to a specified string. */
2578
- queryEquals?: string | undefined;
2579
- /** Optional. Matches if the query segment of the URL starts with a specified string. */
2580
- queryPrefix?: string | undefined;
2581
- /** Optional. Matches if the query segment of the URL ends with a specified string. */
2582
- querySuffix?: string | undefined;
2583
- /** Optional. Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */
2584
- urlContains?: string | undefined;
2585
- /** Optional. Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */
2586
- urlEquals?: string | undefined;
2587
- /** Optional. Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */
2588
- urlMatches?: string | undefined;
2589
- /** Optional. Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */
2590
- originAndPathMatches?: string | undefined;
2591
- /** Optional. Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */
2592
- urlPrefix?: string | undefined;
2593
- /** Optional. Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */
2594
- urlSuffix?: string | undefined;
2595
- /** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */
2596
- schemes?: string[] | undefined;
2597
- /** Optional. Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */
2598
- ports?: Array<number | number[]> | undefined;
2599
- }
2600
-
2601
2558
  export class PageStateMatcherProperties {
2602
2559
  /** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */
2603
- pageUrl?: PageStateUrlDetails | undefined;
2560
+ pageUrl?: events.UrlFilter | undefined;
2604
2561
  /** 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. */
2605
2562
  css?: string[] | undefined;
2606
2563
  /**
@@ -3721,58 +3678,70 @@ export namespace Browser {
3721
3678
  value: string;
3722
3679
  }
3723
3680
 
3724
- export type FilenameConflictAction = "uniquify" | "overwrite" | "prompt";
3681
+ export enum FilenameConflictAction {
3682
+ /** To avoid duplication, the filename is changed to include a counter before the filename extension. */
3683
+ UNIQUIFY = "uniquify",
3684
+ /** The existing file will be overwritten with the new file. */
3685
+ OVERWRITE = "overwrite",
3686
+ /** The user will be prompted with a file chooser dialog. */
3687
+ PROMPT = "prompt",
3688
+ }
3689
+
3690
+ export enum HttpMethod {
3691
+ GET = "GET",
3692
+ POST = "POST",
3693
+ }
3725
3694
 
3726
3695
  export interface DownloadOptions {
3727
- /** Optional. Post body. */
3696
+ /** Post body. */
3728
3697
  body?: string | undefined;
3729
- /** Optional. Use a file-chooser to allow the user to select a filename regardless of whether filename is set or already exists. */
3698
+ /** Use a file-chooser to allow the user to select a filename regardless of whether `filename` is set or already exists. */
3730
3699
  saveAs?: boolean | undefined;
3731
3700
  /** The URL to download. */
3732
3701
  url: string;
3733
- /** Optional. A file path relative to the Downloads directory to contain the downloaded file, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will cause an error. onDeterminingFilename allows suggesting a filename after the file's MIME type and a tentative filename have been determined. */
3702
+ /** A file path relative to the Downloads directory to contain the downloaded file, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will cause an error. {@link onDeterminingFilename} allows suggesting a filename after the file's MIME type and a tentative filename have been determined. */
3734
3703
  filename?: string | undefined;
3735
- /** Optional. Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary containing the keys name and either value or binaryValue, restricted to those allowed by XMLHttpRequest. */
3704
+ /** Extra HTTP headers to send with the request if the URL uses the HTTP[s] protocol. Each header is represented as a dictionary containing the keys `name` and either `value` or `binaryValue`, restricted to those allowed by XMLHttpRequest. */
3736
3705
  headers?: HeaderNameValuePair[] | undefined;
3737
- /** Optional. The HTTP method to use if the URL uses the HTTP[S] protocol. */
3738
- method?: "GET" | "POST" | undefined;
3739
- /** Optional. The action to take if filename already exists. */
3740
- conflictAction?: FilenameConflictAction | undefined;
3706
+ /** The HTTP method to use if the URL uses the HTTP[S] protocol. */
3707
+ method?: `${HttpMethod}` | undefined;
3708
+ /** The action to take if `filename` already exists. */
3709
+ conflictAction?: `${FilenameConflictAction}` | undefined;
3741
3710
  }
3742
3711
 
3743
3712
  export interface DownloadDelta {
3744
- /** The id of the DownloadItem that changed. */
3713
+ /** The id of the {@link DownloadItem} that changed. */
3745
3714
  id: number;
3746
- /** Optional. The change in danger, if any. */
3715
+ /** The change in `danger`, if any. */
3747
3716
  danger?: StringDelta | undefined;
3748
- /** Optional. The change in url, if any. */
3717
+ /** The change in `url`, if any. */
3749
3718
  url?: StringDelta | undefined;
3750
3719
  /**
3751
- * Optional. The change in finalUrl, if any.
3720
+ * The change in `finalUrl`, if any.
3752
3721
  * @since Chrome 54
3753
3722
  */
3754
3723
  finalUrl?: StringDelta | undefined;
3755
- /** Optional. The change in totalBytes, if any. */
3724
+ /** The change in `totalBytes`, if any. */
3756
3725
  totalBytes?: DoubleDelta | undefined;
3757
- /** Optional. The change in filename, if any. */
3726
+ /** The change in `filename`, if any. */
3758
3727
  filename?: StringDelta | undefined;
3759
- /** Optional. The change in paused, if any. */
3728
+ /** The change in `paused`, if any. */
3760
3729
  paused?: BooleanDelta | undefined;
3761
- /** Optional. The change in state, if any. */
3730
+ /** The change in `state`, if any. */
3762
3731
  state?: StringDelta | undefined;
3763
- /** Optional. The change in mime, if any. */
3732
+ /** The change in `mime`, if any. */
3764
3733
  mime?: StringDelta | undefined;
3765
- /** Optional. The change in fileSize, if any. */
3734
+ /** The change in `fileSize`, if any. */
3766
3735
  fileSize?: DoubleDelta | undefined;
3767
- /** Optional. The change in startTime, if any. */
3736
+ /** The change in `startTime`, if any. */
3768
3737
  startTime?: StringDelta | undefined;
3769
- /** Optional. The change in error, if any. */
3738
+ /** The change in `error`, if any. */
3770
3739
  error?: StringDelta | undefined;
3771
- /** Optional. The change in endTime, if any. */
3740
+ /** The change in `endTime`, if any. */
3772
3741
  endTime?: StringDelta | undefined;
3773
- /** Optional. The change in canResume, if any. */
3742
+ /** The change in `canResume`, if any. */
3774
3743
  canResume?: BooleanDelta | undefined;
3775
- /** Optional. The change in exists, if any. */
3744
+ /** The change in `exists`, if any. */
3776
3745
  exists?: BooleanDelta | undefined;
3777
3746
  }
3778
3747
 
@@ -3781,7 +3750,6 @@ export namespace Browser {
3781
3750
  previous?: boolean | undefined;
3782
3751
  }
3783
3752
 
3784
- /** @since Chrome 34 */
3785
3753
  export interface DoubleDelta {
3786
3754
  current?: number | undefined;
3787
3755
  previous?: number | undefined;
@@ -3792,46 +3760,85 @@ export namespace Browser {
3792
3760
  previous?: string | undefined;
3793
3761
  }
3794
3762
 
3795
- export type DownloadInterruptReason =
3796
- | "FILE_FAILED"
3797
- | "FILE_ACCESS_DENIED"
3798
- | "FILE_NO_SPACE"
3799
- | "FILE_NAME_TOO_LONG"
3800
- | "FILE_TOO_LARGE"
3801
- | "FILE_VIRUS_INFECTED"
3802
- | "FILE_TRANSIENT_ERROR"
3803
- | "FILE_BLOCKED"
3804
- | "FILE_SECURITY_CHECK_FAILED"
3805
- | "FILE_TOO_SHORT"
3806
- | "FILE_HASH_MISMATCH"
3807
- | "FILE_SAME_AS_SOURCE"
3808
- | "NETWORK_FAILED"
3809
- | "NETWORK_TIMEOUT"
3810
- | "NETWORK_DISCONNECTED"
3811
- | "NETWORK_SERVER_DOWN"
3812
- | "NETWORK_INVALID_REQUEST"
3813
- | "SERVER_FAILED"
3814
- | "SERVER_NO_RANGE"
3815
- | "SERVER_BAD_CONTENT"
3816
- | "SERVER_UNAUTHORIZED"
3817
- | "SERVER_CERT_PROBLEM"
3818
- | "SERVER_FORBIDDEN"
3819
- | "SERVER_UNREACHABLE"
3820
- | "SERVER_CONTENT_LENGTH_MISMATCH"
3821
- | "SERVER_CROSS_ORIGIN_REDIRECT"
3822
- | "USER_CANCELED"
3823
- | "USER_SHUTDOWN"
3824
- | "CRASH";
3825
-
3826
- export type DownloadState = "in_progress" | "interrupted" | "complete";
3827
-
3828
- export type DangerType = "file" | "url" | "content" | "uncommon" | "host" | "unwanted" | "safe" | "accepted";
3763
+ export enum InterruptReason {
3764
+ FILE_FAILED = "FILE_FAILED",
3765
+ FILE_ACCESS_DENIED = "FILE_ACCESS_DENIED",
3766
+ FILE_NO_SPACE = "FILE_NO_SPACE",
3767
+ FILE_NAME_TOO_LONG = "FILE_NAME_TOO_LONG",
3768
+ FILE_TOO_LARGE = "FILE_TOO_LARGE",
3769
+ FILE_VIRUS_INFECTED = "FILE_VIRUS_INFECTED",
3770
+ FILE_TRANSIENT_ERROR = "FILE_TRANSIENT_ERROR",
3771
+ FILE_BLOCKED = "FILE_BLOCKED",
3772
+ FILE_SECURITY_CHECK_FAILED = "FILE_SECURITY_CHECK_FAILED",
3773
+ FILE_TOO_SHORT = "FILE_TOO_SHORT",
3774
+ FILE_HASH_MISMATCH = "FILE_HASH_MISMATCH",
3775
+ FILE_SAME_AS_SOURCE = "FILE_SAME_AS_SOURCE",
3776
+ NETWORK_FAILED = "NETWORK_FAILED",
3777
+ NETWORK_TIMEOUT = "NETWORK_TIMEOUT",
3778
+ NETWORK_DISCONNECTED = "NETWORK_DISCONNECTED",
3779
+ NETWORK_SERVER_DOWN = "NETWORK_SERVER_DOWN",
3780
+ NETWORK_INVALID_REQUEST = "NETWORK_INVALID_REQUEST",
3781
+ SERVER_FAILED = "SERVER_FAILED",
3782
+ SERVER_NO_RANGE = "SERVER_NO_RANGE",
3783
+ SERVER_BAD_CONTENT = "SERVER_BAD_CONTENT",
3784
+ SERVER_UNAUTHORIZED = "SERVER_UNAUTHORIZED",
3785
+ SERVER_CERT_PROBLEM = "SERVER_CERT_PROBLEM",
3786
+ SERVER_FORBIDDEN = "SERVER_FORBIDDEN",
3787
+ SERVER_UNREACHABLE = "SERVER_UNREACHABLE",
3788
+ SERVER_CONTENT_LENGTH_MISMATCH = "SERVER_CONTENT_LENGTH_MISMATCH",
3789
+ SERVER_CROSS_ORIGIN_REDIRECT = "SERVER_CROSS_ORIGIN_REDIRECT",
3790
+ USER_CANCELED = "USER_CANCELED",
3791
+ USER_SHUTDOWN = "USER_SHUTDOWN",
3792
+ CRASH = "CRASH",
3793
+ }
3794
+
3795
+ export enum State {
3796
+ /** The download is currently receiving data from the server. */
3797
+ IN_PROGRESS = "in_progress",
3798
+ /** An error broke the connection with the file host. */
3799
+ INTERRUPTED = "interrupted",
3800
+ /** The download completed successfully. */
3801
+ COMPLETE = "complete",
3802
+ }
3803
+
3804
+ export enum DangerType {
3805
+ /** The download's filename is suspicious. */
3806
+ FILE = "file",
3807
+ /** The download's URL is known to be malicious. */
3808
+ URL = "url",
3809
+ /** The downloaded file is known to be malicious. */
3810
+ CONTENT = "content",
3811
+ /** The download's URL is not commonly downloaded and could be dangerous. */
3812
+ UNCOMMON = "uncommon",
3813
+ /** The download came from a host known to distribute malicious binaries and is likely dangerous. */
3814
+ HOST = "host",
3815
+ /** The download is potentially unwanted or unsafe. E.g. it could make changes to browser or computer settings. */
3816
+ UNWANTED = "unwanted",
3817
+ /** The download presents no known danger to the user's computer. */
3818
+ SAFE = "safe",
3819
+ /** The user has accepted the dangerous download. */
3820
+ ACCEPTED = "accepted",
3821
+ ALLOWLISTED_BY_POLICY = "allowlistedByPolicy",
3822
+ ASYNC_SCANNING = "asyncScanning",
3823
+ ASYNC_LOCAL_PASSWORD_SCANNING = "asyncLocalPasswordScanning",
3824
+ PASSWORD_PROTECTED = "passwordProtected",
3825
+ BLOCKED_TOO_LARGE = "blockedTooLarge",
3826
+ SENSITIVE_CONTENT_WARNING = "sensitiveContentWarning",
3827
+ SENSITIVE_CONTENT_BLOCK = "sensitiveContentBlock",
3828
+ DEEP_SCANNED_FAILED = "deepScannedFailed",
3829
+ DEEP_SCANNED_SAFE = "deepScannedSafe",
3830
+ DEEP_SCANNED_OPENED_DANGEROUS = "deepScannedOpenedDangerous",
3831
+ PROMPT_FOR_SCANNING = "promptForScanning",
3832
+ PROMPT_FOR_LOCAL_PASSWORD_SCANNING = "promptForLocalPasswordScanning",
3833
+ ACCOUNT_COMPROMISE = "accountCompromise",
3834
+ BLOCKED_SCAN_FAILED = "blockedScanFailed",
3835
+ }
3829
3836
 
3830
3837
  export interface DownloadItem {
3831
3838
  /** Number of bytes received so far from the host, without considering file compression. */
3832
3839
  bytesReceived: number;
3833
3840
  /** Indication of whether this download is thought to be safe or known to be suspicious. */
3834
- danger: DangerType;
3841
+ danger: `${DangerType}`;
3835
3842
  /** The absolute URL that this download initiated from, before any redirects. */
3836
3843
  url: string;
3837
3844
  /**
@@ -3846,16 +3853,16 @@ export namespace Browser {
3846
3853
  /** True if the download has stopped reading data from the host, but kept the connection open. */
3847
3854
  paused: boolean;
3848
3855
  /** Indicates whether the download is progressing, interrupted, or complete. */
3849
- state: DownloadState;
3856
+ state: `${State}`;
3850
3857
  /** The file's MIME type. */
3851
3858
  mime: string;
3852
3859
  /** Number of bytes in the whole file post-decompression, or -1 if unknown. */
3853
3860
  fileSize: number;
3854
- /** The time when the download began in ISO 8601 format. May be passed directly to the Date constructor: Browser.downloads.search({}, function(items){items.forEach(function(item){console.log(new Date(item.startTime))})}) */
3861
+ /** The time when the download began in ISO 8601 format. May be passed directly to the Date constructor: `Browser.downloads.search({}, function(items){items.forEach(function(item){console.log(new Date(item.startTime))})})` */
3855
3862
  startTime: string;
3856
- /** Optional. Why the download was interrupted. Several kinds of HTTP errors may be grouped under one of the errors beginning with SERVER_. Errors relating to the network begin with NETWORK_, errors relating to the process of writing the file to the file system begin with FILE_, and interruptions initiated by the user begin with USER_. */
3857
- error?: DownloadInterruptReason | undefined;
3858
- /** Optional. The time when the download ended in ISO 8601 format. May be passed directly to the Date constructor: Browser.downloads.search({}, function(items){items.forEach(function(item){if (item.endTime) console.log(new Date(item.endTime))})}) */
3863
+ /** Why the download was interrupted. Several kinds of HTTP errors may be grouped under one of the errors beginning with `SERVER_`. Errors relating to the network begin with `NETWORK_`, errors relating to the process of writing the file to the file system begin with `FILE_`, and interruptions initiated by the user begin with `USER_`. */
3864
+ error?: `${InterruptReason}` | undefined;
3865
+ /** The time when the download ended in ISO 8601 format. May be passed directly to the Date constructor: `Browser.downloads.search({}, function(items){items.forEach(function(item){if (item.endTime) console.log(new Date(item.endTime))})})` */
3859
3866
  endTime?: string | undefined;
3860
3867
  /** An identifier that is persistent across browser sessions. */
3861
3868
  id: number;
@@ -3863,248 +3870,232 @@ export namespace Browser {
3863
3870
  incognito: boolean;
3864
3871
  /** Absolute URL. */
3865
3872
  referrer: string;
3866
- /** Optional. Estimated time when the download will complete in ISO 8601 format. May be passed directly to the Date constructor: Browser.downloads.search({}, function(items){items.forEach(function(item){if (item.estimatedEndTime) console.log(new Date(item.estimatedEndTime))})}) */
3873
+ /** Estimated time when the download will complete in ISO 8601 format. May be passed directly to the Date constructor: `Browser.downloads.search({}, function(items){items.forEach(function(item){if (item.estimatedEndTime) console.log(new Date(item.estimatedEndTime))})})` */
3867
3874
  estimatedEndTime?: string | undefined;
3868
3875
  /** True if the download is in progress and paused, or else if it is interrupted and can be resumed starting from where it was interrupted. */
3869
3876
  canResume: boolean;
3870
- /** Whether the downloaded file still exists. This information may be out of date because Chrome does not automatically watch for file removal. Call search() in order to trigger the check for file existence. When the existence check completes, if the file has been deleted, then an onChanged event will fire. Note that search() does not wait for the existence check to finish before returning, so results from search() may not accurately reflect the file system. Also, search() may be called as often as necessary, but will not check for file existence any more frequently than once every 10 seconds. */
3877
+ /** Whether the downloaded file still exists. This information may be out of date because Chrome does not automatically watch for file removal. Call {@link search}() in order to trigger the check for file existence. When the existence check completes, if the file has been deleted, then an {@link onChanged} event will fire. Note that {@link search}() does not wait for the existence check to finish before returning, so results from {@link search}() may not accurately reflect the file system. Also, {@link search}() may be called as often as necessary, but will not check for file existence any more frequently than once every 10 seconds. */
3871
3878
  exists: boolean;
3872
- /** Optional. The identifier for the extension that initiated this download if this download was initiated by an extension. Does not change once it is set. */
3879
+ /** The identifier for the extension that initiated this download if this download was initiated by an extension. Does not change once it is set. */
3873
3880
  byExtensionId?: string | undefined;
3874
- /** Optional. The localized name of the extension that initiated this download if this download was initiated by an extension. May change if the extension changes its name or if the user changes their locale. */
3881
+ /** The localized name of the extension that initiated this download if this download was initiated by an extension. May change if the extension changes its name or if the user changes their locale. */
3875
3882
  byExtensionName?: string | undefined;
3876
3883
  }
3877
3884
 
3878
3885
  export interface GetFileIconOptions {
3879
- /** Optional. * The size of the returned icon. The icon will be square with dimensions size * size pixels. The default and largest size for the icon is 32x32 pixels. The only supported sizes are 16 and 32. It is an error to specify any other size.
3880
- */
3886
+ /** The size of the returned icon. The icon will be square with dimensions size * size pixels. The default and largest size for the icon is 32x32 pixels. The only supported sizes are 16 and 32. It is an error to specify any other size. */
3881
3887
  size?: 16 | 32 | undefined;
3882
3888
  }
3883
3889
 
3884
3890
  export interface DownloadQuery {
3885
- /** Optional. Set elements of this array to DownloadItem properties in order to sort search results. For example, setting orderBy=['startTime'] sorts the DownloadItem by their start time in ascending order. To specify descending order, prefix with a hyphen: '-startTime'. */
3891
+ /** Set elements of this array to {@link DownloadItem} properties in order to sort search results. For example, setting `orderBy=['startTime']` sorts the {@link DownloadItem} by their start time in ascending order. To specify descending order, prefix with a hyphen: '-startTime'. */
3886
3892
  orderBy?: string[] | undefined;
3887
- /** Optional. Limits results to DownloadItem whose url matches the given regular expression. */
3893
+ /** Limits results to {@link DownloadItem} whose `url` matches the given regular expression. */
3888
3894
  urlRegex?: string | undefined;
3889
- /** Optional. Limits results to DownloadItem that ended before the time in ISO 8601 format. */
3895
+ /** Limits results to {@link DownloadItem} that ended before the time in ISO 8601 format. */
3890
3896
  endedBefore?: string | undefined;
3891
- /** Optional. Limits results to DownloadItem whose totalBytes is greater than the given integer. */
3897
+ /** Limits results to {@link DownloadItem} whose `totalBytes` is greater than the given integer. */
3892
3898
  totalBytesGreater?: number | undefined;
3893
- /** Optional. Indication of whether this download is thought to be safe or known to be suspicious. */
3894
- danger?: string | undefined;
3895
- /** Optional. Number of bytes in the whole file, without considering file compression, or -1 if unknown. */
3899
+ /** Indication of whether this download is thought to be safe or known to be suspicious. */
3900
+ danger?: `${DangerType}` | undefined;
3901
+ /** Number of bytes in the whole file, without considering file compression, or -1 if unknown. */
3896
3902
  totalBytes?: number | undefined;
3897
- /** Optional. True if the download has stopped reading data from the host, but kept the connection open. */
3903
+ /** True if the download has stopped reading data from the host, but kept the connection open. */
3898
3904
  paused?: boolean | undefined;
3899
- /** Optional. Limits results to DownloadItem whose filename matches the given regular expression. */
3905
+ /** Limits results to {@link DownloadItem} whose `filename` matches the given regular expression. */
3900
3906
  filenameRegex?: string | undefined;
3901
- /** Optional. This array of search terms limits results to DownloadItem whose filename or url contain all of the search terms that do not begin with a dash '-' and none of the search terms that do begin with a dash. */
3907
+ /**
3908
+ * The absolute URL that this download is being made from, after all redirects.
3909
+ * @since Chrome 54
3910
+ */
3911
+ finalUrl?: string;
3912
+ /**
3913
+ * Limits results to {@link DownloadItem} whose `finalUrl` matches the given regular expression.
3914
+ * @since Chrome 54
3915
+ */
3916
+ finalUrlRegex?: string;
3917
+ /** This array of search terms limits results to {@link DownloadItem} whose `filename` or `url` or `finalUrl` contain all of the search terms that do not begin with a dash '-' and none of the search terms that do begin with a dash. */
3902
3918
  query?: string[] | undefined;
3903
- /** Optional. Limits results to DownloadItem whose totalBytes is less than the given integer. */
3919
+ /** Limits results to {@link DownloadItem} whose `totalBytes` is less than the given integer. */
3904
3920
  totalBytesLess?: number | undefined;
3905
- /** Optional. The id of the DownloadItem to query. */
3921
+ /** The `id` of the {@link DownloadItem} to query. */
3906
3922
  id?: number | undefined;
3907
- /** Optional. Number of bytes received so far from the host, without considering file compression. */
3923
+ /** Number of bytes received so far from the host, without considering file compression. */
3908
3924
  bytesReceived?: number | undefined;
3909
- /** Optional. Limits results to DownloadItem that ended after the time in ISO 8601 format. */
3925
+ /** Limits results to {@link DownloadItem} that ended after the time in ISO 8601 format. */
3910
3926
  endedAfter?: string | undefined;
3911
- /** Optional. Absolute local path. */
3927
+ /** Absolute local path. */
3912
3928
  filename?: string | undefined;
3913
- /** Optional. Indicates whether the download is progressing, interrupted, or complete. */
3914
- state?: string | undefined;
3915
- /** Optional. Limits results to DownloadItem that started after the time in ISO 8601 format. */
3929
+ /** Indicates whether the download is progressing, interrupted, or complete. */
3930
+ state?: `${State}` | undefined;
3931
+ /** Limits results to {@link DownloadItem} that started after the time in ISO 8601 format. */
3916
3932
  startedAfter?: string | undefined;
3917
- /** Optional. The file's MIME type. */
3933
+ /** The file's MIME type. */
3918
3934
  mime?: string | undefined;
3919
- /** Optional. Number of bytes in the whole file post-decompression, or -1 if unknown. */
3935
+ /** Number of bytes in the whole file post-decompression, or -1 if unknown. */
3920
3936
  fileSize?: number | undefined;
3921
- /** Optional. The time when the download began in ISO 8601 format. */
3937
+ /** The time when the download began in ISO 8601 format. */
3922
3938
  startTime?: string | undefined;
3923
- /** Optional. Absolute URL. */
3939
+ /** The absolute URL that this download initiated from, before any redirects. */
3924
3940
  url?: string | undefined;
3925
- /** Optional. Limits results to DownloadItem that started before the time in ISO 8601 format. */
3941
+ /** Limits results to {@link DownloadItem} that started before the time in ISO 8601 format. */
3926
3942
  startedBefore?: string | undefined;
3927
- /** Optional. The maximum number of matching DownloadItem returned. Defaults to 1000. Set to 0 in order to return all matching DownloadItem. See search for how to page through results. */
3943
+ /** The maximum number of matching {@link DownloadItem} returned. Defaults to 1000. Set to 0 in order to return all matching {@link DownloadItem}. See {@link search} for how to page through results. */
3928
3944
  limit?: number | undefined;
3929
- /** Optional. Why a download was interrupted. */
3930
- error?: number | undefined;
3931
- /** Optional. The time when the download ended in ISO 8601 format. */
3945
+ /** Why a download was interrupted. */
3946
+ error?: `${InterruptReason}` | undefined;
3947
+ /** The time when the download ended in ISO 8601 format. */
3932
3948
  endTime?: string | undefined;
3933
- /** Optional. Whether the downloaded file exists; */
3949
+ /** Whether the downloaded file exists; */
3934
3950
  exists?: boolean | undefined;
3935
3951
  }
3936
3952
 
3937
- export interface DownloadFilenameSuggestion {
3938
- /** The DownloadItem's new target DownloadItem.filename, as a path relative to the user's default Downloads directory, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will be ignored. */
3953
+ export interface FilenameSuggestion {
3954
+ /** The {@link DownloadItem}'s new target {@link DownloadItem.filename}, as a path relative to the user's default Downloads directory, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references ".." will be ignored. `filename` is ignored if there are any {@link onDeterminingFilename} listeners registered by any extensions. */
3939
3955
  filename: string;
3940
- /** Optional. The action to take if filename already exists. */
3941
- conflictAction?: string | undefined;
3956
+ /** The action to take if `filename` already exists. */
3957
+ conflictAction?: `${FilenameConflictAction}` | undefined;
3942
3958
  }
3943
3959
 
3960
+ /** @since Chrome 105 */
3944
3961
  export interface UiOptions {
3945
3962
  /** Enable or disable the download UI. */
3946
3963
  enabled: boolean;
3947
3964
  }
3948
3965
 
3949
- export interface DownloadChangedEvent extends Browser.events.Event<(downloadDelta: DownloadDelta) => void> {}
3950
-
3951
- export interface DownloadCreatedEvent extends Browser.events.Event<(downloadItem: DownloadItem) => void> {}
3952
-
3953
- export interface DownloadErasedEvent extends Browser.events.Event<(downloadId: number) => void> {}
3954
-
3955
- export interface DownloadDeterminingFilenameEvent extends
3956
- Browser.events.Event<
3957
- (downloadItem: DownloadItem, suggest: (suggestion?: DownloadFilenameSuggestion) => void) => void
3958
- >
3959
- {}
3960
-
3961
3966
  /**
3962
- * Find DownloadItem. Set query to the empty object to get all DownloadItem. To get a specific DownloadItem, set only the id field. To page through a large number of items, set orderBy: ['-startTime'], set limit to the number of items per page, and set startedAfter to the startTime of the last item from the last page.
3963
- * @return The `search` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
3967
+ * Find {@link DownloadItem}. Set `query` to the empty object to get all {@link DownloadItem}. To get a specific {@link DownloadItem}, set only the `id` field. To page through a large number of items, set `orderBy: ['-startTime']`, set `limit` to the number of items per page, and set `startedAfter` to the `startTime` of the last item from the last page.
3968
+ *
3969
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
3964
3970
  */
3965
3971
  export function search(query: DownloadQuery): Promise<DownloadItem[]>;
3966
- /**
3967
- * Find DownloadItem. Set query to the empty object to get all DownloadItem. To get a specific DownloadItem, set only the id field. To page through a large number of items, set orderBy: ['-startTime'], set limit to the number of items per page, and set startedAfter to the startTime of the last item from the last page.
3968
- */
3969
3972
  export function search(query: DownloadQuery, callback: (results: DownloadItem[]) => void): void;
3973
+
3970
3974
  /**
3971
- * Pause the download. If the request was successful the download is in a paused state. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active.
3975
+ * Pause the download. If the request was successful the download is in a paused state. Otherwise {@link runtime.lastError} contains an error message. The request will fail if the download is not active.
3972
3976
  * @param downloadId The id of the download to pause.
3973
- * @return The `pause` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
3977
+ *
3978
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
3974
3979
  */
3975
3980
  export function pause(downloadId: number): Promise<void>;
3976
- /**
3977
- * Pause the download. If the request was successful the download is in a paused state. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active.
3978
- * @param downloadId The id of the download to pause.
3979
- * @param callback Called when the pause request is completed.
3980
- */
3981
3981
  export function pause(downloadId: number, callback: () => void): void;
3982
+
3982
3983
  /**
3983
- * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message.
3984
- * @param downloadId The identifier for the download.
3985
- * @return The `getFileIcon` method provides its result via callback or returned as a `Promise` (MV3 only).
3986
- */
3987
- export function getFileIcon(downloadId: number, options?: GetFileIconOptions): Promise<string>;
3988
- /**
3989
- * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message.
3990
- * @param downloadId The identifier for the download.
3991
- * @param callback A URL to an image that represents the download.
3992
- */
3993
- export function getFileIcon(downloadId: number, callback: (iconURL: string) => void): void;
3994
- /**
3995
- * Retrieve an icon for the specified download. For new downloads, file icons are available after the onCreated event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, runtime.lastError will contain an error message.
3984
+ * Retrieve an icon for the specified download. For new downloads, file icons are available after the {@link onCreated} event has been received. The image returned by this function while a download is in progress may be different from the image returned after the download is complete. Icon retrieval is done by querying the underlying operating system or toolkit depending on the platform. The icon that is returned will therefore depend on a number of factors including state of the download, platform, registered file types and visual theme. If a file icon cannot be determined, {@link runtime.lastError} will contain an error message.
3996
3985
  * @param downloadId The identifier for the download.
3997
- * @param callback A URL to an image that represents the download.
3986
+ *
3987
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
3998
3988
  */
3989
+ export function getFileIcon(downloadId: number, options?: GetFileIconOptions): Promise<string | undefined>;
3990
+ export function getFileIcon(downloadId: number, callback: (iconURL?: string) => void): void;
3999
3991
  export function getFileIcon(
4000
3992
  downloadId: number,
4001
3993
  options: GetFileIconOptions,
4002
- callback: (iconURL: string) => void,
3994
+ callback: (iconURL?: string) => void,
4003
3995
  ): void;
3996
+
4004
3997
  /**
4005
- * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active.
3998
+ * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise {@link runtime.lastError} contains an error message. The request will fail if the download is not active.
4006
3999
  * @param downloadId The id of the download to resume.
4007
- * @return The `resume` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
4000
+ *
4001
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
4008
4002
  */
4009
4003
  export function resume(downloadId: number): Promise<void>;
4010
- /**
4011
- * Resume a paused download. If the request was successful the download is in progress and unpaused. Otherwise runtime.lastError contains an error message. The request will fail if the download is not active.
4012
- * @param downloadId The id of the download to resume.
4013
- * @param callback Called when the resume request is completed.
4014
- */
4015
4004
  export function resume(downloadId: number, callback: () => void): void;
4005
+
4016
4006
  /**
4017
- * Cancel a download. When callback is run, the download is cancelled, completed, interrupted or doesn't exist anymore.
4007
+ * Cancel a download. When `callback` is run, the download is cancelled, completed, interrupted or doesn't exist anymore.
4018
4008
  * @param downloadId The id of the download to cancel.
4019
- * @return The `cancel` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
4009
+ *
4010
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
4020
4011
  */
4021
4012
  export function cancel(downloadId: number): Promise<void>;
4022
- /**
4023
- * Cancel a download. When callback is run, the download is cancelled, completed, interrupted or doesn't exist anymore.
4024
- * @param downloadId The id of the download to cancel.
4025
- * @param callback Called when the cancel request is completed.
4026
- */
4027
4013
  export function cancel(downloadId: number, callback: () => void): void;
4014
+
4028
4015
  /**
4029
- * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If both filename and saveAs are specified, then the Save As dialog will be displayed, pre-populated with the specified filename. If the download started successfully, callback will be called with the new DownloadItem's downloadId. If there was an error starting the download, then callback will be called with downloadId=undefined and runtime.lastError will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it.
4016
+ * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If both `filename` and `saveAs` are specified, then the Save As dialog will be displayed, pre-populated with the specified `filename`. If the download started successfully, `callback` will be called with the new {@link DownloadItem}'s `downloadId`. If there was an error starting the download, then `callback` will be called with `downloadId=undefined` and {@link runtime.lastError} will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it.
4030
4017
  * @param options What to download and how.
4031
- * @return The `download` method provides its result via callback or returned as a `Promise` (MV3 only).
4018
+ *
4019
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
4032
4020
  */
4033
4021
  export function download(options: DownloadOptions): Promise<number>;
4034
- /**
4035
- * Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If both filename and saveAs are specified, then the Save As dialog will be displayed, pre-populated with the specified filename. If the download started successfully, callback will be called with the new DownloadItem's downloadId. If there was an error starting the download, then callback will be called with downloadId=undefined and runtime.lastError will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it.
4036
- * @param options What to download and how.
4037
- * @param callback Called with the id of the new DownloadItem.
4038
- */
4039
4022
  export function download(options: DownloadOptions, callback: (downloadId: number) => void): void;
4023
+
4040
4024
  /**
4041
- * Open the downloaded file now if the DownloadItem is complete; otherwise returns an error through runtime.lastError. Requires the "downloads.open" permission in addition to the "downloads" permission. An onChanged event will fire when the item is opened for the first time.
4025
+ * Opens the downloaded file now if the {@link DownloadItem} is complete; otherwise returns an error through {@link runtime.lastError}. This method requires the `"downloads.open"` permission in addition to the `"downloads"` permission. An {@link onChanged} event fires when the item is opened for the first time. This method can only be called in response to a user gesture.
4042
4026
  * @param downloadId The identifier for the downloaded file.
4027
+ *
4028
+ * Can return its result via Promise in Manifest V3 or later since Chrome 123.
4043
4029
  */
4044
- export function open(downloadId: number): void;
4030
+ export function open(downloadId: number): Promise<void>;
4031
+ export function open(
4032
+ downloadId: number,
4033
+ /** @since Chrome 123 */
4034
+ callback: () => void,
4035
+ ): void;
4036
+
4045
4037
  /**
4046
4038
  * Show the downloaded file in its folder in a file manager.
4047
4039
  * @param downloadId The identifier for the downloaded file.
4048
4040
  */
4049
4041
  export function show(downloadId: number): void;
4042
+
4050
4043
  /** Show the default Downloads folder in a file manager. */
4051
4044
  export function showDefaultFolder(): void;
4045
+
4052
4046
  /**
4053
- * Erase matching DownloadItem from history without deleting the downloaded file. An onErased event will fire for each DownloadItem that matches query, then callback will be called.
4054
- * @return The `erase` method provides its result via callback or returned as a `Promise` (MV3 only).
4047
+ * Erase matching {@link DownloadItem} from history without deleting the downloaded file. An {@link onErased} event will fire for each {@link DownloadItem} that matches `query`, then `callback` will be called.
4048
+ *
4049
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
4055
4050
  */
4056
4051
  export function erase(query: DownloadQuery): Promise<number[]>;
4057
- /**
4058
- * Erase matching DownloadItem from history without deleting the downloaded file. An onErased event will fire for each DownloadItem that matches query, then callback will be called.
4059
- */
4060
4052
  export function erase(query: DownloadQuery, callback: (erasedIds: number[]) => void): void;
4053
+
4061
4054
  /**
4062
- * Remove the downloaded file if it exists and the DownloadItem is complete; otherwise return an error through runtime.lastError.
4063
- * @return The `removeFile` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
4055
+ * Remove the downloaded file if it exists and the {@link DownloadItem} is complete; otherwise return an error through {@link runtime.lastError}.
4056
+ *
4057
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
4064
4058
  */
4065
4059
  export function removeFile(downloadId: number): Promise<void>;
4060
+ export function removeFile(downloadId: number, callback: () => void): void;
4061
+
4066
4062
  /**
4067
- * Remove the downloaded file if it exists and the DownloadItem is complete; otherwise return an error through runtime.lastError.
4068
- */
4069
- export function removeFile(downloadId: number, callback?: () => void): void;
4070
- /**
4071
- * Prompt the user to accept a dangerous download. Can only be called from a visible context (tab, window, or page/browser action popup). Does not automatically accept dangerous downloads. If the download is accepted, then an onChanged event will fire, otherwise nothing will happen. When all the data is fetched into a temporary file and either the download is not dangerous or the danger has been accepted, then the temporary file is renamed to the target filename, the |state| changes to 'complete', and onChanged fires.
4072
- * @param downloadId The identifier for the DownloadItem.
4073
- * @return The `acceptDanger` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
4063
+ * Prompt the user to accept a dangerous download. Can only be called from a visible context (tab, window, or page/browser action popup). Does not automatically accept dangerous downloads. If the download is accepted, then an {@link onChanged} event will fire, otherwise nothing will happen. When all the data is fetched into a temporary file and either the download is not dangerous or the danger has been accepted, then the temporary file is renamed to the target filename, the `state` changes to 'complete', and {@link onChanged} fires.
4064
+ * @param downloadId The identifier for the {@link DownloadItem}.
4065
+ *
4066
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
4074
4067
  */
4075
4068
  export function acceptDanger(downloadId: number): Promise<void>;
4069
+ export function acceptDanger(downloadId: number, callback: () => void): void;
4070
+
4076
4071
  /**
4077
- * Prompt the user to accept a dangerous download. Can only be called from a visible context (tab, window, or page/browser action popup). Does not automatically accept dangerous downloads. If the download is accepted, then an onChanged event will fire, otherwise nothing will happen. When all the data is fetched into a temporary file and either the download is not dangerous or the danger has been accepted, then the temporary file is renamed to the target filename, the |state| changes to 'complete', and onChanged fires.
4078
- * @param downloadId The identifier for the DownloadItem.
4079
- * @param callback Called when the danger prompt dialog closes.
4072
+ * Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through {@link runtime.lastError}. Requires the `"downloads.shelf"` permission in addition to the `"downloads"` permission.
4073
+ * @deprecated since Chrome 117. Use {@link setUiOptions} instead.
4080
4074
  */
4081
- export function acceptDanger(downloadId: number, callback: () => void): void;
4082
- /** Initiate dragging the downloaded file to another application. Call in a javascript ondragstart handler. */
4083
- export function drag(downloadId: number): void;
4084
- /** Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.shelf" permission in addition to the "downloads" permission. */
4085
4075
  export function setShelfEnabled(enabled: boolean): void;
4076
+
4086
4077
  /**
4087
- * Change the download UI of every window associated with the current browser profile. As long as at least one extension has set UiOptions.enabled to false, the download UI will be hidden. Setting UiOptions.enabled to true while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.ui" permission in addition to the "downloads" permission.
4088
- * @param options Encapsulate a change to the download UI.
4078
+ * Change the download UI of every window associated with the current browser profile. As long as at least one extension has set {@link UiOptions.enabled} to false, the download UI will be hidden. Setting {@link UiOptions.enabled} to true while at least one other extension has disabled it will return an error through {@link runtime.lastError}. Requires the `"downloads.ui"` permission in addition to the `"downloads"` permission.
4089
4079
  * @since Chrome 105
4080
+ *
4081
+ * Can return its result via Promise in Manifest V3 or later since Chrome 105.
4090
4082
  */
4091
4083
  export function setUiOptions(options: UiOptions): Promise<void>;
4092
- /**
4093
- * Change the download UI of every window associated with the current browser profile. As long as at least one extension has set UiOptions.enabled to false, the download UI will be hidden. Setting UiOptions.enabled to true while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.ui" permission in addition to the "downloads" permission.
4094
- * @param options Encapsulate a change to the download UI.
4095
- * @param callback Called when the setUiOptions request is completed.
4096
- * @since Chrome 105
4097
- */
4098
4084
  export function setUiOptions(options: UiOptions, callback: () => void): void;
4099
4085
 
4100
- /** When any of a DownloadItem's properties except bytesReceived and estimatedEndTime changes, this event fires with the downloadId and an object containing the properties that changed. */
4101
- export var onChanged: DownloadChangedEvent;
4102
- /** This event fires with the DownloadItem object when a download begins. */
4103
- export var onCreated: DownloadCreatedEvent;
4104
- /** Fires with the downloadId when a download is erased from history. */
4105
- export var onErased: DownloadErasedEvent;
4106
- /** During the filename determination process, extensions will be given the opportunity to override the target DownloadItem.filename. Each extension may not register more than one listener for this event. Each listener must call suggest exactly once, either synchronously or asynchronously. If the listener calls suggest asynchronously, then it must return true. If the listener neither calls suggest synchronously nor returns true, then suggest will be called automatically. The DownloadItem will not complete until all listeners have called suggest. Listeners may call suggest without any arguments in order to allow the download to use downloadItem.filename for its filename, or pass a suggestion object to suggest in order to override the target filename. If more than one extension overrides the filename, then the last extension installed whose listener passes a suggestion object to suggest wins. In order to avoid confusion regarding which extension will win, users should not install extensions that may conflict. If the download is initiated by download and the target filename is known before the MIME type and tentative filename have been determined, pass filename to download instead. */
4107
- export var onDeterminingFilename: DownloadDeterminingFilenameEvent;
4086
+ /** When any of a {@link DownloadItem}'s properties except `bytesReceived` and `estimatedEndTime` changes, this event fires with the `downloadId` and an object containing the properties that changed. */
4087
+ export const onChanged: events.Event<(downloadDelta: DownloadDelta) => void>;
4088
+
4089
+ /** This event fires with the {@link DownloadItem} object when a download begins. */
4090
+ export const onCreated: events.Event<(downloadItem: DownloadItem) => void>;
4091
+
4092
+ /** Fires with the `downloadId` when a download is erased from history. */
4093
+ export const onErased: events.Event<(downloadId: number) => void>;
4094
+
4095
+ /** During the filename determination process, extensions will be given the opportunity to override the target {@link DownloadItem.filename}. Each extension may not register more than one listener for this event. Each listener must call `suggest` exactly once, either synchronously or asynchronously. If the listener calls `suggest` asynchronously, then it must return `true`. If the listener neither calls `suggest` synchronously nor returns `true`, then `suggest` will be called automatically. The {@link DownloadItem} will not complete until all listeners have called `suggest`. Listeners may call `suggest` without any arguments in order to allow the download to use `downloadItem.filename` for its filename, or pass a `suggestion` object to `suggest` in order to override the target filename. If more than one extension overrides the filename, then the last extension installed whose listener passes a `suggestion` object to `suggest` wins. In order to avoid confusion regarding which extension will win, users should not install extensions that may conflict. If the download is initiated by {@link download} and the target filename is known before the MIME type and tentative filename have been determined, pass `filename` to {@link download} instead. */
4096
+ export const onDeterminingFilename: events.Event<
4097
+ (downloadItem: DownloadItem, suggest: (suggestion?: FilenameSuggestion) => void) => void
4098
+ >;
4108
4099
  }
4109
4100
 
4110
4101
  ////////////////////
@@ -4408,53 +4399,50 @@ export namespace Browser {
4408
4399
  export namespace events {
4409
4400
  /** Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */
4410
4401
  export interface UrlFilter {
4411
- /** Optional. Matches if the scheme of the URL is equal to any of the schemes specified in the array. */
4412
- schemes?: string[] | undefined;
4413
4402
  /**
4414
- * Optional.
4415
- * @since Chrome 23
4416
- * Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax.
4403
+ * Matches if the host part of the URL is an IP address and is contained in any of the CIDR blocks specified in the array.
4404
+ * @since Chrome 123
4417
4405
  */
4406
+ cidrBlocks?: string[] | undefined;
4407
+ /** Matches if the scheme of the URL is equal to any of the schemes specified in the array. */
4408
+ schemes?: string[] | undefined;
4409
+ /** Matches if the URL (without fragment identifier) matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */
4418
4410
  urlMatches?: string | undefined;
4419
- /** Optional. Matches if the path segment of the URL contains a specified string. */
4411
+ /** Matches if the path segment of the URL contains a specified string. */
4420
4412
  pathContains?: string | undefined;
4421
- /** Optional. Matches if the host name of the URL ends with a specified string. */
4413
+ /** Matches if the host name of the URL ends with a specified string. */
4422
4414
  hostSuffix?: string | undefined;
4423
- /** Optional. Matches if the host name of the URL starts with a specified string. */
4415
+ /** Matches if the host name of the URL starts with a specified string. */
4424
4416
  hostPrefix?: string | undefined;
4425
- /** Optional. Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */
4417
+ /** Matches if the host name of the URL contains a specified string. To test whether a host name component has a prefix 'foo', use hostContains: '.foo'. This matches 'www.foobar.com' and 'foo.com', because an implicit dot is added at the beginning of the host name. Similarly, hostContains can be used to match against component suffix ('foo.') and to exactly match against components ('.foo.'). Suffix- and exact-matching for the last components need to be done separately using hostSuffix, because no implicit dot is added at the end of the host name. */
4426
4418
  hostContains?: string | undefined;
4427
- /** Optional. Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */
4419
+ /** Matches if the URL (without fragment identifier) contains a specified string. Port numbers are stripped from the URL if they match the default port number. */
4428
4420
  urlContains?: string | undefined;
4429
- /** Optional. Matches if the query segment of the URL ends with a specified string. */
4421
+ /** Matches if the query segment of the URL ends with a specified string. */
4430
4422
  querySuffix?: string | undefined;
4431
- /** Optional. Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */
4423
+ /** Matches if the URL (without fragment identifier) starts with a specified string. Port numbers are stripped from the URL if they match the default port number. */
4432
4424
  urlPrefix?: string | undefined;
4433
- /** Optional. Matches if the host name of the URL is equal to a specified string. */
4425
+ /** Matches if the host name of the URL is equal to a specified string. */
4434
4426
  hostEquals?: string | undefined;
4435
- /** Optional. Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */
4427
+ /** Matches if the URL (without fragment identifier) is equal to a specified string. Port numbers are stripped from the URL if they match the default port number. */
4436
4428
  urlEquals?: string | undefined;
4437
- /** Optional. Matches if the query segment of the URL contains a specified string. */
4429
+ /** Matches if the query segment of the URL contains a specified string. */
4438
4430
  queryContains?: string | undefined;
4439
- /** Optional. Matches if the path segment of the URL starts with a specified string. */
4431
+ /** Matches if the path segment of the URL starts with a specified string. */
4440
4432
  pathPrefix?: string | undefined;
4441
- /** Optional. Matches if the path segment of the URL is equal to a specified string. */
4433
+ /** Matches if the path segment of the URL is equal to a specified string. */
4442
4434
  pathEquals?: string | undefined;
4443
- /** Optional. Matches if the path segment of the URL ends with a specified string. */
4435
+ /** Matches if the path segment of the URL ends with a specified string. */
4444
4436
  pathSuffix?: string | undefined;
4445
- /** Optional. Matches if the query segment of the URL is equal to a specified string. */
4437
+ /** Matches if the query segment of the URL is equal to a specified string. */
4446
4438
  queryEquals?: string | undefined;
4447
- /** Optional. Matches if the query segment of the URL starts with a specified string. */
4439
+ /** Matches if the query segment of the URL starts with a specified string. */
4448
4440
  queryPrefix?: string | undefined;
4449
- /** Optional. Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */
4441
+ /** Matches if the URL (without fragment identifier) ends with a specified string. Port numbers are stripped from the URL if they match the default port number. */
4450
4442
  urlSuffix?: string | undefined;
4451
- /** Optional. Matches if the port of the URL is contained in any of the specified port lists. For example [80, 443, [1000, 1200]] matches all requests on port 80, 443 and in the range 1000-1200. */
4443
+ /** Matches if the port of the URL is contained in any of the specified port lists. For example `[80, 443, [1000, 1200]]` matches all requests on port 80, 443 and in the range 1000-1200. */
4452
4444
  ports?: Array<number | number[]> | undefined;
4453
- /**
4454
- * Optional.
4455
- * @since Chrome 28
4456
- * Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax.
4457
- */
4445
+ /** Matches if the URL without query segment and fragment identifier matches a specified regular expression. Port numbers are stripped from the URL if they match the default port number. The regular expressions use the RE2 syntax. */
4458
4446
  originAndPathMatches?: string | undefined;
4459
4447
  }
4460
4448
 
@@ -4464,43 +4452,33 @@ export namespace Browser {
4464
4452
  * @param callback Called when an event occurs. The parameters of this function depend on the type of event.
4465
4453
  */
4466
4454
  addListener(callback: T): void;
4455
+
4467
4456
  /**
4468
4457
  * Returns currently registered rules.
4469
- * @param callback Called with registered rules.
4458
+ * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are returned.
4470
4459
  */
4471
4460
  getRules(
4472
- callback: (
4473
- /** Rules that were registered, the optional parameters are filled with values */
4474
- rules: Rule[],
4475
- ) => void,
4461
+ /** @param rules Rules that were registered, the optional parameters are filled with values */
4462
+ callback: (rules: Rule[]) => void,
4476
4463
  ): void;
4477
- /**
4478
- * Returns currently registered rules.
4479
- * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are returned.
4480
- * @param callback Called with registered rules.
4481
- */
4482
4464
  getRules(
4483
4465
  ruleIdentifiers: string[],
4484
- callback: (
4485
- /** Rules that were registered, the optional parameters are filled with values */
4486
- rules: Rule[],
4487
- ) => void,
4466
+ /** @param rules Rules that were registered, the optional parameters are filled with values */
4467
+ callback: (rules: Rule[]) => void,
4488
4468
  ): void;
4469
+
4489
4470
  /**
4490
4471
  * @param callback Listener whose registration status shall be tested.
4472
+ * @returns True if _callback_ is registered to the event.
4491
4473
  */
4492
4474
  hasListener(callback: T): boolean;
4475
+
4493
4476
  /**
4494
4477
  * Unregisters currently registered rules.
4495
4478
  * @param ruleIdentifiers If an array is passed, only rules with identifiers contained in this array are unregistered.
4496
- * @param callback Called when rules were unregistered.
4497
4479
  */
4498
- removeRules(ruleIdentifiers?: string[], callback?: () => void): void;
4499
- /**
4500
- * Unregisters currently registered rules.
4501
- * @param callback Called when rules were unregistered.
4502
- */
4503
- removeRules(callback?: () => void): void;
4480
+ removeRules(ruleIdentifiers?: string[] | undefined, callback?: () => void): void;
4481
+
4504
4482
  /**
4505
4483
  * Registers rules to handle events.
4506
4484
  * @param rules Rules to be registered. These do not replace previously registered rules.
@@ -4508,34 +4486,31 @@ export namespace Browser {
4508
4486
  */
4509
4487
  addRules(
4510
4488
  rules: Rule[],
4511
- callback?: (
4512
- /** Rules that were registered, the optional parameters are filled with values */
4513
- rules: Rule[],
4514
- ) => void,
4489
+ /** @param rules Rules that were registered, the optional parameters are filled with values */
4490
+ callback?: (rules: Rule[]) => void,
4515
4491
  ): void;
4492
+
4516
4493
  /**
4517
4494
  * Deregisters an event listener callback from an event.
4518
4495
  * @param callback Listener that shall be unregistered.
4519
4496
  */
4520
4497
  removeListener(callback: T): void;
4498
+
4499
+ /** @returns True if any event listeners are registered to the event. */
4521
4500
  hasListeners(): boolean;
4522
4501
  }
4523
4502
 
4524
4503
  /** Description of a declarative rule for handling events. */
4525
4504
  export interface Rule {
4526
- /** Optional. Optional priority of this rule. Defaults to 100. */
4505
+ /** Optional priority of this rule. Defaults to 100. */
4527
4506
  priority?: number | undefined;
4528
4507
  /** List of conditions that can trigger the actions. */
4529
4508
  conditions: any[];
4530
- /** Optional. Optional identifier that allows referencing this rule. */
4509
+ /** Optional identifier that allows referencing this rule. */
4531
4510
  id?: string | undefined;
4532
- /** List of actions that are triggered if one of the condtions is fulfilled. */
4511
+ /** List of actions that are triggered if one of the conditions is fulfilled. */
4533
4512
  actions: any[];
4534
- /**
4535
- * Optional.
4536
- * @since Chrome 28
4537
- * Tags can be used to annotate rules and perform operations on sets of rules.
4538
- */
4513
+ /** Tags can be used to annotate rules and perform operations on sets of rules. */
4539
4514
  tags?: string[] | undefined;
4540
4515
  }
4541
4516
  }
@@ -5793,72 +5768,67 @@ export namespace Browser {
5793
5768
  destinationId: string;
5794
5769
  /** The ID of the message. It must be unique for each message in scope of the applications. See the Cloud Messaging documentation for advice for picking and handling an ID. */
5795
5770
  messageId: string;
5796
- /** Optional. Time-to-live of the message in seconds. If it is not possible to send the message within that time, an onSendError event will be raised. A time-to-live of 0 indicates that the message should be sent immediately or fail if it's not possible. The maximum and a default value of time-to-live is 86400 seconds (1 day). */
5771
+ /** Time-to-live of the message in seconds. If it is not possible to send the message within that time, an onSendError event will be raised. A time-to-live of 0 indicates that the message should be sent immediately or fail if it's not possible. The default value of time-to-live is 86,400 seconds (1 day) and the maximum value is 2,419,200 seconds (28 days). */
5797
5772
  timeToLive?: number | undefined;
5798
- /** Message data to send to the server. Case-insensitive goog. and google, as well as case-sensitive collapse_key are disallowed as key prefixes. Sum of all key/value pairs should not exceed gcm.MAX_MESSAGE_SIZE. */
5773
+ /** Message data to send to the server. Case-insensitive `goog.` and `google`, as well as case-sensitive `collapse_key` are disallowed as key prefixes. Sum of all key/value pairs should not exceed {@link gcm.MAX_MESSAGE_SIZE}. */
5799
5774
  data: { [key: string]: unknown };
5800
5775
  }
5801
5776
 
5802
- export interface IncomingMessage {
5803
- /** The message data. */
5804
- data: { [key: string]: unknown };
5805
- /**
5806
- * Optional.
5807
- * The sender who issued the message.
5808
- * @since Chrome 41
5809
- */
5810
- from?: string | undefined;
5811
- /**
5812
- * Optional.
5813
- * The collapse key of a message. See Collapsible Messages section of Cloud Messaging documentation for details.
5814
- */
5815
- collapseKey?: string | undefined;
5816
- }
5817
-
5818
- export interface GcmError {
5819
- /** The error message describing the problem. */
5820
- errorMessage: string;
5821
- /** Optional. The ID of the message with this error, if error is related to a specific message. */
5822
- messageId?: string | undefined;
5823
- /** Additional details related to the error, when available. */
5824
- detail: object;
5825
- }
5826
-
5827
- export interface MessageReceptionEvent extends Browser.events.Event<(message: IncomingMessage) => void> {}
5828
-
5829
- export interface MessageDeletionEvent extends Browser.events.Event<() => void> {}
5830
-
5831
- export interface GcmErrorEvent extends Browser.events.Event<(error: GcmError) => void> {}
5832
-
5833
5777
  /** The maximum size (in bytes) of all key/value pairs in a message. */
5834
- export var MAX_MESSAGE_SIZE: number;
5778
+ export const MAX_MESSAGE_SIZE: 4096;
5835
5779
 
5836
5780
  /**
5837
- * Registers the application with GCM. The registration ID will be returned by the callback. If register is called again with the same list of senderIds, the same registration ID will be returned.
5781
+ * Registers the application with FCM. The registration ID will be returned by the `callback`. If `register` is called again with the same list of `senderIds`, the same registration ID will be returned.
5782
+ *
5783
+ * Can return its result via Promise in Manifest V3 or later since Chrome 116.
5838
5784
  * @param senderIds A list of server IDs that are allowed to send messages to the application. It should contain at least one and no more than 100 sender IDs.
5839
- * @param callback Function called when registration completes. It should check runtime.lastError for error when registrationId is empty.
5840
- * Parameter registrationId: A registration ID assigned to the application by the GCM.
5841
5785
  */
5786
+ export function register(senderIds: string[]): Promise<string>;
5842
5787
  export function register(senderIds: string[], callback: (registrationId: string) => void): void;
5788
+
5843
5789
  /**
5844
- * Unregisters the application from GCM.
5845
- * @param callback A function called after the unregistration completes. Unregistration was successful if runtime.lastError is not set.
5790
+ * Unregister the application from FCM.
5791
+ *
5792
+ * Can return its result via Promise in Manifest V3 or later since Chrome 116.
5846
5793
  */
5794
+ export function unregister(): Promise<void>;
5847
5795
  export function unregister(callback: () => void): void;
5796
+
5848
5797
  /**
5849
5798
  * Sends a message according to its contents.
5850
- * @param message A message to send to the other party via GCM.
5851
- * @param callback A function called after the message is successfully queued for sending. runtime.lastError should be checked, to ensure a message was sent without problems.
5852
- * Parameter messageId: The ID of the message that the callback was issued for.
5799
+ *
5800
+ * Can return its result via Promise in Manifest V3 or later since Chrome 116.
5801
+ * @param message A message to send to the other party via FCM.
5853
5802
  */
5803
+ export function send(message: OutgoingMessage): Promise<string>;
5854
5804
  export function send(message: OutgoingMessage, callback: (messageId: string) => void): void;
5855
5805
 
5856
- /** Fired when a message is received through GCM. */
5857
- export var onMessage: MessageReceptionEvent;
5858
- /** Fired when a GCM server had to delete messages sent by an app server to the application. See Messages deleted event section of Cloud Messaging documentation for details on handling this event. */
5859
- export var onMessagesDeleted: MessageDeletionEvent;
5860
- /** Fired when it was not possible to send a message to the GCM server. */
5861
- export var onSendError: GcmErrorEvent;
5806
+ /** Fired when a message is received through FCM. */
5807
+ export const onMessage: events.Event<
5808
+ (message: {
5809
+ /** The collapse key of a message. See the Non-collapsible and collapsible messages for details. */
5810
+ collapseKey?: string;
5811
+ /** The message data. */
5812
+ data: { [key: string]: unknown };
5813
+ /** The sender who issued the message. */
5814
+ from?: string;
5815
+ }) => void
5816
+ >;
5817
+
5818
+ /** Fired when a FCM server had to delete messages sent by an app server to the application. See Lifetime of a message for details on handling this event. */
5819
+ export const onMessagesDeleted: events.Event<() => void>;
5820
+
5821
+ /** Fired when it was not possible to send a message to the FCM server. */
5822
+ export const onSendError: events.Event<
5823
+ (error: {
5824
+ /** Additional details related to the error, when available. */
5825
+ details: { [key: string]: unknown };
5826
+ /** The error message describing the problem. */
5827
+ errorMessage: string;
5828
+ /** The ID of the message with this error, if error is related to a specific message. */
5829
+ messageId?: string;
5830
+ }) => void
5831
+ >;
5862
5832
  }
5863
5833
 
5864
5834
  ////////////////////
@@ -7815,73 +7785,80 @@ export namespace Browser {
7815
7785
  export interface Match {
7816
7786
  /** The DER encoding of a X.509 certificate. */
7817
7787
  certificate: ArrayBuffer;
7818
- /** The KeyAlgorithm of the certified key. This contains algorithm parameters that are inherent to the key of the certificate (e.g. the key length). Other parameters like the hash function used by the sign function are not included. */
7788
+ /** The KeyAlgorithm of the certified key. This contains algorithm parameters that are inherent to the key of the certificate (e.g. the key length). Other parameters like the hash function used by the sign function are not included. */
7819
7789
  keyAlgorithm: KeyAlgorithm;
7820
7790
  }
7821
7791
 
7822
- export interface ClientCertificateSelectRequestDetails {
7823
- /** This field is a list of the types of certificates requested, sorted in order of the server's preference. Only certificates of a type contained in this list will be retrieved. If certificateTypes is the empty list, however, certificates of any type will be returned. */
7824
- certificateTypes: string[];
7792
+ export interface ClientCertificateRequest {
7793
+ /** This field is a list of the types of certificates requested, sorted in order of the server's preference. Only certificates of a type contained in this list will be retrieved. If `certificateTypes` is the empty list, however, certificates of any type will be returned. */
7794
+ certificateTypes: `${ClientCertificateType}`[];
7825
7795
  /** List of distinguished names of certificate authorities allowed by the server. Each entry must be a DER-encoded X.509 DistinguishedName. */
7826
7796
  certificateAuthorities: ArrayBuffer[];
7827
7797
  }
7828
7798
 
7829
- export interface ClientCertificateSelectDetails {
7799
+ export enum ClientCertificateType {
7800
+ ECDSA_SIGN = "ecdsaSign",
7801
+ RAS_SIGN = "rasSign",
7802
+ }
7803
+
7804
+ export interface SelectDetails {
7830
7805
  /** Only certificates that match this request will be returned. */
7831
- request: ClientCertificateSelectRequestDetails;
7832
- /**
7833
- * Optional.
7834
- * If given, the selectClientCertificates operates on this list. Otherwise, obtains the list of all certificates from the platform's certificate stores that are available to this extensions. Entries that the extension doesn't have permission for or which doesn't match the request, are removed.
7835
- */
7806
+ request: ClientCertificateRequest;
7807
+ /** If given, the `selectClientCertificates` operates on this list. Otherwise, obtains the list of all certificates from the platform's certificate stores that are available to this extensions. Entries that the extension doesn't have permission for or which doesn't match the request, are removed. */
7836
7808
  clientCerts?: ArrayBuffer[] | undefined;
7837
7809
  /** If true, the filtered list is presented to the user to manually select a certificate and thereby granting the extension access to the certificate(s) and key(s). Only the selected certificate(s) will be returned. If is false, the list is reduced to all certificates that the extension has been granted access to (automatically or manually). */
7838
7810
  interactive: boolean;
7839
7811
  }
7840
7812
 
7841
- export interface ServerCertificateVerificationDetails {
7813
+ export interface VerificationDetails {
7842
7814
  /** Each chain entry must be the DER encoding of a X.509 certificate, the first entry must be the server certificate and each entry must certify the entry preceding it. */
7843
7815
  serverCertificateChain: ArrayBuffer[];
7844
- /** The hostname of the server to verify the certificate for, e.g. the server that presented the serverCertificateChain. */
7816
+ /** The hostname of the server to verify the certificate for, e.g. the server that presented the `serverCertificateChain`. */
7845
7817
  hostname: string;
7846
7818
  }
7847
7819
 
7848
- export interface ServerCertificateVerificationResult {
7820
+ export interface VerificationResult {
7849
7821
  /** The result of the trust verification: true if trust for the given verification details could be established and false if trust is rejected for any reason. */
7850
7822
  trusted: boolean;
7851
7823
  /**
7852
7824
  * If the trust verification failed, this array contains the errors reported by the underlying network layer. Otherwise, this array is empty.
7825
+ *
7853
7826
  * Note: This list is meant for debugging only and may not contain all relevant errors. The errors returned may change in future revisions of this API, and are not guaranteed to be forwards or backwards compatible.
7854
7827
  */
7855
7828
  debug_errors: string[];
7856
7829
  }
7857
7830
 
7858
7831
  /**
7859
- * This function filters from a list of client certificates the ones that are known to the platform, match request and for which the extension has permission to access the certificate and its private key. If interactive is true, the user is presented a dialog where they can select from matching certificates and grant the extension access to the certificate. The selected/filtered client certificates will be passed to callback.
7860
- * Parameter matches: The list of certificates that match the request, that the extension has permission for and, if interactive is true, that were selected by the user.
7832
+ * This method filters from a list of client certificates the ones that are known to the platform, match `request` and for which the extension has permission to access the certificate and its private key. If `interactive` is true, the user is presented a dialog where they can select from matching certificates and grant the extension access to the certificate. The selected/filtered client certificates will be passed to `callback`.
7833
+ *
7834
+ * Can return its result via Promise in Manifest V3 or later since Chrome 121.
7861
7835
  */
7836
+ export function selectClientCertificates(details: SelectDetails): Promise<Match[]>;
7862
7837
  export function selectClientCertificates(
7863
- details: ClientCertificateSelectDetails,
7838
+ details: SelectDetails,
7864
7839
  callback: (matches: Match[]) => void,
7865
7840
  ): void;
7841
+
7866
7842
  /**
7867
- * Passes the key pair of certificate for usage with platformKeys.subtleCrypto to callback.
7868
- * @param certificate The certificate of a Match returned by selectClientCertificates.
7869
- * @param parameters Determines signature/hash algorithm parameters additionally to the parameters fixed by the key itself. The same parameters are accepted as by WebCrypto's importKey function, e.g. RsaHashedImportParams for a RSASSA-PKCS1-v1_5 key. For RSASSA-PKCS1-v1_5 keys, additionally the parameters { 'hash': { 'name': 'none' } } are supported. The sign function will then apply PKCS#1 v1.5 padding and but not hash the given data.
7870
- * @param callback The public and private CryptoKey of a certificate which can only be used with platformKeys.subtleCrypto.
7871
- * Optional parameter privateKey: Might be null if this extension does not have access to it.
7843
+ * Passes the key pair of `certificate` for usage with {@link platformKeys.subtleCrypto} to `callback`.
7844
+ * @param certificate The certificate of a {@link Match} returned by {@link selectClientCertificates}.
7845
+ * @param parameters Determines signature/hash algorithm parameters additionally to the parameters fixed by the key itself. The same parameters are accepted as by WebCrypto's importKey function, e.g. `RsaHashedImportParams` for a RSASSA-PKCS1-v1_5 key and `EcKeyImportParams` for EC key. Additionally for RSASSA-PKCS1-v1_5 keys, hashing algorithm name parameter can be specified with one of the following values: "none", "SHA-1", "SHA-256", "SHA-384", or "SHA-512", e.g. `{"hash": { "name": "none" } }`. The sign function will then apply PKCS#1 v1.5 padding but not hash the given data.
7846
+ *
7847
+ * Currently, this method only supports the "RSASSA-PKCS1-v1\_5" and "ECDSA" algorithms.
7872
7848
  */
7873
7849
  export function getKeyPair(
7874
7850
  certificate: ArrayBuffer,
7875
7851
  parameters: { [key: string]: unknown },
7876
7852
  callback: (publicKey: CryptoKey, privateKey: CryptoKey | null) => void,
7877
7853
  ): void;
7854
+
7878
7855
  /**
7879
- * Passes the key pair of publicKeySpkiDer for usage with platformKeys.subtleCrypto to callback.
7856
+ * Passes the key pair identified by `publicKeySpkiDer` for usage with {@link platformKeys.subtleCrypto} to `callback`.
7857
+ *
7880
7858
  * @param publicKeySpkiDer A DER-encoded X.509 SubjectPublicKeyInfo, obtained e.g. by calling WebCrypto's exportKey function with format="spki".
7881
- * @param parameters Provides signature and hash algorithm parameters, in addition to those fixed by the key itself. The same parameters are accepted as by WebCrypto's importKey function, e.g. RsaHashedImportParams for a RSASSA-PKCS1-v1_5 key. For RSASSA-PKCS1-v1_5 keys, we need to also pass a "hash" parameter { "hash": { "name": string } }. The "hash" parameter represents the name of the hashing algorithm to be used in the digest operation before a sign. It is possible to pass "none" as the hash name, in which case the sign function will apply PKCS#1 v1.5 padding and but not hash the given data.
7882
- * Currently, this function only supports the "RSASSA-PKCS1-v1_5" algorithm with one of the hashing algorithms "none", "SHA-1", "SHA-256", "SHA-384", and "SHA-512".
7883
- * @param callback The public and private CryptoKey of a certificate which can only be used with platformKeys.subtleCrypto.
7884
- * Optional parameter privateKey: Might be null if this extension does not have access to it.
7859
+ * @param parameters Provides signature and hash algorithm parameters, in addition to those fixed by the key itself. The same parameters are accepted as by WebCrypto's [importKey](https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-importKey) function, e.g. `RsaHashedImportParams` for a RSASSA-PKCS1-v1\_5 key. For RSASSA-PKCS1-v1\_5 keys, we need to also pass a "hash" parameter `{ "hash": { "name": string } }`. The "hash" parameter represents the name of the hashing algorithm to be used in the digest operation before a sign. It is possible to pass "none" as the hash name, in which case the sign function will apply PKCS#1 v1.5 padding and but not hash the given data.
7860
+ *
7861
+ * Currently, this method supports the "ECDSA" algorithm with named-curve P-256 and "RSASSA-PKCS1-v1\_5" algorithm with one of the hashing algorithms "none", "SHA-1", "SHA-256", "SHA-384", and "SHA-512".
7885
7862
  * @since Chrome 85
7886
7863
  */
7887
7864
  export function getKeyPairBySpki(
@@ -7889,14 +7866,19 @@ export namespace Browser {
7889
7866
  parameters: { [key: string]: unknown },
7890
7867
  callback: (publicKey: CryptoKey, privateKey: CryptoKey | null) => void,
7891
7868
  ): void;
7892
- /** An implementation of WebCrypto's SubtleCrypto that allows crypto operations on keys of client certificates that are available to this extension. */
7893
- export function subtleCrypto(): SubtleCrypto;
7869
+
7870
+ /** An implementation of WebCrypto's SubtleCrypto that allows crypto operations on keys of client certificates that are available to this extension. */
7871
+ export function subtleCrypto(): SubtleCrypto | undefined;
7872
+
7894
7873
  /**
7895
- * Checks whether details.serverCertificateChain can be trusted for details.hostname according to the trust settings of the platform. Note: The actual behavior of the trust verification is not fully specified and might change in the future. The API implementation verifies certificate expiration, validates the certification path and checks trust by a known CA. The implementation is supposed to respect the EKU serverAuth and to support subject alternative names.
7874
+ * Checks whether `details.serverCertificateChain` can be trusted for `details.hostname` according to the trust settings of the platform. Note: The actual behavior of the trust verification is not fully specified and might change in the future. The API implementation verifies certificate expiration, validates the certification path and checks trust by a known CA. The implementation is supposed to respect the EKU serverAuth and to support subject alternative names.
7875
+ *
7876
+ * Can return its result via Promise in Manifest V3 or later since Chrome 121.
7896
7877
  */
7878
+ export function verifyTLSServerCertificate(details: VerificationDetails): Promise<VerificationResult>;
7897
7879
  export function verifyTLSServerCertificate(
7898
- details: ServerCertificateVerificationDetails,
7899
- callback: (result: ServerCertificateVerificationResult) => void,
7880
+ details: VerificationDetails,
7881
+ callback: (result: VerificationResult) => void,
7900
7882
  ): void;
7901
7883
  }
7902
7884
 
@@ -8959,37 +8941,114 @@ export namespace Browser {
8959
8941
  * Use the `Browser.runtime` API to retrieve the service worker, return details about the manifest, and listen for and respond to events in the extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.
8960
8942
  */
8961
8943
  export namespace runtime {
8962
- /** This will be defined during an API method callback if there was an error */
8963
- export var lastError: LastError | undefined;
8944
+ /** Populated with an error message if calling an API function fails; otherwise undefined. This is only defined within the scope of that function's callback. If an error is produced, but `runtime.lastError` is not accessed within the callback, a message is logged to the console listing the API function that produced the error. API functions that return promises do not set this property. */
8945
+ export const lastError: {
8946
+ /** Details about the error which occurred. */
8947
+ message?: string;
8948
+ } | undefined;
8949
+
8964
8950
  /** The ID of the extension/app. */
8965
- export var id: string;
8966
-
8967
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-PlatformOs */
8968
- export type PlatformOs = "mac" | "win" | "android" | "cros" | "linux" | "openbsd" | "fuchsia";
8969
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-PlatformArch */
8970
- export type PlatformArch = "arm" | "arm64" | "x86-32" | "x86-64" | "mips" | "mips64";
8971
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-PlatformNaclArch */
8972
- export type PlatformNaclArch = "arm" | "x86-32" | "x86-64" | "mips" | "mips64";
8973
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-ContextType */
8951
+ export const id: string;
8952
+
8953
+ /**
8954
+ * The operating system Chrome is running on.
8955
+ * @since Chrome 44
8956
+ */
8957
+ export enum PlatformOs {
8958
+ /** Specifies the MacOS operating system. */
8959
+ MAC = "mac",
8960
+ /** Specifies the Windows operating system. */
8961
+ WIN = "win",
8962
+ /** Specifies the Android operating system. */
8963
+ ANDROID = "android",
8964
+ /** Specifies the Chrome operating system. */
8965
+ CROS = "cros",
8966
+ /** Specifies the Linux operating system. */
8967
+ LINUX = "linux",
8968
+ /** Specifies the OpenBSD operating system. */
8969
+ OPENBSD = "openbsd",
8970
+ /** Specifies the Fuchsia operating system. */
8971
+ FUCHSIA = "fuchsia",
8972
+ }
8973
+
8974
+ /**
8975
+ * The machine's processor architecture.
8976
+ * @since Chrome 44
8977
+ */
8978
+ export enum PlatformArch {
8979
+ /** Specifies the processer architecture as arm. */
8980
+ ARM = "arm",
8981
+ /** Specifies the processer architecture as arm64. */
8982
+ ARM64 = "arm64",
8983
+ /** Specifies the processer architecture as x86-32. */
8984
+ X86_32 = "x86-32",
8985
+ /** Specifies the processer architecture as x86-64. */
8986
+ X86_64 = "x86-64",
8987
+ /** Specifies the processer architecture as mips. */
8988
+ MIPS = "mips",
8989
+ /** Specifies the processer architecture as mips64. */
8990
+ MIPS64 = "mips64",
8991
+ }
8992
+
8993
+ /**
8994
+ * The native client architecture. This may be different from arch on some platforms.
8995
+ * @since Chrome 44
8996
+ */
8997
+ export enum PlatformNaclArch {
8998
+ /** Specifies the native client architecture as arm. */
8999
+ ARM = "arm",
9000
+ /** Specifies the native client architecture as x86-32. */
9001
+ X86_32 = "x86-32",
9002
+ /** Specifies the native client architecture as x86-64. */
9003
+ X86_64 = "x86-64",
9004
+ /** Specifies the native client architecture as mips. */
9005
+ MIPS = "mips",
9006
+ /** Specifies the native client architecture as mips64. */
9007
+ MIPS64 = "mips64",
9008
+ }
9009
+
9010
+ /** @since Chrome 114 */
8974
9011
  export enum ContextType {
9012
+ /** Specifies the context type as a tab */
8975
9013
  TAB = "TAB",
9014
+ /** Specifies the context type as an extension popup window */
8976
9015
  POPUP = "POPUP",
9016
+ /** Specifies the context type as a service worker. */
8977
9017
  BACKGROUND = "BACKGROUND",
9018
+ /** Specifies the context type as an offscreen document. */
8978
9019
  OFFSCREEN_DOCUMENT = "OFFSCREEN_DOCUMENT",
9020
+ /** Specifies the context type as a side panel. */
8979
9021
  SIDE_PANEL = "SIDE_PANEL",
9022
+ /** Specifies the context type as developer tools. */
8980
9023
  DEVELOPER_TOOLS = "DEVELOPER_TOOLS",
8981
9024
  }
8982
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-OnInstalledReason */
9025
+
9026
+ /**
9027
+ * The reason that this event is being dispatched.
9028
+ * @since Chrome 44
9029
+ */
8983
9030
  export enum OnInstalledReason {
9031
+ /** Specifies the event reason as an installation. */
8984
9032
  INSTALL = "install",
9033
+ /** Specifies the event reason as an extension update. */
8985
9034
  UPDATE = "update",
9035
+ /** Specifies the event reason as a Chrome update. */
8986
9036
  CHROME_UPDATE = "chrome_update",
9037
+ /** Specifies the event reason as an update to a shared module. */
8987
9038
  SHARED_MODULE_UPDATE = "shared_module_update",
8988
9039
  }
8989
9040
 
8990
- export interface LastError {
8991
- /** Optional. Details about the error which occurred. */
8992
- message?: string | undefined;
9041
+ /**
9042
+ * The reason that the event is being dispatched. 'app_update' is used when the restart is needed because the application is updated to a newer version. 'os_update' is used when the restart is needed because the browser/OS is updated to a newer version. 'periodic' is used when the system runs for more than the permitted uptime set in the enterprise policy.
9043
+ * @since Chrome 44
9044
+ */
9045
+ export enum OnRestartRequiredReason {
9046
+ /** Specifies the event reason as an update to the app. */
9047
+ APP_UPDATE = "app_update",
9048
+ /** Specifies the event reason as an update to the operating system. */
9049
+ OS_UPDATE = "os_update",
9050
+ /** Specifies the event reason as a periodic restart of the app. */
9051
+ PERIODIC = "periodic",
8993
9052
  }
8994
9053
 
8995
9054
  /**
@@ -8998,7 +9057,7 @@ export namespace Browser {
8998
9057
  */
8999
9058
  export interface ContextFilter {
9000
9059
  contextIds?: string[] | undefined;
9001
- contextTypes?: ContextType[] | undefined;
9060
+ contextTypes?: `${ContextType}`[] | undefined;
9002
9061
  documentIds?: string[] | undefined;
9003
9062
  documentOrigins?: string[] | undefined;
9004
9063
  documentUrls?: string[] | undefined;
@@ -9009,26 +9068,19 @@ export namespace Browser {
9009
9068
  }
9010
9069
 
9011
9070
  export interface ConnectInfo {
9071
+ /** Will be passed into onConnect for processes that are listening for the connection event. */
9012
9072
  name?: string | undefined;
9073
+ /** Whether the TLS channel ID will be passed into onConnectExternal for processes that are listening for the connection event. */
9013
9074
  includeTlsChannelId?: boolean | undefined;
9014
9075
  }
9015
9076
 
9016
9077
  export interface InstalledDetails {
9017
- /**
9018
- * The reason that this event is being dispatched.
9019
- */
9078
+ /** The reason that this event is being dispatched. */
9020
9079
  reason: `${OnInstalledReason}`;
9021
- /**
9022
- * Optional.
9023
- * Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'.
9024
- */
9025
- previousVersion?: string | undefined;
9026
- /**
9027
- * Optional.
9028
- * Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'.
9029
- * @since Chrome 29
9030
- */
9031
- id?: string | undefined;
9080
+ /** Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'. */
9081
+ previousVersion?: string;
9082
+ /** Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'. */
9083
+ id?: string;
9032
9084
  }
9033
9085
 
9034
9086
  /**
@@ -9039,29 +9091,20 @@ export namespace Browser {
9039
9091
  /** A unique identifier for this context */
9040
9092
  contextId: string;
9041
9093
  /** The type of context this corresponds to. */
9042
- contextType: ContextType;
9043
- /**
9044
- * Optional.
9045
- * A UUID for the document associated with this context, or undefined if this context is hosted not in a document.
9046
- */
9047
- documentId?: string | undefined;
9048
- /**
9049
- * Optional.
9050
- * The origin of the document associated with this context, or undefined if the context is not hosted in a document.
9051
- */
9052
- documentOrigin?: string | undefined;
9053
- /**
9054
- * Optional.
9055
- * The URL of the document associated with this context, or undefined if the context is not hosted in a document.
9056
- */
9057
- documentUrl?: string | undefined;
9058
- /** The ID of the frame for this context, or -1 if this context is not hosted in a frame. */
9094
+ contextType: `${ContextType}`;
9095
+ /** A UUID for the document associated with this context, or undefined if this context is hosted not in a document.*/
9096
+ documentId?: string;
9097
+ /** The origin of the document associated with this context, or undefined if the context is not hosted in a document. */
9098
+ documentOrigin?: string;
9099
+ /** The URL of the document associated with this context, or undefined if the context is not hosted in a document. */
9100
+ documentUrl?: string;
9101
+ /** The ID of the frame for this context, or `-1` if this context is not hosted in a frame. */
9059
9102
  frameId: number;
9060
9103
  /** Whether the context is associated with an incognito profile. */
9061
9104
  incognito: boolean;
9062
- /** The ID of the tab for this context, or -1 if this context is not hosted in a tab. */
9105
+ /** The ID of the tab for this context, or `-1` if this context is not hosted in a tab. */
9063
9106
  tabId: number;
9064
- /** The ID of the window for this context, or -1 if this context is not hosted in a window. */
9107
+ /** The ID of the window for this context, or `-1` if this context is not hosted in a window. */
9065
9108
  windowId: number;
9066
9109
  }
9067
9110
 
@@ -9070,132 +9113,91 @@ export namespace Browser {
9070
9113
  includeTlsChannelId?: boolean | undefined;
9071
9114
  }
9072
9115
 
9073
- /**
9074
- * An object containing information about the script context that sent a message or request.
9075
- * @since Chrome 26
9076
- */
9116
+ /** An object containing information about the script context that sent a message or request */
9077
9117
  export interface MessageSender {
9078
- /** The ID of the extension or app that opened the connection, if any. */
9079
- id?: string | undefined;
9080
- /** The tabs.Tab which opened the connection, if any. This property will only be present when the connection was opened from a tab (including content scripts), and only if the receiver is an extension, not an app. */
9081
- tab?: Browser.tabs.Tab | undefined;
9082
- /** The name of the native application that opened the connection, if any.
9118
+ /** The ID of the extension that opened the connection, if any. */
9119
+ id?: string;
9120
+ /** The {@link tabs.Tab} which opened the connection, if any. This property will **only** be present when the connection was opened from a tab (including content scripts), and **only** if the receiver is an extension, not an app. */
9121
+ tab?: Browser.tabs.Tab;
9122
+ /**
9123
+ * The name of the native application that opened the connection, if any.
9083
9124
  * @since Chrome 74
9084
9125
  */
9085
- nativeApplication?: string | undefined;
9126
+ nativeApplication?: string;
9127
+ /** The frame that opened the connection. 0 for top-level frames, positive for child frames. This will only be set when tab is set. */
9128
+ frameId?: number;
9129
+ /** The URL of the page or frame that opened the connection. If the sender is in an iframe, it will be iframe's URL not the URL of the page which hosts it. */
9130
+ url?: string;
9131
+ /** The TLS channel ID of the page or frame that opened the connection, if requested by the extension, and if available */
9132
+ tlsChannelId?: string;
9086
9133
  /**
9087
- * The frame that opened the connection. 0 for top-level frames, positive for child frames. This will only be set when tab is set.
9088
- * @since Chrome 41
9134
+ * The origin of the page or frame that opened the connection. It can vary from the url property (e.g., about:blank) or can be opaque (e.g., sandboxed iframes). This is useful for identifying if the origin can be trusted if we can't immediately tell from the URL.
9135
+ * @since Chrome 80
9089
9136
  */
9090
- frameId?: number | undefined;
9091
- /**
9092
- * The URL of the page or frame that opened the connection. If the sender is in an iframe, it will be iframe's URL not the URL of the page which hosts it.
9093
- * @since Chrome 28
9094
- */
9095
- url?: string | undefined;
9096
- /**
9097
- * The TLS channel ID of the page or frame that opened the connection, if requested by the extension or app, and if available.
9098
- * @since Chrome 32
9099
- */
9100
- tlsChannelId?: string | undefined;
9101
- /**
9102
- * The origin of the page or frame that opened the connection. It can vary from the url property (e.g., about:blank) or can be opaque (e.g., sandboxed iframes). This is useful for identifying if the origin can be trusted if we can't immediately tell from the URL.
9103
- * @since Chrome 80
9104
- */
9105
- origin?: string | undefined;
9137
+ origin?: string;
9106
9138
  /**
9107
9139
  * The lifecycle the document that opened the connection is in at the time the port was created. Note that the lifecycle state of the document may have changed since port creation.
9108
9140
  * @since Chrome 106
9109
9141
  */
9110
- documentLifecycle?: extensionTypes.DocumentLifecycle | undefined;
9142
+ documentLifecycle?: extensionTypes.DocumentLifecycle;
9111
9143
  /**
9112
9144
  * A UUID of the document that opened the connection.
9113
9145
  * @since Chrome 106
9114
9146
  */
9115
- documentId?: string | undefined;
9147
+ documentId?: string;
9116
9148
  }
9117
9149
 
9118
- /**
9119
- * An object containing information about the current platform.
9120
- * @since Chrome 36
9121
- */
9150
+ /** An object containing information about the current platform. */
9122
9151
  export interface PlatformInfo {
9123
- /**
9124
- * The operating system chrome is running on.
9125
- */
9126
- os: PlatformOs;
9127
- /**
9128
- * The machine's processor architecture.
9129
- */
9130
- arch: PlatformArch;
9131
- /**
9132
- * The native client architecture. This may be different from arch on some platforms.
9133
- */
9134
- nacl_arch: PlatformNaclArch;
9152
+ /** The operating system Chrome is running on. */
9153
+ os: `${PlatformOs}`;
9154
+ /** The machine's processor architecture. */
9155
+ arch: `${PlatformArch}`;
9156
+ /** The native client architecture. This may be different from arch on some platforms. */
9157
+ nacl_arch: `${PlatformNaclArch}`;
9135
9158
  }
9136
9159
 
9137
- /**
9138
- * An object which allows two way communication with other pages.
9139
- * @since Chrome 26
9140
- */
9160
+ /** An object which allows two way communication with other pages. */
9141
9161
  export interface Port {
9162
+ /** Send a message to the other end of the port. If the port is disconnected, an error is thrown. */
9142
9163
  postMessage: (message: any) => void;
9164
+ /** Immediately disconnect the port. Calling `disconnect()` on an already-disconnected port has no effect. When a port is disconnected, no new events will be dispatched to this port. */
9143
9165
  disconnect: () => void;
9144
- /**
9145
- * Optional.
9146
- * This property will only be present on ports passed to onConnect/onConnectExternal listeners.
9147
- */
9148
- sender?: MessageSender | undefined;
9149
- /** An object which allows the addition and removal of listeners for a Chrome event. */
9150
- onDisconnect: PortDisconnectEvent;
9151
- /** An object which allows the addition and removal of listeners for a Chrome event. */
9152
- onMessage: PortMessageEvent;
9166
+ /** This property will **only** be present on ports passed to {@link runtime.onConnect onConnect} / {@link runtime.onConnectExternal onConnectExternal} / {@link runtime.onConnectExternal onConnectNative} listeners. */
9167
+ sender?: MessageSender;
9168
+ /** Fired when the port is disconnected from the other end(s). {@link runtime.lastError} may be set if the port was disconnected by an error. If the port is closed via {@link Port.disconnect disconnect}, then this event is _only_ fired on the other end. This event is fired at most once (see also Port lifetime). */
9169
+ onDisconnect: events.Event<(port: Port) => void>;
9170
+ /** This event is fired when {@link Port.postMessage postMessage} is called by the other end of the port. */
9171
+ onMessage: events.Event<(message: any, port: Port) => void>;
9172
+ /** The name of the port, as specified in the call to {@link runtime.connect}. */
9153
9173
  name: string;
9154
9174
  }
9155
9175
 
9156
- export interface UpdateAvailableDetails {
9157
- /** The version number of the available update. */
9158
- version: string;
9159
- }
9160
-
9161
9176
  export interface UpdateCheckDetails {
9162
9177
  /** The version of the available update. */
9163
9178
  version: string;
9164
9179
  }
9165
9180
 
9166
- /** Result of the update check. */
9167
- export type RequestUpdateCheckStatus = "throttled" | "no_update" | "update_available";
9181
+ /**
9182
+ * Result of the update check.
9183
+ * @since Chrome 44
9184
+ */
9185
+ export enum RequestUpdateCheckStatus {
9186
+ /** Specifies that the status check has been throttled. This can occur after repeated checks within a short amount of time. */
9187
+ THROTTLED = "throttled",
9188
+ /** Specifies that there are no available updates to install. */
9189
+ NO_UPDATE = "no_update",
9190
+ /** Specifies that there is an available update to install. */
9191
+ UPDATE_AVAILABLE = "update_available",
9192
+ }
9168
9193
 
9169
- /** Result of the update check. */
9170
9194
  export interface RequestUpdateCheckResult {
9171
- /** The status of the update check. */
9172
- status: RequestUpdateCheckStatus;
9173
- /** The version of the available update. */
9174
- version: string;
9195
+ /** Result of the update check. */
9196
+ status: `${RequestUpdateCheckStatus}`;
9197
+ /** If an update is available, this contains the version of the available update. */
9198
+ version?: string;
9175
9199
  }
9176
9200
 
9177
- export interface PortDisconnectEvent extends Browser.events.Event<(port: Port) => void> {}
9178
-
9179
- export interface PortMessageEvent extends Browser.events.Event<(message: any, port: Port) => void> {}
9180
-
9181
- export interface ExtensionMessageEvent extends
9182
- Browser.events.Event<
9183
- (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void
9184
- >
9185
- {}
9186
-
9187
- export interface ExtensionConnectEvent extends Browser.events.Event<(port: Port) => void> {}
9188
-
9189
- export interface RuntimeInstalledEvent extends Browser.events.Event<(details: InstalledDetails) => void> {}
9190
-
9191
- export interface RuntimeEvent extends Browser.events.Event<() => void> {}
9192
-
9193
- export interface RuntimeRestartRequiredEvent extends Browser.events.Event<(reason: string) => void> {}
9194
-
9195
- export interface RuntimeUpdateAvailableEvent
9196
- extends Browser.events.Event<(details: UpdateAvailableDetails) => void>
9197
- {}
9198
-
9199
9201
  export interface ManifestIcons {
9200
9202
  [size: number]: string;
9201
9203
  }
@@ -9571,282 +9573,225 @@ export namespace Browser {
9571
9573
  export type Manifest = ManifestV2 | ManifestV3;
9572
9574
 
9573
9575
  /**
9574
- * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via tabs.connect.
9575
- * @since Chrome 26
9576
+ * Attempts to connect listeners within an extension (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via {@link tabs.connect}.
9577
+ *
9578
+ * @param extensionId The ID of the extension to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for web messaging.
9579
+ * @returns Port through which messages can be sent and received. The port's {@link Port onDisconnect} event is fired if the extension does not exist.
9576
9580
  */
9577
9581
  export function connect(connectInfo?: ConnectInfo): Port;
9582
+ export function connect(extensionId: string | undefined, connectInfo?: ConnectInfo): Port;
9583
+
9578
9584
  /**
9579
- * Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and web messaging. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via tabs.connect.
9580
- * @since Chrome 26
9581
- * @param extensionId Optional.
9582
- * The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for web messaging.
9583
- */
9584
- export function connect(extensionId: string, connectInfo?: ConnectInfo): Port;
9585
- /**
9586
- * Connects to a native application in the host machine.
9587
- * @since Chrome 28
9585
+ * Connects to a native application in the host machine. This method requires the `"nativeMessaging"` permission. See Native Messaging for more information.
9588
9586
  * @param application The name of the registered application to connect to.
9589
9587
  */
9590
9588
  export function connectNative(application: string): Port;
9591
9589
  /**
9592
9590
  * Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set.
9593
- * @deprecated Removed since Chrome 133. Background pages do not exist in MV3 extensions.
9591
+ *
9592
+ * Foreground only
9593
+ *
9594
+ * Can return its result via Promise since Chrome 99.
9595
+ * @deprecated since Chrome 133. Background pages do not exist in MV3 extensions.
9594
9596
  */
9595
- export function getBackgroundPage(): Promise<Window>;
9596
- /** Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set. */
9597
+ export function getBackgroundPage(): Promise<Window | undefined>;
9597
9598
  export function getBackgroundPage(callback: (backgroundPage?: Window) => void): void;
9599
+
9598
9600
  /**
9599
9601
  * Fetches information about active contexts associated with this extension
9600
- * @since Chrome 116 MV3.
9601
- * @return Provides the matching context, if any via callback or returned as a `Promise` (MV3 only).
9602
9602
  * @param filter A filter to find matching contexts. A context matches if it matches all specified fields in the filter. Any unspecified field in the filter matches all contexts.
9603
- */
9604
- export function getContexts(filter: ContextFilter): Promise<ExtensionContext[]>;
9605
- /**
9606
- * Fetches information about active contexts associated with this extension
9607
9603
  * @since Chrome 116 MV3.
9608
- * @return Provides the matching context, if any via callback or returned as a `Promise` (MV3 only).
9609
- * @param filter A filter to find matching contexts. A context matches if it matches all specified fields in the filter. Any unspecified field in the filter matches all contexts.
9610
- * @param callback Called with results
9611
9604
  */
9605
+ export function getContexts(filter: ContextFilter): Promise<ExtensionContext[]>;
9612
9606
  export function getContexts(filter: ContextFilter, callback: (contexts: ExtensionContext[]) => void): void;
9607
+
9613
9608
  /**
9614
9609
  * Returns details about the app or extension from the manifest. The object returned is a serialization of the full manifest file.
9615
9610
  * @return The manifest details.
9616
9611
  */
9617
9612
  export function getManifest(): Manifest;
9613
+
9618
9614
  /**
9619
9615
  * Returns a DirectoryEntry for the package directory.
9620
- * @since Chrome 29
9616
+ *
9617
+ * Foreground only
9618
+ *
9619
+ * Can return its result via Promise in Manifest V3 or later since Chrome 122.
9621
9620
  */
9621
+ export function getPackageDirectoryEntry(): Promise<DirectoryEntry>;
9622
9622
  export function getPackageDirectoryEntry(callback: (directoryEntry: DirectoryEntry) => void): void;
9623
+
9623
9624
  /**
9624
9625
  * Returns information about the current platform.
9625
- * @since Chrome 29
9626
- * @param callback Called with results
9627
- */
9628
- export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void;
9629
- /**
9630
- * Returns information about the current platform.
9631
- * @since Chrome 29
9632
- * @return The `getPlatformInfo` method provides its result via callback or returned as a `Promise` (MV3 only).
9626
+ *
9627
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
9633
9628
  */
9634
9629
  export function getPlatformInfo(): Promise<PlatformInfo>;
9630
+ export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void;
9631
+
9635
9632
  /**
9636
9633
  * Converts a relative path within an app/extension install directory to a fully-qualified URL.
9637
9634
  * @param path A path to a resource within an app/extension expressed relative to its install directory.
9635
+ * @returns The fully-qualified URL to the resource.
9638
9636
  */
9639
9637
  export function getURL(path: string): string;
9640
- /**
9641
- * Reloads the app or extension.
9642
- * @since Chrome 25
9643
- */
9638
+
9639
+ /** Reloads the app or extension. This method is not supported in kiosk mode. For kiosk mode, use {@link Browser.runtime.restart()} method. */
9644
9640
  export function reload(): void;
9641
+
9645
9642
  /**
9646
- * Requests an update check for this app/extension.
9647
- * @since Chrome 109
9648
- * @return This only returns a Promise when the callback parameter is not specified, and with MV3.
9643
+ * Requests an immediate update check be done for this app/extension.
9644
+ *
9645
+ * **Important**: Most extensions/apps should **not** use this method, since Chrome already does automatic checks every few hours, and you can listen for the {@link runtime.onUpdateAvailable} event without needing to call requestUpdateCheck.
9646
+ *
9647
+ * This method is only appropriate to call in very limited circumstances, such as if your extension talks to a backend service, and the backend service has determined that the client extension version is very far out of date and you'd like to prompt a user to update. Most other uses of requestUpdateCheck, such as calling it unconditionally based on a repeating timer, probably only serve to waste client, network, and server resources.
9648
+ *
9649
+ * Note: When called with a callback, instead of returning an object this function will return the two properties as separate arguments passed to the callback.
9650
+ *
9651
+ * Can return its result via Promise in Manifest V3 or later since Chrome 109.
9649
9652
  */
9650
9653
  export function requestUpdateCheck(): Promise<RequestUpdateCheckResult>;
9651
- /**
9652
- * Requests an update check for this app/extension.
9653
- * @since Chrome 25
9654
- * @param callback
9655
- * Parameter status: Result of the update check. One of: "throttled", "no_update", or "update_available"
9656
- * Optional parameter details: If an update is available, this contains more information about the available update.
9657
- */
9658
9654
  export function requestUpdateCheck(
9659
- callback: (status: RequestUpdateCheckStatus, details?: UpdateCheckDetails) => void,
9655
+ callback: (status: `${RequestUpdateCheckStatus}`, details?: { version: string }) => void,
9660
9656
  ): void;
9661
- /**
9662
- * Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op.
9663
- * @since Chrome 32
9664
- */
9657
+
9658
+ /** Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op. */
9665
9659
  export function restart(): void;
9660
+
9666
9661
  /**
9667
- * Restart the ChromeOS device when the app runs in kiosk mode after the
9668
- * given seconds. If called again before the time ends, the reboot will
9669
- * be delayed. If called with a value of -1, the reboot will be
9670
- * cancelled. It's a no-op in non-kiosk mode. It's only allowed to be
9671
- * called repeatedly by the first extension to invoke this API.
9662
+ * Restart the ChromeOS device when the app runs in kiosk mode after the given seconds. If called again before the time ends, the reboot will be delayed. If called with a value of `-1`, the reboot will be cancelled. It's a no-op in non-kiosk mode. It's only allowed to be called repeatedly by the first extension to invoke this API.
9663
+ *
9664
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
9672
9665
  * @since Chrome 53
9673
- * @param seconds
9674
- * @param callback
9675
- */
9676
- export function restartAfterDelay(seconds: number, callback?: () => void): void;
9677
- /**
9678
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9679
- * @since Chrome 26
9680
- * Parameter response: The JSON response object sent by the handler of the message. 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.
9681
9666
  */
9682
- export function sendMessage<M = any, R = any>(message: M, responseCallback: (response: R) => void): void;
9667
+ export function restartAfterDelay(seconds: number): Promise<void>;
9668
+ export function restartAfterDelay(seconds: number, callback: () => void): void;
9669
+
9683
9670
  /**
9684
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9685
- * @since Chrome 32
9686
- * Parameter response: The JSON response object sent by the handler of the message. 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.
9671
+ * Sends a single message to event listeners within your extension or a different extension/app. Similar to {@link runtime.connect} but only sends a single message, with an optional response. If sending to your extension, the {@link runtime.onMessage} event will be fired in every frame of your extension (except for the sender's frame), or {@link runtime.onMessageExternal}, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use {@link tabs.sendMessage}.
9672
+ *
9673
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
9674
+ * @param extensionId The ID of the extension to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging.
9675
+ * @param message The message to send. This message should be a JSON-ifiable object.
9687
9676
  */
9677
+ export function sendMessage<M = any, R = any>(message: M, options?: MessageOptions): Promise<R>;
9678
+ export function sendMessage<M = any, R = any>(message: M, callback: (response: R) => void): void;
9688
9679
  export function sendMessage<M = any, R = any>(
9689
9680
  message: M,
9690
- options: MessageOptions,
9691
- responseCallback: (response: R) => void,
9681
+ options: MessageOptions | undefined,
9682
+ callback: (response: R) => void,
9692
9683
  ): void;
9693
- /**
9694
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9695
- * @since Chrome 26
9696
- * @param extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging.
9697
- * Parameter response: The JSON response object sent by the handler of the message. 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.
9698
- */
9699
9684
  export function sendMessage<M = any, R = any>(
9700
9685
  extensionId: string | undefined | null,
9701
9686
  message: M,
9702
- responseCallback: (response: R) => void,
9703
- ): void;
9704
- /**
9705
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9706
- * @since Chrome 32
9707
- * @param extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging.
9708
- * Parameter response: The JSON response object sent by the handler of the message. 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.
9709
- */
9710
- export function sendMessage<Message = any, Response = any>(
9687
+ options?: MessageOptions,
9688
+ ): Promise<R>;
9689
+ export function sendMessage<M = any, R = any>(
9711
9690
  extensionId: string | undefined | null,
9712
- message: Message,
9713
- options: MessageOptions,
9714
- responseCallback: (response: Response) => void,
9691
+ message: M,
9692
+ callback: (response: R) => void,
9715
9693
  ): void;
9716
- /**
9717
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9718
- * @since Chrome 26
9719
- */
9720
- export function sendMessage<M = any, R = any>(message: M): Promise<R>;
9721
- /**
9722
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9723
- * @since Chrome 32
9724
- */
9725
9694
  export function sendMessage<M = any, R = any>(
9726
- message: M,
9727
- options: MessageOptions,
9728
- ): Promise<R>;
9729
- /**
9730
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9731
- * @since Chrome 26
9732
- * @param extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging.
9733
- */
9734
- export function sendMessage<M = any, R = any>(extensionId: string | undefined | null, message: M): Promise<R>;
9735
- /**
9736
- * Sends a single message to event listeners within your extension/app or a different extension/app. Similar to runtime.connect but only sends a single message, with an optional response. If sending to your extension, the runtime.onMessage event will be fired in each page, or runtime.onMessageExternal, if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use tabs.sendMessage.
9737
- * @since Chrome 32
9738
- * @param extensionId The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for web messaging.
9739
- */
9740
- export function sendMessage<Message = any, Response = any>(
9741
9695
  extensionId: string | undefined | null,
9742
- message: Message,
9743
- options: MessageOptions,
9744
- ): Promise<Response>;
9745
- /**
9746
- * Send a single message to a native application.
9747
- * @since Chrome 28
9748
- * @param application The of the native messaging host.
9749
- * @param message The message that will be passed to the native messaging host.
9750
- * Parameter response: The response message sent by the native messaging host. If an error occurs while connecting to the native messaging host, the callback will be called with no arguments and runtime.lastError will be set to the error message.
9751
- */
9752
- export function sendNativeMessage(
9753
- application: string,
9754
- message: object,
9755
- responseCallback: (response: any) => void,
9696
+ message: M,
9697
+ options: MessageOptions | undefined,
9698
+ callback: (response: R) => void,
9756
9699
  ): void;
9700
+
9757
9701
  /**
9758
- * Send a single message to a native application.
9759
- * @since Chrome 28
9760
- * @param application The of the native messaging host.
9702
+ * Send a single message to a native application. This method requires the `"nativeMessaging"` permission
9703
+ *
9704
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
9705
+ * @param application The name of the native messaging host.
9761
9706
  * @param message The message that will be passed to the native messaging host.
9762
9707
  */
9708
+ export function sendNativeMessage(application: string, message: object): Promise<any>;
9763
9709
  export function sendNativeMessage(
9764
9710
  application: string,
9765
9711
  message: object,
9766
- ): Promise<any>;
9712
+ callback: (response: any) => void,
9713
+ ): void;
9714
+
9767
9715
  /**
9768
- * Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics, and implement surveys. Maximum 255 characters.
9769
- * @since Chrome 41
9770
- * @param url Since Chrome 34.
9771
- * URL to be opened after the extension is uninstalled. This URL must have an http: or https: scheme. Set an empty string to not open a new tab upon uninstallation.
9772
- * @param callback Called when the uninstall URL is set. If the given URL is invalid, runtime.lastError will be set.
9716
+ * Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics, and implement surveys. Maximum 1023 characters.
9717
+ *
9718
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99.
9719
+ * @param url URL to be opened after the extension is uninstalled. This URL must have an http: or https: scheme. Set an empty string to not open a new tab upon uninstallation.
9773
9720
  */
9774
- export function setUninstallURL(url: string, callback?: () => void): void;
9721
+ export function setUninstallURL(url: string): Promise<void>;
9722
+ export function setUninstallURL(url: string, callback: () => void): void;
9723
+
9775
9724
  /**
9776
9725
  * Open your Extension's options page, if possible.
9726
+ *
9777
9727
  * The precise behavior may depend on your manifest's options_ui or options_page key, or what Chrome happens to support at the time. For example, the page may be opened in a new tab, within chrome://extensions, within an App, or it may just focus an open options page. It will never cause the caller page to reload.
9778
- * If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set lastError.
9779
- * @since MV3
9728
+ *
9729
+ * If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set {@link runtime.lastError lastError} .
9730
+ *
9731
+ * Can return its result via Promise in Manifest V3 or later since Chrome 99
9780
9732
  */
9781
9733
  export function openOptionsPage(): Promise<void>;
9782
- /**
9783
- * Open your Extension's options page, if possible.
9784
- * The precise behavior may depend on your manifest's options_ui or options_page key, or what Chrome happens to support at the time. For example, the page may be opened in a new tab, within chrome://extensions, within an App, or it may just focus an open options page. It will never cause the caller page to reload.
9785
- * If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set lastError.
9786
- * @since Chrome 42
9787
- */
9788
- export function openOptionsPage(callback?: () => void): void;
9734
+ export function openOptionsPage(callback: () => void): void;
9735
+
9736
+ /** Fired when a connection is made from either an extension process or a content script (by {@link runtime.connect}). */
9737
+ export const onConnect: events.Event<(port: Port) => void>;
9738
+
9739
+ /** Fired when a connection is made from another extension (by {@link runtime.connect}), or from an externally connectable web site. */
9740
+ export const onConnectExternal: events.Event<(port: Port) => void>;
9789
9741
 
9790
9742
  /**
9791
- * Fired when a connection is made from either an extension process or a content script.
9792
- * @since Chrome 26
9743
+ * Fired when a connection is made from a native application. This event requires the `"nativeMessaging"` permission. It is only supported on Chrome OS.
9744
+ * @since Chrome 76
9793
9745
  */
9794
- export var onConnect: ExtensionConnectEvent;
9795
- /**
9796
- * Fired when a connection is made from another extension.
9797
- * @since Chrome 26
9798
- */
9799
- export var onConnectExternal: ExtensionConnectEvent;
9746
+ export const onConnectNative: events.Event<(port: Port) => void>;
9747
+
9800
9748
  /** Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded. */
9801
- export var onSuspend: RuntimeEvent;
9802
- /**
9803
- * Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode.
9804
- * @since Chrome 23
9805
- */
9806
- export var onStartup: RuntimeEvent;
9749
+ export const onSuspend: events.Event<() => void>;
9750
+
9751
+ /** Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode. */
9752
+ export const onStartup: events.Event<() => void>;
9753
+
9807
9754
  /** Fired when the extension is first installed, when the extension is updated to a new version, and when Chrome is updated to a new version. */
9808
- export var onInstalled: RuntimeInstalledEvent;
9755
+ export const onInstalled: events.Event<(details: InstalledDetails) => void>;
9756
+
9809
9757
  /** Sent after onSuspend to indicate that the app won't be unloaded after all. */
9810
- export var onSuspendCanceled: RuntimeEvent;
9811
- /**
9812
- * Fired when a message is sent from either an extension process or a content script.
9813
- * @since Chrome 26
9814
- */
9815
- export var onMessage: ExtensionMessageEvent;
9816
- /**
9817
- * Fired when a message is sent from another extension/app. Cannot be used in a content script.
9818
- * @since Chrome 26
9819
- */
9820
- export var onMessageExternal: ExtensionMessageEvent;
9821
- /**
9822
- * Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps.
9823
- * @since Chrome 29
9824
- */
9825
- export var onRestartRequired: RuntimeRestartRequiredEvent;
9826
- /**
9827
- * Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call Browser.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call Browser.runtime.reload() manually in response to this event the update will not get installed until the next time chrome itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if Browser.runtime.reload() is called in response to this event.
9828
- * @since Chrome 25
9829
- */
9830
- export var onUpdateAvailable: RuntimeUpdateAvailableEvent;
9758
+ export const onSuspendCanceled: events.Event<() => void>;
9759
+
9760
+ /** Fired when a message is sent from either an extension process (by {@link runtime.sendMessage}) or a content script (by {@link tabs.sendMessage}). */
9761
+ export const onMessage: events.Event<
9762
+ (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void
9763
+ >;
9764
+
9765
+ /** Fired when a message is sent from another extension (by {@link runtime.sendMessage}). Cannot be used in a content script. */
9766
+ export const onMessageExternal: events.Event<
9767
+ (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void
9768
+ >;
9769
+
9770
+ /** Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps. */
9771
+ export const onRestartRequired: events.Event<(reason: `${OnRestartRequiredReason}`) => void>;
9772
+
9773
+ /** Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call Browser.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call Browser.runtime.reload() manually in response to this event the update will not get installed until the next time Chrome itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if Browser.runtime.reload() is called in response to this event. */
9774
+ export const onUpdateAvailable: events.Event<(details: { version: string }) => void>;
9775
+
9831
9776
  /**
9832
- * @deprecated since Chrome 33. Please use Browser.runtime.onRestartRequired.
9833
9777
  * Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required.
9778
+ * @deprecated Please use {@link runtime.onRestartRequired}.
9834
9779
  */
9835
- export var onBrowserUpdateAvailable: RuntimeEvent;
9780
+ export const onBrowserUpdateAvailable: events.Event<() => void>;
9836
9781
 
9837
9782
  /**
9838
- * @since chrome 115+
9839
- * @requires MV3+
9840
- * Listens for connections made from user scripts associated with this extension.
9783
+ * Fired when a connection is made from a user script from this extension.
9784
+ * @since chrome 115 MV3
9841
9785
  */
9842
- export var onUserScriptConnect: ExtensionConnectEvent;
9786
+ export const onUserScriptConnect: events.Event<(port: Port) => void>;
9843
9787
 
9844
9788
  /**
9845
- * @since chrome 115+
9846
- * @requires MV3+
9847
- * Listens for messages sent from user scripts associated with this extension.
9789
+ * Fired when a message is sent from a user script associated with the same extension.
9790
+ * @since chrome 115, MV3
9848
9791
  */
9849
- export var onUserScriptMessage: ExtensionMessageEvent;
9792
+ export const onUserScriptMessage: events.Event<
9793
+ (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void
9794
+ >;
9850
9795
  }
9851
9796
 
9852
9797
  ////////////////////
@@ -12457,6 +12402,11 @@ export namespace Browser {
12457
12402
  color: `${Color}`;
12458
12403
  /** The ID of the group. Group IDs are unique within a browser session. */
12459
12404
  id: number;
12405
+ /**
12406
+ * Whether the group is shared.
12407
+ * @since Chrome 137
12408
+ */
12409
+ shared: boolean;
12460
12410
  /** The title of the group. */
12461
12411
  title?: string;
12462
12412
  /** The ID of the window that contains the group. */
@@ -12472,13 +12422,18 @@ export namespace Browser {
12472
12422
 
12473
12423
  export interface QueryInfo {
12474
12424
  /** Whether the groups are collapsed. */
12475
- collapsed?: boolean;
12425
+ collapsed?: boolean | undefined;
12476
12426
  /** The color of the groups. */
12477
- color?: `${Color}`;
12427
+ color?: `${Color}` | undefined;
12428
+ /**
12429
+ * Whether the group is shared.
12430
+ * @since Chrome 137
12431
+ */
12432
+ shared?: boolean | undefined;
12478
12433
  /** Match group titles against a pattern. */
12479
- title?: string;
12434
+ title?: string | undefined;
12480
12435
  /** The ID of the parent window, or {@link windows.WINDOW_ID_CURRENT} for the current window. */
12481
- windowId?: number;
12436
+ windowId?: number | undefined;
12482
12437
  }
12483
12438
 
12484
12439
  export interface UpdateProperties {
@@ -13894,334 +13849,231 @@ export namespace Browser {
13894
13849
  * Permissions: The Browser.windows API can be used without declaring any permission. However, the "tabs" permission is required in order to populate the url, title, and favIconUrl properties of Tab objects.
13895
13850
  */
13896
13851
  export namespace windows {
13852
+ interface WindowsEvent<T extends (...args: any) => void> extends Omit<Browser.events.Event<T>, "addListener"> {
13853
+ addListener(callback: T, filter?: {
13854
+ windowTypes: `${WindowType}`[];
13855
+ }): void;
13856
+ }
13857
+
13897
13858
  export interface Window {
13898
- /** Optional. Array of tabs.Tab objects representing the current tabs in the window. */
13859
+ /** Array of {@link tabs.Tab} objects representing the current tabs in the window. */
13899
13860
  tabs?: Browser.tabs.Tab[] | undefined;
13900
- /** Optional. The offset of the window from the top edge of the screen in pixels. Under some circumstances a Window may not be assigned top property, for example when querying closed windows from the sessions API. */
13861
+ /** The offset of the window from the top edge of the screen in pixels. In some circumstances a window may not be assigned a `top` property; for example, when querying closed windows from the {@link sessions} API. */
13901
13862
  top?: number | undefined;
13902
- /** Optional. The height of the window, including the frame, in pixels. Under some circumstances a Window may not be assigned height property, for example when querying closed windows from the sessions API. */
13863
+ /** The height of the window, including the frame, in pixels. In some circumstances a window may not be assigned a `height` property, for example when querying closed windows from the {@link sessions} API. */
13903
13864
  height?: number | undefined;
13904
- /** Optional. The width of the window, including the frame, in pixels. Under some circumstances a Window may not be assigned width property, for example when querying closed windows from the sessions API. */
13865
+ /** The width of the window, including the frame, in pixels. In some circumstances a window may not be assigned a `width` property; for example, when querying closed windows from the {@link sessions} API. */
13905
13866
  width?: number | undefined;
13906
- /**
13907
- * The state of this browser window.
13908
- * @since Chrome 17
13909
- */
13910
- state?: windowStateEnum | undefined;
13867
+ /** The state of this browser window. */
13868
+ state?: `${WindowState}` | undefined;
13911
13869
  /** Whether the window is currently the focused window. */
13912
13870
  focused: boolean;
13913
- /**
13914
- * Whether the window is set to be always on top.
13915
- * @since Chrome 19
13916
- */
13871
+ /** Whether the window is set to be always on top. */
13917
13872
  alwaysOnTop: boolean;
13918
13873
  /** Whether the window is incognito. */
13919
13874
  incognito: boolean;
13920
- /**
13921
- * The type of browser window this is.
13922
- */
13923
- type?: windowTypeEnum | undefined;
13924
- /** Optional. The ID of the window. Window IDs are unique within a browser session. Under some circumstances a Window may not be assigned an ID, for example when querying windows using the sessions API, in which case a session ID may be present. */
13875
+ /** The type of browser window this is. */
13876
+ type?: `${WindowType}` | undefined;
13877
+ /** The ID of the window. Window IDs are unique within a browser session. In some circumstances a window may not be assigned an `ID` property; for example, when querying windows using the {@link sessions} API, in which case a session ID may be present. */
13925
13878
  id?: number | undefined;
13926
- /** Optional. The offset of the window from the left edge of the screen in pixels. Under some circumstances a Window may not be assigned left property, for example when querying closed windows from the sessions API. */
13879
+ /** The offset of the window from the left edge of the screen in pixels. In some circumstances a window may not be assigned a `left` property; for example, when querying closed windows from the {@link sessions} API. */
13927
13880
  left?: number | undefined;
13928
- /**
13929
- * Optional. The session ID used to uniquely identify a Window obtained from the sessions API.
13930
- * @since Chrome 31
13931
- */
13881
+ /** The session ID used to uniquely identify a window, obtained from the {@link sessions} API. */
13932
13882
  sessionId?: string | undefined;
13933
13883
  }
13934
13884
 
13885
+ /** @since Chrome 88 */
13935
13886
  export interface QueryOptions {
13936
- /**
13937
- * Optional.
13938
- * If true, the windows.Window object will have a tabs property that contains a list of the tabs.Tab objects.
13939
- * The Tab objects only contain the url, pendingUrl, title and favIconUrl properties if the extension's manifest file includes the "tabs" permission.
13940
- */
13887
+ /** If true, the {@link windows.Window} object has a `tabs` property that contains a list of the {@link tabs.Tab} objects. The `Tab` objects only contain the `url`, `pendingUrl`, `title`, and `favIconUrl` properties if the extension's manifest file includes the `"tabs"` permission. */
13941
13888
  populate?: boolean | undefined;
13942
- /**
13943
- * If set, the Window returned is filtered based on its type. If unset, the default filter is set to ['normal', 'popup'].
13944
- */
13945
- windowTypes?: windowTypeEnum[] | undefined;
13889
+ /** If set, the {@link windows.Window} returned is filtered based on its type. If unset, the default filter is set to `['normal', 'popup']`. */
13890
+ windowTypes?: `${WindowType}`[] | undefined;
13946
13891
  }
13947
13892
 
13948
13893
  export interface CreateData {
13949
- /**
13950
- * Optional. The id of the tab for which you want to adopt to the new window.
13951
- * @since Chrome 10
13952
- */
13894
+ /** The ID of the tab to add to the new window. */
13953
13895
  tabId?: number | undefined;
13954
- /**
13955
- * Optional.
13956
- * A URL or array of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme (i.e. 'http://www.google.com', not 'www.google.com'). Relative URLs will be relative to the current page within the extension. Defaults to the New Tab Page.
13957
- */
13896
+ /** A URL or array of URLs to open as tabs in the window. Fully-qualified URLs must include a scheme, e.g., 'http://www.google.com', not 'www.google.com'. Non-fully-qualified URLs are considered relative within the extension. Defaults to the New Tab Page. */
13958
13897
  url?: string | string[] | undefined;
13959
- /**
13960
- * Optional.
13961
- * The number of pixels to position the new window from the top edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.
13962
- */
13898
+ /** The number of pixels to position the new window from the top edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels. */
13963
13899
  top?: number | undefined;
13964
- /**
13965
- * Optional.
13966
- * The height in pixels of the new window, including the frame. If not specified defaults to a natural height.
13967
- */
13900
+ /** The height in pixels of the new window, including the frame. If not specified, defaults to a natural height. */
13968
13901
  height?: number | undefined;
13969
- /**
13970
- * Optional.
13971
- * The width in pixels of the new window, including the frame. If not specified defaults to a natural width.
13972
- */
13902
+ /** The width in pixels of the new window, including the frame. If not specified, defaults to a natural width. */
13973
13903
  width?: number | undefined;
13974
- /**
13975
- * Optional. If true, opens an active window. If false, opens an inactive window.
13976
- * @since Chrome 12
13977
- */
13904
+ /** If `true`, opens an active window. If `false`, opens an inactive window. */
13978
13905
  focused?: boolean | undefined;
13979
- /** Optional. Whether the new window should be an incognito window. */
13906
+ /** Whether the new window should be an incognito window. */
13980
13907
  incognito?: boolean | undefined;
13981
- /** Optional. Specifies what type of browser window to create. */
13982
- type?: createTypeEnum | undefined;
13983
- /**
13984
- * Optional.
13985
- * The number of pixels to position the new window from the left edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels.
13986
- */
13908
+ /** Specifies what type of browser window to create. */
13909
+ type?: `${CreateType}` | undefined;
13910
+ /** The number of pixels to position the new window from the left edge of the screen. If not specified, the new window is offset naturally from the last focused window. This value is ignored for panels. */
13987
13911
  left?: number | undefined;
13988
13912
  /**
13989
- * Optional. The initial state of the window. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'.
13913
+ * The initial state of the window. The `minimized`, `maximized`, and `fullscreen` states cannot be combined with `left`, `top`, `width`, or `height`.
13990
13914
  * @since Chrome 44
13991
13915
  */
13992
- state?: windowStateEnum | undefined;
13916
+ state?: `${WindowState}` | undefined;
13993
13917
  /**
13994
- * If true, the newly-created window's 'window.opener' is set to the caller and is in the same [unit of related browsing contexts](https://www.w3.org/TR/html51/browsers.html#unit-of-related-browsing-contexts) as the caller.
13918
+ * If `true`, the newly-created window's 'window.opener' is set to the caller and is in the same [unit of related browsing contexts](https://www.w3.org/TR/html51/browsers.html#unit-of-related-browsing-contexts) as the caller.
13995
13919
  * @since Chrome 64
13996
13920
  */
13997
13921
  setSelfAsOpener?: boolean | undefined;
13998
13922
  }
13999
13923
 
14000
13924
  export interface UpdateInfo {
14001
- /** Optional. The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels. */
13925
+ /** The offset from the top edge of the screen to move the window to in pixels. This value is ignored for panels. */
14002
13926
  top?: number | undefined;
14003
- /**
14004
- * Optional. If true, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to false to cancel a previous draw attention request.
14005
- * @since Chrome 14
14006
- */
13927
+ /** If `true`, causes the window to be displayed in a manner that draws the user's attention to the window, without changing the focused window. The effect lasts until the user changes focus to the window. This option has no effect if the window already has focus. Set to `false` to cancel a previous `drawAttention` request. */
14007
13928
  drawAttention?: boolean | undefined;
14008
- /** Optional. The height to resize the window to in pixels. This value is ignored for panels. */
13929
+ /** The height to resize the window to in pixels. This value is ignored for panels. */
14009
13930
  height?: number | undefined;
14010
- /** Optional. The width to resize the window to in pixels. This value is ignored for panels. */
13931
+ /** The width to resize the window to in pixels. This value is ignored for panels. */
14011
13932
  width?: number | undefined;
14012
- /**
14013
- * Optional. The new state of the window. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'.
14014
- * @since Chrome 17
14015
- */
14016
- state?: windowStateEnum | undefined;
14017
- /**
14018
- * Optional. If true, brings the window to the front. If false, brings the next window in the z-order to the front.
14019
- * @since Chrome 8
14020
- */
13933
+ /** The new state of the window. The 'minimized', 'maximized', and 'fullscreen' states cannot be combined with 'left', 'top', 'width', or 'height'. */
13934
+ state?: `${WindowState}` | undefined;
13935
+ /** If `true`, brings the window to the front; cannot be combined with the state 'minimized'. If `false`, brings the next window in the z-order to the front; cannot be combined with the state 'fullscreen' or 'maximized'. */
14021
13936
  focused?: boolean | undefined;
14022
- /** Optional. The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels. */
13937
+ /** The offset from the left edge of the screen to move the window to in pixels. This value is ignored for panels. */
14023
13938
  left?: number | undefined;
14024
13939
  }
14025
13940
 
14026
- export interface WindowEventFilter {
14027
- /**
14028
- * Conditions that the window's type being created must satisfy. By default it will satisfy ['app', 'normal', 'panel', 'popup'], with 'app' and 'panel' window types limited to the extension's own windows.
14029
- */
14030
- windowTypes: windowTypeEnum[];
14031
- }
14032
-
14033
- export interface WindowIdEvent extends Browser.events.Event<(windowId: number) => void> {
14034
- addListener(
14035
- callback: (windowId: number) => void,
14036
- filters?: WindowEventFilter,
14037
- ): void;
14038
- }
14039
-
14040
- export interface WindowReferenceEvent extends Browser.events.Event<(window: Window) => void> {
14041
- addListener(
14042
- callback: (window: Window) => void,
14043
- filters?: WindowEventFilter,
14044
- ): void;
14045
- }
14046
-
14047
13941
  /**
14048
13942
  * Specifies what type of browser window to create.
14049
13943
  * 'panel' is deprecated and is available only to existing whitelisted extensions on Chrome OS.
14050
13944
  * @since Chrome 44
14051
13945
  */
14052
- export type createTypeEnum = "normal" | "popup" | "panel";
13946
+ export enum CreateType {
13947
+ /** Specifies the window as a standard window. */
13948
+ NORMAL = "normal",
13949
+ /** Specifies the window as a popup window. */
13950
+ POPUP = "popup",
13951
+ /** @deprecated Specifies the window as a panel. */
13952
+ PANEL = "panel",
13953
+ }
14053
13954
 
14054
13955
  /**
14055
- * The state of this browser window.
14056
- * In some circumstances a window may not be assigned a state property; for example, when querying closed windows from the sessions API.
13956
+ * The state of this browser window. In some circumstances a window may not be assigned a `state` property; for example, when querying closed windows from the {@link sessions} API.
14057
13957
  * @since Chrome 44
14058
13958
  */
14059
- export type windowStateEnum = "normal" | "minimized" | "maximized" | "fullscreen" | "locked-fullscreen";
13959
+ export enum WindowState {
13960
+ /** Normal window state (not minimized, maximized, or fullscreen). */
13961
+ NORMAL = "normal",
13962
+ /** Minimized window state. */
13963
+ MINIMIZED = "minimized",
13964
+ /** Maximized window state. */
13965
+ MAXIMIZED = "maximized",
13966
+ /** Fullscreen window state. */
13967
+ FULLSCREEN = "fullscreen",
13968
+ /** Locked fullscreen window state. This fullscreen state cannot be exited by user action and is available only to allowlisted extensions on Chrome OS. */
13969
+ LOCKED_FULLSCREEN = "locked-fullscreen",
13970
+ }
14060
13971
 
14061
13972
  /**
14062
- * The type of browser window this is.
14063
- * In some circumstances a window may not be assigned a type property; for example, when querying closed windows from the sessions API.
13973
+ * The type of browser window this is. In some circumstances a window may not be assigned a `type` property; for example, when querying closed windows from the {@link sessions} API.
14064
13974
  * @since Chrome 44
14065
13975
  */
14066
- export type windowTypeEnum = "normal" | "popup" | "panel" | "app" | "devtools";
13976
+ export enum WindowType {
13977
+ /** A normal browser window. */
13978
+ NORMAL = "normal",
13979
+ /** A browser popup. */
13980
+ POPUP = "popup",
13981
+ /** @deprecated A Chrome App panel-style window. Extensions can only see their own panel windows. */
13982
+ PANEL = "panel",
13983
+ /** @deprecated A Chrome App window. Extensions can only see their app own windows. */
13984
+ APP = "app",
13985
+ /** A Developer Tools window. */
13986
+ DEVTOOLS = "devtools",
13987
+ }
14067
13988
 
14068
- /**
14069
- * The windowId value that represents the current window.
14070
- * @since Chrome 18
14071
- */
14072
- export var WINDOW_ID_CURRENT: -2;
14073
- /**
14074
- * The windowId value that represents the absence of a chrome browser window.
14075
- * @since Chrome 6
14076
- */
14077
- export var WINDOW_ID_NONE: -1;
13989
+ /** The windowId value that represents the current window. */
13990
+ export const WINDOW_ID_CURRENT: -2;
13991
+
13992
+ /** The windowId value that represents the absence of a Chrome browser window */
13993
+ export const WINDOW_ID_NONE: -1;
14078
13994
 
14079
- /** Gets details about a window. */
14080
- export function get(windowId: number, callback: (window: Browser.windows.Window) => void): void;
14081
- /**
14082
- * Gets details about a window.
14083
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
14084
- */
14085
- export function get(windowId: number): Promise<Browser.windows.Window>;
14086
13995
  /**
14087
13996
  * Gets details about a window.
14088
- * @since Chrome 18
13997
+ *
13998
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14089
13999
  */
14000
+ export function get(windowId: number, queryOptions?: QueryOptions): Promise<Window>;
14001
+ export function get(windowId: number, callback: (window: Window) => void): void;
14090
14002
  export function get(
14091
14003
  windowId: number,
14092
- queryOptions: QueryOptions,
14093
- callback: (window: Browser.windows.Window) => void,
14004
+ queryOptions: QueryOptions | undefined,
14005
+ callback: (window: Window) => void,
14094
14006
  ): void;
14095
- /**
14096
- * Gets details about a window.
14097
- * @since Chrome 18
14098
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
14099
- */
14100
- export function get(windowId: number, queryOptions: QueryOptions): Promise<Browser.windows.Window>;
14101
- /** Gets the current window. */
14102
- export function getCurrent(callback: (window: Browser.windows.Window) => void): void;
14103
- /**
14104
- * Gets the current window.
14105
- * @return The `getCurrent` method provides its result via callback or returned as a `Promise` (MV3 only).
14106
- */
14107
- export function getCurrent(): Promise<Browser.windows.Window>;
14108
- /**
14109
- * Gets the current window.
14110
- * @param QueryOptions
14111
- * @since Chrome 18
14112
- */
14113
- export function getCurrent(queryOptions: QueryOptions, callback: (window: Browser.windows.Window) => void): void;
14007
+
14114
14008
  /**
14115
14009
  * Gets the current window.
14116
- * @param QueryOptions
14117
- * @since Chrome 18
14118
- * @return The `getCurrent` method provides its result via callback or returned as a `Promise` (MV3 only).
14119
- */
14120
- export function getCurrent(queryOptions: QueryOptions): Promise<Browser.windows.Window>;
14121
- /**
14122
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14123
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only). Contains details about the created window.
14124
- */
14125
- export function create(): Promise<Browser.windows.Window>;
14126
- /**
14127
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14128
- * @param callback
14129
- * Optional parameter window: Contains details about the created window.
14130
- */
14131
- export function create(callback: (window?: Browser.windows.Window) => void): void;
14132
- /**
14133
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14134
- * @param CreateData
14135
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only). Contains details about the created window.
14136
- */
14137
- export function create(createData: CreateData): Promise<Browser.windows.Window>;
14138
- /**
14139
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14140
- * @param CreateData
14141
- * @param callback
14142
- * Optional parameter window: Contains details about the created window.
14143
- */
14144
- export function create(createData: CreateData, callback: (window?: Browser.windows.Window) => void): void;
14145
- /**
14146
- * Gets all windows.
14147
- */
14148
- export function getAll(callback: (windows: Browser.windows.Window[]) => void): void;
14149
- /**
14150
- * Gets all windows.
14151
- * @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only).
14010
+ *
14011
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14152
14012
  */
14153
- export function getAll(): Promise<Browser.windows.Window[]>;
14013
+ export function getCurrent(queryOptions?: QueryOptions): Promise<Window>;
14014
+ export function getCurrent(callback: (window: Window) => void): void;
14015
+ export function getCurrent(queryOptions: QueryOptions | undefined, callback: (window: Window) => void): void;
14016
+
14154
14017
  /**
14155
- * Gets all windows.
14156
- * @since Chrome 18
14018
+ * Creates (opens) a new browser window with any optional sizing, position, or default URL provided.
14019
+ *
14020
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14157
14021
  */
14158
- export function getAll(queryOptions: QueryOptions, callback: (windows: Browser.windows.Window[]) => void): void;
14022
+ export function create(createData?: CreateData): Promise<Window | undefined>;
14023
+ export function create(callback: (window?: Window) => void): void;
14024
+ export function create(createData: CreateData | undefined, callback: (window?: Window) => void): void;
14025
+
14159
14026
  /**
14160
14027
  * Gets all windows.
14161
- * @since Chrome 18
14162
- * @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only).
14028
+ *
14029
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14163
14030
  */
14164
- export function getAll(queryOptions: QueryOptions): Promise<Browser.windows.Window[]>;
14031
+ export function getAll(queryOptions?: QueryOptions): Promise<Window[]>;
14032
+ export function getAll(callback: (windows: Window[]) => void): void;
14033
+ export function getAll(queryOptions: QueryOptions | undefined, callback: (windows: Window[]) => void): void;
14034
+
14165
14035
  /**
14166
- * Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be left unchanged.
14167
- * @return The `update` method provides its result via callback or returned as a `Promise` (MV3 only).
14036
+ * Updates the properties of a window. Specify only the properties that to be changed; unspecified properties are unchanged.
14037
+ *
14038
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14168
14039
  */
14169
- export function update(
14170
- windowId: number,
14171
- updateInfo: UpdateInfo,
14172
- ): Promise<Browser.windows.Window>;
14173
- /** Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be left unchanged. */
14174
- export function update(
14175
- windowId: number,
14176
- updateInfo: UpdateInfo,
14177
- callback: (window: Browser.windows.Window) => void,
14178
- ): void;
14040
+ export function update(windowId: number, updateInfo: UpdateInfo): Promise<Window>;
14041
+ export function update(windowId: number, updateInfo: UpdateInfo, callback: (window: Window) => void): void;
14042
+
14179
14043
  /**
14180
- * Removes (closes) a window, and all the tabs inside it
14181
- * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only). It has no parameters.
14044
+ * Removes (closes) a window and all the tabs inside it.
14045
+ *
14046
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14182
14047
  */
14183
14048
  export function remove(windowId: number): Promise<void>;
14184
- /** Removes (closes) a window, and all the tabs inside it. */
14185
14049
  export function remove(windowId: number, callback: () => void): void;
14050
+
14186
14051
  /**
14187
14052
  * Gets the window that was most recently focused — typically the window 'on top'.
14053
+ *
14054
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14188
14055
  */
14189
- export function getLastFocused(callback: (window: Browser.windows.Window) => void): void;
14190
- /**
14191
- * Gets the window that was most recently focused — typically the window 'on top'.
14192
- * @return The `getLastFocused` method provides its result via callback or returned as a `Promise` (MV3 only).
14193
- */
14194
- export function getLastFocused(): Promise<Browser.windows.Window>;
14195
- /**
14196
- * Gets the window that was most recently focused — typically the window 'on top'.
14197
- * @since Chrome 18
14198
- */
14056
+ export function getLastFocused(queryOptions?: QueryOptions): Promise<Window>;
14057
+ export function getLastFocused(callback: (window: Window) => void): void;
14199
14058
  export function getLastFocused(
14200
- queryOptions: QueryOptions,
14201
- callback: (window: Browser.windows.Window) => void,
14059
+ queryOptions: QueryOptions | undefined,
14060
+ callback: (window: Window) => void,
14202
14061
  ): void;
14203
- /**
14204
- * Gets the window that was most recently focused — typically the window 'on top'.
14205
- * @since Chrome 18
14206
- * @return The `getLastFocused` method provides its result via callback or returned as a `Promise` (MV3 only).
14207
- */
14208
- export function getLastFocused(queryOptions: QueryOptions): Promise<Browser.windows.Window>;
14209
14062
 
14210
14063
  /** Fired when a window is removed (closed). */
14211
- export var onRemoved: WindowIdEvent;
14064
+ export const onRemoved: WindowsEvent<(windowId: number) => void>;
14065
+
14212
14066
  /** Fired when a window is created. */
14213
- export var onCreated: WindowReferenceEvent;
14214
- /**
14215
- * Fired when the currently focused window changes. Will be Browser.windows.WINDOW_ID_NONE if all chrome windows have lost focus.
14216
- * Note: On some Linux window managers, WINDOW_ID_NONE will always be sent immediately preceding a switch from one chrome window to another.
14217
- */
14218
- export var onFocusChanged: WindowIdEvent;
14067
+ export const onCreated: WindowsEvent<(window: Window) => void>;
14068
+
14069
+ /** Fired when the currently focused window changes. Returns `Browser.windows.WINDOW_ID_NONE` if all Chrome windows have lost focus. **Note:** On some Linux window managers, `WINDOW_ID_NONE` is always sent immediately preceding a switch from one Chrome window to another. */
14070
+ export const onFocusChanged: WindowsEvent<(windowId: number) => void>;
14219
14071
 
14220
14072
  /**
14221
14073
  * Fired when a window has been resized; this event is only dispatched when the new bounds are committed, and not for in-progress changes.
14222
14074
  * @since Chrome 86
14223
14075
  */
14224
- export var onBoundsChanged: WindowReferenceEvent;
14076
+ export const onBoundsChanged: events.Event<(window: Window) => void>;
14225
14077
  }
14226
14078
 
14227
14079
  ////////////////////