@wxt-dev/browser 0.0.328 → 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 +763 -923
@@ -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
  ////////////////////
@@ -8971,37 +8941,114 @@ export namespace Browser {
8971
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.
8972
8942
  */
8973
8943
  export namespace runtime {
8974
- /** This will be defined during an API method callback if there was an error */
8975
- 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
+
8976
8950
  /** The ID of the extension/app. */
8977
- export var id: string;
8978
-
8979
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-PlatformOs */
8980
- export type PlatformOs = "mac" | "win" | "android" | "cros" | "linux" | "openbsd" | "fuchsia";
8981
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-PlatformArch */
8982
- export type PlatformArch = "arm" | "arm64" | "x86-32" | "x86-64" | "mips" | "mips64";
8983
- /** https://developer.chrome.com/docs/extensions/reference/api/runtime#type-PlatformNaclArch */
8984
- export type PlatformNaclArch = "arm" | "x86-32" | "x86-64" | "mips" | "mips64";
8985
- /** 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 */
8986
9011
  export enum ContextType {
9012
+ /** Specifies the context type as a tab */
8987
9013
  TAB = "TAB",
9014
+ /** Specifies the context type as an extension popup window */
8988
9015
  POPUP = "POPUP",
9016
+ /** Specifies the context type as a service worker. */
8989
9017
  BACKGROUND = "BACKGROUND",
9018
+ /** Specifies the context type as an offscreen document. */
8990
9019
  OFFSCREEN_DOCUMENT = "OFFSCREEN_DOCUMENT",
9020
+ /** Specifies the context type as a side panel. */
8991
9021
  SIDE_PANEL = "SIDE_PANEL",
9022
+ /** Specifies the context type as developer tools. */
8992
9023
  DEVELOPER_TOOLS = "DEVELOPER_TOOLS",
8993
9024
  }
8994
- /** 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
+ */
8995
9030
  export enum OnInstalledReason {
9031
+ /** Specifies the event reason as an installation. */
8996
9032
  INSTALL = "install",
9033
+ /** Specifies the event reason as an extension update. */
8997
9034
  UPDATE = "update",
9035
+ /** Specifies the event reason as a Chrome update. */
8998
9036
  CHROME_UPDATE = "chrome_update",
9037
+ /** Specifies the event reason as an update to a shared module. */
8999
9038
  SHARED_MODULE_UPDATE = "shared_module_update",
9000
9039
  }
9001
9040
 
9002
- export interface LastError {
9003
- /** Optional. Details about the error which occurred. */
9004
- 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",
9005
9052
  }
9006
9053
 
9007
9054
  /**
@@ -9010,7 +9057,7 @@ export namespace Browser {
9010
9057
  */
9011
9058
  export interface ContextFilter {
9012
9059
  contextIds?: string[] | undefined;
9013
- contextTypes?: ContextType[] | undefined;
9060
+ contextTypes?: `${ContextType}`[] | undefined;
9014
9061
  documentIds?: string[] | undefined;
9015
9062
  documentOrigins?: string[] | undefined;
9016
9063
  documentUrls?: string[] | undefined;
@@ -9021,26 +9068,19 @@ export namespace Browser {
9021
9068
  }
9022
9069
 
9023
9070
  export interface ConnectInfo {
9071
+ /** Will be passed into onConnect for processes that are listening for the connection event. */
9024
9072
  name?: string | undefined;
9073
+ /** Whether the TLS channel ID will be passed into onConnectExternal for processes that are listening for the connection event. */
9025
9074
  includeTlsChannelId?: boolean | undefined;
9026
9075
  }
9027
9076
 
9028
9077
  export interface InstalledDetails {
9029
- /**
9030
- * The reason that this event is being dispatched.
9031
- */
9078
+ /** The reason that this event is being dispatched. */
9032
9079
  reason: `${OnInstalledReason}`;
9033
- /**
9034
- * Optional.
9035
- * Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'.
9036
- */
9037
- previousVersion?: string | undefined;
9038
- /**
9039
- * Optional.
9040
- * Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'.
9041
- * @since Chrome 29
9042
- */
9043
- 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;
9044
9084
  }
9045
9085
 
9046
9086
  /**
@@ -9051,29 +9091,20 @@ export namespace Browser {
9051
9091
  /** A unique identifier for this context */
9052
9092
  contextId: string;
9053
9093
  /** The type of context this corresponds to. */
9054
- contextType: ContextType;
9055
- /**
9056
- * Optional.
9057
- * A UUID for the document associated with this context, or undefined if this context is hosted not in a document.
9058
- */
9059
- documentId?: string | undefined;
9060
- /**
9061
- * Optional.
9062
- * The origin of the document associated with this context, or undefined if the context is not hosted in a document.
9063
- */
9064
- documentOrigin?: string | undefined;
9065
- /**
9066
- * Optional.
9067
- * The URL of the document associated with this context, or undefined if the context is not hosted in a document.
9068
- */
9069
- documentUrl?: string | undefined;
9070
- /** 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. */
9071
9102
  frameId: number;
9072
9103
  /** Whether the context is associated with an incognito profile. */
9073
9104
  incognito: boolean;
9074
- /** 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. */
9075
9106
  tabId: number;
9076
- /** 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. */
9077
9108
  windowId: number;
9078
9109
  }
9079
9110
 
@@ -9082,132 +9113,91 @@ export namespace Browser {
9082
9113
  includeTlsChannelId?: boolean | undefined;
9083
9114
  }
9084
9115
 
9085
- /**
9086
- * An object containing information about the script context that sent a message or request.
9087
- * @since Chrome 26
9088
- */
9116
+ /** An object containing information about the script context that sent a message or request */
9089
9117
  export interface MessageSender {
9090
- /** The ID of the extension or app that opened the connection, if any. */
9091
- id?: string | undefined;
9092
- /** 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. */
9093
- tab?: Browser.tabs.Tab | undefined;
9094
- /** The name of the native application that opened the connection, if any.
9095
- * @since Chrome 74
9096
- */
9097
- nativeApplication?: string | undefined;
9098
- /**
9099
- * The frame that opened the connection. 0 for top-level frames, positive for child frames. This will only be set when tab is set.
9100
- * @since Chrome 41
9101
- */
9102
- frameId?: number | undefined;
9103
- /**
9104
- * 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.
9105
- * @since Chrome 28
9106
- */
9107
- url?: string | undefined;
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;
9108
9122
  /**
9109
- * The TLS channel ID of the page or frame that opened the connection, if requested by the extension or app, and if available.
9110
- * @since Chrome 32
9123
+ * The name of the native application that opened the connection, if any.
9124
+ * @since Chrome 74
9111
9125
  */
9112
- tlsChannelId?: 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;
9113
9133
  /**
9114
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.
9115
9135
  * @since Chrome 80
9116
9136
  */
9117
- origin?: string | undefined;
9137
+ origin?: string;
9118
9138
  /**
9119
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.
9120
9140
  * @since Chrome 106
9121
9141
  */
9122
- documentLifecycle?: extensionTypes.DocumentLifecycle | undefined;
9142
+ documentLifecycle?: extensionTypes.DocumentLifecycle;
9123
9143
  /**
9124
9144
  * A UUID of the document that opened the connection.
9125
9145
  * @since Chrome 106
9126
9146
  */
9127
- documentId?: string | undefined;
9147
+ documentId?: string;
9128
9148
  }
9129
9149
 
9130
- /**
9131
- * An object containing information about the current platform.
9132
- * @since Chrome 36
9133
- */
9150
+ /** An object containing information about the current platform. */
9134
9151
  export interface PlatformInfo {
9135
- /**
9136
- * The operating system chrome is running on.
9137
- */
9138
- os: PlatformOs;
9139
- /**
9140
- * The machine's processor architecture.
9141
- */
9142
- arch: PlatformArch;
9143
- /**
9144
- * The native client architecture. This may be different from arch on some platforms.
9145
- */
9146
- 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}`;
9147
9158
  }
9148
9159
 
9149
- /**
9150
- * An object which allows two way communication with other pages.
9151
- * @since Chrome 26
9152
- */
9160
+ /** An object which allows two way communication with other pages. */
9153
9161
  export interface Port {
9162
+ /** Send a message to the other end of the port. If the port is disconnected, an error is thrown. */
9154
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. */
9155
9165
  disconnect: () => void;
9156
- /**
9157
- * Optional.
9158
- * This property will only be present on ports passed to onConnect/onConnectExternal listeners.
9159
- */
9160
- sender?: MessageSender | undefined;
9161
- /** An object which allows the addition and removal of listeners for a Chrome event. */
9162
- onDisconnect: PortDisconnectEvent;
9163
- /** An object which allows the addition and removal of listeners for a Chrome event. */
9164
- 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}. */
9165
9173
  name: string;
9166
9174
  }
9167
9175
 
9168
- export interface UpdateAvailableDetails {
9169
- /** The version number of the available update. */
9170
- version: string;
9171
- }
9172
-
9173
9176
  export interface UpdateCheckDetails {
9174
9177
  /** The version of the available update. */
9175
9178
  version: string;
9176
9179
  }
9177
9180
 
9178
- /** Result of the update check. */
9179
- 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
+ }
9180
9193
 
9181
- /** Result of the update check. */
9182
9194
  export interface RequestUpdateCheckResult {
9183
- /** The status of the update check. */
9184
- status: RequestUpdateCheckStatus;
9185
- /** The version of the available update. */
9186
- 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;
9187
9199
  }
9188
9200
 
9189
- export interface PortDisconnectEvent extends Browser.events.Event<(port: Port) => void> {}
9190
-
9191
- export interface PortMessageEvent extends Browser.events.Event<(message: any, port: Port) => void> {}
9192
-
9193
- export interface ExtensionMessageEvent extends
9194
- Browser.events.Event<
9195
- (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void
9196
- >
9197
- {}
9198
-
9199
- export interface ExtensionConnectEvent extends Browser.events.Event<(port: Port) => void> {}
9200
-
9201
- export interface RuntimeInstalledEvent extends Browser.events.Event<(details: InstalledDetails) => void> {}
9202
-
9203
- export interface RuntimeEvent extends Browser.events.Event<() => void> {}
9204
-
9205
- export interface RuntimeRestartRequiredEvent extends Browser.events.Event<(reason: string) => void> {}
9206
-
9207
- export interface RuntimeUpdateAvailableEvent
9208
- extends Browser.events.Event<(details: UpdateAvailableDetails) => void>
9209
- {}
9210
-
9211
9201
  export interface ManifestIcons {
9212
9202
  [size: number]: string;
9213
9203
  }
@@ -9583,282 +9573,225 @@ export namespace Browser {
9583
9573
  export type Manifest = ManifestV2 | ManifestV3;
9584
9574
 
9585
9575
  /**
9586
- * 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.
9587
- * @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.
9588
9580
  */
9589
9581
  export function connect(connectInfo?: ConnectInfo): Port;
9582
+ export function connect(extensionId: string | undefined, connectInfo?: ConnectInfo): Port;
9583
+
9590
9584
  /**
9591
- * 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.
9592
- * @since Chrome 26
9593
- * @param extensionId Optional.
9594
- * 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.
9595
- */
9596
- export function connect(extensionId: string, connectInfo?: ConnectInfo): Port;
9597
- /**
9598
- * Connects to a native application in the host machine.
9599
- * @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.
9600
9586
  * @param application The name of the registered application to connect to.
9601
9587
  */
9602
9588
  export function connectNative(application: string): Port;
9603
9589
  /**
9604
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.
9605
- * @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.
9606
9596
  */
9607
- export function getBackgroundPage(): Promise<Window>;
9608
- /** 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>;
9609
9598
  export function getBackgroundPage(callback: (backgroundPage?: Window) => void): void;
9599
+
9610
9600
  /**
9611
9601
  * Fetches information about active contexts associated with this extension
9612
- * @since Chrome 116 MV3.
9613
- * @return Provides the matching context, if any via callback or returned as a `Promise` (MV3 only).
9614
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.
9615
- */
9616
- export function getContexts(filter: ContextFilter): Promise<ExtensionContext[]>;
9617
- /**
9618
- * Fetches information about active contexts associated with this extension
9619
9603
  * @since Chrome 116 MV3.
9620
- * @return Provides the matching context, if any via callback or returned as a `Promise` (MV3 only).
9621
- * @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.
9622
- * @param callback Called with results
9623
9604
  */
9605
+ export function getContexts(filter: ContextFilter): Promise<ExtensionContext[]>;
9624
9606
  export function getContexts(filter: ContextFilter, callback: (contexts: ExtensionContext[]) => void): void;
9607
+
9625
9608
  /**
9626
9609
  * Returns details about the app or extension from the manifest. The object returned is a serialization of the full manifest file.
9627
9610
  * @return The manifest details.
9628
9611
  */
9629
9612
  export function getManifest(): Manifest;
9613
+
9630
9614
  /**
9631
9615
  * Returns a DirectoryEntry for the package directory.
9632
- * @since Chrome 29
9616
+ *
9617
+ * Foreground only
9618
+ *
9619
+ * Can return its result via Promise in Manifest V3 or later since Chrome 122.
9633
9620
  */
9621
+ export function getPackageDirectoryEntry(): Promise<DirectoryEntry>;
9634
9622
  export function getPackageDirectoryEntry(callback: (directoryEntry: DirectoryEntry) => void): void;
9623
+
9635
9624
  /**
9636
9625
  * Returns information about the current platform.
9637
- * @since Chrome 29
9638
- * @param callback Called with results
9639
- */
9640
- export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void;
9641
- /**
9642
- * Returns information about the current platform.
9643
- * @since Chrome 29
9644
- * @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.
9645
9628
  */
9646
9629
  export function getPlatformInfo(): Promise<PlatformInfo>;
9630
+ export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void;
9631
+
9647
9632
  /**
9648
9633
  * Converts a relative path within an app/extension install directory to a fully-qualified URL.
9649
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.
9650
9636
  */
9651
9637
  export function getURL(path: string): string;
9652
- /**
9653
- * Reloads the app or extension.
9654
- * @since Chrome 25
9655
- */
9638
+
9639
+ /** Reloads the app or extension. This method is not supported in kiosk mode. For kiosk mode, use {@link Browser.runtime.restart()} method. */
9656
9640
  export function reload(): void;
9641
+
9657
9642
  /**
9658
- * Requests an update check for this app/extension.
9659
- * @since Chrome 109
9660
- * @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.
9661
9652
  */
9662
9653
  export function requestUpdateCheck(): Promise<RequestUpdateCheckResult>;
9663
- /**
9664
- * Requests an update check for this app/extension.
9665
- * @since Chrome 25
9666
- * @param callback
9667
- * Parameter status: Result of the update check. One of: "throttled", "no_update", or "update_available"
9668
- * Optional parameter details: If an update is available, this contains more information about the available update.
9669
- */
9670
9654
  export function requestUpdateCheck(
9671
- callback: (status: RequestUpdateCheckStatus, details?: UpdateCheckDetails) => void,
9655
+ callback: (status: `${RequestUpdateCheckStatus}`, details?: { version: string }) => void,
9672
9656
  ): void;
9673
- /**
9674
- * Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op.
9675
- * @since Chrome 32
9676
- */
9657
+
9658
+ /** Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op. */
9677
9659
  export function restart(): void;
9660
+
9678
9661
  /**
9679
- * Restart the ChromeOS device when the app runs in kiosk mode after the
9680
- * given seconds. If called again before the time ends, the reboot will
9681
- * be delayed. If called with a value of -1, the reboot will be
9682
- * cancelled. It's a no-op in non-kiosk mode. It's only allowed to be
9683
- * 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.
9684
9665
  * @since Chrome 53
9685
- * @param seconds
9686
- * @param callback
9687
9666
  */
9688
- export function restartAfterDelay(seconds: number, callback?: () => void): void;
9689
- /**
9690
- * 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.
9691
- * @since Chrome 26
9692
- * 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.
9693
- */
9694
- 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
+
9695
9670
  /**
9696
- * 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.
9697
- * @since Chrome 32
9698
- * 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.
9699
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;
9700
9679
  export function sendMessage<M = any, R = any>(
9701
9680
  message: M,
9702
- options: MessageOptions,
9703
- responseCallback: (response: R) => void,
9681
+ options: MessageOptions | undefined,
9682
+ callback: (response: R) => void,
9704
9683
  ): void;
9705
- /**
9706
- * 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.
9707
- * @since Chrome 26
9708
- * @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.
9709
- * 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.
9710
- */
9711
9684
  export function sendMessage<M = any, R = any>(
9712
9685
  extensionId: string | undefined | null,
9713
9686
  message: M,
9714
- responseCallback: (response: R) => void,
9715
- ): 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 32
9719
- * @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.
9720
- * 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.
9721
- */
9722
- export function sendMessage<Message = any, Response = any>(
9687
+ options?: MessageOptions,
9688
+ ): Promise<R>;
9689
+ export function sendMessage<M = any, R = any>(
9723
9690
  extensionId: string | undefined | null,
9724
- message: Message,
9725
- options: MessageOptions,
9726
- responseCallback: (response: Response) => void,
9691
+ message: M,
9692
+ callback: (response: R) => void,
9727
9693
  ): void;
9728
- /**
9729
- * 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.
9730
- * @since Chrome 26
9731
- */
9732
- export function sendMessage<M = any, R = any>(message: M): Promise<R>;
9733
- /**
9734
- * 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.
9735
- * @since Chrome 32
9736
- */
9737
9694
  export function sendMessage<M = any, R = any>(
9738
- message: M,
9739
- options: MessageOptions,
9740
- ): Promise<R>;
9741
- /**
9742
- * 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.
9743
- * @since Chrome 26
9744
- * @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.
9745
- */
9746
- export function sendMessage<M = any, R = any>(extensionId: string | undefined | null, message: M): Promise<R>;
9747
- /**
9748
- * 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.
9749
- * @since Chrome 32
9750
- * @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.
9751
- */
9752
- export function sendMessage<Message = any, Response = any>(
9753
9695
  extensionId: string | undefined | null,
9754
- message: Message,
9755
- options: MessageOptions,
9756
- ): Promise<Response>;
9757
- /**
9758
- * Send a single message to a native application.
9759
- * @since Chrome 28
9760
- * @param application The of the native messaging host.
9761
- * @param message The message that will be passed to the native messaging host.
9762
- * 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.
9763
- */
9764
- export function sendNativeMessage(
9765
- application: string,
9766
- message: object,
9767
- responseCallback: (response: any) => void,
9696
+ message: M,
9697
+ options: MessageOptions | undefined,
9698
+ callback: (response: R) => void,
9768
9699
  ): void;
9700
+
9769
9701
  /**
9770
- * Send a single message to a native application.
9771
- * @since Chrome 28
9772
- * @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.
9773
9706
  * @param message The message that will be passed to the native messaging host.
9774
9707
  */
9708
+ export function sendNativeMessage(application: string, message: object): Promise<any>;
9775
9709
  export function sendNativeMessage(
9776
9710
  application: string,
9777
9711
  message: object,
9778
- ): Promise<any>;
9712
+ callback: (response: any) => void,
9713
+ ): void;
9714
+
9779
9715
  /**
9780
- * 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.
9781
- * @since Chrome 41
9782
- * @param url Since Chrome 34.
9783
- * 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.
9784
- * @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.
9785
9720
  */
9786
- 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
+
9787
9724
  /**
9788
9725
  * Open your Extension's options page, if possible.
9726
+ *
9789
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.
9790
- * If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set lastError.
9791
- * @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
9792
9732
  */
9793
9733
  export function openOptionsPage(): Promise<void>;
9794
- /**
9795
- * Open your Extension's options page, if possible.
9796
- * 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.
9797
- * If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set lastError.
9798
- * @since Chrome 42
9799
- */
9800
- 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>;
9801
9741
 
9802
9742
  /**
9803
- * Fired when a connection is made from either an extension process or a content script.
9804
- * @since Chrome 26
9805
- */
9806
- export var onConnect: ExtensionConnectEvent;
9807
- /**
9808
- * Fired when a connection is made from another extension.
9809
- * @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
9810
9745
  */
9811
- export var onConnectExternal: ExtensionConnectEvent;
9746
+ export const onConnectNative: events.Event<(port: Port) => void>;
9747
+
9812
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. */
9813
- export var onSuspend: RuntimeEvent;
9814
- /**
9815
- * 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.
9816
- * @since Chrome 23
9817
- */
9818
- 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
+
9819
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. */
9820
- export var onInstalled: RuntimeInstalledEvent;
9755
+ export const onInstalled: events.Event<(details: InstalledDetails) => void>;
9756
+
9821
9757
  /** Sent after onSuspend to indicate that the app won't be unloaded after all. */
9822
- export var onSuspendCanceled: RuntimeEvent;
9823
- /**
9824
- * Fired when a message is sent from either an extension process or a content script.
9825
- * @since Chrome 26
9826
- */
9827
- export var onMessage: ExtensionMessageEvent;
9828
- /**
9829
- * Fired when a message is sent from another extension/app. Cannot be used in a content script.
9830
- * @since Chrome 26
9831
- */
9832
- export var onMessageExternal: ExtensionMessageEvent;
9833
- /**
9834
- * 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.
9835
- * @since Chrome 29
9836
- */
9837
- export var onRestartRequired: RuntimeRestartRequiredEvent;
9838
- /**
9839
- * 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.
9840
- * @since Chrome 25
9841
- */
9842
- 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
+
9843
9776
  /**
9844
- * @deprecated since Chrome 33. Please use Browser.runtime.onRestartRequired.
9845
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}.
9846
9779
  */
9847
- export var onBrowserUpdateAvailable: RuntimeEvent;
9780
+ export const onBrowserUpdateAvailable: events.Event<() => void>;
9848
9781
 
9849
9782
  /**
9850
- * @since chrome 115+
9851
- * @requires MV3+
9852
- * 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
9853
9785
  */
9854
- export var onUserScriptConnect: ExtensionConnectEvent;
9786
+ export const onUserScriptConnect: events.Event<(port: Port) => void>;
9855
9787
 
9856
9788
  /**
9857
- * @since chrome 115+
9858
- * @requires MV3+
9859
- * 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
9860
9791
  */
9861
- export var onUserScriptMessage: ExtensionMessageEvent;
9792
+ export const onUserScriptMessage: events.Event<
9793
+ (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void
9794
+ >;
9862
9795
  }
9863
9796
 
9864
9797
  ////////////////////
@@ -12469,6 +12402,11 @@ export namespace Browser {
12469
12402
  color: `${Color}`;
12470
12403
  /** The ID of the group. Group IDs are unique within a browser session. */
12471
12404
  id: number;
12405
+ /**
12406
+ * Whether the group is shared.
12407
+ * @since Chrome 137
12408
+ */
12409
+ shared: boolean;
12472
12410
  /** The title of the group. */
12473
12411
  title?: string;
12474
12412
  /** The ID of the window that contains the group. */
@@ -12484,13 +12422,18 @@ export namespace Browser {
12484
12422
 
12485
12423
  export interface QueryInfo {
12486
12424
  /** Whether the groups are collapsed. */
12487
- collapsed?: boolean;
12425
+ collapsed?: boolean | undefined;
12488
12426
  /** The color of the groups. */
12489
- color?: `${Color}`;
12427
+ color?: `${Color}` | undefined;
12428
+ /**
12429
+ * Whether the group is shared.
12430
+ * @since Chrome 137
12431
+ */
12432
+ shared?: boolean | undefined;
12490
12433
  /** Match group titles against a pattern. */
12491
- title?: string;
12434
+ title?: string | undefined;
12492
12435
  /** The ID of the parent window, or {@link windows.WINDOW_ID_CURRENT} for the current window. */
12493
- windowId?: number;
12436
+ windowId?: number | undefined;
12494
12437
  }
12495
12438
 
12496
12439
  export interface UpdateProperties {
@@ -13906,334 +13849,231 @@ export namespace Browser {
13906
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.
13907
13850
  */
13908
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
+
13909
13858
  export interface Window {
13910
- /** 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. */
13911
13860
  tabs?: Browser.tabs.Tab[] | undefined;
13912
- /** 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. */
13913
13862
  top?: number | undefined;
13914
- /** 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. */
13915
13864
  height?: number | undefined;
13916
- /** 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. */
13917
13866
  width?: number | undefined;
13918
- /**
13919
- * The state of this browser window.
13920
- * @since Chrome 17
13921
- */
13922
- state?: windowStateEnum | undefined;
13867
+ /** The state of this browser window. */
13868
+ state?: `${WindowState}` | undefined;
13923
13869
  /** Whether the window is currently the focused window. */
13924
13870
  focused: boolean;
13925
- /**
13926
- * Whether the window is set to be always on top.
13927
- * @since Chrome 19
13928
- */
13871
+ /** Whether the window is set to be always on top. */
13929
13872
  alwaysOnTop: boolean;
13930
13873
  /** Whether the window is incognito. */
13931
13874
  incognito: boolean;
13932
- /**
13933
- * The type of browser window this is.
13934
- */
13935
- type?: windowTypeEnum | undefined;
13936
- /** 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. */
13937
13878
  id?: number | undefined;
13938
- /** 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. */
13939
13880
  left?: number | undefined;
13940
- /**
13941
- * Optional. The session ID used to uniquely identify a Window obtained from the sessions API.
13942
- * @since Chrome 31
13943
- */
13881
+ /** The session ID used to uniquely identify a window, obtained from the {@link sessions} API. */
13944
13882
  sessionId?: string | undefined;
13945
13883
  }
13946
13884
 
13885
+ /** @since Chrome 88 */
13947
13886
  export interface QueryOptions {
13948
- /**
13949
- * Optional.
13950
- * If true, the windows.Window object will have a tabs property that contains a list of the tabs.Tab objects.
13951
- * The Tab objects only contain the url, pendingUrl, title and favIconUrl properties if the extension's manifest file includes the "tabs" permission.
13952
- */
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. */
13953
13888
  populate?: boolean | undefined;
13954
- /**
13955
- * If set, the Window returned is filtered based on its type. If unset, the default filter is set to ['normal', 'popup'].
13956
- */
13957
- 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;
13958
13891
  }
13959
13892
 
13960
13893
  export interface CreateData {
13961
- /**
13962
- * Optional. The id of the tab for which you want to adopt to the new window.
13963
- * @since Chrome 10
13964
- */
13894
+ /** The ID of the tab to add to the new window. */
13965
13895
  tabId?: number | undefined;
13966
- /**
13967
- * Optional.
13968
- * 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.
13969
- */
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. */
13970
13897
  url?: string | string[] | undefined;
13971
- /**
13972
- * Optional.
13973
- * 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.
13974
- */
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. */
13975
13899
  top?: number | undefined;
13976
- /**
13977
- * Optional.
13978
- * The height in pixels of the new window, including the frame. If not specified defaults to a natural height.
13979
- */
13900
+ /** The height in pixels of the new window, including the frame. If not specified, defaults to a natural height. */
13980
13901
  height?: number | undefined;
13981
- /**
13982
- * Optional.
13983
- * The width in pixels of the new window, including the frame. If not specified defaults to a natural width.
13984
- */
13902
+ /** The width in pixels of the new window, including the frame. If not specified, defaults to a natural width. */
13985
13903
  width?: number | undefined;
13986
- /**
13987
- * Optional. If true, opens an active window. If false, opens an inactive window.
13988
- * @since Chrome 12
13989
- */
13904
+ /** If `true`, opens an active window. If `false`, opens an inactive window. */
13990
13905
  focused?: boolean | undefined;
13991
- /** Optional. Whether the new window should be an incognito window. */
13906
+ /** Whether the new window should be an incognito window. */
13992
13907
  incognito?: boolean | undefined;
13993
- /** Optional. Specifies what type of browser window to create. */
13994
- type?: createTypeEnum | undefined;
13995
- /**
13996
- * Optional.
13997
- * 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.
13998
- */
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. */
13999
13911
  left?: number | undefined;
14000
13912
  /**
14001
- * 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`.
14002
13914
  * @since Chrome 44
14003
13915
  */
14004
- state?: windowStateEnum | undefined;
13916
+ state?: `${WindowState}` | undefined;
14005
13917
  /**
14006
- * 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.
14007
13919
  * @since Chrome 64
14008
13920
  */
14009
13921
  setSelfAsOpener?: boolean | undefined;
14010
13922
  }
14011
13923
 
14012
13924
  export interface UpdateInfo {
14013
- /** 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. */
14014
13926
  top?: number | undefined;
14015
- /**
14016
- * 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.
14017
- * @since Chrome 14
14018
- */
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. */
14019
13928
  drawAttention?: boolean | undefined;
14020
- /** 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. */
14021
13930
  height?: number | undefined;
14022
- /** 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. */
14023
13932
  width?: number | undefined;
14024
- /**
14025
- * Optional. The new state of the window. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'.
14026
- * @since Chrome 17
14027
- */
14028
- state?: windowStateEnum | undefined;
14029
- /**
14030
- * Optional. If true, brings the window to the front. If false, brings the next window in the z-order to the front.
14031
- * @since Chrome 8
14032
- */
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'. */
14033
13936
  focused?: boolean | undefined;
14034
- /** 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. */
14035
13938
  left?: number | undefined;
14036
13939
  }
14037
13940
 
14038
- export interface WindowEventFilter {
14039
- /**
14040
- * 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.
14041
- */
14042
- windowTypes: windowTypeEnum[];
14043
- }
14044
-
14045
- export interface WindowIdEvent extends Browser.events.Event<(windowId: number) => void> {
14046
- addListener(
14047
- callback: (windowId: number) => void,
14048
- filters?: WindowEventFilter,
14049
- ): void;
14050
- }
14051
-
14052
- export interface WindowReferenceEvent extends Browser.events.Event<(window: Window) => void> {
14053
- addListener(
14054
- callback: (window: Window) => void,
14055
- filters?: WindowEventFilter,
14056
- ): void;
14057
- }
14058
-
14059
13941
  /**
14060
13942
  * Specifies what type of browser window to create.
14061
13943
  * 'panel' is deprecated and is available only to existing whitelisted extensions on Chrome OS.
14062
13944
  * @since Chrome 44
14063
13945
  */
14064
- 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
+ }
14065
13954
 
14066
13955
  /**
14067
- * The state of this browser window.
14068
- * 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.
14069
13957
  * @since Chrome 44
14070
13958
  */
14071
- 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
+ }
14072
13971
 
14073
13972
  /**
14074
- * The type of browser window this is.
14075
- * 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.
14076
13974
  * @since Chrome 44
14077
13975
  */
14078
- 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
+ }
14079
13988
 
14080
- /**
14081
- * The windowId value that represents the current window.
14082
- * @since Chrome 18
14083
- */
14084
- export var WINDOW_ID_CURRENT: -2;
14085
- /**
14086
- * The windowId value that represents the absence of a chrome browser window.
14087
- * @since Chrome 6
14088
- */
14089
- 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;
14090
13994
 
14091
- /** Gets details about a window. */
14092
- export function get(windowId: number, callback: (window: Browser.windows.Window) => void): void;
14093
- /**
14094
- * Gets details about a window.
14095
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
14096
- */
14097
- export function get(windowId: number): Promise<Browser.windows.Window>;
14098
13995
  /**
14099
13996
  * Gets details about a window.
14100
- * @since Chrome 18
13997
+ *
13998
+ * Can return its result via Promise in Manifest V3 or later since Chrome 88.
14101
13999
  */
14000
+ export function get(windowId: number, queryOptions?: QueryOptions): Promise<Window>;
14001
+ export function get(windowId: number, callback: (window: Window) => void): void;
14102
14002
  export function get(
14103
14003
  windowId: number,
14104
- queryOptions: QueryOptions,
14105
- callback: (window: Browser.windows.Window) => void,
14004
+ queryOptions: QueryOptions | undefined,
14005
+ callback: (window: Window) => void,
14106
14006
  ): void;
14107
- /**
14108
- * Gets details about a window.
14109
- * @since Chrome 18
14110
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
14111
- */
14112
- export function get(windowId: number, queryOptions: QueryOptions): Promise<Browser.windows.Window>;
14113
- /** Gets the current window. */
14114
- export function getCurrent(callback: (window: Browser.windows.Window) => void): void;
14115
- /**
14116
- * Gets the current window.
14117
- * @return The `getCurrent` method provides its result via callback or returned as a `Promise` (MV3 only).
14118
- */
14119
- export function getCurrent(): Promise<Browser.windows.Window>;
14120
- /**
14121
- * Gets the current window.
14122
- * @param QueryOptions
14123
- * @since Chrome 18
14124
- */
14125
- export function getCurrent(queryOptions: QueryOptions, callback: (window: Browser.windows.Window) => void): void;
14007
+
14126
14008
  /**
14127
14009
  * Gets the current window.
14128
- * @param QueryOptions
14129
- * @since Chrome 18
14130
- * @return The `getCurrent` method provides its result via callback or returned as a `Promise` (MV3 only).
14131
- */
14132
- export function getCurrent(queryOptions: QueryOptions): Promise<Browser.windows.Window>;
14133
- /**
14134
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
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(): Promise<Browser.windows.Window>;
14138
- /**
14139
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14140
- * @param callback
14141
- * Optional parameter window: Contains details about the created window.
14142
- */
14143
- export function create(callback: (window?: Browser.windows.Window) => void): void;
14144
- /**
14145
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14146
- * @param CreateData
14147
- * @return The `create` method provides its result via callback or returned as a `Promise` (MV3 only). Contains details about the created window.
14148
- */
14149
- export function create(createData: CreateData): Promise<Browser.windows.Window>;
14150
- /**
14151
- * Creates (opens) a new browser with any optional sizing, position or default URL provided.
14152
- * @param CreateData
14153
- * @param callback
14154
- * Optional parameter window: Contains details about the created window.
14155
- */
14156
- export function create(createData: CreateData, callback: (window?: Browser.windows.Window) => void): void;
14157
- /**
14158
- * Gets all windows.
14159
- */
14160
- export function getAll(callback: (windows: Browser.windows.Window[]) => void): void;
14161
- /**
14162
- * Gets all windows.
14163
- * @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.
14164
14012
  */
14165
- 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
+
14166
14017
  /**
14167
- * Gets all windows.
14168
- * @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.
14169
14021
  */
14170
- 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
+
14171
14026
  /**
14172
14027
  * Gets all windows.
14173
- * @since Chrome 18
14174
- * @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.
14175
14030
  */
14176
- 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
+
14177
14035
  /**
14178
- * Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be left unchanged.
14179
- * @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.
14180
14039
  */
14181
- export function update(
14182
- windowId: number,
14183
- updateInfo: UpdateInfo,
14184
- ): Promise<Browser.windows.Window>;
14185
- /** Updates the properties of a window. Specify only the properties that you want to change; unspecified properties will be left unchanged. */
14186
- export function update(
14187
- windowId: number,
14188
- updateInfo: UpdateInfo,
14189
- callback: (window: Browser.windows.Window) => void,
14190
- ): 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
+
14191
14043
  /**
14192
- * Removes (closes) a window, and all the tabs inside it
14193
- * @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.
14194
14047
  */
14195
14048
  export function remove(windowId: number): Promise<void>;
14196
- /** Removes (closes) a window, and all the tabs inside it. */
14197
14049
  export function remove(windowId: number, callback: () => void): void;
14050
+
14198
14051
  /**
14199
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.
14200
14055
  */
14201
- export function getLastFocused(callback: (window: Browser.windows.Window) => void): void;
14202
- /**
14203
- * Gets the window that was most recently focused — typically the window 'on top'.
14204
- * @return The `getLastFocused` method provides its result via callback or returned as a `Promise` (MV3 only).
14205
- */
14206
- export function getLastFocused(): Promise<Browser.windows.Window>;
14207
- /**
14208
- * Gets the window that was most recently focused — typically the window 'on top'.
14209
- * @since Chrome 18
14210
- */
14056
+ export function getLastFocused(queryOptions?: QueryOptions): Promise<Window>;
14057
+ export function getLastFocused(callback: (window: Window) => void): void;
14211
14058
  export function getLastFocused(
14212
- queryOptions: QueryOptions,
14213
- callback: (window: Browser.windows.Window) => void,
14059
+ queryOptions: QueryOptions | undefined,
14060
+ callback: (window: Window) => void,
14214
14061
  ): void;
14215
- /**
14216
- * Gets the window that was most recently focused — typically the window 'on top'.
14217
- * @since Chrome 18
14218
- * @return The `getLastFocused` method provides its result via callback or returned as a `Promise` (MV3 only).
14219
- */
14220
- export function getLastFocused(queryOptions: QueryOptions): Promise<Browser.windows.Window>;
14221
14062
 
14222
14063
  /** Fired when a window is removed (closed). */
14223
- export var onRemoved: WindowIdEvent;
14064
+ export const onRemoved: WindowsEvent<(windowId: number) => void>;
14065
+
14224
14066
  /** Fired when a window is created. */
14225
- export var onCreated: WindowReferenceEvent;
14226
- /**
14227
- * Fired when the currently focused window changes. Will be Browser.windows.WINDOW_ID_NONE if all chrome windows have lost focus.
14228
- * Note: On some Linux window managers, WINDOW_ID_NONE will always be sent immediately preceding a switch from one chrome window to another.
14229
- */
14230
- 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>;
14231
14071
 
14232
14072
  /**
14233
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.
14234
14074
  * @since Chrome 86
14235
14075
  */
14236
- export var onBoundsChanged: WindowReferenceEvent;
14076
+ export const onBoundsChanged: events.Event<(window: Window) => void>;
14237
14077
  }
14238
14078
 
14239
14079
  ////////////////////