@wxt-dev/browser 0.0.321 → 0.0.323

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 +143 -143
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wxt-dev/browser",
3
3
  "description": "Provides a cross-browser API for using extension APIs and types based on @types/chrome",
4
- "version": "0.0.321",
4
+ "version": "0.0.323",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
7
7
  "types": "src/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "src"
20
20
  ],
21
21
  "devDependencies": {
22
- "@types/chrome": "0.0.321",
22
+ "@types/chrome": "0.0.323",
23
23
  "fs-extra": "^11.3.0",
24
24
  "nano-spawn": "^0.2.0",
25
25
  "tsx": "4.19.4",
@@ -4,6 +4,9 @@
4
4
  /// <reference path="./har-format/index.d.ts" />
5
5
  /// <reference path="./chrome-cast/index.d.ts" />
6
6
 
7
+ // Helpers
8
+ type SetRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
9
+
7
10
  ////////////////////
8
11
  // Global object
9
12
  ////////////////////
@@ -2988,9 +2991,10 @@ export namespace Browser {
2988
2991
  * Specifies the function to be called when the user clicks a resource link in the Developer Tools window. To unset the handler, either call the method with no parameters or pass null as the parameter.
2989
2992
  * @param callback A function that is called when the user clicks on a valid resource link in Developer Tools window. Note that if the user clicks an invalid URL or an XHR, this function is not called.
2990
2993
  * Parameter resource: A devtools.inspectedWindow.Resource object for the resource that was clicked.
2994
+ * Parameter lineNumber: Specifies the line number within the resource that was clicked.
2991
2995
  */
2992
2996
  export function setOpenResourceHandler(
2993
- callback?: (resource: Browser.devtools.inspectedWindow.Resource) => void,
2997
+ callback?: (resource: Browser.devtools.inspectedWindow.Resource, lineNumber: number) => void,
2994
2998
  ): void;
2995
2999
  /**
2996
3000
  * @since Chrome 38
@@ -7020,181 +7024,177 @@ export namespace Browser {
7020
7024
  * Permissions: "notifications"
7021
7025
  */
7022
7026
  export namespace notifications {
7023
- export type TemplateType = "basic" | "image" | "list" | "progress";
7024
-
7025
- export interface ButtonOptions {
7027
+ export interface NotificationButton {
7028
+ /** @deprecated since Chrome 59. Button icons not visible for Mac OS X users. */
7029
+ iconUrl?: string;
7026
7030
  title: string;
7027
- iconUrl?: string | undefined;
7028
7031
  }
7029
7032
 
7030
- export interface ItemOptions {
7031
- /** Title of one item of a list notification. */
7032
- title: string;
7033
+ export interface NotificationItem {
7033
7034
  /** Additional details about this item. */
7034
7035
  message: string;
7036
+ /** Title of one item of a list notification. */
7037
+ title: string;
7035
7038
  }
7036
7039
 
7037
- export type NotificationOptions<T extends boolean = false> =
7038
- & {
7039
- /**
7040
- * Optional.
7041
- * Alternate notification content with a lower-weight font.
7042
- * @since Chrome 31
7043
- */
7044
- contextMessage?: string | undefined;
7045
- /** Optional. Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default. */
7046
- priority?: number | undefined;
7047
- /** Optional. A timestamp associated with the notification, in milliseconds past the epoch (e.g. Date.now() + n). */
7048
- eventTime?: number | undefined;
7049
- /** Optional. Text and icons for up to two notification action buttons. */
7050
- buttons?: ButtonOptions[] | undefined;
7051
- /** Optional. Items for multi-item notifications. */
7052
- items?: ItemOptions[] | undefined;
7053
- /**
7054
- * Optional.
7055
- * Current progress ranges from 0 to 100.
7056
- * @since Chrome 30
7057
- */
7058
- progress?: number | undefined;
7059
- /**
7060
- * Optional.
7061
- * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification.
7062
- * @since Chrome 32
7063
- */
7064
- isClickable?: boolean | undefined;
7065
- /**
7066
- * Optional.
7067
- * A URL to the app icon mask. URLs have the same restrictions as iconUrl. The app icon mask should be in alpha channel, as only the alpha channel of the image will be considered.
7068
- * @since Chrome 38
7069
- */
7070
- appIconMaskUrl?: string | undefined;
7071
- /** Optional. A URL to the image thumbnail for image-type notifications. URLs have the same restrictions as iconUrl. */
7072
- imageUrl?: string | undefined;
7073
- /**
7074
- * Indicates that the notification should remain visible on screen until the user activates or dismisses the notification.
7075
- * This defaults to false.
7076
- * @since Chrome 50
7077
- */
7078
- requireInteraction?: boolean | undefined;
7079
- /**
7080
- * Optional.
7081
- * Indicates that no sounds or vibrations should be made when the notification is being shown. This defaults to false.
7082
- * @since Chrome 70
7083
- */
7084
- silent?: boolean | undefined;
7085
- }
7086
- & (T extends true ? {
7087
- /**
7088
- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
7089
- * 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.
7090
- */
7091
- iconUrl: string;
7092
- /** Main notification content. Required for notifications.create method. */
7093
- message: string;
7094
- /** Which type of notification to display. Required for notifications.create method. */
7095
- type: TemplateType;
7096
- /** Title of the notification (e.g. sender name for email). Required for notifications.create method. */
7097
- title: string;
7098
- }
7099
- : {
7100
- /**
7101
- * Optional.
7102
- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
7103
- * 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.
7104
- */
7105
- iconUrl?: string | undefined;
7106
- /** Optional. Main notification content. Required for notifications.create method. */
7107
- message?: string | undefined;
7108
- /** Optional. Which type of notification to display. Required for notifications.create method. */
7109
- type?: TemplateType | undefined;
7110
- /** Optional. Title of the notification (e.g. sender name for email). Required for notifications.create method. */
7111
- title?: string | undefined;
7112
- });
7113
-
7114
- export interface NotificationClosedEvent
7115
- extends Browser.events.Event<(notificationId: string, byUser: boolean) => void>
7116
- {}
7117
-
7118
- export interface NotificationClickedEvent extends Browser.events.Event<(notificationId: string) => void> {}
7040
+ export interface NotificationOptions {
7041
+ /**
7042
+ * A URL to the app icon mask. URLs have the same restrictions as {@link notifications.NotificationOptions.iconUrl iconUrl}.
7043
+ *
7044
+ * The app icon mask should be in alpha channel, as only the alpha channel of the image will be considered.
7045
+ * @deprecated since Chrome 59. The app icon mask is not visible for Mac OS X users.
7046
+ */
7047
+ appIconMaskUrl?: string;
7048
+ /** Text and icons for up to two notification action buttons. */
7049
+ buttons?: NotificationButton[];
7050
+ /** Alternate notification content with a lower-weight font. */
7051
+ contextMessage?: string;
7052
+ /** A timestamp associated with the notification, in milliseconds past the epoch (e.g. `Date.now() + n`). */
7053
+ eventTime?: number;
7054
+ /**
7055
+ * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
7056
+ *
7057
+ * URLs can be a data URL, a blob URL, or a URL relative to a resource within this extension's .crx file
7058
+ *
7059
+ * **Note:** This value is required for the {@link notifications.create}() method.
7060
+ */
7061
+ iconUrl?: string;
7062
+ /**
7063
+ * A URL to the image thumbnail for image-type notifications. URLs have the same restrictions as {@link notifications.NotificationOptions.iconUrl iconUrl}.
7064
+ * @deprecated since Chrome 59. The image is not visible for Mac OS X users.
7065
+ */
7066
+ imageUrl?: string;
7067
+ /** @deprecated since Chrome 67. This UI hint is ignored as of Chrome 67 */
7068
+ isClickable?: boolean;
7069
+ /** Items for multi-item notifications. Users on Mac OS X only see the first item. */
7070
+ items?: NotificationItem[];
7071
+ /**
7072
+ * Main notification content.
7073
+ *
7074
+ * **Note:** This value is required for the {@link notifications.create}() method.
7075
+ */
7076
+ message?: string;
7077
+ /** Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default. On platforms that don't support a notification center (Windows, Linux & Mac), -2 and -1 result in an error as notifications with those priorities will not be shown at all. */
7078
+ priority?: number;
7079
+ /** Current progress ranges from 0 to 100. */
7080
+ progress?: number;
7081
+ /**
7082
+ * Indicates that the notification should remain visible on screen until the user activates or dismisses the notification. This defaults to false.
7083
+ * @since Chrome 50
7084
+ */
7085
+ requireInteraction?: boolean;
7086
+ /**
7087
+ * Indicates that no sounds or vibrations should be made when the notification is being shown. This defaults to false.
7088
+ * @since Chrome 70
7089
+ */
7090
+ silent?: boolean;
7091
+ /**
7092
+ * Title of the notification (e.g. sender name for email).
7093
+ *
7094
+ * **Note:** This value is required for the {@link notifications.create}() method.
7095
+ */
7096
+ title?: string;
7097
+ /** Which type of notification to display.
7098
+ *
7099
+ * **Note:** This value is required for the {@link notifications.create}() method.
7100
+ */
7101
+ type?: `${TemplateType}`;
7102
+ }
7119
7103
 
7120
- export interface NotificationButtonClickedEvent
7121
- extends Browser.events.Event<(notificationId: string, buttonIndex: number) => void>
7122
- {}
7104
+ type NotificationCreateOptions = SetRequired<NotificationOptions, "type" | "title" | "message" | "iconUrl">;
7123
7105
 
7124
- export interface NotificationPermissionLevelChangedEvent extends Browser.events.Event<(level: string) => void> {}
7106
+ export enum PermissionLevel {
7107
+ /** Specifies that the user has elected to show notifications from the app or extension. This is the default at install time. */
7108
+ GRANTED = "granted",
7109
+ /** Specifies that the user has elected not to show notifications from the app or extension. */
7110
+ DENIED = "denied",
7111
+ }
7125
7112
 
7126
- export interface NotificationShowSettingsEvent extends Browser.events.Event<() => void> {}
7113
+ export enum TemplateType {
7114
+ /** Contains an icon, title, message, expandedMessage, and up to two buttons. */
7115
+ BASIC = "basic",
7116
+ /** Contains an icon, title, message, expandedMessage, image, and up to two buttons. */
7117
+ IMAGE = "image",
7118
+ /** Contains an icon, title, message, items, and up to two buttons. Users on Mac OS X only see the first item. */
7119
+ LIST = "list",
7120
+ /** Contains an icon, title, message, progress, and up to two buttons. */
7121
+ PROGRESS = "progress",
7122
+ }
7127
7123
 
7128
- /** The notification closed, either by the system or by user action. */
7129
- export var onClosed: NotificationClosedEvent;
7130
- /** The user clicked in a non-button area of the notification. */
7131
- export var onClicked: NotificationClickedEvent;
7132
- /** The user pressed a button in the notification. */
7133
- export var onButtonClicked: NotificationButtonClickedEvent;
7134
- /**
7135
- * The user changes the permission level.
7136
- * @since Chrome 32
7137
- */
7138
- export var onPermissionLevelChanged: NotificationPermissionLevelChangedEvent;
7139
7124
  /**
7140
- * The user clicked on a link for the app's notification settings.
7141
- * @since Chrome 32
7125
+ * Clears the specified notification.
7126
+ * @param notificationId The id of the notification to be cleared. This is returned by {@link notifications.create} method.
7127
+ *
7128
+ * Can return its result via Promise since Chrome 116
7142
7129
  */
7143
- export var onShowSettings: NotificationShowSettingsEvent;
7130
+ export function clear(notificationId: string): Promise<boolean>;
7131
+ export function clear(notificationId: string, callback: (wasCleared: boolean) => void): void;
7144
7132
 
7145
7133
  /**
7146
7134
  * Creates and displays a notification.
7147
- * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation.
7148
- * The notificationId parameter is required before Chrome 42.
7135
+ * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation. The identifier may not be longer than 500 characters.
7136
+ *
7137
+ * The `notificationId` parameter is required before Chrome 42.
7149
7138
  * @param options Contents of the notification.
7150
- * @param callback Returns the notification id (either supplied or generated) that represents the created notification.
7151
- * The callback is required before Chrome 42.
7139
+ *
7140
+ * Can return its result via Promise since Chrome 116
7152
7141
  */
7142
+ export function create(notificationId: string, options: NotificationCreateOptions): Promise<string>;
7143
+ export function create(options: NotificationCreateOptions): Promise<string>;
7153
7144
  export function create(
7154
7145
  notificationId: string,
7155
- options: NotificationOptions<true>,
7156
- callback?: (notificationId: string) => void,
7146
+ options: NotificationCreateOptions,
7147
+ callback: (notificationId: string) => void,
7157
7148
  ): void;
7149
+ export function create(options: NotificationCreateOptions, callback: (notificationId: string) => void): void;
7150
+
7158
7151
  /**
7159
- * Creates and displays a notification.
7160
- * @param notificationId Identifier of the notification. If not set or empty, an ID will automatically be generated. If it matches an existing notification, this method first clears that notification before proceeding with the create operation.
7161
- * The notificationId parameter is required before Chrome 42.
7162
- * @param options Contents of the notification.
7163
- * @param callback Returns the notification id (either supplied or generated) that represents the created notification.
7164
- * The callback is required before Chrome 42.
7152
+ * Retrieves all the notifications of this app or extension.
7153
+ *
7154
+ * Can return its result via Promise since Chrome 116
7155
+ */
7156
+ export function getAll(): Promise<{ [key: string]: true }>;
7157
+ export function getAll(callback: (notifications: { [key: string]: true }) => void): void;
7158
+
7159
+ /**
7160
+ * Retrieves whether the user has enabled notifications from this app or extension.
7161
+ *
7162
+ * Can return its result via Promise since Chrome 116
7165
7163
  */
7166
- export function create(options: NotificationOptions<true>, callback?: (notificationId: string) => void): void;
7164
+ export function getPermissionLevel(): Promise<`${PermissionLevel}`>;
7165
+ export function getPermissionLevel(callback: (level: `${PermissionLevel}`) => void): void;
7166
+
7167
7167
  /**
7168
7168
  * Updates an existing notification.
7169
- * @param notificationId The id of the notification to be updated. This is returned by notifications.create method.
7169
+ * @param notificationId The id of the notification to be updated. This is returned by {@link notifications.create} method.
7170
7170
  * @param options Contents of the notification to update to.
7171
- * @param callback Called to indicate whether a matching notification existed.
7172
- * The callback is required before Chrome 42.
7171
+ *
7172
+ * Can return its result via Promise since Chrome 116
7173
7173
  */
7174
+ export function update(notificationId: string, options: NotificationOptions): Promise<boolean>;
7174
7175
  export function update(
7175
7176
  notificationId: string,
7176
7177
  options: NotificationOptions,
7177
- callback?: (wasUpdated: boolean) => void,
7178
+ callback: (wasUpdated: boolean) => void,
7178
7179
  ): void;
7180
+
7181
+ /** The user pressed a button in the notification. */
7182
+ export const onButtonClicked: events.Event<(notificationId: string, buttonIndex: number) => void>;
7183
+
7184
+ /** The user clicked in a non-button area of the notification. */
7185
+ export const onClicked: events.Event<(notificationId: string) => void>;
7186
+
7187
+ /** The notification closed, either by the system or by user action. */
7188
+ export const onClosed: events.Event<(notificationId: string, byUser: boolean) => void>;
7189
+
7190
+ /** The user changes the permission level. As of Chrome 47, only ChromeOS has UI that dispatches this event. */
7191
+ export const onPermissionLevelChanged: events.Event<(level: `${PermissionLevel}`) => void>;
7192
+
7179
7193
  /**
7180
- * Clears the specified notification.
7181
- * @param notificationId The id of the notification to be cleared. This is returned by notifications.create method.
7182
- * @param callback Called to indicate whether a matching notification existed.
7183
- * The callback is required before Chrome 42.
7184
- */
7185
- export function clear(notificationId: string, callback?: (wasCleared: boolean) => void): void;
7186
- /**
7187
- * Retrieves all the notifications.
7188
- * @since Chrome 29
7189
- * @param callback Returns the set of notification_ids currently in the system.
7190
- */
7191
- export function getAll(callback: (notifications: { [key: string]: true }) => void): void;
7192
- /**
7193
- * Retrieves whether the user has enabled notifications from this app or extension.
7194
- * @since Chrome 32
7195
- * @param callback Returns the current permission level.
7194
+ * The user clicked on a link for the app's notification settings. As of Chrome 47, only ChromeOS has UI that dispatches this event. As of Chrome 65, that UI has been removed from ChromeOS, too.
7195
+ * @deprecated since Chrome 65. Custom notification settings button is no longer supported.
7196
7196
  */
7197
- export function getPermissionLevel(callback: (level: string) => void): void;
7197
+ export const onShowSettings: events.Event<() => void>;
7198
7198
  }
7199
7199
 
7200
7200
  ////////////////////