@types/chrome 0.0.167 → 0.0.171

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. chrome/README.md +1 -1
  2. chrome/index.d.ts +49 -26
  3. chrome/package.json +2 -2
chrome/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Chrome extension development (http://
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, 06 Dec 2021 02:01:00 GMT
11
+ * Last updated: Mon, 13 Dec 2021 18:31:05 GMT
12
12
  * Dependencies: [@types/filesystem](https://npmjs.com/package/@types/filesystem), [@types/har-format](https://npmjs.com/package/@types/har-format)
13
13
  * Global values: `chrome`
14
14
 
chrome/index.d.ts CHANGED
@@ -775,7 +775,7 @@ declare namespace chrome.browserAction {
775
775
 
776
776
  export interface BadgeTextDetails {
777
777
  /** Any number of characters can be passed, but only about four can fit in the space. */
778
- text?: string | null;
778
+ text?: string | null | undefined;
779
779
  /** Optional. Limits the change to when a particular tab is selected. Automatically resets when the tab is closed. */
780
780
  tabId?: number | undefined;
781
781
  }
@@ -1516,7 +1516,7 @@ declare namespace chrome.contextMenus {
1516
1516
  * Since Chrome 35.
1517
1517
  * One of 'image', 'video', or 'audio' if the context menu was activated on one of these types of elements.
1518
1518
  */
1519
- mediaType?: string | undefined;
1519
+ mediaType?: 'image' | 'video' | 'audio' | undefined;
1520
1520
  /**
1521
1521
  * Optional.
1522
1522
  * Since Chrome 35.
@@ -1548,6 +1548,10 @@ declare namespace chrome.contextMenus {
1548
1548
  srcUrl?: string | undefined;
1549
1549
  }
1550
1550
 
1551
+ type ContextType = "all" | "page" | "frame" | "selection" | "link" | "editable" | "image" | "video" | "audio" | "launcher" | "browser_action" | "page_action" | "action";
1552
+
1553
+ type ContextItemType = "normal" | "checkbox" | "radio" | "separator";
1554
+
1551
1555
  export interface CreateProperties {
1552
1556
  /** Optional. Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see Match Patterns. */
1553
1557
  documentUrlPatterns?: string[] | undefined;
@@ -1556,7 +1560,7 @@ declare namespace chrome.contextMenus {
1556
1560
  /** Optional. The text to be displayed in the item; this is required unless type is 'separator'. When the context is 'selection', you can use %s within the string to show the selected text. For example, if this parameter's value is "Translate '%s' to Pig Latin" and the user selects the word "cool", the context menu item for the selection is "Translate 'cool' to Pig Latin". */
1557
1561
  title?: string | undefined;
1558
1562
  /** Optional. List of contexts this menu item will appear in. Defaults to ['page'] if not specified. */
1559
- contexts?: string[] | undefined;
1563
+ contexts?: ContextType | ContextType[] | undefined;
1560
1564
  /**
1561
1565
  * Optional.
1562
1566
  * Since Chrome 20.
@@ -1575,7 +1579,7 @@ declare namespace chrome.contextMenus {
1575
1579
  /** Optional. The ID of a parent menu item; this makes the item a child of a previously added item. */
1576
1580
  parentId?: any;
1577
1581
  /** Optional. The type of menu item. Defaults to 'normal' if not specified. */
1578
- type?: string | undefined;
1582
+ type?: ContextItemType | undefined;
1579
1583
  /**
1580
1584
  * Optional.
1581
1585
  * Since Chrome 21.
@@ -1594,14 +1598,14 @@ declare namespace chrome.contextMenus {
1594
1598
  documentUrlPatterns?: string[] | undefined;
1595
1599
  checked?: boolean | undefined;
1596
1600
  title?: string | undefined;
1597
- contexts?: string[] | undefined;
1601
+ contexts?: ContextType[] | undefined;
1598
1602
  /** Optional. Since Chrome 20. */
1599
1603
  enabled?: boolean | undefined;
1600
1604
  targetUrlPatterns?: string[] | undefined;
1601
1605
  onclick?: Function | undefined;
1602
1606
  /** Optional. Note: You cannot change an item to be a child of one of its own descendants. */
1603
1607
  parentId?: number | string;
1604
- type?: string | undefined;
1608
+ type?: ContextItemType | undefined;
1605
1609
  /**
1606
1610
  * Optional.
1607
1611
  * @since Chrome 62.
@@ -1628,10 +1632,9 @@ declare namespace chrome.contextMenus {
1628
1632
  /**
1629
1633
  * Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in chrome.runtime.lastError).
1630
1634
  * @param callback Called when the item has been created in the browser. If there were any problems creating the item, details will be available in chrome.runtime.lastError.
1631
- * If you specify the callback parameter, it should be a function that looks like this:
1632
- * function() {...};
1635
+ * @returns The ID of the newly created item.
1633
1636
  */
1634
- export function create(createProperties: CreateProperties, callback?: () => void): void;
1637
+ export function create(createProperties: CreateProperties, callback?: () => void): number | string;
1635
1638
  /**
1636
1639
  * Updates a previously created context menu item.
1637
1640
  * @param id The ID of the item to update.
@@ -5402,6 +5405,8 @@ declare namespace chrome.networking.config {
5402
5405
  * @since Chrome 28.
5403
5406
  */
5404
5407
  declare namespace chrome.notifications {
5408
+ export type TemplateType = "basic" | "image" | "list" | "progress";
5409
+
5405
5410
  export interface ButtonOptions {
5406
5411
  title: string;
5407
5412
  iconUrl?: string | undefined;
@@ -5414,19 +5419,7 @@ declare namespace chrome.notifications {
5414
5419
  message: string;
5415
5420
  }
5416
5421
 
5417
- export interface NotificationOptions {
5418
- /** Optional. Which type of notification to display. Required for notifications.create method. */
5419
- type?: string | undefined;
5420
- /**
5421
- * Optional.
5422
- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
5423
- * URLs can be a data URL, a blob URL, or a URL relative to a resource within this extension's .crx file Required for notifications.create method.
5424
- */
5425
- iconUrl?: string | undefined;
5426
- /** Optional. Title of the notification (e.g. sender name for email). Required for notifications.create method. */
5427
- title?: string | undefined;
5428
- /** Optional. Main notification content. Required for notifications.create method. */
5429
- message?: string | undefined;
5422
+ export type NotificationOptions<T extends boolean = false> = {
5430
5423
  /**
5431
5424
  * Optional.
5432
5425
  * Alternate notification content with a lower-weight font.
@@ -5473,7 +5466,32 @@ declare namespace chrome.notifications {
5473
5466
  * @since Chrome 70
5474
5467
  */
5475
5468
  silent?: boolean | undefined;
5476
- }
5469
+ } & (T extends true ? {
5470
+ /**
5471
+ * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
5472
+ * URLs can be a data URL, a blob URL, or a URL relative to a resource within this extension's .crx file. Required for notifications.create method.
5473
+ */
5474
+ iconUrl: string;
5475
+ /** Main notification content. Required for notifications.create method. */
5476
+ message: string;
5477
+ /** Which type of notification to display. Required for notifications.create method. */
5478
+ type: TemplateType;
5479
+ /** Title of the notification (e.g. sender name for email). Required for notifications.create method. */
5480
+ title: string;
5481
+ } : {
5482
+ /**
5483
+ * Optional.
5484
+ * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
5485
+ * URLs can be a data URL, a blob URL, or a URL relative to a resource within this extension's .crx file. Required for notifications.create method.
5486
+ */
5487
+ iconUrl?: string | undefined;
5488
+ /** Optional. Main notification content. Required for notifications.create method. */
5489
+ message?: string | undefined;
5490
+ /** Optional. Which type of notification to display. Required for notifications.create method. */
5491
+ type?: TemplateType | undefined;
5492
+ /** Optional. Title of the notification (e.g. sender name for email). Required for notifications.create method. */
5493
+ title?: string | undefined;
5494
+ })
5477
5495
 
5478
5496
  export interface NotificationClosedEvent
5479
5497
  extends chrome.events.Event<(notificationId: string, byUser: boolean) => void> { }
@@ -5516,7 +5534,7 @@ declare namespace chrome.notifications {
5516
5534
  */
5517
5535
  export function create(
5518
5536
  notificationId: string,
5519
- options: NotificationOptions,
5537
+ options: NotificationOptions<true>,
5520
5538
  callback?: (notificationId: string) => void,
5521
5539
  ): void;
5522
5540
  /**
@@ -5529,7 +5547,7 @@ declare namespace chrome.notifications {
5529
5547
  * If you specify the callback parameter, it should be a function that looks like this:
5530
5548
  * function(string notificationId) {...};
5531
5549
  */
5532
- export function create(options: NotificationOptions, callback?: (notificationId: string) => void): void;
5550
+ export function create(options: NotificationOptions<true>, callback?: (notificationId: string) => void): void;
5533
5551
  /**
5534
5552
  * Updates an existing notification.
5535
5553
  * @param notificationId The id of the notification to be updated. This is returned by notifications.create method.
@@ -7133,7 +7151,10 @@ declare namespace chrome.runtime {
7133
7151
  declare namespace chrome.scripting {
7134
7152
 
7135
7153
  /* The CSS style origin for a style change. */
7136
- export type StyleOrigin = "AUTHOR" | "USER";
7154
+ export type StyleOrigin = 'AUTHOR' | 'USER';
7155
+
7156
+ /* The JavaScript world for a script to execute within. */
7157
+ export type ExecutionWorld = 'ISOLATED' | 'MAIN';
7137
7158
 
7138
7159
  export interface InjectionResult {
7139
7160
  /* The frame associated with the injection. */
@@ -7165,6 +7186,8 @@ declare namespace chrome.scripting {
7165
7186
  export type ScriptInjection<Args extends any[] = []> = {
7166
7187
  /* Details specifying the target into which to inject the script. */
7167
7188
  target: InjectionTarget;
7189
+ /* The JavaScript world for a script to execute within. */
7190
+ world?: ExecutionWorld;
7168
7191
  } & ({
7169
7192
  /* The path of the JS files to inject, relative to the extension's root directory. NOTE: Currently a maximum of one file is supported. Exactly one of files and function must be specified. */
7170
7193
  files: string[];
chrome/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/chrome",
3
- "version": "0.0.167",
3
+ "version": "0.0.171",
4
4
  "description": "TypeScript definitions for Chrome extension development",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/chrome",
6
6
  "license": "MIT",
@@ -103,6 +103,6 @@
103
103
  "@types/filesystem": "*",
104
104
  "@types/har-format": "*"
105
105
  },
106
- "typesPublisherContentHash": "9c6c3c3c312e6bf36acace82e27911b1cfae87b3580e48ccd4f0cbe1b4da7b14",
106
+ "typesPublisherContentHash": "991837772f8e1f780ce2d4e9f1696110899c9ae085ab4e66e4aac15390142b6c",
107
107
  "typeScriptVersion": "3.8"
108
108
  }