@wxt-dev/browser 0.2.7 → 0.2.9

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 +105 -28
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.2.7",
4
+ "version": "0.2.9",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
7
7
  "types": "src/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "src"
26
26
  ],
27
27
  "devDependencies": {
28
- "@types/chrome": "0.2.7",
28
+ "@types/chrome": "0.2.9",
29
29
  "@types/node": "^22",
30
30
  "typescript": "^6.0.3",
31
31
  "vitest": "^4.1.10"
@@ -396,6 +396,11 @@ export namespace Browser {
396
396
  export namespace alarms {
397
397
  type AlarmCreateInfo =
398
398
  & {
399
+ /**
400
+ * Name of this alarm.
401
+ * @since Chrome 152
402
+ */
403
+ name?: string | undefined;
399
404
  /**
400
405
  * Whether the alarm should persist across sessions (browser restarts). In Chrome, this defaults to true to match historical behavior, but you should set this explicitly to maximize compatibility across browsers.
401
406
  * @since Chrome 150
@@ -455,9 +460,18 @@ export namespace Browser {
455
460
  * Can return its result via Promise in Manifest V3 or later since Chrome 111.
456
461
  */
457
462
  function create(alarmInfo: AlarmCreateInfo): Promise<void>;
458
- function create(name: string | undefined, alarmInfo: AlarmCreateInfo): Promise<void>;
463
+ function create(name: undefined, alarmInfo: AlarmCreateInfo): Promise<void>;
464
+ function create<T extends AlarmCreateInfo>(
465
+ name: string,
466
+ alarmInfo: T & (T extends { name: string } ? never : unknown),
467
+ ): Promise<void>;
459
468
  function create(alarmInfo: AlarmCreateInfo, callback: () => void): void;
460
- function create(name: string | undefined, alarmInfo: AlarmCreateInfo, callback: () => void): void;
469
+ function create(name: undefined, alarmInfo: AlarmCreateInfo, callback: () => void): void;
470
+ function create<T extends AlarmCreateInfo>(
471
+ name: string,
472
+ alarmInfo: T & (T extends { name: string } ? never : unknown),
473
+ callback: () => void,
474
+ ): void;
461
475
 
462
476
  /**
463
477
  * Gets an array of all the alarms.
@@ -2890,20 +2904,59 @@ export namespace Browser {
2890
2904
  injectedScript?: string | undefined;
2891
2905
  }
2892
2906
 
2893
- interface EvaluationExceptionInfo {
2894
- /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2895
- isError: boolean;
2896
- /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2897
- code: string;
2898
- /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2899
- description: string;
2900
- /** Set if the error occurred on the DevTools side before the expression is evaluated, contains the array of the values that may be substituted into the description string to provide more information about the cause of the error. */
2901
- details: any[];
2902
- /** Set if the evaluated code produces an unhandled exception. */
2903
- isException: boolean;
2904
- /** Set if the evaluated code produces an unhandled exception. */
2905
- value: string;
2906
- }
2907
+ type EvaluationExceptionInfo =
2908
+ | {
2909
+ /**
2910
+ * Set if the error occurred on the DevTools side before the expression is evaluated.
2911
+ *
2912
+ * If `isError` is set to true, a DevTools-side error has occurred, and `code` is set to an error code.
2913
+ *
2914
+ * See the docs on `isException` for more details on parsing this object.
2915
+ */
2916
+ isError: true;
2917
+ /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2918
+ code: string;
2919
+ /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2920
+ description: string;
2921
+ /** Set if the error occurred on the DevTools side before the expression is evaluated, contains the array of the values that may be substituted into the description string to provide more information about the cause of the error. */
2922
+ details: any[];
2923
+ /**
2924
+ * Set if the evaluated code produces an unhandled exception.
2925
+ *
2926
+ * If `isException` is non-null but not true, and `isError` is true, a DevTools-side error has occurred, and `code` is set to an error code.
2927
+ *
2928
+ * If `isException` is set to true, a JavaScript error has occurred, and `value` is set to the string value of the thrown object.
2929
+ */
2930
+ isException?: undefined;
2931
+ /** Set if the evaluated code produces an unhandled exception. */
2932
+ value?: undefined;
2933
+ }
2934
+ | {
2935
+ /**
2936
+ * Set if the error occurred on the DevTools side before the expression is evaluated.
2937
+ *
2938
+ * If `isError` is set to true, a DevTools-side error has occurred, and `code` is set to an error code.
2939
+ *
2940
+ * See the docs on `isException` for more details on parsing this object.
2941
+ */
2942
+ isError?: undefined;
2943
+ /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2944
+ code?: undefined;
2945
+ /** Set if the error occurred on the DevTools side before the expression is evaluated. */
2946
+ description?: undefined;
2947
+ /** Set if the error occurred on the DevTools side before the expression is evaluated, contains the array of the values that may be substituted into the description string to provide more information about the cause of the error. */
2948
+ details?: undefined;
2949
+ /**
2950
+ * Set if the evaluated code produces an unhandled exception.
2951
+ *
2952
+ * If `isException` is non-null but not true, and `isError` is true, a DevTools-side error has occurred, and `code` is set to an error code.
2953
+ *
2954
+ * If `isException` is set to true, a JavaScript error has occurred, and `value` is set to the string value of the thrown object.
2955
+ */
2956
+ isException: true;
2957
+ /** Set if the evaluated code produces an unhandled exception. */
2958
+ value: string;
2959
+ };
2907
2960
 
2908
2961
  /** The ID of the tab being inspected. This ID may be used with {@link Browser.tabs} API. */
2909
2962
  const tabId: number;
@@ -2923,15 +2976,23 @@ export namespace Browser {
2923
2976
  function eval<T = { [key: string]: unknown }>(
2924
2977
  expression: string,
2925
2978
  options?: EvalOptions,
2926
- ): Promise<{ result: T; exceptionInfo: EvaluationExceptionInfo }>;
2979
+ ): Promise<T>;
2927
2980
  function eval<T = { [key: string]: unknown }>(
2928
2981
  expression: string,
2929
- callback?: (result: T, exceptionInfo: EvaluationExceptionInfo) => void,
2982
+ callback: (
2983
+ ...args:
2984
+ | [result: T, exceptionInfo: undefined]
2985
+ | [result: undefined, exceptionInfo: EvaluationExceptionInfo]
2986
+ ) => void,
2930
2987
  ): void;
2931
2988
  function eval<T = { [key: string]: unknown }>(
2932
2989
  expression: string,
2933
2990
  options: EvalOptions | undefined,
2934
- callback?: (result: T, exceptionInfo: EvaluationExceptionInfo) => void,
2991
+ callback: (
2992
+ ...args:
2993
+ | [result: T, exceptionInfo: undefined]
2994
+ | [result: undefined, exceptionInfo: EvaluationExceptionInfo]
2995
+ ) => void,
2935
2996
  ): void;
2936
2997
 
2937
2998
  /**
@@ -3076,10 +3137,13 @@ export namespace Browser {
3076
3137
  /**
3077
3138
  * Creates a pane within panel's sidebar.
3078
3139
  * @param title Text that is displayed in sidebar caption.
3140
+ *
3141
+ * Can return its result via Promise in Manifest V3 or later since Chrome 152.
3079
3142
  */
3143
+ createSidebarPane(title: string): Promise<ExtensionSidebarPane>;
3080
3144
  createSidebarPane(
3081
3145
  title: string,
3082
- callback?: (
3146
+ callback: (
3083
3147
  /** An ExtensionSidebarPane object for created sidebar pane. */
3084
3148
  result: ExtensionSidebarPane,
3085
3149
  ) => void,
@@ -3093,10 +3157,13 @@ export namespace Browser {
3093
3157
  /**
3094
3158
  * Creates a pane within panel's sidebar.
3095
3159
  * @param title Text that is displayed in sidebar caption.
3160
+ *
3161
+ * Can return its result via Promise in Manifest V3 or later since Chrome 152.
3096
3162
  */
3163
+ createSidebarPane(title: string): Promise<ExtensionSidebarPane>;
3097
3164
  createSidebarPane(
3098
3165
  title: string,
3099
- callback?: (
3166
+ callback: (
3100
3167
  /** An ExtensionSidebarPane object for created sidebar pane. */
3101
3168
  result: ExtensionSidebarPane,
3102
3169
  ) => void,
@@ -3116,19 +3183,23 @@ export namespace Browser {
3116
3183
  * Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.
3117
3184
  * @param expression An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch.
3118
3185
  * @param rootTitle An optional title for the root of the expression tree.
3186
+ *
3187
+ * Can return its result via Promise in Manifest V3 or later since Chrome 152.
3119
3188
  */
3120
- setExpression(expression: string, callback?: () => void): void;
3121
- setExpression(expression: string, rootTitle: string | undefined, callback?: () => void): void;
3189
+ setExpression(expression: string, rootTitle?: string): Promise<void>;
3190
+ setExpression(expression: string, rootTitle: string | undefined, callback: () => void): void;
3122
3191
  /**
3123
3192
  * Sets a JSON-compliant object to be displayed in the sidebar pane.
3124
3193
  * @param jsonObject An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client).
3125
3194
  * @param rootTitle An optional title for the root of the expression tree.
3195
+ *
3196
+ * Can return its result via Promise in Manifest V3 or later since Chrome 152.
3126
3197
  */
3127
- setObject(jsonObject: { [key: string]: unknown }, callback?: () => void): void;
3198
+ setObject(jsonObject: { [key: string]: unknown }, rootTitle?: string): Promise<void>;
3128
3199
  setObject(
3129
3200
  jsonObject: { [key: string]: unknown },
3130
3201
  rootTitle: string | undefined,
3131
- callback?: () => void,
3202
+ callback: () => void,
3132
3203
  ): void;
3133
3204
  /**
3134
3205
  * Sets an HTML page to be displayed in the sidebar pane.
@@ -3158,12 +3229,15 @@ export namespace Browser {
3158
3229
  * @param title Title that is displayed next to the extension icon in the Developer Tools toolbar.
3159
3230
  * @param iconPath Path of the panel's icon relative to the extension directory.
3160
3231
  * @param pagePath Path of the panel's HTML page relative to the extension directory.
3232
+ *
3233
+ * Can return its result via Promise in Manifest V3 or later since Chrome 152.
3161
3234
  */
3235
+ function create(title: string, iconPath: string, pagePath: string): Promise<ExtensionPanel>;
3162
3236
  function create(
3163
3237
  title: string,
3164
3238
  iconPath: string,
3165
3239
  pagePath: string,
3166
- callback?: (
3240
+ callback: (
3167
3241
  /** An ExtensionPanel object representing the created panel. */
3168
3242
  panel: ExtensionPanel,
3169
3243
  ) => void,
@@ -3190,13 +3264,16 @@ export namespace Browser {
3190
3264
  * @param url The URL of the resource to open.
3191
3265
  * @param lineNumber Specifies the line number to scroll to when the resource is loaded.
3192
3266
  * @param columnNumber Specifies the column number to scroll to when the resource is loaded.
3267
+ *
3268
+ * Can return its result via Promise in Manifest V3 or later since Chrome 152.
3193
3269
  */
3194
- function openResource(url: string, lineNumber: number, callback?: () => void): void;
3270
+ function openResource(url: string, lineNumber: number, columnNumber?: number): Promise<void>;
3271
+ function openResource(url: string, lineNumber: number, callback: () => void): void;
3195
3272
  function openResource(
3196
3273
  url: string,
3197
3274
  lineNumber: number,
3198
3275
  columnNumber: number | undefined,
3199
- callback?: () => void,
3276
+ callback: () => void,
3200
3277
  ): void;
3201
3278
 
3202
3279
  /**