@types/chrome 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. chrome/README.md +1 -1
  2. chrome/index.d.ts +139 -116
  3. chrome/package.json +2 -2
chrome/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for chrome (https://developer.chrome.com/
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Mon, 27 Oct 2025 18:40:39 GMT
11
+ * Last updated: Mon, 27 Oct 2025 20:34:59 GMT
12
12
  * Dependencies: [@types/filesystem](https://npmjs.com/package/@types/filesystem), [@types/har-format](https://npmjs.com/package/@types/har-format)
13
13
 
14
14
  # Credits
chrome/index.d.ts CHANGED
@@ -11869,7 +11869,7 @@ declare namespace chrome {
11869
11869
  * Permissions: "topSites"
11870
11870
  */
11871
11871
  export namespace topSites {
11872
- /** An object encapsulating a most visited URL, such as the URLs on the new tab page. */
11872
+ /** An object encapsulating a most visited URL, such as the default shortcuts on the new tab page. */
11873
11873
  export interface MostVisitedURL {
11874
11874
  /** The most visited URL. */
11875
11875
  url: string;
@@ -11877,14 +11877,13 @@ declare namespace chrome {
11877
11877
  title: string;
11878
11878
  }
11879
11879
 
11880
- /** Gets a list of top sites. */
11881
- export function get(callback: (data: MostVisitedURL[]) => void): void;
11882
-
11883
11880
  /**
11884
11881
  * Gets a list of top sites.
11885
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
11882
+ *
11883
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
11886
11884
  */
11887
11885
  export function get(): Promise<MostVisitedURL[]>;
11886
+ export function get(callback: (data: MostVisitedURL[]) => void): void;
11888
11887
  }
11889
11888
 
11890
11889
  ////////////////////
@@ -12471,27 +12470,35 @@ declare namespace chrome {
12471
12470
  * @since Chrome 43
12472
12471
  */
12473
12472
  export namespace wallpaper {
12473
+ /**
12474
+ * The supported wallpaper layouts.
12475
+ * @since Chrome 44
12476
+ */
12477
+ export enum WallpaperLayout {
12478
+ STRETCH = "STRETCH",
12479
+ CENTER = "CENTER",
12480
+ CENTER_CROPPED = "CENTER_CROPPED",
12481
+ }
12482
+
12474
12483
  export interface WallpaperDetails {
12475
- /** Optional. The jpeg or png encoded wallpaper image. */
12484
+ /** The jpeg or png encoded wallpaper image as an ArrayBuffer. */
12476
12485
  data?: ArrayBuffer | undefined;
12477
- /** Optional. The URL of the wallpaper to be set. */
12486
+ /** The URL of the wallpaper to be set (can be relative). */
12478
12487
  url?: string | undefined;
12479
- /**
12480
- * The supported wallpaper layouts.
12481
- * One of: "STRETCH", "CENTER", or "CENTER_CROPPED"
12482
- */
12483
- layout: "STRETCH" | "CENTER" | "CENTER_CROPPED";
12488
+ /** The supported wallpaper layouts. */
12489
+ layout: `${WallpaperLayout}`;
12484
12490
  /** The file name of the saved wallpaper. */
12485
12491
  filename: string;
12486
- /** Optional. True if a 128x60 thumbnail should be generated. */
12492
+ /** True if a 128x60 thumbnail should be generated. Layout and ratio are not supported yet. */
12487
12493
  thumbnail?: boolean | undefined;
12488
12494
  }
12489
12495
 
12490
12496
  /**
12491
12497
  * Sets wallpaper to the image at url or wallpaperData with the specified layout
12492
- * @param callback
12493
- * Optional parameter thumbnail: The jpeg encoded wallpaper thumbnail. It is generated by resizing the wallpaper to 128x60.
12498
+ *
12499
+ * Can return its result via Promise in Manifest V3 or later since Chrome 96.
12494
12500
  */
12501
+ export function setWallpaper(details: WallpaperDetails): Promise<ArrayBuffer | undefined>;
12495
12502
  export function setWallpaper(details: WallpaperDetails, callback: (thumbnail?: ArrayBuffer) => void): void;
12496
12503
  }
12497
12504
 
@@ -14442,133 +14449,165 @@ declare namespace chrome {
14442
14449
  * @since Chrome 120, MV3
14443
14450
  */
14444
14451
  export namespace userScripts {
14445
- /**
14446
- * Execution environment for a user script.
14447
- */
14448
- export type ExecutionWorld = "MAIN" | "USER_SCRIPT";
14452
+ /** The JavaScript world for a user script to execute within. */
14453
+ export enum ExecutionWorld {
14454
+ /** Specifies the execution environment of the DOM, which is the execution environment shared with the host page's JavaScript. */
14455
+ MAIN = "MAIN",
14456
+ /** Specifies the execution environment that is specific to user scripts and is exempt from the page's CSP. */
14457
+ USER_SCRIPT = "USER_SCRIPT",
14458
+ }
14449
14459
 
14450
14460
  /** @since Chrome 135 */
14451
- export interface InjectionResult {
14452
- /** The document associated with the injection. */
14453
- documentId: string;
14454
- /** The error, if any. `error` and `result` are mutually exclusive. */
14455
- error?: string;
14456
- /** The frame associated with the injection. */
14457
- frameId: number;
14458
- /** The result of the script execution. */
14459
- result: any;
14460
- }
14461
+ export type InjectionResult<T = unknown> =
14462
+ & {
14463
+ /** The document associated with the injection. */
14464
+ documentId: string;
14465
+ /** The frame associated with the injection. */
14466
+ frameId: number;
14467
+ }
14468
+ & (
14469
+ | {
14470
+ /** The error, if any */
14471
+ error?: never;
14472
+ /** The result of the script execution. */
14473
+ result: T;
14474
+ }
14475
+ | {
14476
+ /** The error, if any */
14477
+ error: string;
14478
+ /** The result of the script execution. */
14479
+ result?: never;
14480
+ }
14481
+ );
14461
14482
 
14462
14483
  export interface WorldProperties {
14463
14484
  /** Specifies the world csp. The default is the `ISOLATED` world csp. */
14464
- csp?: string;
14465
- /** Specifies whether messaging APIs are exposed. The default is false.*/
14466
- messaging?: boolean;
14485
+ csp?: string | undefined;
14486
+ /** Specifies whether messaging APIs are exposed. The default is `false`.*/
14487
+ messaging?: boolean | undefined;
14467
14488
  /**
14468
14489
  * Specifies the ID of the specific user script world to update. If not provided, updates the properties of the default user script world. Values with leading underscores (`_`) are reserved.
14469
14490
  * @since Chrome 133
14470
14491
  */
14471
- worldId?: string;
14492
+ worldId?: string | undefined;
14472
14493
  }
14473
14494
 
14474
14495
  export interface UserScriptFilter {
14475
- ids?: string[];
14496
+ /** {@link getScripts} only returns scripts with the IDs specified in this list. */
14497
+ ids?: string[] | undefined;
14476
14498
  }
14477
14499
 
14478
- /** @since Chrome 135 */
14479
- export interface InjectionTarget {
14480
- /** Whether the script should inject into all frames within the tab. Defaults to false. This must not be true if `frameIds` is specified. */
14481
- allFrames?: boolean;
14482
- /** The IDs of specific documentIds to inject into. This must not be set if `frameIds` is set. */
14483
- documentIds?: string[];
14484
- /** The IDs of specific frames to inject into. */
14485
- frameIds?: number[];
14486
- /** The ID of the tab into which to inject. */
14487
- tabId: number;
14488
- }
14500
+ // /** @since Chrome 135 */
14501
+ export type InjectionTarget =
14502
+ & {
14503
+ /** The ID of the tab into which to inject. */
14504
+ tabId: number;
14505
+ }
14506
+ & (
14507
+ | {
14508
+ /** Whether the script should inject into all frames within the tab. Defaults to false. */
14509
+ allFrames?: boolean | undefined;
14510
+ /** The IDs of specific documentIds to inject into. */
14511
+ documentIds?: never;
14512
+ /** The IDs of specific frames to inject into. */
14513
+ frameIds?: never;
14514
+ }
14515
+ | {
14516
+ /** Whether the script should inject into all frames within the tab. Defaults to false. */
14517
+ allFrames?: false | undefined;
14518
+ /** The IDs of specific documentIds to inject into. */
14519
+ documentIds?: never;
14520
+ /** The IDs of specific frames to inject into. */
14521
+ frameIds: number[] | undefined;
14522
+ }
14523
+ | {
14524
+ /** Whether the script should inject into all frames within the tab. Defaults to false. */
14525
+ allFrames?: false | undefined;
14526
+ /** The IDs of specific documentIds to inject into. */
14527
+ documentIds?: string[] | undefined;
14528
+ /** The IDs of specific frames to inject into. */
14529
+ frameIds?: never;
14530
+ }
14531
+ );
14489
14532
 
14490
14533
  export interface RegisteredUserScript {
14491
14534
  /** If true, it will inject into all frames, even if the frame is not the top-most frame in the tab. Each frame is checked independently for URL requirements; it will not inject into child frames if the URL requirements are not met. Defaults to false, meaning that only the top frame is matched. */
14492
- allFrames?: boolean;
14535
+ allFrames?: boolean | undefined;
14493
14536
  /** Specifies wildcard patterns for pages this user script will NOT be injected into. */
14494
- excludeGlobs?: string[];
14537
+ excludeGlobs?: string[] | undefined;
14495
14538
  /**Excludes pages that this user script would otherwise be injected into. See Match Patterns for more details on the syntax of these strings. */
14496
- excludeMatches?: string[];
14539
+ excludeMatches?: string[] | undefined;
14497
14540
  /** The ID of the user script specified in the API call. This property must not start with a '_' as it's reserved as a prefix for generated script IDs. */
14498
14541
  id: string;
14499
14542
  /** Specifies wildcard patterns for pages this user script will be injected into. */
14500
- includeGlobs?: string[];
14543
+ includeGlobs?: string[] | undefined;
14501
14544
  /** The list of ScriptSource objects defining sources of scripts to be injected into matching pages. This property must be specified for {@link register}, and when specified it must be a non-empty array.*/
14502
14545
  js: ScriptSource[];
14503
- /** Specifies which pages this user script will be injected into. See Match Patterns for more details on the syntax of these strings. This property must be specified for ${ref:register}. */
14504
- matches?: string[];
14505
- /** Specifies when JavaScript files are injected into the web page. The preferred and default value is document_idle */
14506
- runAt?: extensionTypes.RunAt;
14546
+ /** Specifies which pages this user script will be injected into. See Match Patterns for more details on the syntax of these strings. This property must be specified for {@link register}. */
14547
+ matches?: string[] | undefined;
14548
+ /** Specifies when JavaScript files are injected into the web page. The preferred and default value is `document_idle` */
14549
+ runAt?: extensionTypes.RunAt | undefined;
14507
14550
  /** The JavaScript execution environment to run the script in. The default is `USER_SCRIPT` */
14508
- world?: ExecutionWorld;
14551
+ world?: `${ExecutionWorld}` | undefined;
14509
14552
  /**
14510
14553
  * Specifies the user script world ID to execute in. If omitted, the script will execute in the default user script world. Only valid if `world` is omitted or is `USER_SCRIPT`. Values with leading underscores (`_`) are reserved.
14511
14554
  * @since Chrome 133
14512
14555
  */
14513
- worldId?: string;
14556
+ worldId?: string | undefined;
14514
14557
  }
14515
14558
 
14516
14559
  /** @since Chrome 135 */
14517
14560
  export interface UserScriptInjection {
14518
14561
  /** Whether the injection should be triggered in the target as soon as possible. Note that this is not a guarantee that injection will occur prior to page load, as the page may have already loaded by the time the script reaches the target. */
14519
- injectImmediately?: boolean;
14562
+ injectImmediately?: boolean | undefined;
14520
14563
  /** The list of ScriptSource objects defining sources of scripts to be injected into the target. */
14521
- js: ScriptSource[];
14564
+ js: [ScriptSource, ...ScriptSource[]];
14522
14565
  /** Details specifying the target into which to inject the script. */
14523
14566
  target: InjectionTarget;
14524
14567
  /** The JavaScript "world" to run the script in. The default is `USER_SCRIPT`. */
14525
- world?: ExecutionWorld;
14568
+ world?: `${ExecutionWorld}` | undefined;
14526
14569
  /** Specifies the user script world ID to execute in. If omitted, the script will execute in the default user script world. Only valid if `world` is omitted or is `USER_SCRIPT`. Values with leading underscores (`_`) are reserved. */
14527
- worldId?: string;
14570
+ worldId?: string | undefined;
14528
14571
  }
14529
14572
 
14530
- /**
14531
- * Properties for a script source.
14532
- */
14533
- export interface ScriptSource {
14534
- /** A string containing the JavaScript code to inject. Exactly one of file or code must be specified. */
14535
- code?: string;
14536
- /** The path of the JavaScript file to inject relative to the extension's root directory. Exactly one of file or code must be specified. */
14537
- file?: string;
14538
- }
14573
+ export type ScriptSource = {
14574
+ /** A string containing the JavaScript code to inject. */
14575
+ code: string;
14576
+ /** The path of the JavaScript file to inject relative to the extension's root directory. */
14577
+ file?: undefined;
14578
+ } | {
14579
+ /** A string containing the JavaScript code to inject. */
14580
+ code?: undefined;
14581
+ /** The path of the JavaScript file to inject relative to the extension's root directory. */
14582
+ file: string;
14583
+ };
14539
14584
 
14540
14585
  /**
14541
14586
  * Configures the `USER_SCRIPT` execution environment.
14542
14587
  *
14543
- * @param properties - Contains the user script world configuration.
14544
- * @returns A Promise that resolves with the same type that is passed to the callback.
14588
+ * Can return its result via Promise.
14589
+ * @param properties Contains the user script world configuration.
14545
14590
  */
14546
14591
  export function configureWorld(properties: WorldProperties): Promise<void>;
14547
- /**
14548
- * Configures the `USER_SCRIPT` execution environment.
14549
- *
14550
- * @param properties - Contains the user script world configuration.
14551
- * @param callback - Callback function to be executed after configuring the world.
14552
- */
14553
14592
  export function configureWorld(properties: WorldProperties, callback: () => void): void;
14554
14593
 
14555
14594
  /**
14556
14595
  * Returns all dynamically-registered user scripts for this extension.
14557
14596
  *
14558
- * @param filter - If specified, this method returns only the user scripts that match it.
14559
- * @returns A Promise that resolves with the same type that is passed to the callback.
14597
+ * Can return its result via Promise.
14598
+ * @param filter If specified, this method returns only the user scripts that match it.
14560
14599
  */
14561
14600
  export function getScripts(filter?: UserScriptFilter): Promise<RegisteredUserScript[]>;
14562
- /**
14563
- * Returns all dynamically-registered user scripts for this extension.
14564
- *
14565
- * @param filter - If specified, this method returns only the user scripts that match it.
14566
- * @param callback - Callback function to be executed after getting user scripts.
14567
- */
14568
- export function getScripts(filter: UserScriptFilter, callback: (scripts: RegisteredUserScript[]) => void): void;
14601
+ export function getScripts(callback: (scripts: RegisteredUserScript[]) => void): void;
14602
+ export function getScripts(
14603
+ filter: UserScriptFilter | undefined,
14604
+ callback: (scripts: RegisteredUserScript[]) => void,
14605
+ ): void;
14569
14606
 
14570
14607
  /**
14571
14608
  * Retrieves all registered world configurations.
14609
+ *
14610
+ * Can return its result via Promise.
14572
14611
  * @since Chrome 133
14573
14612
  */
14574
14613
  export function getWorldConfigurations(): Promise<WorldProperties[]>;
@@ -14576,24 +14615,23 @@ declare namespace chrome {
14576
14615
 
14577
14616
  /**
14578
14617
  * Injects a script into a target context. By default, the script will be run at `document_idle`, or immediately if the page has already loaded. If the `injectImmediately` property is set, the script will inject without waiting, even if the page has not finished loading. If the script evaluates to a promise, the browser will wait for the promise to settle and return the resulting value.
14618
+ *
14619
+ * Can return its result via Promise.
14579
14620
  * @since Chrome 135
14580
14621
  */
14581
- export function execute(injection: UserScriptInjection): Promise<InjectionResult[]>;
14582
- export function execute(injection: UserScriptInjection, callback: (result: InjectionResult[]) => void): void;
14622
+ export function execute<T>(injection: UserScriptInjection): Promise<InjectionResult<T>[]>;
14623
+ export function execute<T>(
14624
+ injection: UserScriptInjection,
14625
+ callback: (result: InjectionResult<T>[]) => void,
14626
+ ): void;
14583
14627
 
14584
14628
  /**
14585
14629
  * Registers one or more user scripts for this extension.
14586
14630
  *
14631
+ * Can return its result via Promise.
14587
14632
  * @param scripts - Contains a list of user scripts to be registered.
14588
- * @returns A Promise that resolves with the same type that is passed to the callback.
14589
14633
  */
14590
14634
  export function register(scripts: RegisteredUserScript[]): Promise<void>;
14591
- /**
14592
- * Registers one or more user scripts for this extension.
14593
- *
14594
- * @param scripts - Contains a list of user scripts to be registered.
14595
- * @param callback - Callback function to be executed after registering user scripts.
14596
- */
14597
14635
  export function register(scripts: RegisteredUserScript[], callback: () => void): void;
14598
14636
 
14599
14637
  /**
@@ -14601,41 +14639,26 @@ declare namespace chrome {
14601
14639
  * @param worldId The ID of the user script world to reset. If omitted, resets the default world's configuration.
14602
14640
  */
14603
14641
  export function resetWorldConfiguration(worldId?: string): Promise<void>;
14604
- export function resetWorldConfiguration(worldId: string, callback: () => void): void;
14605
14642
  export function resetWorldConfiguration(callback: () => void): void;
14643
+ export function resetWorldConfiguration(worldId: string | undefined, callback: () => void): void;
14606
14644
 
14607
14645
  /**
14608
14646
  * Unregisters all dynamically-registered user scripts for this extension.
14609
14647
  *
14610
- * @param filter - If specified, this method unregisters only the user scripts that match it.
14611
- * @returns A Promise that resolves with the same type that is passed to the callback.
14648
+ * Can return its result via Promise.
14649
+ * @param filter If specified, this method unregisters only the user scripts that match it.
14612
14650
  */
14613
14651
  export function unregister(filter?: UserScriptFilter): Promise<void>;
14614
- /**
14615
- * Unregisters all dynamically-registered user scripts for this extension.
14616
- *
14617
- * @param filter - If specified, this method unregisters only the user scripts that match it.
14618
- * @param callback - Callback function to be executed after unregistering user scripts.
14619
- */
14620
- export function unregister(filter: UserScriptFilter, callback: () => void): void;
14652
+ export function unregister(callback: () => void): void;
14653
+ export function unregister(filter: UserScriptFilter | undefined, callback: () => void): void;
14621
14654
 
14622
14655
  /**
14623
14656
  * Updates one or more user scripts for this extension.
14624
14657
  *
14625
- * @param scripts - Contains a list of user scripts to be updated. A property is only updated for the existing script
14626
- * if it is specified in this object. If there are errors during script parsing/file validation, or if
14627
- * the IDs specified do not correspond to a fully registered script, then no scripts are updated.
14628
- * @returns A Promise that resolves with the same type that is passed to the callback.
14658
+ * Can return its result via Promise.
14659
+ * @param scripts Contains a list of user scripts to be updated. A property is only updated for the existing script if it is specified in this object. If there are errors during script parsing/file validation, or if the IDs specified do not correspond to a fully registered script, then no scripts are updated.
14629
14660
  */
14630
14661
  export function update(scripts: RegisteredUserScript[]): Promise<void>;
14631
- /**
14632
- * Updates one or more user scripts for this extension.
14633
- *
14634
- * @param scripts - Contains a list of user scripts to be updated. A property is only updated for the existing script
14635
- * if it is specified in this object. If there are errors during script parsing/file validation, or if
14636
- * the IDs specified do not correspond to a fully registered script, then no scripts are updated.
14637
- * @param callback - Callback function to be executed after updating user scripts.
14638
- */
14639
14662
  export function update(scripts: RegisteredUserScript[], callback: () => void): void;
14640
14663
  }
14641
14664
  }
chrome/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/chrome",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "TypeScript definitions for chrome",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome",
6
6
  "license": "MIT",
@@ -94,6 +94,6 @@
94
94
  "@types/har-format": "*"
95
95
  },
96
96
  "peerDependencies": {},
97
- "typesPublisherContentHash": "d216a6c8c00a765cff5c13cda2f955a491576cb4cf67da012fc054017600a879",
97
+ "typesPublisherContentHash": "855bc18cd67fbe7ca35c8d69bffa87a3a938f61821b97032b7fc5ef9613bd1ce",
98
98
  "typeScriptVersion": "5.2"
99
99
  }