wxt 0.10.3 → 0.11.0

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