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
|
@@ -1,133 +1,14 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import { Manifest, Scripting } from '
|
|
1
|
+
import type * as vite from 'vite';
|
|
2
|
+
import type { Manifest, Scripting } from 'wxt/browser';
|
|
3
3
|
import { UnimportOptions, Import } from 'unimport';
|
|
4
4
|
import { LogLevel } from 'consola';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
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 {
|
|
5
|
+
import type { ContentScriptContext } from './client/content-scripts/content-script-context';
|
|
6
|
+
import type { PluginVisualizerOptions } from '@aklinker1/rollup-plugin-visualizer';
|
|
7
|
+
import type { FSWatcher } from 'chokidar';
|
|
8
|
+
import { ResolvedConfig as C12ResolvedConfig } from 'c12';
|
|
9
|
+
import { Hookable, NestedHooks } from 'hookable';
|
|
10
|
+
import type * as Nypm from 'nypm';
|
|
11
|
+
export interface InlineConfig {
|
|
131
12
|
/**
|
|
132
13
|
* Your project's root directory containing the `package.json` used to fill out the
|
|
133
14
|
* `manifest.json`.
|
|
@@ -409,43 +290,34 @@ interface InlineConfig {
|
|
|
409
290
|
* }
|
|
410
291
|
*/
|
|
411
292
|
alias?: Record<string, string>;
|
|
293
|
+
/**
|
|
294
|
+
* Which extension API to use.
|
|
295
|
+
*
|
|
296
|
+
* - `"webextension-polyfill"`: Use `browser` and types from [`webextension-polyfill`](https://www.npmjs.com/package/webextension-polyfill).
|
|
297
|
+
* - `"chrome"` (unstable): Use the regular `chrome` (or `browser` for Firefox/Safari) globals provided by the browser. Types provided by [`@types/chrome`](https://www.npmjs.com/package/@types/chrome), make sure to install the package or types won't work.
|
|
298
|
+
*
|
|
299
|
+
* @default "webextension-polyfill"
|
|
300
|
+
* @since 0.19.0
|
|
301
|
+
*/
|
|
302
|
+
extensionApi?: 'webextension-polyfill' | 'chrome';
|
|
303
|
+
/**
|
|
304
|
+
* @deprecated Will be removed in v0.20.0, please migrate to using `vite-node`, the new default.
|
|
305
|
+
*
|
|
306
|
+
* Method used to import entrypoint files during the build process to extract their options.
|
|
307
|
+
*
|
|
308
|
+
* - `"vite-node"` (default as of 0.19.0): Uses `vite-node` to import the entrypoints. Automatically includes vite config based on your wxt.config.ts file
|
|
309
|
+
* - `"jiti"`: Simplest and fastest, but doesn't allow using any imported variables outside the entrypoint's main function
|
|
310
|
+
*
|
|
311
|
+
* @see {@link https://wxt.dev/guide/go-further/entrypoint-importers.html|Entrypoint Importers}
|
|
312
|
+
*
|
|
313
|
+
* @default "vite-node"
|
|
314
|
+
* @since 0.19.0
|
|
315
|
+
*/
|
|
316
|
+
entrypointLoader?: 'vite-node' | 'jiti';
|
|
412
317
|
/**
|
|
413
318
|
* Experimental settings - use with caution.
|
|
414
319
|
*/
|
|
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
|
-
};
|
|
320
|
+
experimental?: {};
|
|
449
321
|
/**
|
|
450
322
|
* Config effecting dev mode only.
|
|
451
323
|
*/
|
|
@@ -487,7 +359,7 @@ interface InlineConfig {
|
|
|
487
359
|
*/
|
|
488
360
|
modules?: string[];
|
|
489
361
|
}
|
|
490
|
-
interface InlineConfig {
|
|
362
|
+
export interface InlineConfig {
|
|
491
363
|
/**
|
|
492
364
|
* Return custom Vite options from a function. See
|
|
493
365
|
* <https://vitejs.dev/config/shared-options.html>.
|
|
@@ -500,14 +372,34 @@ interface InlineConfig {
|
|
|
500
372
|
*/
|
|
501
373
|
vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
|
|
502
374
|
}
|
|
503
|
-
|
|
504
|
-
|
|
375
|
+
export interface ResolvedConfig {
|
|
376
|
+
vite: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
|
|
377
|
+
}
|
|
378
|
+
export type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
|
|
379
|
+
export interface WxtHooks {
|
|
380
|
+
/**
|
|
381
|
+
* Called when WXT has created Vite's config for a build step. Useful if you
|
|
382
|
+
* want to add plugins or update the vite config per entrypoint group.
|
|
383
|
+
*
|
|
384
|
+
* @param entrypoints The list of entrypoints being built with the provided config.
|
|
385
|
+
* @param viteConfig The config that will be used for the dev server.
|
|
386
|
+
*/
|
|
387
|
+
'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
|
|
388
|
+
/**
|
|
389
|
+
* Called when WXT has created Vite's config for the dev server. Useful if
|
|
390
|
+
* you want to add plugins or update the vite config per entrypoint group.
|
|
391
|
+
*
|
|
392
|
+
* @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
|
|
393
|
+
*/
|
|
394
|
+
'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
|
|
395
|
+
}
|
|
396
|
+
export interface BuildOutput {
|
|
505
397
|
manifest: Manifest.WebExtensionManifest;
|
|
506
398
|
publicAssets: OutputAsset[];
|
|
507
399
|
steps: BuildStepOutput[];
|
|
508
400
|
}
|
|
509
|
-
type OutputFile = OutputChunk | OutputAsset;
|
|
510
|
-
interface OutputChunk {
|
|
401
|
+
export type OutputFile = OutputChunk | OutputAsset;
|
|
402
|
+
export interface OutputChunk {
|
|
511
403
|
type: 'chunk';
|
|
512
404
|
/**
|
|
513
405
|
* Relative, normalized path relative to the output directory.
|
|
@@ -520,7 +412,7 @@ interface OutputChunk {
|
|
|
520
412
|
*/
|
|
521
413
|
moduleIds: string[];
|
|
522
414
|
}
|
|
523
|
-
interface OutputAsset {
|
|
415
|
+
export interface OutputAsset {
|
|
524
416
|
type: 'asset';
|
|
525
417
|
/**
|
|
526
418
|
* Relative, normalized path relative to the output directory.
|
|
@@ -529,11 +421,11 @@ interface OutputAsset {
|
|
|
529
421
|
*/
|
|
530
422
|
fileName: string;
|
|
531
423
|
}
|
|
532
|
-
interface BuildStepOutput {
|
|
424
|
+
export interface BuildStepOutput {
|
|
533
425
|
entrypoints: EntrypointGroup;
|
|
534
426
|
chunks: OutputFile[];
|
|
535
427
|
}
|
|
536
|
-
interface WxtDevServer extends Omit<WxtBuilderServer, 'listen' | 'close'>, ServerInfo {
|
|
428
|
+
export interface WxtDevServer extends Omit<WxtBuilderServer, 'listen' | 'close'>, ServerInfo {
|
|
537
429
|
/**
|
|
538
430
|
* Stores the current build output of the server.
|
|
539
431
|
*/
|
|
@@ -581,14 +473,14 @@ interface WxtDevServer extends Omit<WxtBuilderServer, 'listen' | 'close'>, Serve
|
|
|
581
473
|
*/
|
|
582
474
|
restartBrowser: () => void;
|
|
583
475
|
}
|
|
584
|
-
interface ReloadContentScriptPayload {
|
|
476
|
+
export interface ReloadContentScriptPayload {
|
|
585
477
|
registration?: BaseContentScriptEntrypointOptions['registration'];
|
|
586
478
|
contentScript: Omit<Scripting.RegisteredContentScript, 'id'>;
|
|
587
479
|
}
|
|
588
|
-
type TargetBrowser = string;
|
|
589
|
-
type TargetManifestVersion = 2 | 3;
|
|
590
|
-
type UserConfig = Omit<InlineConfig, 'configFile'>;
|
|
591
|
-
interface Logger {
|
|
480
|
+
export type TargetBrowser = string;
|
|
481
|
+
export type TargetManifestVersion = 2 | 3;
|
|
482
|
+
export type UserConfig = Omit<InlineConfig, 'configFile'>;
|
|
483
|
+
export interface Logger {
|
|
592
484
|
debug(...args: any[]): void;
|
|
593
485
|
log(...args: any[]): void;
|
|
594
486
|
info(...args: any[]): void;
|
|
@@ -598,7 +490,7 @@ interface Logger {
|
|
|
598
490
|
success(...args: any[]): void;
|
|
599
491
|
level: LogLevel;
|
|
600
492
|
}
|
|
601
|
-
interface BaseEntrypointOptions {
|
|
493
|
+
export interface BaseEntrypointOptions {
|
|
602
494
|
/**
|
|
603
495
|
* List of target browsers to include this entrypoint in. Defaults to being included in all
|
|
604
496
|
* builds. Cannot be used with `exclude`. You must choose one of the two options.
|
|
@@ -614,7 +506,7 @@ interface BaseEntrypointOptions {
|
|
|
614
506
|
*/
|
|
615
507
|
exclude?: TargetBrowser[];
|
|
616
508
|
}
|
|
617
|
-
interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
|
|
509
|
+
export interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
|
|
618
510
|
persistent?: PerBrowserOption<boolean>;
|
|
619
511
|
/**
|
|
620
512
|
* Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
|
|
@@ -626,7 +518,7 @@ interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
|
|
|
626
518
|
*/
|
|
627
519
|
type?: PerBrowserOption<'module'>;
|
|
628
520
|
}
|
|
629
|
-
interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
521
|
+
export interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
630
522
|
matches: PerBrowserOption<Manifest.ContentScript['matches']>;
|
|
631
523
|
/**
|
|
632
524
|
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
@@ -690,20 +582,20 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
|
690
582
|
*/
|
|
691
583
|
registration?: PerBrowserOption<'manifest' | 'runtime'>;
|
|
692
584
|
}
|
|
693
|
-
interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
585
|
+
export interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
694
586
|
/**
|
|
695
587
|
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
696
588
|
*/
|
|
697
589
|
world: 'MAIN';
|
|
698
590
|
}
|
|
699
|
-
interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
591
|
+
export interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
700
592
|
/**
|
|
701
593
|
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
702
594
|
* @default "ISOLATED"
|
|
703
595
|
*/
|
|
704
596
|
world?: 'ISOLATED';
|
|
705
597
|
}
|
|
706
|
-
interface PopupEntrypointOptions extends BaseEntrypointOptions {
|
|
598
|
+
export interface PopupEntrypointOptions extends BaseEntrypointOptions {
|
|
707
599
|
/**
|
|
708
600
|
* Defaults to "browser_action" to be equivalent to MV3's "action" key
|
|
709
601
|
*/
|
|
@@ -712,12 +604,12 @@ interface PopupEntrypointOptions extends BaseEntrypointOptions {
|
|
|
712
604
|
defaultTitle?: PerBrowserOption<string>;
|
|
713
605
|
browserStyle?: PerBrowserOption<boolean>;
|
|
714
606
|
}
|
|
715
|
-
interface OptionsEntrypointOptions extends BaseEntrypointOptions {
|
|
607
|
+
export interface OptionsEntrypointOptions extends BaseEntrypointOptions {
|
|
716
608
|
openInTab?: PerBrowserOption<boolean>;
|
|
717
609
|
browserStyle?: PerBrowserOption<boolean>;
|
|
718
610
|
chromeStyle?: PerBrowserOption<boolean>;
|
|
719
611
|
}
|
|
720
|
-
interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
|
|
612
|
+
export interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
|
|
721
613
|
/**
|
|
722
614
|
* Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
|
|
723
615
|
* @default false
|
|
@@ -730,7 +622,7 @@ interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
|
|
|
730
622
|
defaultIcon?: string | Record<string, string>;
|
|
731
623
|
defaultTitle?: PerBrowserOption<string>;
|
|
732
624
|
}
|
|
733
|
-
interface BaseEntrypoint {
|
|
625
|
+
export interface BaseEntrypoint {
|
|
734
626
|
/**
|
|
735
627
|
* The entrypoint's name. This is the filename or dirname without the type suffix.
|
|
736
628
|
*
|
|
@@ -759,34 +651,34 @@ interface BaseEntrypoint {
|
|
|
759
651
|
outputDir: string;
|
|
760
652
|
skipped: boolean;
|
|
761
653
|
}
|
|
762
|
-
interface GenericEntrypoint extends BaseEntrypoint {
|
|
654
|
+
export interface GenericEntrypoint extends BaseEntrypoint {
|
|
763
655
|
type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
|
|
764
656
|
options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
|
|
765
657
|
}
|
|
766
|
-
interface BackgroundEntrypoint extends BaseEntrypoint {
|
|
658
|
+
export interface BackgroundEntrypoint extends BaseEntrypoint {
|
|
767
659
|
type: 'background';
|
|
768
660
|
options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
|
|
769
661
|
}
|
|
770
|
-
interface ContentScriptEntrypoint extends BaseEntrypoint {
|
|
662
|
+
export interface ContentScriptEntrypoint extends BaseEntrypoint {
|
|
771
663
|
type: 'content-script';
|
|
772
664
|
options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
|
|
773
665
|
}
|
|
774
|
-
interface PopupEntrypoint extends BaseEntrypoint {
|
|
666
|
+
export interface PopupEntrypoint extends BaseEntrypoint {
|
|
775
667
|
type: 'popup';
|
|
776
668
|
options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
|
|
777
669
|
}
|
|
778
|
-
interface OptionsEntrypoint extends BaseEntrypoint {
|
|
670
|
+
export interface OptionsEntrypoint extends BaseEntrypoint {
|
|
779
671
|
type: 'options';
|
|
780
672
|
options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
|
|
781
673
|
}
|
|
782
|
-
interface SidepanelEntrypoint extends BaseEntrypoint {
|
|
674
|
+
export interface SidepanelEntrypoint extends BaseEntrypoint {
|
|
783
675
|
type: 'sidepanel';
|
|
784
676
|
options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
|
|
785
677
|
}
|
|
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 {
|
|
678
|
+
export type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
|
|
679
|
+
export type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
680
|
+
export type OnContentScriptStopped = (cb: () => void) => void;
|
|
681
|
+
export interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
|
|
790
682
|
/**
|
|
791
683
|
* Main function executed when the content script is loaded.
|
|
792
684
|
*
|
|
@@ -796,7 +688,7 @@ interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScrip
|
|
|
796
688
|
*/
|
|
797
689
|
main(ctx: ContentScriptContext): any | Promise<any>;
|
|
798
690
|
}
|
|
799
|
-
interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
691
|
+
export interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
800
692
|
/**
|
|
801
693
|
* Main function executed when the content script is loaded.
|
|
802
694
|
*
|
|
@@ -806,14 +698,14 @@ interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypo
|
|
|
806
698
|
*/
|
|
807
699
|
main(): any | Promise<any>;
|
|
808
700
|
}
|
|
809
|
-
type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
810
|
-
interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
701
|
+
export type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
702
|
+
export interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
811
703
|
/**
|
|
812
704
|
* Main function executed when the background script is started. Cannot be async.
|
|
813
705
|
*/
|
|
814
706
|
main(): void;
|
|
815
707
|
}
|
|
816
|
-
interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
708
|
+
export interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
817
709
|
/**
|
|
818
710
|
* Main function executed when the unlisted script is ran.
|
|
819
711
|
*
|
|
@@ -826,8 +718,8 @@ interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
|
826
718
|
/**
|
|
827
719
|
* Either a single value or a map of different browsers to the value for that browser.
|
|
828
720
|
*/
|
|
829
|
-
type PerBrowserOption<T> = T | PerBrowserMap<T>;
|
|
830
|
-
type PerBrowserMap<T> = {
|
|
721
|
+
export type PerBrowserOption<T> = T | PerBrowserMap<T>;
|
|
722
|
+
export type PerBrowserMap<T> = {
|
|
831
723
|
[browser: TargetBrowser]: T;
|
|
832
724
|
};
|
|
833
725
|
/**
|
|
@@ -836,7 +728,7 @@ type PerBrowserMap<T> = {
|
|
|
836
728
|
*
|
|
837
729
|
* A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
|
|
838
730
|
*/
|
|
839
|
-
type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
|
|
731
|
+
export type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
|
|
840
732
|
[key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
|
|
841
733
|
} & {
|
|
842
734
|
[key in TOmitted]: T[key];
|
|
@@ -845,9 +737,9 @@ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
|
|
|
845
737
|
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
|
|
846
738
|
* here, they are configured inline.
|
|
847
739
|
*/
|
|
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 {
|
|
740
|
+
export type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
|
|
741
|
+
export type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
|
|
742
|
+
export interface ConfigEnv {
|
|
851
743
|
/**
|
|
852
744
|
* The build mode passed into the CLI. By default, `wxt` uses `"development"` and `wxt build|zip`
|
|
853
745
|
* uses `"production"`.
|
|
@@ -868,11 +760,11 @@ interface ConfigEnv {
|
|
|
868
760
|
*/
|
|
869
761
|
manifestVersion: 2 | 3;
|
|
870
762
|
}
|
|
871
|
-
type WxtCommand = 'build' | 'serve';
|
|
763
|
+
export type WxtCommand = 'build' | 'serve';
|
|
872
764
|
/**
|
|
873
765
|
* Configure how the browser starts up.
|
|
874
766
|
*/
|
|
875
|
-
interface ExtensionRunnerConfig {
|
|
767
|
+
export interface ExtensionRunnerConfig {
|
|
876
768
|
/**
|
|
877
769
|
* Whether or not to open the browser with the extension installed in dev mode.
|
|
878
770
|
*
|
|
@@ -954,7 +846,7 @@ interface ExtensionRunnerConfig {
|
|
|
954
846
|
*/
|
|
955
847
|
keepProfileChanges?: boolean;
|
|
956
848
|
}
|
|
957
|
-
interface WxtBuilder {
|
|
849
|
+
export interface WxtBuilder {
|
|
958
850
|
/**
|
|
959
851
|
* Name of tool used to build. Ex: "Vite" or "Webpack".
|
|
960
852
|
*/
|
|
@@ -977,7 +869,7 @@ interface WxtBuilder {
|
|
|
977
869
|
*/
|
|
978
870
|
createServer(info: ServerInfo): Promise<WxtBuilderServer>;
|
|
979
871
|
}
|
|
980
|
-
interface WxtBuilderServer {
|
|
872
|
+
export interface WxtBuilderServer {
|
|
981
873
|
/**
|
|
982
874
|
* Start the server.
|
|
983
875
|
*/
|
|
@@ -1012,7 +904,7 @@ interface WxtBuilderServer {
|
|
|
1012
904
|
*/
|
|
1013
905
|
watcher: FSWatcher;
|
|
1014
906
|
}
|
|
1015
|
-
interface ServerInfo {
|
|
907
|
+
export interface ServerInfo {
|
|
1016
908
|
/**
|
|
1017
909
|
* Ex: `3000`
|
|
1018
910
|
*/
|
|
@@ -1026,25 +918,8 @@ interface ServerInfo {
|
|
|
1026
918
|
*/
|
|
1027
919
|
origin: string;
|
|
1028
920
|
}
|
|
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 {
|
|
921
|
+
export type HookResult = Promise<void> | void;
|
|
922
|
+
export interface WxtHooks {
|
|
1048
923
|
/**
|
|
1049
924
|
* Called after WXT initialization, when the WXT instance is ready to work.
|
|
1050
925
|
* @param wxt The configured WXT object
|
|
@@ -1068,6 +943,20 @@ interface WxtHooks {
|
|
|
1068
943
|
* })
|
|
1069
944
|
*/
|
|
1070
945
|
'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
|
|
946
|
+
/**
|
|
947
|
+
* Called before generating the list of public paths inside
|
|
948
|
+
* `.wxt/types/paths.d.ts`. Use this hook to add additional paths (relative
|
|
949
|
+
* to output directory) WXT doesn't add automatically.
|
|
950
|
+
*
|
|
951
|
+
* @param wxt The configured WXT object
|
|
952
|
+
* @param paths This list of paths TypeScript allows `browser.runtime.getURL` to be called with.
|
|
953
|
+
*
|
|
954
|
+
* @example
|
|
955
|
+
* wxt.hooks.hook('prepare:publicPaths', (wxt, paths) => {
|
|
956
|
+
* paths.push('/icons/128.png');
|
|
957
|
+
* })
|
|
958
|
+
*/
|
|
959
|
+
'prepare:publicPaths': (wxt: Wxt, paths: string[]) => HookResult;
|
|
1071
960
|
/**
|
|
1072
961
|
* Called before the build is started in both dev mode and build mode.
|
|
1073
962
|
*
|
|
@@ -1075,7 +964,9 @@ interface WxtHooks {
|
|
|
1075
964
|
*/
|
|
1076
965
|
'build:before': (wxt: Wxt) => HookResult;
|
|
1077
966
|
/**
|
|
1078
|
-
* Called once the build process has finished.
|
|
967
|
+
* Called once the build process has finished. You can add files to the build
|
|
968
|
+
* summary here by pushing to `output.publicAssets`.
|
|
969
|
+
*
|
|
1079
970
|
* @param wxt The configured WXT object
|
|
1080
971
|
* @param output The results of the build
|
|
1081
972
|
*/
|
|
@@ -1107,7 +998,7 @@ interface WxtHooks {
|
|
|
1107
998
|
*/
|
|
1108
999
|
'build:publicAssets': (wxt: Wxt, files: ResolvedPublicFile[]) => HookResult;
|
|
1109
1000
|
}
|
|
1110
|
-
interface Wxt {
|
|
1001
|
+
export interface Wxt {
|
|
1111
1002
|
config: ResolvedConfig;
|
|
1112
1003
|
hooks: Hookable<WxtHooks>;
|
|
1113
1004
|
/**
|
|
@@ -1131,10 +1022,7 @@ interface Wxt {
|
|
|
1131
1022
|
*/
|
|
1132
1023
|
builder: WxtBuilder;
|
|
1133
1024
|
}
|
|
1134
|
-
interface ResolvedConfig {
|
|
1135
|
-
vite: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
|
|
1136
|
-
}
|
|
1137
|
-
interface ResolvedConfig {
|
|
1025
|
+
export interface ResolvedConfig {
|
|
1138
1026
|
root: string;
|
|
1139
1027
|
srcDir: string;
|
|
1140
1028
|
publicDir: string;
|
|
@@ -1174,7 +1062,7 @@ interface ResolvedConfig {
|
|
|
1174
1062
|
imports: false | WxtResolvedUnimportOptions;
|
|
1175
1063
|
manifest: UserManifest;
|
|
1176
1064
|
fsCache: FsCache;
|
|
1177
|
-
runnerConfig:
|
|
1065
|
+
runnerConfig: C12ResolvedConfig<ExtensionRunnerConfig>;
|
|
1178
1066
|
zip: {
|
|
1179
1067
|
name?: string;
|
|
1180
1068
|
artifactTemplate: string;
|
|
@@ -1202,15 +1090,15 @@ interface ResolvedConfig {
|
|
|
1202
1090
|
outputName: string;
|
|
1203
1091
|
keepArtifacts: boolean;
|
|
1204
1092
|
};
|
|
1205
|
-
userConfigMetadata: Omit<
|
|
1093
|
+
userConfigMetadata: Omit<C12ResolvedConfig<UserConfig>, 'config'>;
|
|
1206
1094
|
/**
|
|
1207
1095
|
* Import aliases to absolute paths.
|
|
1208
1096
|
*/
|
|
1209
1097
|
alias: Record<string, string>;
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
};
|
|
1098
|
+
extensionApi: 'webextension-polyfill' | 'chrome';
|
|
1099
|
+
browserModule: 'wxt/browser' | 'wxt/browser/chrome';
|
|
1100
|
+
entrypointLoader: 'vite-node' | 'jiti';
|
|
1101
|
+
experimental: {};
|
|
1214
1102
|
dev: {
|
|
1215
1103
|
/** Only defined during dev command */
|
|
1216
1104
|
server?: {
|
|
@@ -1231,16 +1119,16 @@ interface ResolvedConfig {
|
|
|
1231
1119
|
*/
|
|
1232
1120
|
plugins: string[];
|
|
1233
1121
|
}
|
|
1234
|
-
interface FsCache {
|
|
1122
|
+
export interface FsCache {
|
|
1235
1123
|
set(key: string, value: string): Promise<void>;
|
|
1236
1124
|
get(key: string): Promise<string | undefined>;
|
|
1237
1125
|
}
|
|
1238
|
-
interface ExtensionRunner {
|
|
1126
|
+
export interface ExtensionRunner {
|
|
1239
1127
|
openBrowser(): Promise<void>;
|
|
1240
1128
|
closeBrowser(): Promise<void>;
|
|
1241
1129
|
}
|
|
1242
|
-
type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
|
1243
|
-
interface Eslintrc {
|
|
1130
|
+
export type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
|
|
1131
|
+
export interface Eslintrc {
|
|
1244
1132
|
/**
|
|
1245
1133
|
* When true, generates a file that can be used by ESLint to know which variables are valid globals.
|
|
1246
1134
|
*
|
|
@@ -1266,14 +1154,14 @@ interface Eslintrc {
|
|
|
1266
1154
|
*/
|
|
1267
1155
|
globalsPropValue?: EslintGlobalsPropValue;
|
|
1268
1156
|
}
|
|
1269
|
-
interface ResolvedEslintrc {
|
|
1157
|
+
export interface ResolvedEslintrc {
|
|
1270
1158
|
/** False if disabled, otherwise the major version of ESLint installed */
|
|
1271
1159
|
enabled: false | 8 | 9;
|
|
1272
1160
|
/** Absolute path */
|
|
1273
1161
|
filePath: string;
|
|
1274
1162
|
globalsPropValue: EslintGlobalsPropValue;
|
|
1275
1163
|
}
|
|
1276
|
-
type WxtUnimportOptions = Partial<UnimportOptions> & {
|
|
1164
|
+
export type WxtUnimportOptions = Partial<UnimportOptions> & {
|
|
1277
1165
|
/**
|
|
1278
1166
|
* When using ESLint, auto-imported variables are linted as "undeclared
|
|
1279
1167
|
* globals". This option lets you configure a base eslintrc that, when
|
|
@@ -1283,13 +1171,13 @@ type WxtUnimportOptions = Partial<UnimportOptions> & {
|
|
|
1283
1171
|
*/
|
|
1284
1172
|
eslintrc?: Eslintrc;
|
|
1285
1173
|
};
|
|
1286
|
-
type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
|
|
1174
|
+
export type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
|
|
1287
1175
|
eslintrc: ResolvedEslintrc;
|
|
1288
1176
|
};
|
|
1289
1177
|
/**
|
|
1290
1178
|
* Package management utils built on top of [`nypm`](https://www.npmjs.com/package/nypm)
|
|
1291
1179
|
*/
|
|
1292
|
-
interface WxtPackageManager extends Nypm.PackageManager {
|
|
1180
|
+
export interface WxtPackageManager extends Nypm.PackageManager {
|
|
1293
1181
|
addDependency: typeof Nypm.addDependency;
|
|
1294
1182
|
addDevDependency: typeof Nypm.addDevDependency;
|
|
1295
1183
|
ensureDependencyInstalled: typeof Nypm.ensureDependencyInstalled;
|
|
@@ -1318,13 +1206,13 @@ interface WxtPackageManager extends Nypm.PackageManager {
|
|
|
1318
1206
|
*/
|
|
1319
1207
|
overridesKey: string;
|
|
1320
1208
|
}
|
|
1321
|
-
interface Dependency {
|
|
1209
|
+
export interface Dependency {
|
|
1322
1210
|
name: string;
|
|
1323
1211
|
version: string;
|
|
1324
1212
|
}
|
|
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> {
|
|
1213
|
+
export type WxtModuleOptions = Record<string, any>;
|
|
1214
|
+
export type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions?: TOptions) => void | Promise<void>;
|
|
1215
|
+
export interface WxtModule<TOptions extends WxtModuleOptions> {
|
|
1328
1216
|
name?: string;
|
|
1329
1217
|
/**
|
|
1330
1218
|
* Key for users to pass options into your module from their `wxt.config.ts` file.
|
|
@@ -1338,19 +1226,19 @@ interface WxtModule<TOptions extends WxtModuleOptions> {
|
|
|
1338
1226
|
* Alternative to adding hooks in setup function with `wxt.hooks`. Hooks are
|
|
1339
1227
|
* added before the `setup` function is called.
|
|
1340
1228
|
*/
|
|
1341
|
-
hooks?: WxtHooks
|
|
1229
|
+
hooks?: Partial<WxtHooks>;
|
|
1342
1230
|
/**
|
|
1343
1231
|
* A custom function that can be used to setup hooks and call module-specific
|
|
1344
1232
|
* APIs.
|
|
1345
1233
|
*/
|
|
1346
1234
|
setup?: WxtModuleSetup<TOptions>;
|
|
1347
1235
|
}
|
|
1348
|
-
interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtModule<TOptions> {
|
|
1236
|
+
export interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtModule<TOptions> {
|
|
1349
1237
|
type: 'local' | 'node_module';
|
|
1350
1238
|
id: string;
|
|
1351
1239
|
}
|
|
1352
|
-
type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
|
|
1353
|
-
interface ResolvedBasePublicFile {
|
|
1240
|
+
export type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
|
|
1241
|
+
export interface ResolvedBasePublicFile {
|
|
1354
1242
|
/**
|
|
1355
1243
|
* The relative path in the output directory to copy the file to.
|
|
1356
1244
|
* @example
|
|
@@ -1358,7 +1246,7 @@ interface ResolvedBasePublicFile {
|
|
|
1358
1246
|
*/
|
|
1359
1247
|
relativeDest: string;
|
|
1360
1248
|
}
|
|
1361
|
-
interface CopiedPublicFile extends ResolvedBasePublicFile {
|
|
1249
|
+
export interface CopiedPublicFile extends ResolvedBasePublicFile {
|
|
1362
1250
|
/**
|
|
1363
1251
|
* The absolute path to the file that will be copied to the output directory.
|
|
1364
1252
|
* @example
|
|
@@ -1366,24 +1254,24 @@ interface CopiedPublicFile extends ResolvedBasePublicFile {
|
|
|
1366
1254
|
*/
|
|
1367
1255
|
absoluteSrc: string;
|
|
1368
1256
|
}
|
|
1369
|
-
interface GeneratedPublicFile extends ResolvedBasePublicFile {
|
|
1257
|
+
export interface GeneratedPublicFile extends ResolvedBasePublicFile {
|
|
1370
1258
|
/**
|
|
1371
1259
|
* Text to write to the file.
|
|
1372
1260
|
*/
|
|
1373
1261
|
contents: string;
|
|
1374
1262
|
}
|
|
1375
|
-
type WxtPlugin = () => void;
|
|
1376
|
-
type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
|
|
1263
|
+
export type WxtPlugin = () => void;
|
|
1264
|
+
export type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
|
|
1377
1265
|
/**
|
|
1378
1266
|
* Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
|
|
1379
1267
|
*/
|
|
1380
|
-
interface WxtDirTypeReferenceEntry {
|
|
1268
|
+
export interface WxtDirTypeReferenceEntry {
|
|
1381
1269
|
module: string;
|
|
1382
1270
|
}
|
|
1383
1271
|
/**
|
|
1384
1272
|
* Represents a file to be written to the project's `.wxt/` directory.
|
|
1385
1273
|
*/
|
|
1386
|
-
interface WxtDirFileEntry {
|
|
1274
|
+
export interface WxtDirFileEntry {
|
|
1387
1275
|
/**
|
|
1388
1276
|
* Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
|
|
1389
1277
|
*/
|
|
@@ -1397,5 +1285,3 @@ interface WxtDirFileEntry {
|
|
|
1397
1285
|
*/
|
|
1398
1286
|
tsReference?: boolean;
|
|
1399
1287
|
}
|
|
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 };
|