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