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,294 +0,0 @@
|
|
|
1
|
-
import { Manifest } from 'webextension-polyfill';
|
|
2
|
-
|
|
3
|
-
declare class WxtLocationChangeEvent extends Event {
|
|
4
|
-
readonly newUrl: URL;
|
|
5
|
-
readonly oldUrl: URL;
|
|
6
|
-
static EVENT_NAME: string;
|
|
7
|
-
constructor(newUrl: URL, oldUrl: URL);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
12
|
-
* Used to detect and stop content script code when the script is invalidated.
|
|
13
|
-
*
|
|
14
|
-
* It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
|
|
15
|
-
* content scripts instead of `window.setTimeout` or `window.setInterval`.
|
|
16
|
-
*
|
|
17
|
-
* To create context for testing, you can use the class's constructor:
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { ContentScriptContext } from 'wxt/client';
|
|
21
|
-
*
|
|
22
|
-
* test("storage listener should be removed when context is invalidated", () => {
|
|
23
|
-
* const ctx = new ContentScriptContext('test');
|
|
24
|
-
* const item = storage.defineItem("local:count", { defaultValue: 0 });
|
|
25
|
-
* const watcher = vi.fn();
|
|
26
|
-
*
|
|
27
|
-
* const unwatch = item.watch(watcher);
|
|
28
|
-
* ctx.onInvalidated(unwatch); // Listen for invalidate here
|
|
29
|
-
*
|
|
30
|
-
* await item.setValue(1);
|
|
31
|
-
* expect(watcher).toBeCalledTimes(1);
|
|
32
|
-
* expect(watcher).toBeCalledWith(1, 0);
|
|
33
|
-
*
|
|
34
|
-
* ctx.notifyInvalidated(); // Use this function to invalidate the context
|
|
35
|
-
* await item.setValue(2);
|
|
36
|
-
* expect(watcher).toBeCalledTimes(1);
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare class ContentScriptContext implements AbortController {
|
|
41
|
-
#private;
|
|
42
|
-
private readonly contentScriptName;
|
|
43
|
-
readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
|
|
44
|
-
private static SCRIPT_STARTED_MESSAGE_TYPE;
|
|
45
|
-
constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
|
|
46
|
-
get signal(): AbortSignal;
|
|
47
|
-
abort(reason?: any): void;
|
|
48
|
-
get isInvalid(): boolean;
|
|
49
|
-
get isValid(): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Add a listener that is called when the content script's context is invalidated.
|
|
52
|
-
*
|
|
53
|
-
* @returns A function to remove the listener.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* browser.runtime.onMessage.addListener(cb);
|
|
57
|
-
* const removeInvalidatedListener = ctx.onInvalidated(() => {
|
|
58
|
-
* browser.runtime.onMessage.removeListener(cb);
|
|
59
|
-
* })
|
|
60
|
-
* // ...
|
|
61
|
-
* removeInvalidatedListener();
|
|
62
|
-
*/
|
|
63
|
-
onInvalidated(cb: () => void): () => void;
|
|
64
|
-
/**
|
|
65
|
-
* Return a promise that never resolves. Useful if you have an async function that shouldn't run
|
|
66
|
-
* after the context is expired.
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* const getValueFromStorage = async () => {
|
|
70
|
-
* if (ctx.isInvalid) return ctx.block();
|
|
71
|
-
*
|
|
72
|
-
* // ...
|
|
73
|
-
* }
|
|
74
|
-
*/
|
|
75
|
-
block<T>(): Promise<T>;
|
|
76
|
-
/**
|
|
77
|
-
* Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
|
|
78
|
-
*/
|
|
79
|
-
setInterval(handler: () => void, timeout?: number): number;
|
|
80
|
-
/**
|
|
81
|
-
* Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
|
|
82
|
-
*/
|
|
83
|
-
setTimeout(handler: () => void, timeout?: number): number;
|
|
84
|
-
/**
|
|
85
|
-
* Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
|
|
86
|
-
* invalidated.
|
|
87
|
-
*/
|
|
88
|
-
requestAnimationFrame(callback: FrameRequestCallback): number;
|
|
89
|
-
/**
|
|
90
|
-
* Wrapper around `window.requestIdleCallback` that automatically cancels the request when
|
|
91
|
-
* invalidated.
|
|
92
|
-
*/
|
|
93
|
-
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
|
|
94
|
-
/**
|
|
95
|
-
* Call `target.addEventListener` and remove the event listener when the context is invalidated.
|
|
96
|
-
*
|
|
97
|
-
* Includes additional events useful for content scripts:
|
|
98
|
-
*
|
|
99
|
-
* - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
|
|
100
|
-
* scripts are not reloaded when navigating this way, so this can be used to reset the content
|
|
101
|
-
* script state on URL change, or run custom code.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ctx.addEventListener(document, "visibilitychange", () => {
|
|
105
|
-
* // ...
|
|
106
|
-
* });
|
|
107
|
-
* ctx.addEventListener(document, "wxt:locationchange", () => {
|
|
108
|
-
* // ...
|
|
109
|
-
* });
|
|
110
|
-
*/
|
|
111
|
-
addEventListener<TTarget extends EventTarget, TType extends keyof WxtContentScriptEventMap>(target: TTarget, type: TType, handler: (event: WxtContentScriptEventMap[TType]) => void, options?: AddEventListenerOptions): void;
|
|
112
|
-
/**
|
|
113
|
-
* @internal
|
|
114
|
-
* Abort the abort controller and execute all `onInvalidated` listeners.
|
|
115
|
-
*/
|
|
116
|
-
notifyInvalidated(): void;
|
|
117
|
-
}
|
|
118
|
-
interface WxtContentScriptEventMap extends WindowEventMap {
|
|
119
|
-
'wxt:locationchange': WxtLocationChangeEvent;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
type TargetBrowser = string;
|
|
123
|
-
interface BaseEntrypointOptions {
|
|
124
|
-
/**
|
|
125
|
-
* List of target browsers to include this entrypoint in. Defaults to being included in all
|
|
126
|
-
* builds. Cannot be used with `exclude`. You must choose one of the two options.
|
|
127
|
-
*
|
|
128
|
-
* @default undefined
|
|
129
|
-
*/
|
|
130
|
-
include?: TargetBrowser[];
|
|
131
|
-
/**
|
|
132
|
-
* List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
|
|
133
|
-
* must choose one of the two options.
|
|
134
|
-
*
|
|
135
|
-
* @default undefined
|
|
136
|
-
*/
|
|
137
|
-
exclude?: TargetBrowser[];
|
|
138
|
-
}
|
|
139
|
-
interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
|
|
140
|
-
persistent?: PerBrowserOption<boolean>;
|
|
141
|
-
/**
|
|
142
|
-
* Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
|
|
143
|
-
* reduce the overall size of the bundled extension.
|
|
144
|
-
*
|
|
145
|
-
* When `undefined`, the background is bundled individually into an IIFE format.
|
|
146
|
-
*
|
|
147
|
-
* @default undefined
|
|
148
|
-
*/
|
|
149
|
-
type?: PerBrowserOption<'module'>;
|
|
150
|
-
}
|
|
151
|
-
interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
152
|
-
matches: PerBrowserOption<Manifest.ContentScript['matches']>;
|
|
153
|
-
/**
|
|
154
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
155
|
-
* @default "documentIdle"
|
|
156
|
-
*/
|
|
157
|
-
runAt?: PerBrowserOption<Manifest.ContentScript['run_at']>;
|
|
158
|
-
/**
|
|
159
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
160
|
-
* @default false
|
|
161
|
-
*/
|
|
162
|
-
matchAboutBlank?: PerBrowserOption<Manifest.ContentScript['match_about_blank']>;
|
|
163
|
-
/**
|
|
164
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
165
|
-
* @default []
|
|
166
|
-
*/
|
|
167
|
-
excludeMatches?: PerBrowserOption<Manifest.ContentScript['exclude_matches']>;
|
|
168
|
-
/**
|
|
169
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
170
|
-
* @default []
|
|
171
|
-
*/
|
|
172
|
-
includeGlobs?: PerBrowserOption<Manifest.ContentScript['include_globs']>;
|
|
173
|
-
/**
|
|
174
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
175
|
-
* @default []
|
|
176
|
-
*/
|
|
177
|
-
excludeGlobs?: PerBrowserOption<Manifest.ContentScript['exclude_globs']>;
|
|
178
|
-
/**
|
|
179
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
180
|
-
* @default false
|
|
181
|
-
*/
|
|
182
|
-
allFrames?: PerBrowserOption<Manifest.ContentScript['all_frames']>;
|
|
183
|
-
/**
|
|
184
|
-
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
185
|
-
* @default false
|
|
186
|
-
*/
|
|
187
|
-
matchOriginAsFallback?: PerBrowserOption<boolean>;
|
|
188
|
-
/**
|
|
189
|
-
* Customize how imported/generated styles are injected with the content script. Regardless of the
|
|
190
|
-
* mode selected, CSS will always be built and included in the output directory.
|
|
191
|
-
*
|
|
192
|
-
* - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
|
|
193
|
-
* - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
|
|
194
|
-
* onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
|
|
195
|
-
* URL
|
|
196
|
-
* - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
|
|
197
|
-
* calling `createShadowRootUi`
|
|
198
|
-
*
|
|
199
|
-
* @default "manifest"
|
|
200
|
-
*/
|
|
201
|
-
cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
|
|
202
|
-
/**
|
|
203
|
-
* Specify how the content script is registered.
|
|
204
|
-
*
|
|
205
|
-
* - `"manifest"`: The content script will be added to the `content_scripts` entry in the
|
|
206
|
-
* manifest. This is the normal and most well known way of registering a content script.
|
|
207
|
-
* - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
|
|
208
|
-
* responsible for using the scripting API to register/execute the content script
|
|
209
|
-
* dynamically at runtime.
|
|
210
|
-
*
|
|
211
|
-
* @default "manifest"
|
|
212
|
-
*/
|
|
213
|
-
registration?: PerBrowserOption<'manifest' | 'runtime'>;
|
|
214
|
-
}
|
|
215
|
-
interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
216
|
-
/**
|
|
217
|
-
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
218
|
-
*/
|
|
219
|
-
world: 'MAIN';
|
|
220
|
-
}
|
|
221
|
-
interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
222
|
-
/**
|
|
223
|
-
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
224
|
-
* @default "ISOLATED"
|
|
225
|
-
*/
|
|
226
|
-
world?: 'ISOLATED';
|
|
227
|
-
}
|
|
228
|
-
interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
|
|
229
|
-
/**
|
|
230
|
-
* Main function executed when the content script is loaded.
|
|
231
|
-
*
|
|
232
|
-
* When running a content script with `browser.scripting.executeScript`,
|
|
233
|
-
* values returned from this function will be returned in the `executeScript`
|
|
234
|
-
* result as well. Otherwise returning a value does nothing.
|
|
235
|
-
*/
|
|
236
|
-
main(ctx: ContentScriptContext): any | Promise<any>;
|
|
237
|
-
}
|
|
238
|
-
interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
239
|
-
/**
|
|
240
|
-
* Main function executed when the content script is loaded.
|
|
241
|
-
*
|
|
242
|
-
* When running a content script with `browser.scripting.executeScript`,
|
|
243
|
-
* values returned from this function will be returned in the `executeScript`
|
|
244
|
-
* result as well. Otherwise returning a value does nothing.
|
|
245
|
-
*/
|
|
246
|
-
main(): any | Promise<any>;
|
|
247
|
-
}
|
|
248
|
-
type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
249
|
-
interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
250
|
-
/**
|
|
251
|
-
* Main function executed when the background script is started. Cannot be async.
|
|
252
|
-
*/
|
|
253
|
-
main(): void;
|
|
254
|
-
}
|
|
255
|
-
interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
256
|
-
/**
|
|
257
|
-
* Main function executed when the unlisted script is ran.
|
|
258
|
-
*
|
|
259
|
-
* When running a content script with `browser.scripting.executeScript`,
|
|
260
|
-
* values returned from this function will be returned in the `executeScript`
|
|
261
|
-
* result as well. Otherwise returning a value does nothing.
|
|
262
|
-
*/
|
|
263
|
-
main(): any | Promise<any>;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Either a single value or a map of different browsers to the value for that browser.
|
|
267
|
-
*/
|
|
268
|
-
type PerBrowserOption<T> = T | PerBrowserMap<T>;
|
|
269
|
-
type PerBrowserMap<T> = {
|
|
270
|
-
[browser: TargetBrowser]: T;
|
|
271
|
-
};
|
|
272
|
-
type WxtPlugin = () => void;
|
|
273
|
-
|
|
274
|
-
interface WxtAppConfig {
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Runtime app config defined in `<srcDir>/app.config.ts`.
|
|
278
|
-
*
|
|
279
|
-
* You can add fields to this interface via ["Module Augmentation"](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation):
|
|
280
|
-
*
|
|
281
|
-
* ```ts
|
|
282
|
-
* // app.config.ts
|
|
283
|
-
* import 'wxt/sandbox';
|
|
284
|
-
*
|
|
285
|
-
* declare module "wxt/sandbox" {
|
|
286
|
-
* export interface WxtAppConfig {
|
|
287
|
-
* analytics: AnalyticsConfig
|
|
288
|
-
* }
|
|
289
|
-
* }
|
|
290
|
-
* ```
|
|
291
|
-
*/
|
|
292
|
-
declare function defineAppConfig(config: WxtAppConfig): WxtAppConfig;
|
|
293
|
-
|
|
294
|
-
export { type BackgroundDefinition as B, type ContentScriptDefinition as C, type UnlistedScriptDefinition as U, type WxtPlugin as W, type WxtAppConfig as a, ContentScriptContext as b, defineAppConfig as d };
|