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