@wxt-dev/browser 0.1.3 → 0.1.4

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 +108 -85
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.1.3",
4
+ "version": "0.1.4",
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.1.3",
22
+ "@types/chrome": "0.1.4",
23
23
  "fs-extra": "^11.3.0",
24
24
  "nano-spawn": "^0.2.0",
25
25
  "tsx": "4.19.4",
@@ -2088,7 +2088,12 @@ export namespace Browser {
2088
2088
  */
2089
2089
  export namespace cookies {
2090
2090
  /** A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute. **/
2091
- export type SameSiteStatus = "unspecified" | "no_restriction" | "lax" | "strict";
2091
+ export enum SameSiteStatus {
2092
+ NO_RESTRICTION = "no_restriction",
2093
+ LAX = "lax",
2094
+ STRICT = "strict",
2095
+ UNSPECIFIED = "unspecified",
2096
+ }
2092
2097
 
2093
2098
  /** Represents information about an HTTP cookie. */
2094
2099
  export interface Cookie {
@@ -2109,8 +2114,8 @@ export namespace Browser {
2109
2114
  session: boolean;
2110
2115
  /** True if the cookie is a host-only cookie (i.e. a request's host must exactly match the domain of the cookie). */
2111
2116
  hostOnly: boolean;
2112
- /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */
2113
- expirationDate?: number | undefined;
2117
+ /** The expiration date of the cookie as the number of seconds since the UNIX epoch. Not provided for session cookies. */
2118
+ expirationDate?: number;
2114
2119
  /** The path of the cookie. */
2115
2120
  path: string;
2116
2121
  /** True if the cookie is marked as HttpOnly (i.e. the cookie is inaccessible to client-side scripts). */
@@ -2121,10 +2126,13 @@ export namespace Browser {
2121
2126
  * The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests).
2122
2127
  * @since Chrome 51
2123
2128
  */
2124
- sameSite: SameSiteStatus;
2129
+ sameSite: `${SameSiteStatus}`;
2125
2130
  }
2126
2131
 
2127
- /** Represents a partitioned cookie's partition key. */
2132
+ /**
2133
+ * Represents a partitioned cookie's partition key.
2134
+ * @since Chrome 119
2135
+ */
2128
2136
  export interface CookiePartitionKey {
2129
2137
  /**
2130
2138
  * Indicates if the cookie was set in a cross-cross site context. This prevents a top-level site embedded in a cross-site context from accessing cookies set by the top-level site in a same-site context.
@@ -2144,31 +2152,31 @@ export namespace Browser {
2144
2152
  }
2145
2153
 
2146
2154
  export interface GetAllDetails {
2147
- /** Optional. Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */
2155
+ /** Restricts the retrieved cookies to those whose domains match or are subdomains of this one. */
2148
2156
  domain?: string | undefined;
2149
- /** Optional. Filters the cookies by name. */
2157
+ /** Filters the cookies by name. */
2150
2158
  name?: string | undefined;
2151
2159
  /**
2152
2160
  * The partition key for reading or modifying cookies with the Partitioned attribute.
2153
2161
  * @since Chrome 119
2154
2162
  */
2155
2163
  partitionKey?: CookiePartitionKey | undefined;
2156
- /** Optional. Restricts the retrieved cookies to those that would match the given URL. */
2164
+ /** Restricts the retrieved cookies to those that would match the given URL. */
2157
2165
  url?: string | undefined;
2158
- /** Optional. The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */
2166
+ /** The cookie store to retrieve cookies from. If omitted, the current execution context's cookie store will be used. */
2159
2167
  storeId?: string | undefined;
2160
- /** Optional. Filters out session vs. persistent cookies. */
2168
+ /** Filters out session vs. persistent cookies. */
2161
2169
  session?: boolean | undefined;
2162
- /** Optional. Restricts the retrieved cookies to those whose path exactly matches this string. */
2170
+ /** Restricts the retrieved cookies to those whose path exactly matches this string. */
2163
2171
  path?: string | undefined;
2164
- /** Optional. Filters the cookies by their Secure property. */
2172
+ /** Filters the cookies by their Secure property. */
2165
2173
  secure?: boolean | undefined;
2166
2174
  }
2167
2175
 
2168
2176
  export interface SetDetails {
2169
- /** Optional. The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */
2177
+ /** The domain of the cookie. If omitted, the cookie becomes a host-only cookie. */
2170
2178
  domain?: string | undefined;
2171
- /** Optional. The name of the cookie. Empty by default if omitted. */
2179
+ /** The name of the cookie. Empty by default if omitted. */
2172
2180
  name?: string | undefined;
2173
2181
  /**
2174
2182
  * The partition key for reading or modifying cookies with the Partitioned attribute.
@@ -2177,26 +2185,29 @@ export namespace Browser {
2177
2185
  partitionKey?: CookiePartitionKey | undefined;
2178
2186
  /** The request-URI to associate with the setting of the cookie. This value can affect the default domain and path values of the created cookie. If host permissions for this URL are not specified in the manifest file, the API call will fail. */
2179
2187
  url: string;
2180
- /** Optional. The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */
2188
+ /** The ID of the cookie store in which to set the cookie. By default, the cookie is set in the current execution context's cookie store. */
2181
2189
  storeId?: string | undefined;
2182
- /** Optional. The value of the cookie. Empty by default if omitted. */
2190
+ /** The value of the cookie. Empty by default if omitted. */
2183
2191
  value?: string | undefined;
2184
- /** Optional. The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */
2192
+ /** The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie. */
2185
2193
  expirationDate?: number | undefined;
2186
- /** Optional. The path of the cookie. Defaults to the path portion of the url parameter. */
2194
+ /** The path of the cookie. Defaults to the path portion of the url parameter. */
2187
2195
  path?: string | undefined;
2188
- /** Optional. Whether the cookie should be marked as HttpOnly. Defaults to false. */
2196
+ /** Whether the cookie should be marked as HttpOnly. Defaults to false. */
2189
2197
  httpOnly?: boolean | undefined;
2190
- /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */
2198
+ /** Whether the cookie should be marked as Secure. Defaults to false. */
2191
2199
  secure?: boolean | undefined;
2192
2200
  /**
2193
- * Optional. The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute.
2201
+ * The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute.
2194
2202
  * @since Chrome 51
2195
2203
  */
2196
- sameSite?: SameSiteStatus | undefined;
2204
+ sameSite?: `${SameSiteStatus}` | undefined;
2197
2205
  }
2198
2206
 
2199
- /** Details to identify the cookie. */
2207
+ /**
2208
+ * Details to identify the cookie.
2209
+ * @since Chrome 88
2210
+ */
2200
2211
  export interface CookieDetails {
2201
2212
  /** The name of the cookie to access. */
2202
2213
  name: string;
@@ -2216,11 +2227,8 @@ export namespace Browser {
2216
2227
  cookie: Cookie;
2217
2228
  /** True if a cookie was removed. */
2218
2229
  removed: boolean;
2219
- /**
2220
- * @since Chrome 12
2221
- * The underlying reason behind the cookie's change.
2222
- */
2223
- cause: string;
2230
+ /** The underlying reason behind the cookie's change. */
2231
+ cause: `${OnChangedCause}`;
2224
2232
  }
2225
2233
 
2226
2234
  /**
@@ -2229,30 +2237,37 @@ export namespace Browser {
2229
2237
  */
2230
2238
  export interface FrameDetails {
2231
2239
  /** The unique identifier for the document. If the frameId and/or tabId are provided they will be validated to match the document found by provided document ID. */
2232
- documentId?: string;
2240
+ documentId?: string | undefined;
2233
2241
  /** The unique identifier for the frame within the tab. */
2234
- frameId?: number;
2242
+ frameId?: number | undefined;
2235
2243
  /* The unique identifier for the tab containing the frame. */
2236
- tabId?: number;
2244
+ tabId?: number | undefined;
2237
2245
  }
2238
2246
 
2239
- export interface CookieChangedEvent extends Browser.events.Event<(changeInfo: CookieChangeInfo) => void> {}
2240
-
2241
2247
  /**
2242
- * Lists all existing cookie stores.
2243
- * Parameter cookieStores: All the existing cookie stores.
2248
+ * The underlying reason behind the cookie's change. If a cookie was inserted, or removed via an explicit call to "Browser.cookies.remove", "cause" will be "explicit". If a cookie was automatically removed due to expiry, "cause" will be "expired". If a cookie was removed due to being overwritten with an already-expired expiration date, "cause" will be set to "expired_overwrite". If a cookie was automatically removed due to garbage collection, "cause" will be "evicted". If a cookie was automatically removed due to a "set" call that overwrote it, "cause" will be "overwrite". Plan your response accordingly.
2249
+ * @since Chrome 44
2244
2250
  */
2245
- export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void;
2251
+ export enum OnChangedCause {
2252
+ EVICTED = "evicted",
2253
+ EXPIRED = "expired",
2254
+ EXPLICIT = "explicit",
2255
+ EXPIRED_OVERWRITE = "expired_overwrite",
2256
+ OVERWRITE = "overwrite",
2257
+ }
2246
2258
 
2247
2259
  /**
2248
2260
  * Lists all existing cookie stores.
2249
- * @return The `getAllCookieStores` method provides its result via callback or returned as a `Promise` (MV3 only).
2261
+ *
2262
+ * Can return its result via Promise in Manifest V3 or later.
2250
2263
  */
2251
2264
  export function getAllCookieStores(): Promise<CookieStore[]>;
2265
+ export function getAllCookieStores(callback: (cookieStores: CookieStore[]) => void): void;
2252
2266
 
2253
2267
  /**
2254
2268
  * The partition key for the frame indicated.
2255
- * Can return its result via Promise in Manifest V3
2269
+ *
2270
+ * Can return its result via Promise in Manifest V3 or later.
2256
2271
  * @since Chrome 132
2257
2272
  */
2258
2273
  export function getPartitionKey(details: FrameDetails): Promise<{ partitionKey: CookiePartitionKey }>;
@@ -2262,62 +2277,41 @@ export namespace Browser {
2262
2277
  ): void;
2263
2278
 
2264
2279
  /**
2265
- * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first.
2266
- * @param details Information to filter the cookies being retrieved.
2267
- * Parameter cookies: All the existing, unexpired cookies that match the given cookie info.
2268
- */
2269
- export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void;
2270
-
2271
- /**
2272
- * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first.
2273
- * @param details Information to filter the cookies being retrieved.
2274
- * @return The `getAll` method provides its result via callback or returned as a `Promise` (MV3 only).
2280
+ * Retrieves all cookies from a single cookie store that match the given information. The cookies returned will be sorted, with those with the longest path first. If multiple cookies have the same path length, those with the earliest creation time will be first. This method only retrieves cookies for domains that the extension has host permissions to
2281
+ * @param details Information to identify the cookie to remove.
2282
+ *
2283
+ * Can return its result via Promise in Manifest V3 or later.
2275
2284
  */
2276
2285
  export function getAll(details: GetAllDetails): Promise<Cookie[]>;
2286
+ export function getAll(details: GetAllDetails, callback: (cookies: Cookie[]) => void): void;
2277
2287
 
2278
2288
  /**
2279
2289
  * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
2280
2290
  * @param details Details about the cookie being set.
2281
- * @return The `set` method provides its result via callback or returned as a `Promise` (MV3 only).
2291
+ *
2292
+ * Can return its result via Promise in Manifest V3 or later.
2282
2293
  */
2283
2294
  export function set(details: SetDetails): Promise<Cookie | null>;
2284
-
2285
- /**
2286
- * Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
2287
- * @param details Details about the cookie being set.
2288
- * Optional parameter cookie: Contains details about the cookie that's been set. If setting failed for any reason, this will be "null", and "Browser.runtime.lastError" will be set.
2289
- */
2290
2295
  export function set(details: SetDetails, callback: (cookie: Cookie | null) => void): void;
2291
2296
 
2292
2297
  /**
2293
2298
  * Deletes a cookie by name.
2294
- * @param details Information to identify the cookie to remove.
2295
- * @return The `remove` method provides its result via callback or returned as a `Promise` (MV3 only).
2299
+ *
2300
+ * Can return its result via Promise in Manifest V3 or later.
2296
2301
  */
2297
2302
  export function remove(details: CookieDetails): Promise<CookieDetails>;
2298
-
2299
- /**
2300
- * Deletes a cookie by name.
2301
- * @param details Information to identify the cookie to remove.
2302
- */
2303
2303
  export function remove(details: CookieDetails, callback?: (details: CookieDetails) => void): void;
2304
2304
 
2305
2305
  /**
2306
2306
  * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned.
2307
- * @param details Details to identify the cookie being retrieved.
2308
- * Parameter cookie: Contains details about the cookie. This parameter is null if no such cookie was found.
2309
- */
2310
- export function get(details: CookieDetails, callback: (cookie: Cookie | null) => void): void;
2311
-
2312
- /**
2313
- * Retrieves information about a single cookie. If more than one cookie of the same name exists for the given URL, the one with the longest path will be returned. For cookies with the same path length, the cookie with the earliest creation time will be returned.
2314
- * @param details Details to identify the cookie being retrieved.
2315
- * @return The `get` method provides its result via callback or returned as a `Promise` (MV3 only).
2307
+ *
2308
+ * Can return its result via Promise in Manifest V3 or later.
2316
2309
  */
2317
2310
  export function get(details: CookieDetails): Promise<Cookie | null>;
2311
+ export function get(details: CookieDetails, callback: (cookie: Cookie | null) => void): void;
2318
2312
 
2319
2313
  /** Fired when a cookie is set or removed. As a special case, note that updating a cookie's properties is implemented as a two step process: the cookie to be updated is first removed entirely, generating a notification with "cause" of "overwrite" . Afterwards, a new cookie is written with the updated values, generating a second notification with "cause" "explicit". */
2320
- export var onChanged: CookieChangedEvent;
2314
+ export const onChanged: events.Event<(changeInfo: CookieChangeInfo) => void>;
2321
2315
  }
2322
2316
 
2323
2317
  ////////////////////
@@ -2625,31 +2619,39 @@ export namespace Browser {
2625
2619
  * Permissions: "desktopCapture"
2626
2620
  */
2627
2621
  export namespace desktopCapture {
2628
- /** Contains properties that describe the stream. */
2622
+ /** Enum used to define set of desktop media sources used in {@link chooseDesktopMedia}. */
2623
+ export enum DesktopCaptureSourceType {
2624
+ SCREEN = "screen",
2625
+ WINDOW = "window",
2626
+ TAB = "tab",
2627
+ AUDIO = "audio",
2628
+ }
2629
+
2630
+ /**
2631
+ * Contains properties that describe the stream.
2632
+ * @since Chrome 57
2633
+ */
2629
2634
  export interface StreamOptions {
2630
2635
  /** True if "audio" is included in parameter sources, and the end user does not uncheck the "Share audio" checkbox. Otherwise false, and in this case, one should not ask for audio stream through getUserMedia call. */
2631
2636
  canRequestAudioTrack: boolean;
2632
2637
  }
2633
2638
  /**
2634
2639
  * Shows desktop media picker UI with the specified set of sources.
2635
- * @param sources Set of sources that should be shown to the user.
2636
- * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used.
2640
+ * @param sources Set of sources that should be shown to the user. The sources order in the set decides the tab order in the picker.
2641
+ * @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches `tab.url`. The tab's origin must be a secure origin, e.g. HTTPS.
2642
+ * @param callback streamId: An opaque string that can be passed to `getUserMedia()` API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty `streamId`. The created `streamId` can be used only once and expires after a few seconds when it is not used.
2643
+ * @return An id that can be passed to cancelChooseDesktopMedia() in case the prompt need to be canceled.
2637
2644
  */
2638
2645
  export function chooseDesktopMedia(
2639
- sources: string[],
2646
+ sources: `${DesktopCaptureSourceType}`[],
2640
2647
  callback: (streamId: string, options: StreamOptions) => void,
2641
2648
  ): number;
2642
- /**
2643
- * Shows desktop media picker UI with the specified set of sources.
2644
- * @param sources Set of sources that should be shown to the user.
2645
- * @param targetTab Optional tab for which the stream is created. If not specified then the resulting stream can be used only by the calling extension. The stream can only be used by frames in the given tab whose security origin matches tab.url.
2646
- * Parameter streamId: An opaque string that can be passed to getUserMedia() API to generate media stream that corresponds to the source selected by the user. If user didn't select any source (i.e. canceled the prompt) then the callback is called with an empty streamId. The created streamId can be used only once and expires after a few seconds when it is not used.
2647
- */
2648
2649
  export function chooseDesktopMedia(
2649
- sources: string[],
2650
- targetTab: Browser.tabs.Tab,
2650
+ sources: `${DesktopCaptureSourceType}`[],
2651
+ targetTab: tabs.Tab | undefined,
2651
2652
  callback: (streamId: string, options: StreamOptions) => void,
2652
2653
  ): number;
2654
+
2653
2655
  /**
2654
2656
  * Hides desktop media picker dialog shown by chooseDesktopMedia().
2655
2657
  * @param desktopMediaRequestId Id returned by chooseDesktopMedia()
@@ -4264,6 +4266,24 @@ export namespace Browser {
4264
4266
  export function getHardwarePlatformInfo(callback: (info: HardwarePlatformInfo) => void): void;
4265
4267
  }
4266
4268
 
4269
+ ////////////////////
4270
+ // Enterprise Login
4271
+ ////////////////////
4272
+ /**
4273
+ * Use the `Browser.enterprise.login` API to exit Managed Guest sessions. Note: This API is only available to extensions installed by enterprise policy in ChromeOS Managed Guest sessions.
4274
+ *
4275
+ * Permissions: "enterprise.login"
4276
+ *
4277
+ * Note: Only available to policy installed extensions.
4278
+ * @platform ChromeOS only
4279
+ * @since Chrome 139
4280
+ */
4281
+ export namespace enterprise.login {
4282
+ /** Exits the current managed guest session. */
4283
+ export function exitCurrentManagedGuestSession(): Promise<void>;
4284
+ export function exitCurrentManagedGuestSession(callback: () => void): void;
4285
+ }
4286
+
4267
4287
  ////////////////////
4268
4288
  // Enterprise Networking Attributes
4269
4289
  ////////////////////
@@ -8573,6 +8593,8 @@ export namespace Browser {
8573
8593
  MIPS = "mips",
8574
8594
  /** Specifies the processer architecture as mips64. */
8575
8595
  MIPS64 = "mips64",
8596
+ /** Specifies the processer architecture as riscv64. */
8597
+ RISCV64 = "riscv64",
8576
8598
  }
8577
8599
 
8578
8600
  /**
@@ -8739,7 +8761,7 @@ export namespace Browser {
8739
8761
  /** The machine's processor architecture. */
8740
8762
  arch: `${PlatformArch}`;
8741
8763
  /** The native client architecture. This may be different from arch on some platforms. */
8742
- nacl_arch: `${PlatformNaclArch}`;
8764
+ nacl_arch?: `${PlatformNaclArch}`;
8743
8765
  }
8744
8766
 
8745
8767
  /** An object which allows two way communication with other pages. */
@@ -8828,6 +8850,7 @@ export namespace Browser {
8828
8850
  | "downloads.ui"
8829
8851
  | "enterprise.deviceAttributes"
8830
8852
  | "enterprise.hardwarePlatform"
8853
+ | "enterprise.login"
8831
8854
  | "enterprise.networkingAttributes"
8832
8855
  | "enterprise.platformKeys"
8833
8856
  | "experimental"