@wxt-dev/browser 0.0.322 → 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 +141 -142
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.322",
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.322",
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
  ////////////////////
@@ -7021,181 +7024,177 @@ export namespace Browser {
7021
7024
  * Permissions: "notifications"
7022
7025
  */
7023
7026
  export namespace notifications {
7024
- export type TemplateType = "basic" | "image" | "list" | "progress";
7025
-
7026
- export interface ButtonOptions {
7027
+ export interface NotificationButton {
7028
+ /** @deprecated since Chrome 59. Button icons not visible for Mac OS X users. */
7029
+ iconUrl?: string;
7027
7030
  title: string;
7028
- iconUrl?: string | undefined;
7029
7031
  }
7030
7032
 
7031
- export interface ItemOptions {
7032
- /** Title of one item of a list notification. */
7033
- title: string;
7033
+ export interface NotificationItem {
7034
7034
  /** Additional details about this item. */
7035
7035
  message: string;
7036
+ /** Title of one item of a list notification. */
7037
+ title: string;
7036
7038
  }
7037
7039
 
7038
- export type NotificationOptions<T extends boolean = false> =
7039
- & {
7040
- /**
7041
- * Optional.
7042
- * Alternate notification content with a lower-weight font.
7043
- * @since Chrome 31
7044
- */
7045
- contextMessage?: string | undefined;
7046
- /** Optional. Priority ranges from -2 to 2. -2 is lowest priority. 2 is highest. Zero is default. */
7047
- priority?: number | undefined;
7048
- /** Optional. A timestamp associated with the notification, in milliseconds past the epoch (e.g. Date.now() + n). */
7049
- eventTime?: number | undefined;
7050
- /** Optional. Text and icons for up to two notification action buttons. */
7051
- buttons?: ButtonOptions[] | undefined;
7052
- /** Optional. Items for multi-item notifications. */
7053
- items?: ItemOptions[] | undefined;
7054
- /**
7055
- * Optional.
7056
- * Current progress ranges from 0 to 100.
7057
- * @since Chrome 30
7058
- */
7059
- progress?: number | undefined;
7060
- /**
7061
- * Optional.
7062
- * Whether to show UI indicating that the app will visibly respond to clicks on the body of a notification.
7063
- * @since Chrome 32
7064
- */
7065
- isClickable?: boolean | undefined;
7066
- /**
7067
- * Optional.
7068
- * 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.
7069
- * @since Chrome 38
7070
- */
7071
- appIconMaskUrl?: string | undefined;
7072
- /** Optional. A URL to the image thumbnail for image-type notifications. URLs have the same restrictions as iconUrl. */
7073
- imageUrl?: string | undefined;
7074
- /**
7075
- * Indicates that the notification should remain visible on screen until the user activates or dismisses the notification.
7076
- * This defaults to false.
7077
- * @since Chrome 50
7078
- */
7079
- requireInteraction?: boolean | undefined;
7080
- /**
7081
- * Optional.
7082
- * Indicates that no sounds or vibrations should be made when the notification is being shown. This defaults to false.
7083
- * @since Chrome 70
7084
- */
7085
- silent?: boolean | undefined;
7086
- }
7087
- & (T extends true ? {
7088
- /**
7089
- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
7090
- * 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.
7091
- */
7092
- iconUrl: string;
7093
- /** Main notification content. Required for notifications.create method. */
7094
- message: string;
7095
- /** Which type of notification to display. Required for notifications.create method. */
7096
- type: TemplateType;
7097
- /** Title of the notification (e.g. sender name for email). Required for notifications.create method. */
7098
- title: string;
7099
- }
7100
- : {
7101
- /**
7102
- * Optional.
7103
- * A URL to the sender's avatar, app icon, or a thumbnail for image notifications.
7104
- * 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.
7105
- */
7106
- iconUrl?: string | undefined;
7107
- /** Optional. Main notification content. Required for notifications.create method. */
7108
- message?: string | undefined;
7109
- /** Optional. Which type of notification to display. Required for notifications.create method. */
7110
- type?: TemplateType | undefined;
7111
- /** Optional. Title of the notification (e.g. sender name for email). Required for notifications.create method. */
7112
- title?: string | undefined;
7113
- });
7114
-
7115
- export interface NotificationClosedEvent
7116
- extends Browser.events.Event<(notificationId: string, byUser: boolean) => void>
7117
- {}
7118
-
7119
- 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
+ }
7120
7103
 
7121
- export interface NotificationButtonClickedEvent
7122
- extends Browser.events.Event<(notificationId: string, buttonIndex: number) => void>
7123
- {}
7104
+ type NotificationCreateOptions = SetRequired<NotificationOptions, "type" | "title" | "message" | "iconUrl">;
7124
7105
 
7125
- 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
+ }
7126
7112
 
7127
- 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
+ }
7128
7123
 
7129
- /** The notification closed, either by the system or by user action. */
7130
- export var onClosed: NotificationClosedEvent;
7131
- /** The user clicked in a non-button area of the notification. */
7132
- export var onClicked: NotificationClickedEvent;
7133
- /** The user pressed a button in the notification. */
7134
- export var onButtonClicked: NotificationButtonClickedEvent;
7135
- /**
7136
- * The user changes the permission level.
7137
- * @since Chrome 32
7138
- */
7139
- export var onPermissionLevelChanged: NotificationPermissionLevelChangedEvent;
7140
7124
  /**
7141
- * The user clicked on a link for the app's notification settings.
7142
- * @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
7143
7129
  */
7144
- export var onShowSettings: NotificationShowSettingsEvent;
7130
+ export function clear(notificationId: string): Promise<boolean>;
7131
+ export function clear(notificationId: string, callback: (wasCleared: boolean) => void): void;
7145
7132
 
7146
7133
  /**
7147
7134
  * Creates and displays a notification.
7148
- * @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.
7149
- * 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.
7150
7138
  * @param options Contents of the notification.
7151
- * @param callback Returns the notification id (either supplied or generated) that represents the created notification.
7152
- * The callback is required before Chrome 42.
7139
+ *
7140
+ * Can return its result via Promise since Chrome 116
7153
7141
  */
7142
+ export function create(notificationId: string, options: NotificationCreateOptions): Promise<string>;
7143
+ export function create(options: NotificationCreateOptions): Promise<string>;
7154
7144
  export function create(
7155
7145
  notificationId: string,
7156
- options: NotificationOptions<true>,
7157
- callback?: (notificationId: string) => void,
7146
+ options: NotificationCreateOptions,
7147
+ callback: (notificationId: string) => void,
7158
7148
  ): void;
7149
+ export function create(options: NotificationCreateOptions, callback: (notificationId: string) => void): void;
7150
+
7159
7151
  /**
7160
- * Creates and displays a notification.
7161
- * @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.
7162
- * The notificationId parameter is required before Chrome 42.
7163
- * @param options Contents of the notification.
7164
- * @param callback Returns the notification id (either supplied or generated) that represents the created notification.
7165
- * 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
7166
7163
  */
7167
- 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
+
7168
7167
  /**
7169
7168
  * Updates an existing notification.
7170
- * @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.
7171
7170
  * @param options Contents of the notification to update to.
7172
- * @param callback Called to indicate whether a matching notification existed.
7173
- * The callback is required before Chrome 42.
7171
+ *
7172
+ * Can return its result via Promise since Chrome 116
7174
7173
  */
7174
+ export function update(notificationId: string, options: NotificationOptions): Promise<boolean>;
7175
7175
  export function update(
7176
7176
  notificationId: string,
7177
7177
  options: NotificationOptions,
7178
- callback?: (wasUpdated: boolean) => void,
7178
+ callback: (wasUpdated: boolean) => void,
7179
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
+
7180
7193
  /**
7181
- * Clears the specified notification.
7182
- * @param notificationId The id of the notification to be cleared. This is returned by notifications.create method.
7183
- * @param callback Called to indicate whether a matching notification existed.
7184
- * The callback is required before Chrome 42.
7185
- */
7186
- export function clear(notificationId: string, callback?: (wasCleared: boolean) => void): void;
7187
- /**
7188
- * Retrieves all the notifications.
7189
- * @since Chrome 29
7190
- * @param callback Returns the set of notification_ids currently in the system.
7191
- */
7192
- export function getAll(callback: (notifications: { [key: string]: true }) => void): void;
7193
- /**
7194
- * Retrieves whether the user has enabled notifications from this app or extension.
7195
- * @since Chrome 32
7196
- * @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.
7197
7196
  */
7198
- export function getPermissionLevel(callback: (level: string) => void): void;
7197
+ export const onShowSettings: events.Event<() => void>;
7199
7198
  }
7200
7199
 
7201
7200
  ////////////////////