wxt 0.18.15 → 0.19.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.
- package/bin/wxt.mjs +1 -1
- package/dist/browser/chrome.d.ts +17 -0
- package/dist/browser/chrome.mjs +7 -0
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.mjs +2 -0
- package/dist/builtin-modules/index.d.ts +2 -0
- package/dist/builtin-modules/index.mjs +2 -0
- package/dist/builtin-modules/unimport.d.ts +8 -0
- package/dist/builtin-modules/unimport.mjs +99 -0
- package/dist/cli/cli-utils.d.ts +25 -0
- package/dist/cli/cli-utils.mjs +58 -0
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.mjs +104 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.mjs +11 -0
- package/dist/client/app-config.d.ts +2 -0
- package/dist/client/app-config.mjs +4 -0
- package/dist/client/content-scripts/content-script-context.d.ts +114 -0
- package/dist/client/content-scripts/content-script-context.mjs +169 -0
- package/dist/client/content-scripts/custom-events.d.ts +10 -0
- package/dist/client/content-scripts/custom-events.mjs +13 -0
- package/dist/client/content-scripts/index.d.ts +2 -0
- package/dist/client/content-scripts/index.mjs +2 -0
- package/dist/client/content-scripts/location-watcher.d.ts +12 -0
- package/dist/client/content-scripts/location-watcher.mjs +22 -0
- package/dist/client/content-scripts/ui/index.d.ts +23 -0
- package/dist/client/content-scripts/ui/index.mjs +188 -0
- package/dist/{client.d.ts → client/content-scripts/ui/types.d.ts} +17 -45
- package/dist/client/content-scripts/ui/types.mjs +0 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.mjs +2 -0
- package/dist/core/build.d.ts +15 -0
- package/dist/core/build.mjs +6 -0
- package/dist/core/builders/vite/index.d.ts +3 -0
- package/dist/core/builders/vite/index.mjs +285 -0
- package/dist/core/builders/vite/plugins/bundleAnalysis.d.ts +7 -0
- package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +15 -0
- package/dist/core/builders/vite/plugins/cssEntrypoints.d.ts +13 -0
- package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +22 -0
- package/dist/core/builders/vite/plugins/defineImportMeta.d.ts +14 -0
- package/dist/core/builders/vite/plugins/defineImportMeta.mjs +13 -0
- package/dist/core/builders/vite/plugins/devHtmlPrerender.d.ts +7 -0
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +140 -0
- package/dist/core/builders/vite/plugins/devServerGlobals.d.ts +6 -0
- package/dist/core/builders/vite/plugins/devServerGlobals.mjs +15 -0
- package/dist/core/builders/vite/plugins/download.d.ts +10 -0
- package/dist/core/builders/vite/plugins/download.mjs +14 -0
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.d.ts +6 -0
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +16 -0
- package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +11 -0
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +26 -0
- package/dist/core/builders/vite/plugins/globals.d.ts +3 -0
- package/dist/core/builders/vite/plugins/globals.mjs +15 -0
- package/dist/core/builders/vite/plugins/index.d.ts +17 -0
- package/dist/core/builders/vite/plugins/index.mjs +17 -0
- package/dist/core/builders/vite/plugins/multipageMove.d.ts +20 -0
- package/dist/core/builders/vite/plugins/multipageMove.mjs +59 -0
- package/dist/core/builders/vite/plugins/noopBackground.d.ts +6 -0
- package/dist/core/builders/vite/plugins/noopBackground.mjs +17 -0
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.d.ts +6 -0
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +12 -0
- package/dist/core/builders/vite/plugins/resolveAppConfig.d.ts +6 -0
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +26 -0
- package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +10 -0
- package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +15 -0
- package/dist/core/builders/vite/plugins/resolveVirtualModules.d.ts +6 -0
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +30 -0
- package/dist/core/builders/vite/plugins/tsconfigPaths.d.ts +3 -0
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +12 -0
- package/dist/core/builders/vite/plugins/wxtPluginLoader.d.ts +6 -0
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +56 -0
- package/dist/core/clean.d.ts +21 -0
- package/dist/core/clean.mjs +38 -0
- package/dist/core/create-server.d.ts +11 -0
- package/dist/core/create-server.mjs +206 -0
- package/dist/core/define-config.d.ts +2 -0
- package/dist/core/define-config.mjs +3 -0
- package/dist/core/define-runner-config.d.ts +2 -0
- package/dist/core/define-runner-config.mjs +3 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.mjs +8 -0
- package/dist/core/initialize.d.ts +5 -0
- package/dist/core/initialize.mjs +128 -0
- package/dist/core/package-managers/bun.d.ts +2 -0
- package/dist/core/package-managers/bun.mjs +19 -0
- package/dist/core/package-managers/index.d.ts +2 -0
- package/dist/core/package-managers/index.mjs +65 -0
- package/dist/core/package-managers/npm.d.ts +17 -0
- package/dist/core/package-managers/npm.mjs +58 -0
- package/dist/core/package-managers/pnpm.d.ts +2 -0
- package/dist/core/package-managers/pnpm.mjs +21 -0
- package/dist/core/package-managers/types.d.ts +2 -0
- package/dist/core/package-managers/types.mjs +0 -0
- package/dist/core/package-managers/yarn.d.ts +2 -0
- package/dist/core/package-managers/yarn.mjs +31 -0
- package/dist/core/prepare.d.ts +2 -0
- package/dist/core/prepare.mjs +8 -0
- package/dist/core/runners/index.d.ts +2 -0
- package/dist/core/runners/index.mjs +12 -0
- package/dist/core/runners/manual.d.ts +5 -0
- package/dist/core/runners/manual.mjs +16 -0
- package/dist/core/runners/safari.d.ts +5 -0
- package/dist/core/runners/safari.mjs +16 -0
- package/dist/core/runners/web-ext.d.ts +5 -0
- package/dist/core/runners/web-ext.mjs +78 -0
- package/dist/core/runners/wsl.d.ts +5 -0
- package/dist/core/runners/wsl.mjs +16 -0
- package/dist/core/utils/arrays.d.ts +13 -0
- package/dist/{chunk-BERPNPEZ.js → core/utils/arrays.mjs} +6 -10
- package/dist/core/utils/building/build-entrypoints.d.ts +3 -0
- package/dist/core/utils/building/build-entrypoints.mjs +47 -0
- package/dist/core/utils/building/detect-dev-changes.d.ts +57 -0
- package/dist/core/utils/building/detect-dev-changes.mjs +93 -0
- package/dist/core/utils/building/find-entrypoints.d.ts +5 -0
- package/dist/core/utils/building/find-entrypoints.mjs +385 -0
- package/dist/core/utils/building/generate-wxt-dir.d.ts +5 -0
- package/dist/core/utils/building/generate-wxt-dir.mjs +192 -0
- package/dist/core/utils/building/group-entrypoints.d.ts +8 -0
- package/dist/core/utils/building/group-entrypoints.mjs +37 -0
- package/dist/core/utils/building/import-entrypoint.d.ts +16 -0
- package/dist/core/utils/building/import-entrypoint.mjs +97 -0
- package/dist/core/utils/building/index.d.ts +9 -0
- package/dist/core/utils/building/index.mjs +9 -0
- package/dist/core/utils/building/internal-build.d.ts +12 -0
- package/dist/core/utils/building/internal-build.mjs +112 -0
- package/dist/core/utils/building/rebuild.d.ts +23 -0
- package/dist/core/utils/building/rebuild.mjs +39 -0
- package/dist/core/utils/building/resolve-config.d.ts +11 -0
- package/dist/core/utils/building/resolve-config.mjs +364 -0
- package/dist/core/utils/cache.d.ts +8 -0
- package/dist/core/utils/cache.mjs +21 -0
- package/dist/core/utils/cli.d.ts +3 -0
- package/dist/core/utils/cli.mjs +26 -0
- package/dist/core/utils/constants.d.ts +5 -0
- package/dist/core/utils/constants.mjs +1 -0
- package/dist/core/utils/content-scripts.d.ts +11 -0
- package/dist/core/utils/content-scripts.mjs +60 -0
- package/dist/core/utils/content-security-policy.d.ts +14 -0
- package/dist/core/utils/content-security-policy.mjs +39 -0
- package/dist/core/utils/entrypoints.d.ts +25 -0
- package/dist/core/utils/entrypoints.mjs +31 -0
- package/dist/core/utils/eslint.d.ts +1 -0
- package/dist/core/utils/eslint.mjs +11 -0
- package/dist/core/utils/fs.d.ts +13 -0
- package/dist/core/utils/fs.mjs +15 -0
- package/dist/core/utils/globals.d.ts +11 -0
- package/dist/core/utils/globals.mjs +53 -0
- package/dist/core/utils/i18n.d.ts +11 -0
- package/dist/core/utils/i18n.mjs +35 -0
- package/dist/core/utils/log/index.d.ts +4 -0
- package/dist/core/utils/log/index.mjs +4 -0
- package/dist/core/utils/log/printBuildSummary.d.ts +2 -0
- package/dist/core/utils/log/printBuildSummary.mjs +32 -0
- package/dist/core/utils/log/printFileList.d.ts +1 -0
- package/dist/core/utils/log/printFileList.mjs +42 -0
- package/dist/core/utils/log/printHeader.d.ts +1 -0
- package/dist/core/utils/log/printHeader.mjs +7 -0
- package/dist/core/utils/log/printTable.d.ts +1 -0
- package/dist/core/utils/log/printTable.mjs +22 -0
- package/dist/core/utils/manifest.d.ts +44 -0
- package/dist/core/utils/manifest.mjs +512 -0
- package/dist/core/utils/network.d.ts +7 -0
- package/dist/core/utils/network.mjs +38 -0
- package/dist/core/utils/package.d.ts +6 -0
- package/dist/core/utils/package.mjs +14 -0
- package/dist/core/utils/paths.d.ts +11 -0
- package/dist/core/utils/paths.mjs +10 -0
- package/dist/core/utils/strings.d.ts +14 -0
- package/dist/core/utils/strings.mjs +18 -0
- package/dist/core/utils/testing/fake-objects.d.ts +4556 -0
- package/dist/core/utils/testing/fake-objects.mjs +322 -0
- package/dist/core/utils/time.d.ts +9 -0
- package/dist/core/utils/time.mjs +17 -0
- package/dist/core/utils/transform.d.ts +9 -0
- package/dist/core/utils/transform.mjs +17 -0
- package/dist/core/utils/types.d.ts +10 -0
- package/dist/core/utils/types.mjs +0 -0
- package/dist/core/utils/validation.d.ts +15 -0
- package/dist/core/utils/validation.mjs +55 -0
- package/dist/core/utils/virtual-modules.d.ts +22 -0
- package/dist/core/utils/virtual-modules.mjs +14 -0
- package/dist/core/utils/wsl.d.ts +4 -0
- package/dist/core/utils/wsl.mjs +4 -0
- package/dist/core/wxt.d.ts +19 -0
- package/dist/core/wxt.mjs +41 -0
- package/dist/core/zip.d.ts +7 -0
- package/dist/core/zip.mjs +137 -0
- package/dist/index.d.ts +4 -79
- package/dist/index.mjs +3 -0
- package/dist/modules.d.ts +10 -20
- package/dist/{chunk-6XSIWUWF.js → modules.mjs} +7 -16
- package/dist/sandbox/define-app-config.d.ts +19 -0
- package/dist/sandbox/define-app-config.mjs +3 -0
- package/dist/sandbox/define-background.d.ts +3 -0
- package/dist/sandbox/define-background.mjs +4 -0
- package/dist/sandbox/define-content-script.d.ts +2 -0
- package/dist/sandbox/define-content-script.mjs +3 -0
- package/dist/sandbox/define-unlisted-script.d.ts +3 -0
- package/dist/sandbox/define-unlisted-script.mjs +4 -0
- package/dist/sandbox/define-wxt-plugin.d.ts +2 -0
- package/dist/sandbox/define-wxt-plugin.mjs +3 -0
- package/dist/sandbox/dev-server-websocket.d.ts +21 -0
- package/dist/sandbox/dev-server-websocket.mjs +37 -0
- package/dist/sandbox/index.d.ts +11 -0
- package/dist/sandbox/index.mjs +6 -0
- package/dist/sandbox/utils/logger.d.ts +9 -0
- package/dist/sandbox/utils/logger.mjs +15 -0
- package/dist/storage.d.ts +39 -16
- package/dist/{storage.js → storage.mjs} +30 -41
- package/dist/testing/fake-browser.d.ts +1 -0
- package/dist/testing/fake-browser.mjs +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/{testing.d.ts → testing/wxt-vitest-plugin.d.ts} +3 -15
- package/dist/testing/wxt-vitest-plugin.mjs +26 -0
- package/dist/{index-nWRfwAJi.d.cts → types.d.ts} +150 -264
- package/dist/types.mjs +0 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.mjs +1 -0
- package/dist/virtual/{background-entrypoint.js → background-entrypoint.mjs} +31 -40
- package/dist/virtual/{content-script-isolated-world-entrypoint.js → content-script-isolated-world-entrypoint.mjs} +9 -13
- package/dist/virtual/{content-script-main-world-entrypoint.js → content-script-main-world-entrypoint.mjs} +9 -14
- package/dist/virtual/mock-browser.mjs +6 -0
- package/dist/virtual/{reload-html.js → reload-html.mjs} +8 -9
- package/dist/virtual/{unlisted-script-entrypoint.js → unlisted-script-entrypoint.mjs} +8 -12
- package/package.json +47 -57
- package/dist/browser.d.ts +0 -18
- package/dist/browser.js +0 -6
- package/dist/chunk-BM6QYGAW.js +0 -1063
- package/dist/chunk-FNTE2L27.js +0 -7
- package/dist/chunk-FP7RYLVL.js +0 -3617
- package/dist/chunk-KPD5J7PZ.js +0 -1065
- package/dist/chunk-QGM4M3NI.js +0 -37
- package/dist/chunk-SGKCDMVR.js +0 -38
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -4438
- package/dist/client.js +0 -424
- package/dist/define-app-config-bg54F_lV.d.ts +0 -294
- package/dist/execa-4UBDUBJZ.js +0 -7244
- package/dist/execa-QLUM2B3W.js +0 -7245
- package/dist/index-nWRfwAJi.d.ts +0 -1401
- package/dist/index.cjs +0 -14473
- package/dist/index.d.cts +0 -81
- package/dist/index.js +0 -696
- package/dist/modules.cjs +0 -96
- package/dist/modules.d.cts +0 -119
- package/dist/modules.js +0 -17
- package/dist/prompt-25QIVJDC.js +0 -755
- package/dist/prompt-7BMKNSWS.js +0 -754
- package/dist/sandbox.d.ts +0 -16
- package/dist/sandbox.js +0 -36
- package/dist/storage.cjs +0 -439
- package/dist/storage.d.cts +0 -200
- package/dist/testing.cjs +0 -2815
- package/dist/testing.d.cts +0 -30
- package/dist/testing.js +0 -40
- package/dist/virtual/mock-browser.js +0 -6
package/dist/index-nWRfwAJi.d.ts
DELETED
|
@@ -1,1401 +0,0 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import { Manifest, Scripting } from 'webextension-polyfill';
|
|
3
|
-
import { UnimportOptions, Import } from 'unimport';
|
|
4
|
-
import { LogLevel } from 'consola';
|
|
5
|
-
import { PluginVisualizerOptions } from '@aklinker1/rollup-plugin-visualizer';
|
|
6
|
-
import { FSWatcher } from 'chokidar';
|
|
7
|
-
import { ResolvedConfig as ResolvedConfig$1 } from 'c12';
|
|
8
|
-
import { NestedHooks, Hookable } from 'hookable';
|
|
9
|
-
import * as Nypm from 'nypm';
|
|
10
|
-
|
|
11
|
-
declare class WxtLocationChangeEvent extends Event {
|
|
12
|
-
readonly newUrl: URL;
|
|
13
|
-
readonly oldUrl: URL;
|
|
14
|
-
static EVENT_NAME: string;
|
|
15
|
-
constructor(newUrl: URL, oldUrl: URL);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
20
|
-
* Used to detect and stop content script code when the script is invalidated.
|
|
21
|
-
*
|
|
22
|
-
* It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
|
|
23
|
-
* content scripts instead of `window.setTimeout` or `window.setInterval`.
|
|
24
|
-
*
|
|
25
|
-
* To create context for testing, you can use the class's constructor:
|
|
26
|
-
*
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { ContentScriptContext } from 'wxt/client';
|
|
29
|
-
*
|
|
30
|
-
* test("storage listener should be removed when context is invalidated", () => {
|
|
31
|
-
* const ctx = new ContentScriptContext('test');
|
|
32
|
-
* const item = storage.defineItem("local:count", { defaultValue: 0 });
|
|
33
|
-
* const watcher = vi.fn();
|
|
34
|
-
*
|
|
35
|
-
* const unwatch = item.watch(watcher);
|
|
36
|
-
* ctx.onInvalidated(unwatch); // Listen for invalidate here
|
|
37
|
-
*
|
|
38
|
-
* await item.setValue(1);
|
|
39
|
-
* expect(watcher).toBeCalledTimes(1);
|
|
40
|
-
* expect(watcher).toBeCalledWith(1, 0);
|
|
41
|
-
*
|
|
42
|
-
* ctx.notifyInvalidated(); // Use this function to invalidate the context
|
|
43
|
-
* await item.setValue(2);
|
|
44
|
-
* expect(watcher).toBeCalledTimes(1);
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
declare class ContentScriptContext implements AbortController {
|
|
49
|
-
#private;
|
|
50
|
-
private readonly contentScriptName;
|
|
51
|
-
readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
|
|
52
|
-
private static SCRIPT_STARTED_MESSAGE_TYPE;
|
|
53
|
-
constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
|
|
54
|
-
get signal(): AbortSignal;
|
|
55
|
-
abort(reason?: any): void;
|
|
56
|
-
get isInvalid(): boolean;
|
|
57
|
-
get isValid(): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Add a listener that is called when the content script's context is invalidated.
|
|
60
|
-
*
|
|
61
|
-
* @returns A function to remove the listener.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* browser.runtime.onMessage.addListener(cb);
|
|
65
|
-
* const removeInvalidatedListener = ctx.onInvalidated(() => {
|
|
66
|
-
* browser.runtime.onMessage.removeListener(cb);
|
|
67
|
-
* })
|
|
68
|
-
* // ...
|
|
69
|
-
* removeInvalidatedListener();
|
|
70
|
-
*/
|
|
71
|
-
onInvalidated(cb: () => void): () => void;
|
|
72
|
-
/**
|
|
73
|
-
* Return a promise that never resolves. Useful if you have an async function that shouldn't run
|
|
74
|
-
* after the context is expired.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* const getValueFromStorage = async () => {
|
|
78
|
-
* if (ctx.isInvalid) return ctx.block();
|
|
79
|
-
*
|
|
80
|
-
* // ...
|
|
81
|
-
* }
|
|
82
|
-
*/
|
|
83
|
-
block<T>(): Promise<T>;
|
|
84
|
-
/**
|
|
85
|
-
* Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
|
|
86
|
-
*/
|
|
87
|
-
setInterval(handler: () => void, timeout?: number): number;
|
|
88
|
-
/**
|
|
89
|
-
* Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
|
|
90
|
-
*/
|
|
91
|
-
setTimeout(handler: () => void, timeout?: number): number;
|
|
92
|
-
/**
|
|
93
|
-
* Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
|
|
94
|
-
* invalidated.
|
|
95
|
-
*/
|
|
96
|
-
requestAnimationFrame(callback: FrameRequestCallback): number;
|
|
97
|
-
/**
|
|
98
|
-
* Wrapper around `window.requestIdleCallback` that automatically cancels the request when
|
|
99
|
-
* invalidated.
|
|
100
|
-
*/
|
|
101
|
-
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
|
|
102
|
-
/**
|
|
103
|
-
* Call `target.addEventListener` and remove the event listener when the context is invalidated.
|
|
104
|
-
*
|
|
105
|
-
* Includes additional events useful for content scripts:
|
|
106
|
-
*
|
|
107
|
-
* - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
|
|
108
|
-
* scripts are not reloaded when navigating this way, so this can be used to reset the content
|
|
109
|
-
* script state on URL change, or run custom code.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ctx.addEventListener(document, "visibilitychange", () => {
|
|
113
|
-
* // ...
|
|
114
|
-
* });
|
|
115
|
-
* ctx.addEventListener(document, "wxt:locationchange", () => {
|
|
116
|
-
* // ...
|
|
117
|
-
* });
|
|
118
|
-
*/
|
|
119
|
-
addEventListener<TTarget extends EventTarget, TType extends keyof WxtContentScriptEventMap>(target: TTarget, type: TType, handler: (event: WxtContentScriptEventMap[TType]) => void, options?: AddEventListenerOptions): void;
|
|
120
|
-
/**
|
|
121
|
-
* @internal
|
|
122
|
-
* Abort the abort controller and execute all `onInvalidated` listeners.
|
|
123
|
-
*/
|
|
124
|
-
notifyInvalidated(): void;
|
|
125
|
-
}
|
|
126
|
-
interface WxtContentScriptEventMap extends WindowEventMap {
|
|
127
|
-
'wxt:locationchange': WxtLocationChangeEvent;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
interface InlineConfig {
|
|
131
|
-
/**
|
|
132
|
-
* Your project's root directory containing the `package.json` used to fill out the
|
|
133
|
-
* `manifest.json`.
|
|
134
|
-
*
|
|
135
|
-
* @default process.cwd()
|
|
136
|
-
*/
|
|
137
|
-
root?: string;
|
|
138
|
-
/**
|
|
139
|
-
* Directory containing all source code. Set to `"src"` to move all source code to a `src/`
|
|
140
|
-
* directory.
|
|
141
|
-
*
|
|
142
|
-
* After changing, don't forget to move the `public/` and `entrypoints/` directories into the new
|
|
143
|
-
* source dir.
|
|
144
|
-
*
|
|
145
|
-
* @default config.root
|
|
146
|
-
*/
|
|
147
|
-
srcDir?: string;
|
|
148
|
-
/**
|
|
149
|
-
* Directory containing files that will be copied to the output directory as-is.
|
|
150
|
-
*
|
|
151
|
-
* @default "${config.root}/public"
|
|
152
|
-
*/
|
|
153
|
-
publicDir?: string;
|
|
154
|
-
/**
|
|
155
|
-
* @default "${config.srcDir}/entrypoints"
|
|
156
|
-
*/
|
|
157
|
-
entrypointsDir?: string;
|
|
158
|
-
/**
|
|
159
|
-
* @default "${config.srcDir}/modules"
|
|
160
|
-
*/
|
|
161
|
-
modulesDir?: string;
|
|
162
|
-
/**
|
|
163
|
-
* A list of entrypoint names (`"popup"`, `"options"`, etc.) to build. Will speed up the build if
|
|
164
|
-
* your extension has lots of entrypoints, and you don't need to build all of them to develop a
|
|
165
|
-
* feature.
|
|
166
|
-
*/
|
|
167
|
-
filterEntrypoints?: string[];
|
|
168
|
-
/**
|
|
169
|
-
* Output directory that stored build folders and ZIPs.
|
|
170
|
-
*
|
|
171
|
-
* @default ".output"
|
|
172
|
-
*/
|
|
173
|
-
outDir?: string;
|
|
174
|
-
/**
|
|
175
|
-
* > Only available when using the JS API. Not available in `wxt.config.ts` files
|
|
176
|
-
*
|
|
177
|
-
* Path to `wxt.config.ts` file or `false` to disable config file discovery.
|
|
178
|
-
*
|
|
179
|
-
* @default "wxt.config.ts"
|
|
180
|
-
*/
|
|
181
|
-
configFile?: string | false;
|
|
182
|
-
/**
|
|
183
|
-
* Set to `true` to show debug logs. Overriden by the command line `--debug` option.
|
|
184
|
-
*
|
|
185
|
-
* @default false
|
|
186
|
-
*/
|
|
187
|
-
debug?: boolean;
|
|
188
|
-
/**
|
|
189
|
-
* Explicitly set a mode to run in. This will override the default mode for each command, and can
|
|
190
|
-
* be overridden by the command line `--mode` option.
|
|
191
|
-
*/
|
|
192
|
-
mode?: string;
|
|
193
|
-
/**
|
|
194
|
-
* Customize auto-import options. Set to `false` to disable auto-imports.
|
|
195
|
-
*
|
|
196
|
-
* For example, to add a directory to auto-import from, you can use:
|
|
197
|
-
*
|
|
198
|
-
* ```ts
|
|
199
|
-
* export default defineConfig({
|
|
200
|
-
* imports: {
|
|
201
|
-
* dirs: ["some-directory"]
|
|
202
|
-
* }
|
|
203
|
-
* })
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
imports?: WxtUnimportOptions | false;
|
|
207
|
-
/**
|
|
208
|
-
* Explicitly set a browser to build for. This will override the default browser for each command,
|
|
209
|
-
* and can be overridden by the command line `--browser` option.
|
|
210
|
-
*
|
|
211
|
-
* @default
|
|
212
|
-
* "chrome"
|
|
213
|
-
*/
|
|
214
|
-
browser?: TargetBrowser;
|
|
215
|
-
/**
|
|
216
|
-
* Explicitly set a manifest version to target. This will override the default manifest version
|
|
217
|
-
* for each command, and can be overridden by the command line `--mv2` or `--mv3` option.
|
|
218
|
-
*/
|
|
219
|
-
manifestVersion?: TargetManifestVersion;
|
|
220
|
-
/**
|
|
221
|
-
* Override the logger used.
|
|
222
|
-
*
|
|
223
|
-
* @default
|
|
224
|
-
* consola
|
|
225
|
-
*/
|
|
226
|
-
logger?: Logger;
|
|
227
|
-
/**
|
|
228
|
-
* Customize the `manifest.json` output. Can be an object, promise, or function that returns an
|
|
229
|
-
* object or promise.
|
|
230
|
-
*/
|
|
231
|
-
manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
|
|
232
|
-
/**
|
|
233
|
-
* Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
|
|
234
|
-
*/
|
|
235
|
-
runner?: ExtensionRunnerConfig;
|
|
236
|
-
zip?: {
|
|
237
|
-
/**
|
|
238
|
-
* Configure the filename output when zipping files.
|
|
239
|
-
*
|
|
240
|
-
* Available template variables:
|
|
241
|
-
*
|
|
242
|
-
* - <span v-pre>`{{name}}`</span> - The project's name converted to kebab-case
|
|
243
|
-
* - <span v-pre>`{{version}}`</span> - The version_name or version from the manifest
|
|
244
|
-
* - <span v-pre>`{{browser}}`</span> - The target browser from the `--browser` CLI flag
|
|
245
|
-
* - <span v-pre>`{{mode}}`</span> - The current mode
|
|
246
|
-
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
|
247
|
-
*
|
|
248
|
-
* @default "{{name}}-{{version}}-{{browser}}.zip"
|
|
249
|
-
*/
|
|
250
|
-
artifactTemplate?: string;
|
|
251
|
-
/**
|
|
252
|
-
* Configure the filename output when zipping files.
|
|
253
|
-
*
|
|
254
|
-
* Available template variables:
|
|
255
|
-
*
|
|
256
|
-
* - <span v-pre>`{{name}}`</span> - The project's name converted to kebab-case
|
|
257
|
-
* - <span v-pre>`{{version}}`</span> - The version_name or version from the manifest
|
|
258
|
-
* - <span v-pre>`{{browser}}`</span> - The target browser from the `--browser` CLI flag
|
|
259
|
-
* - <span v-pre>`{{mode}}`</span> - The current mode
|
|
260
|
-
* - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
|
|
261
|
-
*
|
|
262
|
-
* @default "{{name}}-{{version}}-sources.zip"
|
|
263
|
-
*/
|
|
264
|
-
sourcesTemplate?: string;
|
|
265
|
-
/**
|
|
266
|
-
* Override the artifactTemplate's `{name}` template variable. Defaults to the `package.json`'s
|
|
267
|
-
* name, or if that doesn't exist, the current working directories name.
|
|
268
|
-
*/
|
|
269
|
-
name?: string;
|
|
270
|
-
/**
|
|
271
|
-
* Root directory to ZIP when generating the sources ZIP.
|
|
272
|
-
*
|
|
273
|
-
* @default config.root
|
|
274
|
-
*/
|
|
275
|
-
sourcesRoot?: string;
|
|
276
|
-
/**
|
|
277
|
-
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to include when
|
|
278
|
-
* creating a ZIP of all your source code for Firefox. Patterns are relative to your
|
|
279
|
-
* `config.zip.sourcesRoot`.
|
|
280
|
-
*
|
|
281
|
-
* This setting overrides `excludeSources`. So if a file matches both lists, it is included in the ZIP.
|
|
282
|
-
*
|
|
283
|
-
* @example
|
|
284
|
-
* [
|
|
285
|
-
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
286
|
-
* ]
|
|
287
|
-
*/
|
|
288
|
-
includeSources?: string[];
|
|
289
|
-
/**
|
|
290
|
-
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
|
|
291
|
-
* creating a ZIP of all your source code for Firefox. Patterns are relative to your
|
|
292
|
-
* `config.zip.sourcesRoot`.
|
|
293
|
-
*
|
|
294
|
-
* Hidden files, node_modules, and tests are ignored by default.
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* [
|
|
298
|
-
* "coverage", // Include the coverage directory in the `sourcesRoot`
|
|
299
|
-
* ]
|
|
300
|
-
*/
|
|
301
|
-
excludeSources?: string[];
|
|
302
|
-
/**
|
|
303
|
-
* The Firefox review process requires the extension be buildable from source to make reviewing
|
|
304
|
-
* easier. This field allows you to use private packages without exposing your auth tokens.
|
|
305
|
-
*
|
|
306
|
-
* Just list the name of all the packages you want to download and include in the sources zip.
|
|
307
|
-
* Usually, these will be private packages behind auth tokens, but they don't have to be.
|
|
308
|
-
*
|
|
309
|
-
* All packages listed here will be downloaded to in `.wxt/local_modules/` and an `overrides` or
|
|
310
|
-
* `resolutions` field (depending on your package manager) will be added to the `package.json`,
|
|
311
|
-
* pointing to the downloaded packages.
|
|
312
|
-
*
|
|
313
|
-
* > ***DO NOT include versions or version filters.*** Just the package name. If multiple
|
|
314
|
-
* > versions of a package are present in the project, all versions will be downloaded and
|
|
315
|
-
* > referenced in the package.json correctly.
|
|
316
|
-
*
|
|
317
|
-
* @default []
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* // Correct:
|
|
321
|
-
* ["@scope/package-name", "package-name"]
|
|
322
|
-
*
|
|
323
|
-
* // Incorrect, don't include versions!!!
|
|
324
|
-
* ["@scope/package-name@1.1.3", "package-name@^2"]
|
|
325
|
-
*/
|
|
326
|
-
downloadPackages?: string[];
|
|
327
|
-
/**
|
|
328
|
-
* Compression level to use when zipping files.
|
|
329
|
-
*
|
|
330
|
-
* Levels: 0 (no compression) to 9 (maximum compression).
|
|
331
|
-
*
|
|
332
|
-
* @default 9
|
|
333
|
-
*/
|
|
334
|
-
compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
|
|
338
|
-
* will be removed in v1.0
|
|
339
|
-
*
|
|
340
|
-
* Transform the final manifest before it's written to the file system. Edit the `manifest`
|
|
341
|
-
* parameter directly, do not return a new object. Return values are ignored.
|
|
342
|
-
*
|
|
343
|
-
* @example
|
|
344
|
-
* defineConfig({
|
|
345
|
-
* // Add a CSS-only content script.
|
|
346
|
-
* transformManifest(manifest) {
|
|
347
|
-
* manifest.content_scripts.push({
|
|
348
|
-
* matches: ["*://google.com/*"],
|
|
349
|
-
* css: ["content-scripts/some-example.css"],
|
|
350
|
-
* });
|
|
351
|
-
* }
|
|
352
|
-
* })
|
|
353
|
-
*/
|
|
354
|
-
transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
|
|
355
|
-
analysis?: {
|
|
356
|
-
/**
|
|
357
|
-
* Explicitly include bundle analysis when running `wxt build`. This can be overridden by the
|
|
358
|
-
* command line `--analysis` option.
|
|
359
|
-
*
|
|
360
|
-
* @default false
|
|
361
|
-
*/
|
|
362
|
-
enabled?: boolean;
|
|
363
|
-
/**
|
|
364
|
-
* Set to true to automatically open the `stats.html` file when the build is finished. When building in CI, the browser will never open.
|
|
365
|
-
*
|
|
366
|
-
* @default false
|
|
367
|
-
*/
|
|
368
|
-
open?: boolean;
|
|
369
|
-
/**
|
|
370
|
-
* When running `wxt build --analyze` or setting `analysis.enabled` to true, customize how the
|
|
371
|
-
* bundle will be visualized. See
|
|
372
|
-
* [`rollup-plugin-visualizer`](https://github.com/btd/rollup-plugin-visualizer#how-to-use-generated-files)
|
|
373
|
-
* for more details.
|
|
374
|
-
*
|
|
375
|
-
* @default "treemap"
|
|
376
|
-
*/
|
|
377
|
-
template?: PluginVisualizerOptions['template'];
|
|
378
|
-
/**
|
|
379
|
-
* Name of the output HTML file. Relative to the project's root directory.
|
|
380
|
-
*
|
|
381
|
-
* Changing the filename of the outputFile also effects the names of the artifacts generated
|
|
382
|
-
* when setting `keepArtifacts` to true:
|
|
383
|
-
* - "stats.html" => "stats-*.json"
|
|
384
|
-
* - "stats/bundle.html" => "bundle-*.json"
|
|
385
|
-
* - ".analysis/index.html" => "index-*.json"
|
|
386
|
-
*
|
|
387
|
-
* @default "stats.html"
|
|
388
|
-
*/
|
|
389
|
-
outputFile?: string;
|
|
390
|
-
/**
|
|
391
|
-
* By default, the `stats-*.json` artifacts generated during bundle analysis are deleted. Set to
|
|
392
|
-
* `true` to keep them.
|
|
393
|
-
*
|
|
394
|
-
* One stats file is output per build step.
|
|
395
|
-
*
|
|
396
|
-
* @default false
|
|
397
|
-
*/
|
|
398
|
-
keepArtifacts?: boolean;
|
|
399
|
-
};
|
|
400
|
-
/**
|
|
401
|
-
* Add additional paths to the `.wxt/tsconfig.json`. Use this instead of overwriting the `paths`
|
|
402
|
-
* in the root `tsconfig.json` if you want to add new paths.
|
|
403
|
-
*
|
|
404
|
-
* The key is the import alias and the value is either a relative path to the root directory or an absolute path.
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* {
|
|
408
|
-
* "testing": "src/utils/testing.ts"
|
|
409
|
-
* }
|
|
410
|
-
*/
|
|
411
|
-
alias?: Record<string, string>;
|
|
412
|
-
/**
|
|
413
|
-
* Experimental settings - use with caution.
|
|
414
|
-
*/
|
|
415
|
-
experimental?: {
|
|
416
|
-
/**
|
|
417
|
-
* Whether to use [`webextension-polyfill`](https://www.npmjs.com/package/webextension-polyfill)
|
|
418
|
-
* when importing `browser` from `wxt/browser`.
|
|
419
|
-
*
|
|
420
|
-
* When set to `false`, WXT will export the chrome global instead of the polyfill from
|
|
421
|
-
* `wxt/browser`.
|
|
422
|
-
*
|
|
423
|
-
* You should use `browser` to access the web extension APIs.
|
|
424
|
-
*
|
|
425
|
-
* @experimental This option will remain experimental until Manifest V2 is dead.
|
|
426
|
-
*
|
|
427
|
-
* @default true
|
|
428
|
-
* @example
|
|
429
|
-
* export default defineConfig({
|
|
430
|
-
* experimental: {
|
|
431
|
-
* includeBrowserPolyfill: false
|
|
432
|
-
* }
|
|
433
|
-
* })
|
|
434
|
-
*/
|
|
435
|
-
includeBrowserPolyfill?: boolean;
|
|
436
|
-
/**
|
|
437
|
-
* Method used to import entrypoint files during the build process to extract their options.
|
|
438
|
-
*
|
|
439
|
-
* - "jiti": Simplest and fastest, but doesn't allow using any imported variables outside the entrypoint's main function
|
|
440
|
-
* - "vite-runtime" (unstable): Uses Vite 5.3's new runtime API to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
|
|
441
|
-
* - "vite-node" (unstable): Uses `vite-node` to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
|
|
442
|
-
*
|
|
443
|
-
* @see {@link https://wxt.dev/guide/go-further/entrypoint-side-effects.html|Entrypoint Side-effect Docs}
|
|
444
|
-
*
|
|
445
|
-
* @default "jiti"
|
|
446
|
-
*/
|
|
447
|
-
entrypointImporter?: 'jiti' | 'vite-runtime' | 'vite-node';
|
|
448
|
-
};
|
|
449
|
-
/**
|
|
450
|
-
* Config effecting dev mode only.
|
|
451
|
-
*/
|
|
452
|
-
dev?: {
|
|
453
|
-
server?: {
|
|
454
|
-
/**
|
|
455
|
-
* Port to run the dev server on. Defaults to the first open port from 3000 to 3010.
|
|
456
|
-
*/
|
|
457
|
-
port?: number;
|
|
458
|
-
/**
|
|
459
|
-
* Hostname to run the dev server on.
|
|
460
|
-
*
|
|
461
|
-
* @default "localhost"
|
|
462
|
-
*/
|
|
463
|
-
hostname?: string;
|
|
464
|
-
};
|
|
465
|
-
/**
|
|
466
|
-
* Controls whether a custom keyboard shortcut command, `Alt+R`, is added during dev mode to
|
|
467
|
-
* quickly reload the extension.
|
|
468
|
-
*
|
|
469
|
-
* If false, the shortcut is not added during development.
|
|
470
|
-
*
|
|
471
|
-
* If set to a custom string, you can override the key combo used. See
|
|
472
|
-
* [Chrome's command docs](https://developer.chrome.com/docs/extensions/reference/api/commands)
|
|
473
|
-
* for available options.
|
|
474
|
-
*
|
|
475
|
-
* @default "Alt+R"
|
|
476
|
-
*/
|
|
477
|
-
reloadCommand?: string | false;
|
|
478
|
-
};
|
|
479
|
-
/**
|
|
480
|
-
* Project hooks for running logic during the build process.
|
|
481
|
-
*/
|
|
482
|
-
hooks?: NestedHooks<WxtHooks>;
|
|
483
|
-
/**
|
|
484
|
-
* List of WXT module names to include. Can be the full package name
|
|
485
|
-
* ("wxt-module-analytics"), or just the suffix ("analytics" would resolve to
|
|
486
|
-
* "wxt-module-analytics").
|
|
487
|
-
*/
|
|
488
|
-
modules?: string[];
|
|
489
|
-
}
|
|
490
|
-
interface InlineConfig {
|
|
491
|
-
/**
|
|
492
|
-
* Return custom Vite options from a function. See
|
|
493
|
-
* <https://vitejs.dev/config/shared-options.html>.
|
|
494
|
-
*
|
|
495
|
-
* [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
|
|
496
|
-
* instead of Vite's.
|
|
497
|
-
*
|
|
498
|
-
* This is a function because any vite plugins added need to be recreated for each individual
|
|
499
|
-
* build step, incase they have internal state causing them to fail when reused.
|
|
500
|
-
*/
|
|
501
|
-
vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
|
|
502
|
-
}
|
|
503
|
-
type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
|
|
504
|
-
interface BuildOutput {
|
|
505
|
-
manifest: Manifest.WebExtensionManifest;
|
|
506
|
-
publicAssets: OutputAsset[];
|
|
507
|
-
steps: BuildStepOutput[];
|
|
508
|
-
}
|
|
509
|
-
type OutputFile = OutputChunk | OutputAsset;
|
|
510
|
-
interface OutputChunk {
|
|
511
|
-
type: 'chunk';
|
|
512
|
-
/**
|
|
513
|
-
* Relative, normalized path relative to the output directory.
|
|
514
|
-
*
|
|
515
|
-
* Ex: "content-scripts/overlay.js"
|
|
516
|
-
*/
|
|
517
|
-
fileName: string;
|
|
518
|
-
/**
|
|
519
|
-
* Absolute, normalized paths to all dependencies this chunk relies on.
|
|
520
|
-
*/
|
|
521
|
-
moduleIds: string[];
|
|
522
|
-
}
|
|
523
|
-
interface OutputAsset {
|
|
524
|
-
type: 'asset';
|
|
525
|
-
/**
|
|
526
|
-
* Relative, normalized path relative to the output directory.
|
|
527
|
-
*
|
|
528
|
-
* Ex: "icons/16.png"
|
|
529
|
-
*/
|
|
530
|
-
fileName: string;
|
|
531
|
-
}
|
|
532
|
-
interface BuildStepOutput {
|
|
533
|
-
entrypoints: EntrypointGroup;
|
|
534
|
-
chunks: OutputFile[];
|
|
535
|
-
}
|
|
536
|
-
interface WxtDevServer extends Omit<WxtBuilderServer, 'listen' | 'close'>, ServerInfo {
|
|
537
|
-
/**
|
|
538
|
-
* Stores the current build output of the server.
|
|
539
|
-
*/
|
|
540
|
-
currentOutput: BuildOutput | undefined;
|
|
541
|
-
/**
|
|
542
|
-
* Start the server.
|
|
543
|
-
*/
|
|
544
|
-
start(): Promise<void>;
|
|
545
|
-
/**
|
|
546
|
-
* Stop the server.
|
|
547
|
-
*/
|
|
548
|
-
stop(): Promise<void>;
|
|
549
|
-
/**
|
|
550
|
-
* Close the browser, stop the server, rebuild the entire extension, and start the server again.
|
|
551
|
-
*/
|
|
552
|
-
restart(): Promise<void>;
|
|
553
|
-
/**
|
|
554
|
-
* Transform the HTML for dev mode.
|
|
555
|
-
*/
|
|
556
|
-
transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
|
|
557
|
-
/**
|
|
558
|
-
* Tell the extension to reload by running `browser.runtime.reload`.
|
|
559
|
-
*/
|
|
560
|
-
reloadExtension: () => void;
|
|
561
|
-
/**
|
|
562
|
-
* Tell an extension page to reload.
|
|
563
|
-
*
|
|
564
|
-
* The path is the bundle path, not the input paths, so if the input paths is
|
|
565
|
-
* "src/options/index.html", you would pass "options.html" because that's where it is written to
|
|
566
|
-
* in the dist directory, and where it's available at in the actual extension.
|
|
567
|
-
*
|
|
568
|
-
* @example
|
|
569
|
-
* server.reloadPage("popup.html")
|
|
570
|
-
* server.reloadPage("sandbox.html")
|
|
571
|
-
*/
|
|
572
|
-
reloadPage: (path: string) => void;
|
|
573
|
-
/**
|
|
574
|
-
* Tell the extension to restart a content script.
|
|
575
|
-
*
|
|
576
|
-
* @param payload Information about the content script to reload.
|
|
577
|
-
*/
|
|
578
|
-
reloadContentScript: (payload: ReloadContentScriptPayload) => void;
|
|
579
|
-
/**
|
|
580
|
-
* Grab the latest runner config and restart the browser.
|
|
581
|
-
*/
|
|
582
|
-
restartBrowser: () => void;
|
|
583
|
-
}
|
|
584
|
-
interface ReloadContentScriptPayload {
|
|
585
|
-
registration?: BaseContentScriptEntrypointOptions['registration'];
|
|
586
|
-
contentScript: Omit<Scripting.RegisteredContentScript, 'id'>;
|
|
587
|
-
}
|
|
588
|
-
type TargetBrowser = string;
|
|
589
|
-
type TargetManifestVersion = 2 | 3;
|
|
590
|
-
type UserConfig = Omit<InlineConfig, 'configFile'>;
|
|
591
|
-
interface Logger {
|
|
592
|
-
debug(...args: any[]): void;
|
|
593
|
-
log(...args: any[]): void;
|
|
594
|
-
info(...args: any[]): void;
|
|
595
|
-
warn(...args: any[]): void;
|
|
596
|
-
error(...args: any[]): void;
|
|
597
|
-
fatal(...args: any[]): void;
|
|
598
|
-
success(...args: any[]): void;
|
|
599
|
-
level: LogLevel;
|
|
600
|
-
}
|
|
601
|
-
interface BaseEntrypointOptions {
|
|
602
|
-
/**
|
|
603
|
-
* List of target browsers to include this entrypoint in. Defaults to being included in all
|
|
604
|
-
* builds. Cannot be used with `exclude`. You must choose one of the two options.
|
|
605
|
-
*
|
|
606
|
-
* @default undefined
|
|
607
|
-
*/
|
|
608
|
-
include?: TargetBrowser[];
|
|
609
|
-
/**
|
|
610
|
-
* List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
|
|
611
|
-
* must choose one of the two options.
|
|
612
|
-
*
|
|
613
|
-
* @default undefined
|
|
614
|
-
*/
|
|
615
|
-
exclude?: TargetBrowser[];
|
|
616
|
-
}
|
|
617
|
-
interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
|
|
618
|
-
persistent?: PerBrowserOption<boolean>;
|
|
619
|
-
/**
|
|
620
|
-
* Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
|
|
621
|
-
* reduce the overall size of the bundled extension.
|
|
622
|
-
*
|
|
623
|
-
* When `undefined`, the background is bundled individually into an IIFE format.
|
|
624
|
-
*
|
|
625
|
-
* @default undefined
|
|
626
|
-
*/
|
|
627
|
-
type?: PerBrowserOption<'module'>;
|
|
628
|
-
}
|
|
629
|
-
interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
630
|
-
matches: PerBrowserOption<Manifest.ContentScript['matches']>;
|
|
631
|
-
/**
|
|
632
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
633
|
-
* @default "documentIdle"
|
|
634
|
-
*/
|
|
635
|
-
runAt?: PerBrowserOption<Manifest.ContentScript['run_at']>;
|
|
636
|
-
/**
|
|
637
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
638
|
-
* @default false
|
|
639
|
-
*/
|
|
640
|
-
matchAboutBlank?: PerBrowserOption<Manifest.ContentScript['match_about_blank']>;
|
|
641
|
-
/**
|
|
642
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
643
|
-
* @default []
|
|
644
|
-
*/
|
|
645
|
-
excludeMatches?: PerBrowserOption<Manifest.ContentScript['exclude_matches']>;
|
|
646
|
-
/**
|
|
647
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
648
|
-
* @default []
|
|
649
|
-
*/
|
|
650
|
-
includeGlobs?: PerBrowserOption<Manifest.ContentScript['include_globs']>;
|
|
651
|
-
/**
|
|
652
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
653
|
-
* @default []
|
|
654
|
-
*/
|
|
655
|
-
excludeGlobs?: PerBrowserOption<Manifest.ContentScript['exclude_globs']>;
|
|
656
|
-
/**
|
|
657
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
658
|
-
* @default false
|
|
659
|
-
*/
|
|
660
|
-
allFrames?: PerBrowserOption<Manifest.ContentScript['all_frames']>;
|
|
661
|
-
/**
|
|
662
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
663
|
-
* @default false
|
|
664
|
-
*/
|
|
665
|
-
matchOriginAsFallback?: PerBrowserOption<boolean>;
|
|
666
|
-
/**
|
|
667
|
-
* Customize how imported/generated styles are injected with the content script. Regardless of the
|
|
668
|
-
* mode selected, CSS will always be built and included in the output directory.
|
|
669
|
-
*
|
|
670
|
-
* - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
|
|
671
|
-
* - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
|
|
672
|
-
* onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
|
|
673
|
-
* URL
|
|
674
|
-
* - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
|
|
675
|
-
* calling `createShadowRootUi`
|
|
676
|
-
*
|
|
677
|
-
* @default "manifest"
|
|
678
|
-
*/
|
|
679
|
-
cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
|
|
680
|
-
/**
|
|
681
|
-
* Specify how the content script is registered.
|
|
682
|
-
*
|
|
683
|
-
* - `"manifest"`: The content script will be added to the `content_scripts` entry in the
|
|
684
|
-
* manifest. This is the normal and most well known way of registering a content script.
|
|
685
|
-
* - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
|
|
686
|
-
* responsible for using the scripting API to register/execute the content script
|
|
687
|
-
* dynamically at runtime.
|
|
688
|
-
*
|
|
689
|
-
* @default "manifest"
|
|
690
|
-
*/
|
|
691
|
-
registration?: PerBrowserOption<'manifest' | 'runtime'>;
|
|
692
|
-
}
|
|
693
|
-
interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
694
|
-
/**
|
|
695
|
-
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
696
|
-
*/
|
|
697
|
-
world: 'MAIN';
|
|
698
|
-
}
|
|
699
|
-
interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
700
|
-
/**
|
|
701
|
-
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
702
|
-
* @default "ISOLATED"
|
|
703
|
-
*/
|
|
704
|
-
world?: 'ISOLATED';
|
|
705
|
-
}
|
|
706
|
-
interface PopupEntrypointOptions extends BaseEntrypointOptions {
|
|
707
|
-
/**
|
|
708
|
-
* Defaults to "browser_action" to be equivalent to MV3's "action" key
|
|
709
|
-
*/
|
|
710
|
-
mv2Key?: PerBrowserOption<'browser_action' | 'page_action'>;
|
|
711
|
-
defaultIcon?: Record<string, string>;
|
|
712
|
-
defaultTitle?: PerBrowserOption<string>;
|
|
713
|
-
browserStyle?: PerBrowserOption<boolean>;
|
|
714
|
-
}
|
|
715
|
-
interface OptionsEntrypointOptions extends BaseEntrypointOptions {
|
|
716
|
-
openInTab?: PerBrowserOption<boolean>;
|
|
717
|
-
browserStyle?: PerBrowserOption<boolean>;
|
|
718
|
-
chromeStyle?: PerBrowserOption<boolean>;
|
|
719
|
-
}
|
|
720
|
-
interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
|
|
721
|
-
/**
|
|
722
|
-
* Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
|
|
723
|
-
* @default false
|
|
724
|
-
*/
|
|
725
|
-
openAtInstall?: PerBrowserOption<boolean>;
|
|
726
|
-
/**
|
|
727
|
-
* @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
|
|
728
|
-
*/
|
|
729
|
-
browserStyle?: PerBrowserOption<boolean>;
|
|
730
|
-
defaultIcon?: string | Record<string, string>;
|
|
731
|
-
defaultTitle?: PerBrowserOption<string>;
|
|
732
|
-
}
|
|
733
|
-
interface BaseEntrypoint {
|
|
734
|
-
/**
|
|
735
|
-
* The entrypoint's name. This is the filename or dirname without the type suffix.
|
|
736
|
-
*
|
|
737
|
-
* Examples:
|
|
738
|
-
* - `popup.html` → `popup`
|
|
739
|
-
* - `options/index.html` → `options`
|
|
740
|
-
* - `named.sandbox.html` → `named`
|
|
741
|
-
* - `named.sandbox/index.html` → `named`
|
|
742
|
-
* - `sandbox.html` → `sandbox`
|
|
743
|
-
* - `sandbox/index.html` → `sandbox`
|
|
744
|
-
* - `overlay.content.ts` → `overlay`
|
|
745
|
-
* - `overlay.content/index.ts` → `overlay`
|
|
746
|
-
*
|
|
747
|
-
* The name is used when generating an output file:
|
|
748
|
-
* `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
|
|
749
|
-
*/
|
|
750
|
-
name: string;
|
|
751
|
-
/**
|
|
752
|
-
* Absolute path to the entrypoint's input file.
|
|
753
|
-
*/
|
|
754
|
-
inputPath: string;
|
|
755
|
-
/**
|
|
756
|
-
* Absolute path to the entrypoint's output directory. Can be `wxt.config.outDir` or a
|
|
757
|
-
* subdirectory of it.
|
|
758
|
-
*/
|
|
759
|
-
outputDir: string;
|
|
760
|
-
skipped: boolean;
|
|
761
|
-
}
|
|
762
|
-
interface GenericEntrypoint extends BaseEntrypoint {
|
|
763
|
-
type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
|
|
764
|
-
options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
|
|
765
|
-
}
|
|
766
|
-
interface BackgroundEntrypoint extends BaseEntrypoint {
|
|
767
|
-
type: 'background';
|
|
768
|
-
options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
|
|
769
|
-
}
|
|
770
|
-
interface ContentScriptEntrypoint extends BaseEntrypoint {
|
|
771
|
-
type: 'content-script';
|
|
772
|
-
options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
|
|
773
|
-
}
|
|
774
|
-
interface PopupEntrypoint extends BaseEntrypoint {
|
|
775
|
-
type: 'popup';
|
|
776
|
-
options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
|
|
777
|
-
}
|
|
778
|
-
interface OptionsEntrypoint extends BaseEntrypoint {
|
|
779
|
-
type: 'options';
|
|
780
|
-
options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
|
|
781
|
-
}
|
|
782
|
-
interface SidepanelEntrypoint extends BaseEntrypoint {
|
|
783
|
-
type: 'sidepanel';
|
|
784
|
-
options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
|
|
785
|
-
}
|
|
786
|
-
type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
|
|
787
|
-
type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
788
|
-
type OnContentScriptStopped = (cb: () => void) => void;
|
|
789
|
-
interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
|
|
790
|
-
/**
|
|
791
|
-
* Main function executed when the content script is loaded.
|
|
792
|
-
*
|
|
793
|
-
* When running a content script with `browser.scripting.executeScript`,
|
|
794
|
-
* values returned from this function will be returned in the `executeScript`
|
|
795
|
-
* result as well. Otherwise returning a value does nothing.
|
|
796
|
-
*/
|
|
797
|
-
main(ctx: ContentScriptContext): any | Promise<any>;
|
|
798
|
-
}
|
|
799
|
-
interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
800
|
-
/**
|
|
801
|
-
* Main function executed when the content script is loaded.
|
|
802
|
-
*
|
|
803
|
-
* When running a content script with `browser.scripting.executeScript`,
|
|
804
|
-
* values returned from this function will be returned in the `executeScript`
|
|
805
|
-
* result as well. Otherwise returning a value does nothing.
|
|
806
|
-
*/
|
|
807
|
-
main(): any | Promise<any>;
|
|
808
|
-
}
|
|
809
|
-
type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
810
|
-
interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
811
|
-
/**
|
|
812
|
-
* Main function executed when the background script is started. Cannot be async.
|
|
813
|
-
*/
|
|
814
|
-
main(): void;
|
|
815
|
-
}
|
|
816
|
-
interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
817
|
-
/**
|
|
818
|
-
* Main function executed when the unlisted script is ran.
|
|
819
|
-
*
|
|
820
|
-
* When running a content script with `browser.scripting.executeScript`,
|
|
821
|
-
* values returned from this function will be returned in the `executeScript`
|
|
822
|
-
* result as well. Otherwise returning a value does nothing.
|
|
823
|
-
*/
|
|
824
|
-
main(): any | Promise<any>;
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Either a single value or a map of different browsers to the value for that browser.
|
|
828
|
-
*/
|
|
829
|
-
type PerBrowserOption<T> = T | PerBrowserMap<T>;
|
|
830
|
-
type PerBrowserMap<T> = {
|
|
831
|
-
[browser: TargetBrowser]: T;
|
|
832
|
-
};
|
|
833
|
-
/**
|
|
834
|
-
* Convert `{ key: PerBrowserOption<T> }` to just `{ key: T }`, stripping away the
|
|
835
|
-
* `PerBrowserOption` type for all fields inside the object.
|
|
836
|
-
*
|
|
837
|
-
* A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
|
|
838
|
-
*/
|
|
839
|
-
type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
|
|
840
|
-
[key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
|
|
841
|
-
} & {
|
|
842
|
-
[key in TOmitted]: T[key];
|
|
843
|
-
};
|
|
844
|
-
/**
|
|
845
|
-
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
|
|
846
|
-
* here, they are configured inline.
|
|
847
|
-
*/
|
|
848
|
-
type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
|
|
849
|
-
type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
|
|
850
|
-
interface ConfigEnv {
|
|
851
|
-
/**
|
|
852
|
-
* The build mode passed into the CLI. By default, `wxt` uses `"development"` and `wxt build|zip`
|
|
853
|
-
* uses `"production"`.
|
|
854
|
-
*/
|
|
855
|
-
mode: string;
|
|
856
|
-
/**
|
|
857
|
-
* The command used to run WXT. `"serve"` during development and `"build"` for any other command.
|
|
858
|
-
*/
|
|
859
|
-
command: WxtCommand;
|
|
860
|
-
/**
|
|
861
|
-
* Browser passed in from the CLI via the `-b` or `--browser` flag. Defaults to `"chrome"` when not passed.
|
|
862
|
-
*/
|
|
863
|
-
browser: TargetBrowser;
|
|
864
|
-
/**
|
|
865
|
-
* Manifest version passed in from the CLI via the `--mv2` or `--mv3` flags. When not passed, it depends on the target browser. See
|
|
866
|
-
* [the guide](https://wxt.dev/guide/key-concepts/multiple-browsers.html#target-manifest-version) for more
|
|
867
|
-
* details.
|
|
868
|
-
*/
|
|
869
|
-
manifestVersion: 2 | 3;
|
|
870
|
-
}
|
|
871
|
-
type WxtCommand = 'build' | 'serve';
|
|
872
|
-
/**
|
|
873
|
-
* Configure how the browser starts up.
|
|
874
|
-
*/
|
|
875
|
-
interface ExtensionRunnerConfig {
|
|
876
|
-
/**
|
|
877
|
-
* Whether or not to open the browser with the extension installed in dev mode.
|
|
878
|
-
*
|
|
879
|
-
* @default false
|
|
880
|
-
*/
|
|
881
|
-
disabled?: boolean;
|
|
882
|
-
/**
|
|
883
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#browser-console
|
|
884
|
-
*/
|
|
885
|
-
openConsole?: boolean;
|
|
886
|
-
/**
|
|
887
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#devtools
|
|
888
|
-
*/
|
|
889
|
-
openDevtools?: boolean;
|
|
890
|
-
/**
|
|
891
|
-
* List of browser names and the binary that should be used to open the browser.
|
|
892
|
-
*
|
|
893
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
|
|
894
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
|
|
895
|
-
*/
|
|
896
|
-
binaries?: Record<string, string>;
|
|
897
|
-
/**
|
|
898
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
|
|
899
|
-
*/
|
|
900
|
-
firefoxProfile?: string;
|
|
901
|
-
/**
|
|
902
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
903
|
-
*/
|
|
904
|
-
chromiumProfile?: string;
|
|
905
|
-
/**
|
|
906
|
-
* An map of chrome preferences from https://chromium.googlesource.com/chromium/src/+/main/chrome/common/pref_names.h
|
|
907
|
-
*
|
|
908
|
-
* @example
|
|
909
|
-
* // change your downloads directory
|
|
910
|
-
* {
|
|
911
|
-
* download: {
|
|
912
|
-
* default_directory: "/my/custom/dir",
|
|
913
|
-
* },
|
|
914
|
-
* }
|
|
915
|
-
*
|
|
916
|
-
* @default
|
|
917
|
-
* // Enable dev mode and allow content script sourcemaps
|
|
918
|
-
* {
|
|
919
|
-
* devtools: {
|
|
920
|
-
* synced_preferences_sync_disabled: {
|
|
921
|
-
* skipContentScripts: false,
|
|
922
|
-
* },
|
|
923
|
-
* }
|
|
924
|
-
* extensions: {
|
|
925
|
-
* ui: {
|
|
926
|
-
* developer_mode: true,
|
|
927
|
-
* },
|
|
928
|
-
* }
|
|
929
|
-
* }
|
|
930
|
-
*/
|
|
931
|
-
chromiumPref?: string;
|
|
932
|
-
/**
|
|
933
|
-
* By default, chrome opens a random port for debugging. Set this value to use a specific port.
|
|
934
|
-
*/
|
|
935
|
-
chromiumPort?: number;
|
|
936
|
-
/**
|
|
937
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
938
|
-
*/
|
|
939
|
-
firefoxPrefs?: Record<string, string>;
|
|
940
|
-
/**
|
|
941
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
|
|
942
|
-
*/
|
|
943
|
-
firefoxArgs?: string[];
|
|
944
|
-
/**
|
|
945
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
|
|
946
|
-
*/
|
|
947
|
-
chromiumArgs?: string[];
|
|
948
|
-
/**
|
|
949
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#start-url
|
|
950
|
-
*/
|
|
951
|
-
startUrls?: string[];
|
|
952
|
-
/**
|
|
953
|
-
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#keep-profile-changes
|
|
954
|
-
*/
|
|
955
|
-
keepProfileChanges?: boolean;
|
|
956
|
-
}
|
|
957
|
-
interface WxtBuilder {
|
|
958
|
-
/**
|
|
959
|
-
* Name of tool used to build. Ex: "Vite" or "Webpack".
|
|
960
|
-
*/
|
|
961
|
-
name: string;
|
|
962
|
-
/**
|
|
963
|
-
* Version of tool used to build. Ex: "5.0.2"
|
|
964
|
-
*/
|
|
965
|
-
version: string;
|
|
966
|
-
/**
|
|
967
|
-
* Import the entrypoint file, returning the default export containing the options.
|
|
968
|
-
*/
|
|
969
|
-
importEntrypoint<T>(path: string): Promise<T>;
|
|
970
|
-
/**
|
|
971
|
-
* Build a single entrypoint group. This is effectively one of the multiple "steps" during the
|
|
972
|
-
* build process.
|
|
973
|
-
*/
|
|
974
|
-
build(group: EntrypointGroup): Promise<BuildStepOutput>;
|
|
975
|
-
/**
|
|
976
|
-
* Start a dev server at the provided port.
|
|
977
|
-
*/
|
|
978
|
-
createServer(info: ServerInfo): Promise<WxtBuilderServer>;
|
|
979
|
-
}
|
|
980
|
-
interface WxtBuilderServer {
|
|
981
|
-
/**
|
|
982
|
-
* Start the server.
|
|
983
|
-
*/
|
|
984
|
-
listen(): Promise<void>;
|
|
985
|
-
/**
|
|
986
|
-
* Stop the server.
|
|
987
|
-
*/
|
|
988
|
-
close(): Promise<void>;
|
|
989
|
-
/**
|
|
990
|
-
* Transform the HTML for dev mode.
|
|
991
|
-
*/
|
|
992
|
-
transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
|
|
993
|
-
/**
|
|
994
|
-
* The web socket server used to communicate with the extension.
|
|
995
|
-
*/
|
|
996
|
-
ws: {
|
|
997
|
-
/**
|
|
998
|
-
* Send a message via the server's websocket, with an optional payload.
|
|
999
|
-
*
|
|
1000
|
-
* @example
|
|
1001
|
-
* ws.send("wxt:reload-extension");
|
|
1002
|
-
* ws.send("wxt:reload-content-script", { ... });
|
|
1003
|
-
*/
|
|
1004
|
-
send(message: string, payload?: any): void;
|
|
1005
|
-
/**
|
|
1006
|
-
* Listen for messages over the server's websocket.
|
|
1007
|
-
*/
|
|
1008
|
-
on(message: string, cb: (payload: any) => void): void;
|
|
1009
|
-
};
|
|
1010
|
-
/**
|
|
1011
|
-
* Chokidar file watcher instance.
|
|
1012
|
-
*/
|
|
1013
|
-
watcher: FSWatcher;
|
|
1014
|
-
}
|
|
1015
|
-
interface ServerInfo {
|
|
1016
|
-
/**
|
|
1017
|
-
* Ex: `3000`
|
|
1018
|
-
*/
|
|
1019
|
-
port: number;
|
|
1020
|
-
/**
|
|
1021
|
-
* Ex: `"localhost"`
|
|
1022
|
-
*/
|
|
1023
|
-
hostname: string;
|
|
1024
|
-
/**
|
|
1025
|
-
* Ex: `"http://localhost:3000"`
|
|
1026
|
-
*/
|
|
1027
|
-
origin: string;
|
|
1028
|
-
}
|
|
1029
|
-
type HookResult = Promise<void> | void;
|
|
1030
|
-
interface WxtHooks {
|
|
1031
|
-
/**
|
|
1032
|
-
* Called when WXT has created Vite's config for a build step. Useful if you
|
|
1033
|
-
* want to add plugins or update the vite config per entrypoint group.
|
|
1034
|
-
*
|
|
1035
|
-
* @param entrypoints The list of entrypoints being built with the provided config.
|
|
1036
|
-
* @param viteConfig The config that will be used for the dev server.
|
|
1037
|
-
*/
|
|
1038
|
-
'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
|
|
1039
|
-
/**
|
|
1040
|
-
* Called when WXT has created Vite's config for the dev server. Useful if
|
|
1041
|
-
* you want to add plugins or update the vite config per entrypoint group.
|
|
1042
|
-
*
|
|
1043
|
-
* @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
|
|
1044
|
-
*/
|
|
1045
|
-
'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
|
|
1046
|
-
}
|
|
1047
|
-
interface WxtHooks {
|
|
1048
|
-
/**
|
|
1049
|
-
* Called after WXT initialization, when the WXT instance is ready to work.
|
|
1050
|
-
* @param wxt The configured WXT object
|
|
1051
|
-
* @returns Promise
|
|
1052
|
-
*/
|
|
1053
|
-
ready: (wxt: Wxt) => HookResult;
|
|
1054
|
-
/**
|
|
1055
|
-
* Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
|
|
1056
|
-
* addition of custom references and declarations in wxt.d.ts, or directly
|
|
1057
|
-
* modifying the options in `tsconfig.json`.
|
|
1058
|
-
*
|
|
1059
|
-
* @example
|
|
1060
|
-
* wxt.hooks.hook("prepare:types", (wxt, entries) => {
|
|
1061
|
-
* // Add a file, ".wxt/types/example.d.ts", that defines a global
|
|
1062
|
-
* // variable called "example" in the TS project.
|
|
1063
|
-
* entries.push({
|
|
1064
|
-
* path: "types/example.d.ts",
|
|
1065
|
-
* textContent: "declare const a: string;",
|
|
1066
|
-
* tsReference: true,
|
|
1067
|
-
* });
|
|
1068
|
-
* })
|
|
1069
|
-
*/
|
|
1070
|
-
'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
|
|
1071
|
-
/**
|
|
1072
|
-
* Called before the build is started in both dev mode and build mode.
|
|
1073
|
-
*
|
|
1074
|
-
* @param wxt The configured WXT object
|
|
1075
|
-
*/
|
|
1076
|
-
'build:before': (wxt: Wxt) => HookResult;
|
|
1077
|
-
/**
|
|
1078
|
-
* Called once the build process has finished.
|
|
1079
|
-
* @param wxt The configured WXT object
|
|
1080
|
-
* @param output The results of the build
|
|
1081
|
-
*/
|
|
1082
|
-
'build:done': (wxt: Wxt, output: Readonly<BuildOutput>) => HookResult;
|
|
1083
|
-
/**
|
|
1084
|
-
* Called once the manifest has been generated. Used to transform the manifest by reference before
|
|
1085
|
-
* it is written to the output directory.
|
|
1086
|
-
* @param wxt The configured WXT object
|
|
1087
|
-
* @param manifest The manifest that was generated
|
|
1088
|
-
*/
|
|
1089
|
-
'build:manifestGenerated': (wxt: Wxt, manifest: Manifest.WebExtensionManifest) => HookResult;
|
|
1090
|
-
/**
|
|
1091
|
-
* Called once all entrypoints have been loaded from the `entrypointsDir`.
|
|
1092
|
-
* @param wxt The configured WXT object
|
|
1093
|
-
* @param entrypoints The list of entrypoints to be built
|
|
1094
|
-
*/
|
|
1095
|
-
'entrypoints:resolved': (wxt: Wxt, entrypoints: Entrypoint[]) => HookResult;
|
|
1096
|
-
/**
|
|
1097
|
-
* Called once all entrypoints have been grouped into their build groups.
|
|
1098
|
-
* @param wxt The configured WXT object
|
|
1099
|
-
* @param entrypoints The list of groups to build in each build step
|
|
1100
|
-
*/
|
|
1101
|
-
'entrypoints:grouped': (wxt: Wxt, groups: EntrypointGroup[]) => HookResult;
|
|
1102
|
-
/**
|
|
1103
|
-
* Called when public assets are found. You can modify the `files` list by
|
|
1104
|
-
* reference to add or remove public files.
|
|
1105
|
-
* @param wxt The configured WXT object
|
|
1106
|
-
* @param entrypoints The list of files that will be copied into the output directory
|
|
1107
|
-
*/
|
|
1108
|
-
'build:publicAssets': (wxt: Wxt, files: ResolvedPublicFile[]) => HookResult;
|
|
1109
|
-
}
|
|
1110
|
-
interface Wxt {
|
|
1111
|
-
config: ResolvedConfig;
|
|
1112
|
-
hooks: Hookable<WxtHooks>;
|
|
1113
|
-
/**
|
|
1114
|
-
* Alias for config.logger
|
|
1115
|
-
*/
|
|
1116
|
-
logger: Logger;
|
|
1117
|
-
/**
|
|
1118
|
-
* Reload config file and update the `config` field with the result.
|
|
1119
|
-
*/
|
|
1120
|
-
reloadConfig: () => Promise<void>;
|
|
1121
|
-
/**
|
|
1122
|
-
* Package manager utilities.
|
|
1123
|
-
*/
|
|
1124
|
-
pm: WxtPackageManager;
|
|
1125
|
-
/**
|
|
1126
|
-
* If the dev server was started, it will be availble.
|
|
1127
|
-
*/
|
|
1128
|
-
server?: WxtDevServer;
|
|
1129
|
-
/**
|
|
1130
|
-
* The module in charge of executing all the build steps.
|
|
1131
|
-
*/
|
|
1132
|
-
builder: WxtBuilder;
|
|
1133
|
-
}
|
|
1134
|
-
interface ResolvedConfig {
|
|
1135
|
-
vite: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
|
|
1136
|
-
}
|
|
1137
|
-
interface ResolvedConfig {
|
|
1138
|
-
root: string;
|
|
1139
|
-
srcDir: string;
|
|
1140
|
-
publicDir: string;
|
|
1141
|
-
/**
|
|
1142
|
-
* Absolute path pointing to `.wxt` directory in project root.
|
|
1143
|
-
* @example
|
|
1144
|
-
* "/path/to/project/.wxt"
|
|
1145
|
-
*/
|
|
1146
|
-
wxtDir: string;
|
|
1147
|
-
typesDir: string;
|
|
1148
|
-
entrypointsDir: string;
|
|
1149
|
-
modulesDir: string;
|
|
1150
|
-
filterEntrypoints?: Set<string>;
|
|
1151
|
-
/**
|
|
1152
|
-
* Absolute path to the `.output` directory
|
|
1153
|
-
* @example
|
|
1154
|
-
* "/path/to/project/.output"
|
|
1155
|
-
*/
|
|
1156
|
-
outBaseDir: string;
|
|
1157
|
-
/**
|
|
1158
|
-
* Absolute path to the target output directory.
|
|
1159
|
-
* @example
|
|
1160
|
-
* "/path/to/project/.output/chrome-mv3"
|
|
1161
|
-
*/
|
|
1162
|
-
outDir: string;
|
|
1163
|
-
debug: boolean;
|
|
1164
|
-
/**
|
|
1165
|
-
* Absolute path pointing to the `node_modules/wxt` directory, wherever WXT is installed.
|
|
1166
|
-
*/
|
|
1167
|
-
wxtModuleDir: string;
|
|
1168
|
-
mode: string;
|
|
1169
|
-
command: WxtCommand;
|
|
1170
|
-
browser: TargetBrowser;
|
|
1171
|
-
manifestVersion: TargetManifestVersion;
|
|
1172
|
-
env: ConfigEnv;
|
|
1173
|
-
logger: Logger;
|
|
1174
|
-
imports: false | WxtResolvedUnimportOptions;
|
|
1175
|
-
manifest: UserManifest;
|
|
1176
|
-
fsCache: FsCache;
|
|
1177
|
-
runnerConfig: ResolvedConfig$1<ExtensionRunnerConfig>;
|
|
1178
|
-
zip: {
|
|
1179
|
-
name?: string;
|
|
1180
|
-
artifactTemplate: string;
|
|
1181
|
-
sourcesTemplate: string;
|
|
1182
|
-
includeSources: string[];
|
|
1183
|
-
excludeSources: string[];
|
|
1184
|
-
sourcesRoot: string;
|
|
1185
|
-
downloadedPackagesDir: string;
|
|
1186
|
-
downloadPackages: string[];
|
|
1187
|
-
compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
1188
|
-
};
|
|
1189
|
-
/**
|
|
1190
|
-
* @deprecated Use `build:manifestGenerated` hook instead.
|
|
1191
|
-
*/
|
|
1192
|
-
transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
|
|
1193
|
-
analysis: {
|
|
1194
|
-
enabled: boolean;
|
|
1195
|
-
open: boolean;
|
|
1196
|
-
template: NonNullable<PluginVisualizerOptions['template']>;
|
|
1197
|
-
/** Absolute file path to the `stats.html` file */
|
|
1198
|
-
outputFile: string;
|
|
1199
|
-
/** The directory where the final `stats.html` file is located */
|
|
1200
|
-
outputDir: string;
|
|
1201
|
-
/** Name of the `stats.html` file, minus ".html" */
|
|
1202
|
-
outputName: string;
|
|
1203
|
-
keepArtifacts: boolean;
|
|
1204
|
-
};
|
|
1205
|
-
userConfigMetadata: Omit<ResolvedConfig$1<UserConfig>, 'config'>;
|
|
1206
|
-
/**
|
|
1207
|
-
* Import aliases to absolute paths.
|
|
1208
|
-
*/
|
|
1209
|
-
alias: Record<string, string>;
|
|
1210
|
-
experimental: {
|
|
1211
|
-
includeBrowserPolyfill: boolean;
|
|
1212
|
-
entrypointImporter: 'jiti' | 'vite-runtime' | 'vite-node';
|
|
1213
|
-
};
|
|
1214
|
-
dev: {
|
|
1215
|
-
/** Only defined during dev command */
|
|
1216
|
-
server?: {
|
|
1217
|
-
port: number;
|
|
1218
|
-
hostname: string;
|
|
1219
|
-
};
|
|
1220
|
-
reloadCommand: string | false;
|
|
1221
|
-
};
|
|
1222
|
-
hooks: NestedHooks<WxtHooks>;
|
|
1223
|
-
builtinModules: WxtModule<any>[];
|
|
1224
|
-
userModules: WxtModuleWithMetadata<any>[];
|
|
1225
|
-
/**
|
|
1226
|
-
* An array of string to import plugins from. These paths should be
|
|
1227
|
-
* resolvable by vite, and they should `export default defineWxtPlugin(...)`.
|
|
1228
|
-
*
|
|
1229
|
-
* @example
|
|
1230
|
-
* ["@wxt-dev/module-vue/plugin", "wxt-module-google-analytics/plugin"]
|
|
1231
|
-
*/
|
|
1232
|
-
plugins: string[];
|
|
1233
|
-
}
|
|
1234
|
-
interface FsCache {
|
|
1235
|
-
set(key: string, value: string): Promise<void>;
|
|
1236
|
-
get(key: string): Promise<string | undefined>;
|
|
1237
|
-
}
|
|
1238
|
-
interface ExtensionRunner {
|
|
1239
|
-
openBrowser(): Promise<void>;
|
|
1240
|
-
closeBrowser(): Promise<void>;
|
|
1241
|
-
}
|
|
1242
|
-
type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
|
1243
|
-
interface Eslintrc {
|
|
1244
|
-
/**
|
|
1245
|
-
* When true, generates a file that can be used by ESLint to know which variables are valid globals.
|
|
1246
|
-
*
|
|
1247
|
-
* - `false`: Don't generate the file.
|
|
1248
|
-
* - `'auto'`: Check if eslint is installed, and if it is, generate a compatible config file.
|
|
1249
|
-
* - `true`: Same as `8`.
|
|
1250
|
-
* - `8`: Generate a config file compatible with ESLint 8.
|
|
1251
|
-
* - `9`: Generate a config file compatible with ESLint 9.
|
|
1252
|
-
*
|
|
1253
|
-
* @default 'auto'
|
|
1254
|
-
*/
|
|
1255
|
-
enabled?: false | true | 'auto' | 8 | 9;
|
|
1256
|
-
/**
|
|
1257
|
-
* File path to save the generated eslint config.
|
|
1258
|
-
*
|
|
1259
|
-
* Default depends on version of ESLint used:
|
|
1260
|
-
* - 9 and above: './.wxt/eslint-auto-imports.mjs'
|
|
1261
|
-
* - 8 and below: './.wxt/eslintrc-auto-import.json'
|
|
1262
|
-
*/
|
|
1263
|
-
filePath?: string;
|
|
1264
|
-
/**
|
|
1265
|
-
* @default true
|
|
1266
|
-
*/
|
|
1267
|
-
globalsPropValue?: EslintGlobalsPropValue;
|
|
1268
|
-
}
|
|
1269
|
-
interface ResolvedEslintrc {
|
|
1270
|
-
/** False if disabled, otherwise the major version of ESLint installed */
|
|
1271
|
-
enabled: false | 8 | 9;
|
|
1272
|
-
/** Absolute path */
|
|
1273
|
-
filePath: string;
|
|
1274
|
-
globalsPropValue: EslintGlobalsPropValue;
|
|
1275
|
-
}
|
|
1276
|
-
type WxtUnimportOptions = Partial<UnimportOptions> & {
|
|
1277
|
-
/**
|
|
1278
|
-
* When using ESLint, auto-imported variables are linted as "undeclared
|
|
1279
|
-
* globals". This option lets you configure a base eslintrc that, when
|
|
1280
|
-
* extended, fixes these lint errors.
|
|
1281
|
-
*
|
|
1282
|
-
* See <https://wxt.dev/guide/key-concepts/auto-imports.html#eslint>
|
|
1283
|
-
*/
|
|
1284
|
-
eslintrc?: Eslintrc;
|
|
1285
|
-
};
|
|
1286
|
-
type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
|
|
1287
|
-
eslintrc: ResolvedEslintrc;
|
|
1288
|
-
};
|
|
1289
|
-
/**
|
|
1290
|
-
* Package management utils built on top of [`nypm`](https://www.npmjs.com/package/nypm)
|
|
1291
|
-
*/
|
|
1292
|
-
interface WxtPackageManager extends Nypm.PackageManager {
|
|
1293
|
-
addDependency: typeof Nypm.addDependency;
|
|
1294
|
-
addDevDependency: typeof Nypm.addDevDependency;
|
|
1295
|
-
ensureDependencyInstalled: typeof Nypm.ensureDependencyInstalled;
|
|
1296
|
-
installDependencies: typeof Nypm.installDependencies;
|
|
1297
|
-
removeDependency: typeof Nypm.removeDependency;
|
|
1298
|
-
/**
|
|
1299
|
-
* Download a package's TGZ file and move it into the `downloadDir`. Use's `npm pack <name>`, so
|
|
1300
|
-
* you must have setup authorization in `.npmrc` file, regardless of the package manager used.
|
|
1301
|
-
*
|
|
1302
|
-
* @param id Name of the package to download, can include a version (like `wxt@0.17.1`)
|
|
1303
|
-
* @param downloadDir Where to store the package.
|
|
1304
|
-
* @returns Absolute path to downloaded file.
|
|
1305
|
-
*/
|
|
1306
|
-
downloadDependency: (id: string, downloadDir: string) => Promise<string>;
|
|
1307
|
-
/**
|
|
1308
|
-
* Run `npm ls`, `pnpm ls`, or `bun pm ls`, or `yarn list` and return the results.
|
|
1309
|
-
*
|
|
1310
|
-
* WARNING: Yarn always returns all dependencies
|
|
1311
|
-
*/
|
|
1312
|
-
listDependencies: (options?: {
|
|
1313
|
-
cwd?: string;
|
|
1314
|
-
all?: boolean;
|
|
1315
|
-
}) => Promise<Dependency[]>;
|
|
1316
|
-
/**
|
|
1317
|
-
* Key used to override package versions. Sometimes called "resolutions".
|
|
1318
|
-
*/
|
|
1319
|
-
overridesKey: string;
|
|
1320
|
-
}
|
|
1321
|
-
interface Dependency {
|
|
1322
|
-
name: string;
|
|
1323
|
-
version: string;
|
|
1324
|
-
}
|
|
1325
|
-
type WxtModuleOptions = Record<string, any>;
|
|
1326
|
-
type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions?: TOptions) => void | Promise<void>;
|
|
1327
|
-
interface WxtModule<TOptions extends WxtModuleOptions> {
|
|
1328
|
-
name?: string;
|
|
1329
|
-
/**
|
|
1330
|
-
* Key for users to pass options into your module from their `wxt.config.ts` file.
|
|
1331
|
-
*/
|
|
1332
|
-
configKey?: string;
|
|
1333
|
-
/**
|
|
1334
|
-
* Provide a list of imports to add to auto-imports.
|
|
1335
|
-
*/
|
|
1336
|
-
imports?: Import[];
|
|
1337
|
-
/**
|
|
1338
|
-
* Alternative to adding hooks in setup function with `wxt.hooks`. Hooks are
|
|
1339
|
-
* added before the `setup` function is called.
|
|
1340
|
-
*/
|
|
1341
|
-
hooks?: WxtHooks;
|
|
1342
|
-
/**
|
|
1343
|
-
* A custom function that can be used to setup hooks and call module-specific
|
|
1344
|
-
* APIs.
|
|
1345
|
-
*/
|
|
1346
|
-
setup?: WxtModuleSetup<TOptions>;
|
|
1347
|
-
}
|
|
1348
|
-
interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtModule<TOptions> {
|
|
1349
|
-
type: 'local' | 'node_module';
|
|
1350
|
-
id: string;
|
|
1351
|
-
}
|
|
1352
|
-
type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
|
|
1353
|
-
interface ResolvedBasePublicFile {
|
|
1354
|
-
/**
|
|
1355
|
-
* The relative path in the output directory to copy the file to.
|
|
1356
|
-
* @example
|
|
1357
|
-
* "content-scripts/base-styles.css"
|
|
1358
|
-
*/
|
|
1359
|
-
relativeDest: string;
|
|
1360
|
-
}
|
|
1361
|
-
interface CopiedPublicFile extends ResolvedBasePublicFile {
|
|
1362
|
-
/**
|
|
1363
|
-
* The absolute path to the file that will be copied to the output directory.
|
|
1364
|
-
* @example
|
|
1365
|
-
* "/path/to/any/file.css"
|
|
1366
|
-
*/
|
|
1367
|
-
absoluteSrc: string;
|
|
1368
|
-
}
|
|
1369
|
-
interface GeneratedPublicFile extends ResolvedBasePublicFile {
|
|
1370
|
-
/**
|
|
1371
|
-
* Text to write to the file.
|
|
1372
|
-
*/
|
|
1373
|
-
contents: string;
|
|
1374
|
-
}
|
|
1375
|
-
type WxtPlugin = () => void;
|
|
1376
|
-
type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
|
|
1377
|
-
/**
|
|
1378
|
-
* Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
|
|
1379
|
-
*/
|
|
1380
|
-
interface WxtDirTypeReferenceEntry {
|
|
1381
|
-
module: string;
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Represents a file to be written to the project's `.wxt/` directory.
|
|
1385
|
-
*/
|
|
1386
|
-
interface WxtDirFileEntry {
|
|
1387
|
-
/**
|
|
1388
|
-
* Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
|
|
1389
|
-
*/
|
|
1390
|
-
path: string;
|
|
1391
|
-
/**
|
|
1392
|
-
* The text that will be written to the file.
|
|
1393
|
-
*/
|
|
1394
|
-
text: string;
|
|
1395
|
-
/**
|
|
1396
|
-
* Set to `true` to add a reference to this file in `.wxt/wxt.d.ts`.
|
|
1397
|
-
*/
|
|
1398
|
-
tsReference?: boolean;
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, ResolvedBasePublicFile as ab, CopiedPublicFile as ac, GeneratedPublicFile as ad, WxtPlugin as ae, WxtDirEntry as af, WxtDirTypeReferenceEntry as ag, WxtDirFileEntry as ah, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
|