wxt 0.10.4 → 0.11.1

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.
@@ -0,0 +1,710 @@
1
+ import * as vite from 'vite';
2
+ import { Manifest, Scripting } from 'webextension-polyfill';
3
+ import { UnimportOptions } from 'unimport';
4
+ import { LogLevel } from 'consola';
5
+ import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
6
+ import { FSWatcher } from 'chokidar';
7
+
8
+ declare class WxtLocationChangeEvent extends Event {
9
+ readonly newUrl: URL;
10
+ readonly oldUrl: URL;
11
+ static EVENT_NAME: string;
12
+ constructor(newUrl: URL, oldUrl: URL);
13
+ }
14
+
15
+ /**
16
+ * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
17
+ * Used to detect and stop content script code when the script is invalidated.
18
+ *
19
+ * It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
20
+ * content scripts instead of `window.setTimeout` or `window.setInterval`.
21
+ */
22
+ declare class ContentScriptContext implements AbortController {
23
+ #private;
24
+ private readonly contentScriptName;
25
+ readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
26
+ private static SCRIPT_STARTED_MESSAGE_TYPE;
27
+ constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
28
+ get signal(): AbortSignal;
29
+ abort(reason?: any): void;
30
+ get isInvalid(): boolean;
31
+ get isValid(): boolean;
32
+ /**
33
+ * Add a listener that is called when the content script's context is invalidated.
34
+ *
35
+ * @returns A function to remove the listener.
36
+ *
37
+ * @example
38
+ * browser.runtime.onMessage.addListener(cb);
39
+ * const removeInvalidatedListener = ctx.onInvalidated(() => {
40
+ * browser.runtime.onMessage.removeListener(cb);
41
+ * })
42
+ * // ...
43
+ * removeInvalidatedListener();
44
+ */
45
+ onInvalidated(cb: () => void): () => void;
46
+ /**
47
+ * Return a promise that never resolves. Useful if you have an async function that shouldn't run
48
+ * after the context is expired.
49
+ *
50
+ * @example
51
+ * const getValueFromStorage = async () => {
52
+ * if (ctx.isInvalid) return ctx.block();
53
+ *
54
+ * // ...
55
+ * }
56
+ */
57
+ block<T>(): Promise<T>;
58
+ /**
59
+ * Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
60
+ */
61
+ setInterval(handler: () => void, timeout?: number): number;
62
+ /**
63
+ * Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
64
+ */
65
+ setTimeout(handler: () => void, timeout?: number): number;
66
+ /**
67
+ * Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
68
+ * invalidated.
69
+ */
70
+ requestAnimationFrame(callback: FrameRequestCallback): number;
71
+ /**
72
+ * Wrapper around `window.requestIdleCallback` that automatically cancels the request when
73
+ * invalidated.
74
+ */
75
+ requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
76
+ /**
77
+ * Call `target.addEventListener` and remove the event listener when the context is invalidated.
78
+ *
79
+ * Includes additional events useful for content scripts:
80
+ *
81
+ * - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
82
+ * scripts are not reloaded when navigating this way, so this can be used to reset the content
83
+ * script state on URL change, or run custom code.
84
+ *
85
+ * @example
86
+ * ctx.addEventListener(document, "visibilitychange", () => {
87
+ * // ...
88
+ * });
89
+ * ctx.addEventListener(document, "wxt:locationchange", () => {
90
+ * // ...
91
+ * });
92
+ */
93
+ addEventListener<TTarget extends EventTarget, TType extends keyof WxtContentScriptEventMap>(target: TTarget, type: TType, handler: (event: WxtContentScriptEventMap[TType]) => void, options?: AddEventListenerOptions): void;
94
+ /**
95
+ * @internal
96
+ * Abort the abort controller and execute all `onInvalidated` listeners.
97
+ */
98
+ notifyInvalidated(): void;
99
+ }
100
+ interface WxtContentScriptEventMap extends WindowEventMap {
101
+ 'wxt:locationchange': WxtLocationChangeEvent;
102
+ }
103
+
104
+ interface InlineConfig {
105
+ /**
106
+ * Your project's root directory containing the `package.json` used to fill out the
107
+ * `manifest.json`.
108
+ *
109
+ * @default process.cwd()
110
+ */
111
+ root?: string;
112
+ /**
113
+ * Directory containing all source code. Set to `"src"` to move all source code to a `src/`
114
+ * directory.
115
+ *
116
+ * @default config.root
117
+ */
118
+ srcDir?: string;
119
+ /**
120
+ * Directory containing files that will be copied to the output directory as-is.
121
+ *
122
+ * @default "${config.root}/public"
123
+ */
124
+ publicDir?: string;
125
+ /**
126
+ * @default "${config.srcDir}/entrypoints"
127
+ */
128
+ entrypointsDir?: string;
129
+ /**
130
+ * Output directory that stored build folders and ZIPs.
131
+ *
132
+ * @default ".output"
133
+ */
134
+ outDir?: string;
135
+ /**
136
+ * > Only available when using the JS API. Not available in `wxt.config.ts` files
137
+ *
138
+ * Path to `wxt.config.ts` file or `false` to disable config file discovery.
139
+ *
140
+ * @default "wxt.config.ts"
141
+ */
142
+ configFile?: string | false;
143
+ /**
144
+ * Set to `true` to show debug logs. Overriden by the command line `--debug` option.
145
+ *
146
+ * @default false
147
+ */
148
+ debug?: boolean;
149
+ /**
150
+ * Explicitly set a mode to run in. This will override the default mode for each command, and can
151
+ * be overridden by the command line `--mode` option.
152
+ */
153
+ mode?: string;
154
+ /**
155
+ * Customize auto-import options. Set to `false` to disable auto-imports.
156
+ *
157
+ * For example, to add a directory to auto-import from, you can use:
158
+ *
159
+ * ```ts
160
+ * export default defineConfig({
161
+ * imports: {
162
+ * dirs: ["some-directory"]
163
+ * }
164
+ * })
165
+ * ```
166
+ */
167
+ imports?: Partial<UnimportOptions> | false;
168
+ /**
169
+ * Explicitly set a browser to build for. This will override the default browser for each command,
170
+ * and can be overridden by the command line `--browser` option.
171
+ *
172
+ * @default
173
+ * "chrome"
174
+ */
175
+ browser?: TargetBrowser;
176
+ /**
177
+ * Explicitly set a manifest version to target. This will override the default manifest version
178
+ * for each command, and can be overridden by the command line `--mv2` or `--mv3` option.
179
+ */
180
+ manifestVersion?: TargetManifestVersion;
181
+ /**
182
+ * Override the logger used.
183
+ *
184
+ * @default
185
+ * consola
186
+ */
187
+ logger?: Logger;
188
+ /**
189
+ * Customize the `manifest.json` output. Can be an object, promise, or function that returns an
190
+ * object or promise.
191
+ */
192
+ manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
193
+ /**
194
+ * Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
195
+ */
196
+ runner?: ExtensionRunnerConfig;
197
+ zip?: {
198
+ /**
199
+ * Configure the filename output when zipping files.
200
+ *
201
+ * Available template variables:
202
+ *
203
+ * - `{{name}}` - The project's name converted to kebab-case
204
+ * - `{{version}}` - The version_name or version from the manifest
205
+ * - `{{browser}}` - The target browser from the `--browser` CLI flag
206
+ * - `{{manifestVersion}}` - Either "2" or "3"
207
+ *
208
+ * @default "{{name}}-{{version}}-{{browser}}.zip"
209
+ */
210
+ artifactTemplate?: string;
211
+ /**
212
+ * Configure the filename output when zipping files.
213
+ *
214
+ * Available template variables:
215
+ *
216
+ * - `{{name}}` - The project's name converted to kebab-case
217
+ * - `{{version}}` - The version_name or version from the manifest
218
+ * - `{{browser}}` - The target browser from the `--browser` CLI flag
219
+ * - `{{manifestVersion}}` - Either "2" or "3"
220
+ *
221
+ * @default "{{name}}-{{version}}-sources.zip"
222
+ */
223
+ sourcesTemplate?: string;
224
+ /**
225
+ * Override the artifactTemplate's `{name}` template variable. Defaults to the `package.json`'s
226
+ * name, or if that doesn't exist, the current working directories name.
227
+ */
228
+ name?: string;
229
+ /**
230
+ * Root directory to ZIP when generating the sources ZIP.
231
+ *
232
+ * @default config.root
233
+ */
234
+ sourcesRoot?: string;
235
+ /**
236
+ * [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
237
+ * creating a ZIP of all your source code for Firfox. Patterns are relative to your
238
+ * `config.zip.sourcesRoot`.
239
+ *
240
+ * Hidden files, node_modules, and tests are ignored by default.
241
+ *
242
+ * @example
243
+ * [
244
+ * "coverage", // Ignore the coverage directory in the `sourcesRoot`
245
+ * ]
246
+ */
247
+ ignoredSources?: string[];
248
+ };
249
+ /**
250
+ * Transform the final manifest before it's written to the file system. Edit the `manifest`
251
+ * parameter directly, do not return a new object. Return values are ignored.
252
+ *
253
+ * @example
254
+ * defineConfig({
255
+ * // Add a CSS-only content script.
256
+ * transformManifest(manifest) {
257
+ * manifest.content_scripts.push({
258
+ * matches: ["*://google.com/*"],
259
+ * css: ["content-scripts/some-example.css"],
260
+ * });
261
+ * }
262
+ * })
263
+ */
264
+ transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
265
+ analysis?: {
266
+ /**
267
+ * Explicitly include bundle analysis when running `wxt build`. This can be overridden by the
268
+ * command line `--analysis` option.
269
+ *
270
+ * @default false
271
+ */
272
+ enabled?: boolean;
273
+ /**
274
+ * When running `wxt build --analyze` or setting `analysis.enabled` to true, customize how the
275
+ * bundle will be visualized. See
276
+ * [`rollup-plugin-visualizer`](https://github.com/btd/rollup-plugin-visualizer#how-to-use-generated-files)
277
+ * for more details.
278
+ *
279
+ * @default "treemap"
280
+ */
281
+ template?: PluginVisualizerOptions['template'];
282
+ };
283
+ /**
284
+ * Add additional paths to the `.wxt/tsconfig.json`. Use this instead of overwriting the `paths`
285
+ * in the root `tsconfig.json` if you want to add new paths.
286
+ *
287
+ * The key is the import alias and the value is either a relative path to the root directory or an absolute path.
288
+ *
289
+ * @example
290
+ * {
291
+ * "testing": "src/utils/testing.ts"
292
+ * }
293
+ */
294
+ alias?: Record<string, string>;
295
+ /**
296
+ * Experimental settings - use with caution.
297
+ */
298
+ experimental?: {
299
+ /**
300
+ * Whether to use [`webextension-polyfill`](https://www.npmjs.com/package/webextension-polyfill)
301
+ * when importing `browser` from `wxt/browser`.
302
+ *
303
+ * When set to `false`, WXT will export the chrome global instead of the polyfill from
304
+ * `wxt/browser`.
305
+ *
306
+ * You should use `browser` to access the web extension APIs.
307
+ *
308
+ * @experimental This option will remain experimental until Manifest V2 is dead.
309
+ *
310
+ * @default true
311
+ * @example
312
+ * export default defineConfig({
313
+ * experimental: {
314
+ * includeBrowserPolyfill: false
315
+ * }
316
+ * })
317
+ */
318
+ includeBrowserPolyfill?: boolean;
319
+ };
320
+ }
321
+ interface InlineConfig {
322
+ /**
323
+ * Return custom Vite options from a function. See
324
+ * <https://vitejs.dev/config/shared-options.html>.
325
+ *
326
+ * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
327
+ * instead of Vite's.
328
+ *
329
+ * This is a function because any vite plugins added need to be recreated for each individual
330
+ * build step, incase they have internal state causing them to fail when reused.
331
+ */
332
+ vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
333
+ }
334
+ type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
335
+ interface BuildOutput {
336
+ manifest: Manifest.WebExtensionManifest;
337
+ publicAssets: OutputAsset[];
338
+ steps: BuildStepOutput[];
339
+ }
340
+ type OutputFile = OutputChunk | OutputAsset;
341
+ interface OutputChunk {
342
+ type: 'chunk';
343
+ /**
344
+ * Relative, normalized path relative to the output directory.
345
+ *
346
+ * Ex: "content-scripts/overlay.js"
347
+ */
348
+ fileName: string;
349
+ /**
350
+ * Absolute, normalized paths to all dependencies this chunk relies on.
351
+ */
352
+ moduleIds: string[];
353
+ }
354
+ interface OutputAsset {
355
+ type: 'asset';
356
+ /**
357
+ * Relative, normalized path relative to the output directory.
358
+ *
359
+ * Ex: "icons/16.png"
360
+ */
361
+ fileName: string;
362
+ }
363
+ interface BuildStepOutput {
364
+ entrypoints: EntrypointGroup;
365
+ chunks: OutputFile[];
366
+ }
367
+ interface WxtDevServer extends Omit<WxtBuilderServer, 'listen'>, ServerInfo {
368
+ /**
369
+ * Stores the current build output of the server.
370
+ */
371
+ currentOutput: BuildOutput;
372
+ /**
373
+ * Start the server.
374
+ */
375
+ start(): Promise<void>;
376
+ /**
377
+ * Transform the HTML for dev mode.
378
+ */
379
+ transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
380
+ /**
381
+ * Tell the extension to reload by running `browser.runtime.reload`.
382
+ */
383
+ reloadExtension: () => void;
384
+ /**
385
+ * Tell an extension page to reload.
386
+ *
387
+ * The path is the bundle path, not the input paths, so if the input paths is
388
+ * "src/options/index.html", you would pass "options.html" because that's where it is written to
389
+ * in the dist directory, and where it's available at in the actual extension.
390
+ *
391
+ * @example
392
+ * server.reloadPage("popup.html")
393
+ * server.reloadPage("sandbox.html")
394
+ */
395
+ reloadPage: (path: string) => void;
396
+ /**
397
+ * Tell the extension to restart a content script.
398
+ *
399
+ * @param contentScript The manifest definition for a content script
400
+ */
401
+ reloadContentScript: (contentScript: Omit<Scripting.RegisteredContentScript, 'id'>) => void;
402
+ }
403
+ type TargetBrowser = string;
404
+ type TargetManifestVersion = 2 | 3;
405
+ type UserConfig = Omit<InlineConfig, 'configFile'>;
406
+ interface Logger {
407
+ debug(...args: any[]): void;
408
+ log(...args: any[]): void;
409
+ info(...args: any[]): void;
410
+ warn(...args: any[]): void;
411
+ error(...args: any[]): void;
412
+ fatal(...args: any[]): void;
413
+ success(...args: any[]): void;
414
+ level: LogLevel;
415
+ }
416
+ interface BaseEntrypointOptions {
417
+ include?: TargetBrowser[];
418
+ exclude?: TargetBrowser[];
419
+ }
420
+ interface BaseEntrypoint {
421
+ /**
422
+ * The entrypoint's name. This is the filename or dirname without the type suffix.
423
+ *
424
+ * Examples:
425
+ * - `popup.html` &rarr; `popup`
426
+ * - `options/index.html` &rarr; `options`
427
+ * - `named.sandbox.html` &rarr; `named`
428
+ * - `named.sandbox/index.html` &rarr; `named`
429
+ * - `sandbox.html` &rarr; `sandbox`
430
+ * - `sandbox/index.html` &rarr; `sandbox`
431
+ * - `overlay.content.ts` &rarr; `overlay`
432
+ * - `overlay.content/index.ts` &rarr; `overlay`
433
+ *
434
+ * The name is used when generating an output file:
435
+ * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
436
+ */
437
+ name: string;
438
+ /**
439
+ * Absolute path to the entrypoint's input file.
440
+ */
441
+ inputPath: string;
442
+ /**
443
+ * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
444
+ * subdirectory of it.
445
+ */
446
+ outputDir: string;
447
+ options: BaseEntrypointOptions;
448
+ }
449
+ interface GenericEntrypoint extends BaseEntrypoint {
450
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
451
+ }
452
+ interface BackgroundEntrypoint extends BaseEntrypoint {
453
+ type: 'background';
454
+ options: {
455
+ persistent?: boolean;
456
+ type?: 'module';
457
+ } & BaseEntrypointOptions;
458
+ }
459
+ interface ContentScriptEntrypoint extends BaseEntrypoint {
460
+ type: 'content-script';
461
+ options: Omit<ContentScriptDefinition, 'main'> & BaseEntrypointOptions;
462
+ }
463
+ interface PopupEntrypoint extends BaseEntrypoint {
464
+ type: 'popup';
465
+ options: {
466
+ /**
467
+ * Defaults to "browser_action" to be equivalent to MV3's "action" key
468
+ */
469
+ mv2Key?: 'browser_action' | 'page_action';
470
+ defaultIcon?: Record<string, string>;
471
+ defaultTitle?: string;
472
+ browserStyle?: boolean;
473
+ } & BaseEntrypointOptions;
474
+ }
475
+ interface OptionsEntrypoint extends BaseEntrypoint {
476
+ type: 'options';
477
+ options: {
478
+ openInTab?: boolean;
479
+ browserStyle?: boolean;
480
+ chromeStyle?: boolean;
481
+ } & BaseEntrypointOptions;
482
+ }
483
+ type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
484
+ type EntrypointGroup = Entrypoint | Entrypoint[];
485
+ type OnContentScriptStopped = (cb: () => void) => void;
486
+ interface ContentScriptDefinition extends ExcludableEntrypoint {
487
+ matches: PerBrowserOption<Manifest.ContentScript['matches']>;
488
+ /**
489
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
490
+ * @default "documentIdle"
491
+ */
492
+ runAt?: PerBrowserOption<Manifest.ContentScript['run_at']>;
493
+ /**
494
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
495
+ * @default false
496
+ */
497
+ matchAboutBlank?: PerBrowserOption<Manifest.ContentScript['match_about_blank']>;
498
+ /**
499
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
500
+ * @default []
501
+ */
502
+ excludeMatches?: PerBrowserOption<Manifest.ContentScript['exclude_matches']>;
503
+ /**
504
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
505
+ * @default []
506
+ */
507
+ includeGlobs?: PerBrowserOption<Manifest.ContentScript['include_globs']>;
508
+ /**
509
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
510
+ * @default []
511
+ */
512
+ excludeGlobs?: PerBrowserOption<Manifest.ContentScript['exclude_globs']>;
513
+ /**
514
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
515
+ * @default false
516
+ */
517
+ allFrames?: PerBrowserOption<Manifest.ContentScript['all_frames']>;
518
+ /**
519
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
520
+ * @default false
521
+ */
522
+ matchOriginAsFallback?: PerBrowserOption<boolean>;
523
+ /**
524
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
525
+ * @default "ISOLATED"
526
+ */
527
+ world?: PerBrowserOption<'ISOLATED' | 'MAIN'>;
528
+ /**
529
+ * Customize how imported/generated styles are injected with the content script. Regardless of the
530
+ * mode selected, CSS will always be built and included in the output directory.
531
+ *
532
+ * - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
533
+ * - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
534
+ * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
535
+ * URL
536
+ * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
537
+ * calling `createContentScriptUi`
538
+ *
539
+ * @default "manifest"
540
+ */
541
+ cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
542
+ /**
543
+ * Main function executed when the content script is loaded.
544
+ */
545
+ main(ctx: ContentScriptContext): void | Promise<void>;
546
+ }
547
+ interface BackgroundDefinition extends ExcludableEntrypoint {
548
+ type?: PerBrowserOption<'module'>;
549
+ persistent?: PerBrowserOption<boolean>;
550
+ main(): void;
551
+ }
552
+ interface UnlistedScriptDefinition extends ExcludableEntrypoint {
553
+ /**
554
+ * Main function executed when the unlisted script is ran.
555
+ */
556
+ main(): void | Promise<void>;
557
+ }
558
+ type PerBrowserOption<T> = T | {
559
+ [browser: TargetBrowser]: T;
560
+ };
561
+ interface ExcludableEntrypoint {
562
+ /**
563
+ * List of target browsers to include this entrypoint in. Defaults to being included in all
564
+ * builds. Cannot be used with `exclude`. You must choose one of the two options.
565
+ *
566
+ * @default undefined
567
+ */
568
+ include?: TargetBrowser[];
569
+ /**
570
+ * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
571
+ * must choose one of the two options.
572
+ *
573
+ * @default undefined
574
+ */
575
+ exclude?: TargetBrowser[];
576
+ }
577
+ /**
578
+ * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
579
+ * here, they are configured inline.
580
+ */
581
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'sidepanel' | 'sidebar_action'>>;
582
+ type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
583
+ interface ConfigEnv {
584
+ mode: string;
585
+ command: 'build' | 'serve';
586
+ /**
587
+ * Browser passed in from the CLI
588
+ */
589
+ browser: TargetBrowser;
590
+ /**
591
+ * Manifest version passed in from the CLI
592
+ */
593
+ manifestVersion: 2 | 3;
594
+ }
595
+ /**
596
+ * Configure how the browser starts up.
597
+ */
598
+ interface ExtensionRunnerConfig {
599
+ /**
600
+ * Whether or not to open the browser with the extension installed in dev mode.
601
+ *
602
+ * @default false
603
+ */
604
+ disabled?: boolean;
605
+ /**
606
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#browser-console
607
+ */
608
+ openConsole?: boolean;
609
+ /**
610
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#devtools
611
+ */
612
+ openDevtools?: boolean;
613
+ /**
614
+ * List of browser names and the binary that should be used to open the browser.
615
+ *
616
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
617
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
618
+ */
619
+ binaries?: Record<string, string>;
620
+ /**
621
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
622
+ */
623
+ firefoxProfile?: string;
624
+ /**
625
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
626
+ */
627
+ chromiumProfile?: string;
628
+ /**
629
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
630
+ */
631
+ firefoxPrefs?: Record<string, string>;
632
+ /**
633
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
634
+ */
635
+ firefoxArgs?: string[];
636
+ /**
637
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
638
+ */
639
+ chromiumArgs?: string[];
640
+ /**
641
+ * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#start-url
642
+ */
643
+ startUrls?: string[];
644
+ }
645
+ interface WxtBuilder {
646
+ /**
647
+ * Name of tool used to build. Ex: "Vite" or "Webpack".
648
+ */
649
+ name: string;
650
+ /**
651
+ * Version of tool used to build. Ex: "5.0.2"
652
+ */
653
+ version: string;
654
+ /**
655
+ * Build a single entrypoint group. This is effectively one of the multiple "steps" during the
656
+ * build process.
657
+ */
658
+ build(group: EntrypointGroup): Promise<BuildStepOutput>;
659
+ /**
660
+ * Start a dev server at the provided port.
661
+ */
662
+ createServer(info: ServerInfo): Promise<WxtBuilderServer>;
663
+ }
664
+ interface WxtBuilderServer {
665
+ /**
666
+ * Start the server.
667
+ */
668
+ listen(): Promise<void>;
669
+ /**
670
+ * Transform the HTML for dev mode.
671
+ */
672
+ transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
673
+ /**
674
+ * The web socket server used to communicate with the extension.
675
+ */
676
+ ws: {
677
+ /**
678
+ * Send a message via the server's websocket, with an optional payload.
679
+ *
680
+ * @example
681
+ * ws.send("wxt:reload-extension");
682
+ * ws.send("wxt:reload-content-script", { ... });
683
+ */
684
+ send(message: string, payload?: any): void;
685
+ /**
686
+ * Listen for messages over the server's websocket.
687
+ */
688
+ on(message: string, cb: (payload: any) => void): void;
689
+ };
690
+ /**
691
+ * Chokidar file watcher instance.
692
+ */
693
+ watcher: FSWatcher;
694
+ }
695
+ interface ServerInfo {
696
+ /**
697
+ * Ex: `3000`
698
+ */
699
+ port: number;
700
+ /**
701
+ * Ex: `"localhost"`
702
+ */
703
+ hostname: string;
704
+ /**
705
+ * Ex: `"http://localhost:3000"`
706
+ */
707
+ origin: string;
708
+ }
709
+
710
+ export type { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ServerInfo as S, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, BackgroundDefinition as n, UnlistedScriptDefinition as o, PerBrowserOption as p, ExcludableEntrypoint as q, UserManifest as r, UserManifestFn as s, ConfigEnv as t, WxtBuilder as u, WxtBuilderServer as v };