wxt 0.8.3 → 0.8.5
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/README.md +3 -2
- package/dist/browser.js +3 -4
- package/dist/chunk-FNTE2L27.js +7 -0
- package/dist/chunk-NTYO6B6Y.js +2390 -0
- package/dist/chunk-YUG22S6W.js +38 -0
- package/dist/cli.cjs +3939 -3768
- package/dist/cli.d.cts +2 -0
- package/dist/client.d.ts +5 -171
- package/dist/client.js +128 -131
- package/dist/execa-WKZHVHC5.js +2043 -0
- package/dist/external-9107db91.d.ts +176 -0
- package/dist/external-cb0967d6.d.ts +572 -0
- package/dist/index.cjs +2741 -2364
- package/dist/index.d.cts +36 -583
- package/dist/index.d.ts +36 -583
- package/dist/index.js +330 -4479
- package/dist/sandbox.d.ts +2 -23
- package/dist/sandbox.js +1 -2
- package/dist/testing.cjs +141 -35
- package/dist/testing.d.cts +7 -273
- package/dist/testing.d.ts +7 -273
- package/dist/testing.js +10 -676
- package/dist/{virtual-modules → virtual}/background-entrypoint.js +6 -7
- package/dist/{virtual-modules → virtual}/content-script-entrypoint.js +4 -5
- package/dist/virtual/mock-browser.js +152 -0
- package/dist/{virtual-modules → virtual}/reload-html.js +2 -3
- package/dist/{virtual-modules → virtual}/unlisted-script-entrypoint.js +2 -3
- package/package.json +6 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/virtual-modules/background-entrypoint.js.map +0 -1
- package/dist/virtual-modules/content-script-entrypoint.js.map +0 -1
- package/dist/virtual-modules/fake-browser.cjs +0 -31
- package/dist/virtual-modules/fake-browser.js +0 -8
- package/dist/virtual-modules/reload-html.js.map +0 -1
- package/dist/virtual-modules/unlisted-script-entrypoint.js.map +0 -1
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Manifest, Scripting } from 'webextension-polyfill';
|
|
3
|
+
import { UnimportOptions } from 'unimport';
|
|
4
|
+
import { LogLevel } from 'consola';
|
|
5
|
+
import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
|
|
9
|
+
* Used to detect and stop content script code when the script is invalidated.
|
|
10
|
+
*
|
|
11
|
+
* It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
|
|
12
|
+
* content scripts instead of `window.setTimeout` or `window.setInterval`.
|
|
13
|
+
*/
|
|
14
|
+
declare class ContentScriptContext implements AbortController {
|
|
15
|
+
#private;
|
|
16
|
+
private readonly contentScriptName;
|
|
17
|
+
readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
|
|
18
|
+
private static SCRIPT_STARTED_MESSAGE_TYPE;
|
|
19
|
+
constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
|
|
20
|
+
get signal(): AbortSignal;
|
|
21
|
+
abort(reason?: any): void;
|
|
22
|
+
get isInvalid(): boolean;
|
|
23
|
+
get isValid(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Add a listener that is called when the content script's context is invalidated.
|
|
26
|
+
*
|
|
27
|
+
* @returns A function to remove the listener.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* browser.runtime.onMessage.addListener(cb);
|
|
31
|
+
* const removeInvalidatedListener = ctx.onInvalidated(() => {
|
|
32
|
+
* browser.runtime.onMessage.removeListener(cb);
|
|
33
|
+
* })
|
|
34
|
+
* // ...
|
|
35
|
+
* removeInvalidatedListener();
|
|
36
|
+
*/
|
|
37
|
+
onInvalidated(cb: () => void): () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Return a promise that never resolves. Useful if you have an async function that shouldn't run
|
|
40
|
+
* after the context is expired.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* const getValueFromStorage = async () => {
|
|
44
|
+
* if (ctx.isInvalid) return ctx.block();
|
|
45
|
+
*
|
|
46
|
+
* // ...
|
|
47
|
+
* }
|
|
48
|
+
*/
|
|
49
|
+
block<T>(): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
|
|
52
|
+
*/
|
|
53
|
+
setInterval(handler: () => void, timeout?: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
|
|
56
|
+
*/
|
|
57
|
+
setTimeout(handler: () => void, timeout?: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
|
|
60
|
+
* invalidated.
|
|
61
|
+
*/
|
|
62
|
+
requestAnimationFrame(callback: FrameRequestCallback): number;
|
|
63
|
+
/**
|
|
64
|
+
* Wrapper around `window.requestIdleCallback` that automatically cancels the request when
|
|
65
|
+
* invalidated.
|
|
66
|
+
*/
|
|
67
|
+
requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
|
|
68
|
+
/**
|
|
69
|
+
* Call `target.addEventListener` and remove the event listener when the context is invalidated.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ctx.addEventListener(window, "mousemove", () => {
|
|
73
|
+
* // ...
|
|
74
|
+
* });
|
|
75
|
+
* ctx.addEventListener(document, "visibilitychange", () => {
|
|
76
|
+
* // ...
|
|
77
|
+
* });
|
|
78
|
+
*/
|
|
79
|
+
addEventListener(target: any, type: string, handler: (event: Event) => void, options?: AddEventListenerOptions): void;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
* Abort the abort controller and execute all `onInvalidated` listeners.
|
|
83
|
+
*/
|
|
84
|
+
notifyInvalidated(): void;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface InlineConfig {
|
|
88
|
+
/**
|
|
89
|
+
* Your project's root directory containing the `package.json` used to fill out the
|
|
90
|
+
* `manifest.json`.
|
|
91
|
+
*
|
|
92
|
+
* @default process.cwd()
|
|
93
|
+
*/
|
|
94
|
+
root?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Directory containing all source code. Set to `"src"` to move all source code to a `src/`
|
|
97
|
+
* directory.
|
|
98
|
+
*
|
|
99
|
+
* @default config.root
|
|
100
|
+
*/
|
|
101
|
+
srcDir?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Directory containing files that will be copied to the output directory as-is.
|
|
104
|
+
*
|
|
105
|
+
* @default "${config.root}/public"
|
|
106
|
+
*/
|
|
107
|
+
publicDir?: string;
|
|
108
|
+
/**
|
|
109
|
+
* @default "${config.srcDir}/entrypoints"
|
|
110
|
+
*/
|
|
111
|
+
entrypointsDir?: string;
|
|
112
|
+
/**
|
|
113
|
+
* > Only available when using the JS API. Not available in `wxt.config.ts` files
|
|
114
|
+
*
|
|
115
|
+
* Path to `wxt.config.ts` file or `false` to disable config file discovery.
|
|
116
|
+
*
|
|
117
|
+
* @default "wxt.config.ts"
|
|
118
|
+
*/
|
|
119
|
+
configFile?: string | false;
|
|
120
|
+
/**
|
|
121
|
+
* Set to `true` to show debug logs. Overriden by the command line `--debug` option.
|
|
122
|
+
*
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
debug?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Explicitly set a mode to run in. This will override the default mode for each command, and can
|
|
128
|
+
* be overridden by the command line `--mode` option.
|
|
129
|
+
*/
|
|
130
|
+
mode?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Customize auto-import options. Set to `false` to disable auto-imports.
|
|
133
|
+
*
|
|
134
|
+
* For example, to add a directory to auto-import from, you can use:
|
|
135
|
+
*
|
|
136
|
+
* ```ts
|
|
137
|
+
* export default defineConfig({
|
|
138
|
+
* imports: {
|
|
139
|
+
* dirs: ["some-directory"]
|
|
140
|
+
* }
|
|
141
|
+
* })
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
imports?: Partial<UnimportOptions> | false;
|
|
145
|
+
/**
|
|
146
|
+
* Explicitly set a browser to build for. This will override the default browser for each command,
|
|
147
|
+
* and can be overridden by the command line `--browser` option.
|
|
148
|
+
*
|
|
149
|
+
* @default
|
|
150
|
+
* "chrome"
|
|
151
|
+
*/
|
|
152
|
+
browser?: TargetBrowser;
|
|
153
|
+
/**
|
|
154
|
+
* Explicitly set a manifest version to target. This will override the default manifest version
|
|
155
|
+
* for each command, and can be overridden by the command line `--mv2` or `--mv3` option.
|
|
156
|
+
*/
|
|
157
|
+
manifestVersion?: TargetManifestVersion;
|
|
158
|
+
/**
|
|
159
|
+
* Override the logger used.
|
|
160
|
+
*
|
|
161
|
+
* @default
|
|
162
|
+
* consola
|
|
163
|
+
*/
|
|
164
|
+
logger?: Logger;
|
|
165
|
+
/**
|
|
166
|
+
* Return custom Vite options from a function. See
|
|
167
|
+
* <https://vitejs.dev/config/shared-options.html>.
|
|
168
|
+
*
|
|
169
|
+
* [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
|
|
170
|
+
* instead of Vite's.
|
|
171
|
+
*
|
|
172
|
+
* This is a function because any vite plugins added need to be recreated for each individual
|
|
173
|
+
* build step, incase they have internal state causing them to fail when reused.
|
|
174
|
+
*/
|
|
175
|
+
vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
|
|
176
|
+
/**
|
|
177
|
+
* Customize the `manifest.json` output. Can be an object, promise, or function that returns an
|
|
178
|
+
* object or promise.
|
|
179
|
+
*/
|
|
180
|
+
manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
|
|
181
|
+
/**
|
|
182
|
+
* Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
|
|
183
|
+
*/
|
|
184
|
+
runner?: ExtensionRunnerConfig;
|
|
185
|
+
zip?: {
|
|
186
|
+
/**
|
|
187
|
+
* Configure the filename output when zipping files.
|
|
188
|
+
*
|
|
189
|
+
* Available template variables:
|
|
190
|
+
*
|
|
191
|
+
* - `{{name}}` - The project's name converted to kebab-case
|
|
192
|
+
* - `{{version}}` - The version_name or version from the manifest
|
|
193
|
+
* - `{{browser}}` - The target browser from the `--browser` CLI flag
|
|
194
|
+
* - `{{manifestVersion}}` - Either "2" or "3"
|
|
195
|
+
*
|
|
196
|
+
* @default "{{name}}-{{version}}-{{browser}}.zip"
|
|
197
|
+
*/
|
|
198
|
+
artifactTemplate?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Configure the filename output when zipping files.
|
|
201
|
+
*
|
|
202
|
+
* Available template variables:
|
|
203
|
+
*
|
|
204
|
+
* - `{{name}}` - The project's name converted to kebab-case
|
|
205
|
+
* - `{{version}}` - The version_name or version from the manifest
|
|
206
|
+
* - `{{browser}}` - The target browser from the `--browser` CLI flag
|
|
207
|
+
* - `{{manifestVersion}}` - Either "2" or "3"
|
|
208
|
+
*
|
|
209
|
+
* @default "{{name}}-{{version}}-sources.zip"
|
|
210
|
+
*/
|
|
211
|
+
sourcesTemplate?: string;
|
|
212
|
+
/**
|
|
213
|
+
* Override the artifactTemplate's `{name}` template variable. Defaults to the `package.json`'s
|
|
214
|
+
* name, or if that doesn't exist, the current working directories name.
|
|
215
|
+
*/
|
|
216
|
+
name?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Root directory to ZIP when generating the sources ZIP.
|
|
219
|
+
*
|
|
220
|
+
* @default config.root
|
|
221
|
+
*/
|
|
222
|
+
sourcesRoot?: string;
|
|
223
|
+
/**
|
|
224
|
+
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
|
|
225
|
+
* creating a ZIP of all your source code for Firfox. Patterns are relative to your
|
|
226
|
+
* `config.zip.sourcesRoot`.
|
|
227
|
+
*
|
|
228
|
+
* Hidden files, node_modules, and tests are ignored by default.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* [
|
|
232
|
+
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
233
|
+
* ]
|
|
234
|
+
*/
|
|
235
|
+
ignoredSources?: string[];
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Transform the final manifest before it's written to the file system. Edit the `manifest`
|
|
239
|
+
* parameter directly, do not return a new object. Return values are ignored.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* defineConfig({
|
|
243
|
+
* // Add a CSS-only content script.
|
|
244
|
+
* transformManifest(manifest) {
|
|
245
|
+
* manifest.content_scripts.push({
|
|
246
|
+
* matches: ["*://google.com/*"],
|
|
247
|
+
* css: ["content-scripts/some-example.css"],
|
|
248
|
+
* });
|
|
249
|
+
* }
|
|
250
|
+
* })
|
|
251
|
+
*/
|
|
252
|
+
transformManifest?: (manifest: Manifest.WebExtensionManifest) => void;
|
|
253
|
+
analysis?: {
|
|
254
|
+
/**
|
|
255
|
+
* Explicitly include bundle analysis when running `wxt build`. This can be overridden by the
|
|
256
|
+
* command line `--analysis` option.
|
|
257
|
+
*
|
|
258
|
+
* @default false
|
|
259
|
+
*/
|
|
260
|
+
enabled?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* When running `wxt build --analyze` or setting `analysis.enabled` to true, customize how the
|
|
263
|
+
* bundle will be visualized. See
|
|
264
|
+
* [`rollup-plugin-visualizer`](https://github.com/btd/rollup-plugin-visualizer#how-to-use-generated-files)
|
|
265
|
+
* for more details.
|
|
266
|
+
*
|
|
267
|
+
* @default "treemap"
|
|
268
|
+
*/
|
|
269
|
+
template?: PluginVisualizerOptions['template'];
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
|
|
273
|
+
build?: Omit<vite.BuildOptions, 'outDir'>;
|
|
274
|
+
}
|
|
275
|
+
interface BuildOutput {
|
|
276
|
+
manifest: Manifest.WebExtensionManifest;
|
|
277
|
+
publicAssets: vite.Rollup.OutputAsset[];
|
|
278
|
+
steps: BuildStepOutput[];
|
|
279
|
+
}
|
|
280
|
+
interface BuildStepOutput {
|
|
281
|
+
entrypoints: EntrypointGroup;
|
|
282
|
+
chunks: (vite.Rollup.OutputChunk | vite.Rollup.OutputAsset)[];
|
|
283
|
+
}
|
|
284
|
+
interface WxtDevServer extends vite.ViteDevServer {
|
|
285
|
+
/**
|
|
286
|
+
* Ex: `3000`
|
|
287
|
+
*/
|
|
288
|
+
port: number;
|
|
289
|
+
/**
|
|
290
|
+
* Ex: `"localhost"`
|
|
291
|
+
*/
|
|
292
|
+
hostname: string;
|
|
293
|
+
/**
|
|
294
|
+
* Ex: `"http://localhost:3000"`
|
|
295
|
+
*/
|
|
296
|
+
origin: string;
|
|
297
|
+
/**
|
|
298
|
+
* Stores the current build output of the server.
|
|
299
|
+
*/
|
|
300
|
+
currentOutput: BuildOutput;
|
|
301
|
+
/**
|
|
302
|
+
* Start the server on the first open port.
|
|
303
|
+
*/
|
|
304
|
+
start(): Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Tell the extension to reload by running `browser.runtime.reload`.
|
|
307
|
+
*/
|
|
308
|
+
reloadExtension: () => void;
|
|
309
|
+
/**
|
|
310
|
+
* Tell an extension page to reload.
|
|
311
|
+
*
|
|
312
|
+
* The path is the bundle path, not the input paths, so if the input paths is
|
|
313
|
+
* "src/options/index.html", you would pass "options.html" because that's where it is written to
|
|
314
|
+
* in the dist directory, and where it's available at in the actual extension.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* server.reloadPage("popup.html")
|
|
318
|
+
* server.reloadPage("sandbox.html")
|
|
319
|
+
*/
|
|
320
|
+
reloadPage: (path: string) => void;
|
|
321
|
+
/**
|
|
322
|
+
* Tell the extension to restart a content script.
|
|
323
|
+
*
|
|
324
|
+
* @param contentScript The manifest definition for a content script
|
|
325
|
+
*/
|
|
326
|
+
reloadContentScript: (contentScript: Omit<Scripting.RegisteredContentScript, 'id'>) => void;
|
|
327
|
+
}
|
|
328
|
+
type TargetBrowser = string;
|
|
329
|
+
type TargetManifestVersion = 2 | 3;
|
|
330
|
+
type UserConfig = Omit<InlineConfig, 'configFile'>;
|
|
331
|
+
interface Logger {
|
|
332
|
+
debug(...args: any[]): void;
|
|
333
|
+
log(...args: any[]): void;
|
|
334
|
+
info(...args: any[]): void;
|
|
335
|
+
warn(...args: any[]): void;
|
|
336
|
+
error(...args: any[]): void;
|
|
337
|
+
fatal(...args: any[]): void;
|
|
338
|
+
success(...args: any[]): void;
|
|
339
|
+
level: LogLevel;
|
|
340
|
+
}
|
|
341
|
+
interface BaseEntrypointOptions {
|
|
342
|
+
include?: TargetBrowser[];
|
|
343
|
+
exclude?: TargetBrowser[];
|
|
344
|
+
}
|
|
345
|
+
interface BaseEntrypoint {
|
|
346
|
+
/**
|
|
347
|
+
* The entrypoint's name. This is the filename or dirname without the type suffix.
|
|
348
|
+
*
|
|
349
|
+
* Examples:
|
|
350
|
+
* - `popup.html` → `popup`
|
|
351
|
+
* - `options/index.html` → `options`
|
|
352
|
+
* - `named.sandbox.html` → `named`
|
|
353
|
+
* - `named.sandbox/index.html` → `named`
|
|
354
|
+
* - `sandbox.html` → `sandbox`
|
|
355
|
+
* - `sandbox.index.html` → `sandbox`
|
|
356
|
+
* - `overlay.content.ts` → `overlay`
|
|
357
|
+
* - `overlay.content/index.ts` → `overlay`
|
|
358
|
+
*
|
|
359
|
+
* The name is used when generating an output file:
|
|
360
|
+
* `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
|
|
361
|
+
*/
|
|
362
|
+
name: string;
|
|
363
|
+
/**
|
|
364
|
+
* Absolute path to the entrypoint's input file.
|
|
365
|
+
*/
|
|
366
|
+
inputPath: string;
|
|
367
|
+
/**
|
|
368
|
+
* Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
|
|
369
|
+
* subdirectory of it.
|
|
370
|
+
*/
|
|
371
|
+
outputDir: string;
|
|
372
|
+
options: BaseEntrypointOptions;
|
|
373
|
+
}
|
|
374
|
+
interface GenericEntrypoint extends BaseEntrypoint {
|
|
375
|
+
type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
|
|
376
|
+
}
|
|
377
|
+
interface BackgroundEntrypoint extends BaseEntrypoint {
|
|
378
|
+
type: 'background';
|
|
379
|
+
options: {
|
|
380
|
+
persistent?: boolean;
|
|
381
|
+
type?: 'module';
|
|
382
|
+
} & BaseEntrypointOptions;
|
|
383
|
+
}
|
|
384
|
+
interface ContentScriptEntrypoint extends BaseEntrypoint {
|
|
385
|
+
type: 'content-script';
|
|
386
|
+
options: Omit<ContentScriptDefinition, 'main'> & BaseEntrypointOptions;
|
|
387
|
+
}
|
|
388
|
+
interface PopupEntrypoint extends BaseEntrypoint {
|
|
389
|
+
type: 'popup';
|
|
390
|
+
options: {
|
|
391
|
+
/**
|
|
392
|
+
* Defaults to "browser_action" to be equivalent to MV3's "action" key
|
|
393
|
+
*/
|
|
394
|
+
mv2Key?: 'browser_action' | 'page_action';
|
|
395
|
+
defaultIcon?: Record<string, string>;
|
|
396
|
+
defaultTitle?: string;
|
|
397
|
+
browserStyle?: boolean;
|
|
398
|
+
} & BaseEntrypointOptions;
|
|
399
|
+
}
|
|
400
|
+
interface OptionsEntrypoint extends BaseEntrypoint {
|
|
401
|
+
type: 'options';
|
|
402
|
+
options: {
|
|
403
|
+
openInTab?: boolean;
|
|
404
|
+
browserStyle?: boolean;
|
|
405
|
+
chromeStyle?: boolean;
|
|
406
|
+
} & BaseEntrypointOptions;
|
|
407
|
+
}
|
|
408
|
+
type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
|
|
409
|
+
type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
410
|
+
type OnContentScriptStopped = (cb: () => void) => void;
|
|
411
|
+
interface ContentScriptDefinition extends ExcludableEntrypoint {
|
|
412
|
+
matches: PerBrowserOption<Manifest.ContentScript['matches']>;
|
|
413
|
+
/**
|
|
414
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
415
|
+
* @default "documentIdle"
|
|
416
|
+
*/
|
|
417
|
+
runAt?: PerBrowserOption<Manifest.ContentScript['run_at']>;
|
|
418
|
+
/**
|
|
419
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
420
|
+
* @default false
|
|
421
|
+
*/
|
|
422
|
+
matchAboutBlank?: PerBrowserOption<Manifest.ContentScript['match_about_blank']>;
|
|
423
|
+
/**
|
|
424
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
425
|
+
* @default []
|
|
426
|
+
*/
|
|
427
|
+
excludeMatches?: PerBrowserOption<Manifest.ContentScript['exclude_matches']>;
|
|
428
|
+
/**
|
|
429
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
430
|
+
* @default []
|
|
431
|
+
*/
|
|
432
|
+
includeGlobs?: PerBrowserOption<Manifest.ContentScript['include_globs']>;
|
|
433
|
+
/**
|
|
434
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
435
|
+
* @default []
|
|
436
|
+
*/
|
|
437
|
+
excludeGlobs?: PerBrowserOption<Manifest.ContentScript['exclude_globs']>;
|
|
438
|
+
/**
|
|
439
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
440
|
+
* @default false
|
|
441
|
+
*/
|
|
442
|
+
allFrames?: PerBrowserOption<Manifest.ContentScript['all_frames']>;
|
|
443
|
+
/**
|
|
444
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
445
|
+
* @default false
|
|
446
|
+
*/
|
|
447
|
+
matchOriginAsFallback?: PerBrowserOption<boolean>;
|
|
448
|
+
/**
|
|
449
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
450
|
+
* @default "ISOLATED"
|
|
451
|
+
*/
|
|
452
|
+
world?: PerBrowserOption<'ISOLATED' | 'MAIN'>;
|
|
453
|
+
/**
|
|
454
|
+
* Customize how imported/generated styles are injected with the content script. Regardless of the
|
|
455
|
+
* mode selected, CSS will always be built and included in the output directory.
|
|
456
|
+
*
|
|
457
|
+
* - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
|
|
458
|
+
* - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
|
|
459
|
+
* onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
|
|
460
|
+
* URL
|
|
461
|
+
* - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
|
|
462
|
+
* calling `createContentScriptUi`
|
|
463
|
+
*
|
|
464
|
+
* @default "manifest"
|
|
465
|
+
*/
|
|
466
|
+
cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
|
|
467
|
+
/**
|
|
468
|
+
* Main function executed when the content script is loaded.
|
|
469
|
+
*/
|
|
470
|
+
main(ctx: ContentScriptContext): void | Promise<void>;
|
|
471
|
+
}
|
|
472
|
+
interface BackgroundDefinition extends ExcludableEntrypoint {
|
|
473
|
+
type?: PerBrowserOption<'module'>;
|
|
474
|
+
persistent?: PerBrowserOption<boolean>;
|
|
475
|
+
main(): void;
|
|
476
|
+
}
|
|
477
|
+
interface UnlistedScriptDefinition extends ExcludableEntrypoint {
|
|
478
|
+
/**
|
|
479
|
+
* Main function executed when the unlisted script is ran.
|
|
480
|
+
*/
|
|
481
|
+
main(): void | Promise<void>;
|
|
482
|
+
}
|
|
483
|
+
type PerBrowserOption<T> = T | {
|
|
484
|
+
[browser: TargetBrowser]: T;
|
|
485
|
+
};
|
|
486
|
+
interface ExcludableEntrypoint {
|
|
487
|
+
/**
|
|
488
|
+
* List of target browsers to include this entrypoint in. Defaults to being included in all
|
|
489
|
+
* builds. Cannot be used with `exclude`. You must choose one of the two options.
|
|
490
|
+
*
|
|
491
|
+
* @default undefined
|
|
492
|
+
*/
|
|
493
|
+
include?: TargetBrowser[];
|
|
494
|
+
/**
|
|
495
|
+
* List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
|
|
496
|
+
* must choose one of the two options.
|
|
497
|
+
*
|
|
498
|
+
* @default undefined
|
|
499
|
+
*/
|
|
500
|
+
exclude?: TargetBrowser[];
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
|
|
504
|
+
* here, they are configured inline.
|
|
505
|
+
*/
|
|
506
|
+
type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'sidepanel' | 'sidebar_action'>>;
|
|
507
|
+
type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
|
|
508
|
+
interface ConfigEnv {
|
|
509
|
+
mode: string;
|
|
510
|
+
command: 'build' | 'serve';
|
|
511
|
+
/**
|
|
512
|
+
* Browser passed in from the CLI
|
|
513
|
+
*/
|
|
514
|
+
browser: TargetBrowser;
|
|
515
|
+
/**
|
|
516
|
+
* Manifest version passed in from the CLI
|
|
517
|
+
*/
|
|
518
|
+
manifestVersion: 2 | 3;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Configure how the browser starts up.
|
|
522
|
+
*/
|
|
523
|
+
interface ExtensionRunnerConfig {
|
|
524
|
+
/**
|
|
525
|
+
* Whether or not to open the browser with the extension installed in dev mode.
|
|
526
|
+
*
|
|
527
|
+
* @default false
|
|
528
|
+
*/
|
|
529
|
+
disabled?: boolean;
|
|
530
|
+
/**
|
|
531
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#browser-console
|
|
532
|
+
*/
|
|
533
|
+
openConsole?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#devtools
|
|
536
|
+
*/
|
|
537
|
+
openDevtools?: boolean;
|
|
538
|
+
/**
|
|
539
|
+
* List of browser names and the binary that should be used to open the browser.
|
|
540
|
+
*
|
|
541
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
|
|
542
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
|
|
543
|
+
*/
|
|
544
|
+
binaries?: Record<string, string>;
|
|
545
|
+
/**
|
|
546
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
|
|
547
|
+
*/
|
|
548
|
+
firefoxProfile?: string;
|
|
549
|
+
/**
|
|
550
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
551
|
+
*/
|
|
552
|
+
chromiumProfile?: string;
|
|
553
|
+
/**
|
|
554
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
555
|
+
*/
|
|
556
|
+
firefoxPrefs?: Record<string, string>;
|
|
557
|
+
/**
|
|
558
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
|
|
559
|
+
*/
|
|
560
|
+
firefoxArgs?: string[];
|
|
561
|
+
/**
|
|
562
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
|
|
563
|
+
*/
|
|
564
|
+
chromiumArgs?: string[];
|
|
565
|
+
/**
|
|
566
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#start-url
|
|
567
|
+
*/
|
|
568
|
+
startUrls?: string[];
|
|
569
|
+
}
|
|
570
|
+
type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
|
|
571
|
+
|
|
572
|
+
export { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OptionsEntrypoint as O, PopupEntrypoint as P, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtInlineViteConfig as a, BuildStepOutput as b, TargetManifestVersion as c, BaseEntrypointOptions as d, BaseEntrypoint as e, BackgroundEntrypoint as f, Entrypoint as g, EntrypointGroup as h, OnContentScriptStopped as i, ContentScriptDefinition as j, BackgroundDefinition as k, UnlistedScriptDefinition as l, PerBrowserOption as m, ExcludableEntrypoint as n, UserManifest as o, UserManifestFn as p, ConfigEnv as q, WxtViteConfig as r };
|