wxt 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +7 -4
- package/dist/browser.js +1 -1
- package/dist/cli.cjs +435 -494
- package/dist/index.cjs +239 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +430 -0
- package/dist/index.d.ts +34 -27
- package/dist/index.js +235 -83
- package/dist/index.js.map +1 -1
- package/package.json +26 -22
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { Manifest, Scripting } from 'webextension-polyfill';
|
|
3
|
+
import { UnimportOptions } from 'unimport';
|
|
4
|
+
import { LogLevel } from 'consola';
|
|
5
|
+
|
|
6
|
+
interface InlineConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Your project's root directory containing the `package.json` used to fill out the
|
|
9
|
+
* `manifest.json`.
|
|
10
|
+
*
|
|
11
|
+
* @default process.cwd()
|
|
12
|
+
*/
|
|
13
|
+
root?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Directory containing all source code. Set to `"src"` to move all source code to a `src/`
|
|
16
|
+
* directory.
|
|
17
|
+
*
|
|
18
|
+
* @default config.root
|
|
19
|
+
*/
|
|
20
|
+
srcDir?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Directory containing files that will be copied to the output directory as-is.
|
|
23
|
+
*
|
|
24
|
+
* @default "${config.root}/public"
|
|
25
|
+
*/
|
|
26
|
+
publicDir?: string;
|
|
27
|
+
/**
|
|
28
|
+
* @default "${config.srcDir}/entrypoints"
|
|
29
|
+
*/
|
|
30
|
+
entrypointsDir?: string;
|
|
31
|
+
/**
|
|
32
|
+
* > Only available when using the JS API. Not available in `wxt.config.ts` files
|
|
33
|
+
*
|
|
34
|
+
* Path to `"wxt.config.ts"` file or false to disable config file discovery.
|
|
35
|
+
*
|
|
36
|
+
* @default "wxt.config.ts"
|
|
37
|
+
*/
|
|
38
|
+
configFile?: string | false;
|
|
39
|
+
/**
|
|
40
|
+
* Set to `true` to show debug logs. Overriden by the command line `--debug` option.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
debug?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* ID of the extension for each store. Used for publishing.
|
|
47
|
+
*/
|
|
48
|
+
storeIds?: {
|
|
49
|
+
chrome?: string;
|
|
50
|
+
firefox?: string;
|
|
51
|
+
edge?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Explicitly set a mode to run in. This will override the default mode for each command, and can
|
|
55
|
+
* be overridden by the command line `--mode` option.
|
|
56
|
+
*/
|
|
57
|
+
mode?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Customize auto-import options.
|
|
60
|
+
*/
|
|
61
|
+
imports?: Partial<UnimportOptions>;
|
|
62
|
+
/**
|
|
63
|
+
* Explicitly set a browser to build for. This will override the default browser for each command,
|
|
64
|
+
* and can be overridden by the command line `--browser` option.
|
|
65
|
+
*
|
|
66
|
+
* @default
|
|
67
|
+
* "chrome"
|
|
68
|
+
*/
|
|
69
|
+
browser?: TargetBrowser;
|
|
70
|
+
/**
|
|
71
|
+
* Explicitly set a manifest version to target. This will override the default manifest version
|
|
72
|
+
* for each command, and can be overridden by the command line `--mv2` or `--mv3` option.
|
|
73
|
+
*/
|
|
74
|
+
manifestVersion?: TargetManifestVersion;
|
|
75
|
+
/**
|
|
76
|
+
* Override the logger used.
|
|
77
|
+
*
|
|
78
|
+
* @default
|
|
79
|
+
* consola
|
|
80
|
+
*/
|
|
81
|
+
logger?: Logger;
|
|
82
|
+
/**
|
|
83
|
+
* Custom Vite options.
|
|
84
|
+
*/
|
|
85
|
+
vite?: Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
|
|
86
|
+
/**
|
|
87
|
+
* Customize the `manifest.json` output. Can be an object, promise, or function that returns an
|
|
88
|
+
* object or promise.
|
|
89
|
+
*/
|
|
90
|
+
manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
|
|
91
|
+
/**
|
|
92
|
+
* Custom server options.
|
|
93
|
+
*/
|
|
94
|
+
server?: WxtDevServer;
|
|
95
|
+
/**
|
|
96
|
+
* Custom runner options. Options set here can be overridden in a `web-ext.config.ts` file.
|
|
97
|
+
*/
|
|
98
|
+
runner?: ExtensionRunnerConfig;
|
|
99
|
+
zip?: {
|
|
100
|
+
/**
|
|
101
|
+
* Configure the filename output when zipping files.
|
|
102
|
+
*
|
|
103
|
+
* Available template variables:
|
|
104
|
+
*
|
|
105
|
+
* - `{name}` - The project's name converted to kebab-case
|
|
106
|
+
* - `{version}` - The version_name or version from the manifest
|
|
107
|
+
* - `{browser}` - The target browser from the `--browser` CLI flag
|
|
108
|
+
* - `{manifestVersion}` - Either "2" or "3"
|
|
109
|
+
*
|
|
110
|
+
* @default "{name}-{version}-{browser}.zip"
|
|
111
|
+
*/
|
|
112
|
+
artifactTemplate?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Configure the filename output when zipping files.
|
|
115
|
+
*
|
|
116
|
+
* Available template variables:
|
|
117
|
+
*
|
|
118
|
+
* - `{name}` - The project's name converted to kebab-case
|
|
119
|
+
* - `{version}` - The version_name or version from the manifest
|
|
120
|
+
* - `{browser}` - The target browser from the `--browser` CLI flag
|
|
121
|
+
* - `{manifestVersion}` - Either "2" or "3"
|
|
122
|
+
*
|
|
123
|
+
* @default "{name}-{version}-sources.zip"
|
|
124
|
+
*/
|
|
125
|
+
sourcesTemplate?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Override the artifactTemplate's `{name}` template variable. Defaults to the `package.json`'s
|
|
128
|
+
* name, or if that doesn't exist, the current working directories name.
|
|
129
|
+
*/
|
|
130
|
+
name?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Root directory to ZIP when generating the sources ZIP.
|
|
133
|
+
*
|
|
134
|
+
* @default config.root
|
|
135
|
+
*/
|
|
136
|
+
sourcesRoot?: string;
|
|
137
|
+
/**
|
|
138
|
+
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
|
|
139
|
+
* creating a ZIP of all your source code for Firfox. Patterns are relative to your
|
|
140
|
+
* `config.zip.sourcesRoot`.
|
|
141
|
+
*
|
|
142
|
+
* Hidden files, node_modules, and tests are ignored by default.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* [
|
|
146
|
+
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
147
|
+
* ]
|
|
148
|
+
*/
|
|
149
|
+
ignoredSources?: string[];
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
|
|
153
|
+
build?: Omit<vite.BuildOptions, 'outDir'>;
|
|
154
|
+
}
|
|
155
|
+
interface BuildOutput {
|
|
156
|
+
manifest: Manifest.WebExtensionManifest;
|
|
157
|
+
publicAssets: vite.Rollup.OutputAsset[];
|
|
158
|
+
steps: BuildStepOutput[];
|
|
159
|
+
}
|
|
160
|
+
interface BuildStepOutput {
|
|
161
|
+
entrypoints: EntrypointGroup;
|
|
162
|
+
chunks: (vite.Rollup.OutputChunk | vite.Rollup.OutputAsset)[];
|
|
163
|
+
}
|
|
164
|
+
interface WxtDevServer extends vite.ViteDevServer {
|
|
165
|
+
/**
|
|
166
|
+
* Ex: `3000`
|
|
167
|
+
*/
|
|
168
|
+
port: number;
|
|
169
|
+
/**
|
|
170
|
+
* Ex: `"localhost"`
|
|
171
|
+
*/
|
|
172
|
+
hostname: string;
|
|
173
|
+
/**
|
|
174
|
+
* Ex: `"http://localhost:3000"`
|
|
175
|
+
*/
|
|
176
|
+
origin: string;
|
|
177
|
+
/**
|
|
178
|
+
* Stores the current build output of the server.
|
|
179
|
+
*/
|
|
180
|
+
currentOutput: BuildOutput;
|
|
181
|
+
/**
|
|
182
|
+
* Start the server on the first open port.
|
|
183
|
+
*/
|
|
184
|
+
start(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Tell the extension to reload by running `browser.runtime.reload`.
|
|
187
|
+
*/
|
|
188
|
+
reloadExtension: () => void;
|
|
189
|
+
/**
|
|
190
|
+
* Tell an extension page to reload.
|
|
191
|
+
*
|
|
192
|
+
* The path is the bundle path, not the input paths, so if the input paths is
|
|
193
|
+
* "src/options/index.html", you would pass "options.html" because that's where it is written to
|
|
194
|
+
* in the dist directory, and where it's available at in the actual extension.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* server.reloadPage("popup.html")
|
|
198
|
+
* server.reloadPage("sandbox.html")
|
|
199
|
+
*/
|
|
200
|
+
reloadPage: (path: string) => void;
|
|
201
|
+
/**
|
|
202
|
+
* Tell the extension to restart a content script.
|
|
203
|
+
*
|
|
204
|
+
* @param contentScript The manifest definition for a content script
|
|
205
|
+
*/
|
|
206
|
+
reloadContentScript: (contentScript: Omit<Scripting.RegisteredContentScript, 'id'>) => void;
|
|
207
|
+
}
|
|
208
|
+
type TargetBrowser = 'chrome' | 'firefox' | 'safari' | 'edge' | 'opera';
|
|
209
|
+
type TargetManifestVersion = 2 | 3;
|
|
210
|
+
type UserConfig = Omit<InlineConfig, 'configFile'>;
|
|
211
|
+
interface Logger {
|
|
212
|
+
debug(...args: any[]): void;
|
|
213
|
+
log(...args: any[]): void;
|
|
214
|
+
info(...args: any[]): void;
|
|
215
|
+
warn(...args: any[]): void;
|
|
216
|
+
error(...args: any[]): void;
|
|
217
|
+
fatal(...args: any[]): void;
|
|
218
|
+
success(...args: any[]): void;
|
|
219
|
+
level: LogLevel;
|
|
220
|
+
}
|
|
221
|
+
interface BaseEntrypoint {
|
|
222
|
+
/**
|
|
223
|
+
* The entrypoint's name. This is the filename or dirname without the type suffix.
|
|
224
|
+
*
|
|
225
|
+
* Examples:
|
|
226
|
+
* - `popup.html` → `popup`
|
|
227
|
+
* - `options/index.html` → `options`
|
|
228
|
+
* - `named.sandbox.html` → `named`
|
|
229
|
+
* - `named.sandbox/index.html` → `named`
|
|
230
|
+
* - `sandbox.html` → `sandbox`
|
|
231
|
+
* - `sandbox.index.html` → `sandbox`
|
|
232
|
+
* - `overlay.content.ts` → `overlay`
|
|
233
|
+
* - `overlay.content/index.ts` → `overlay`
|
|
234
|
+
*
|
|
235
|
+
* The name is used when generating an output file:
|
|
236
|
+
* `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
|
|
237
|
+
*/
|
|
238
|
+
name: string;
|
|
239
|
+
/**
|
|
240
|
+
* Absolute path to the entrypoint's input file.
|
|
241
|
+
*/
|
|
242
|
+
inputPath: string;
|
|
243
|
+
/**
|
|
244
|
+
* Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
|
|
245
|
+
* subdirectory of it.
|
|
246
|
+
*/
|
|
247
|
+
outputDir: string;
|
|
248
|
+
}
|
|
249
|
+
interface GenericEntrypoint extends BaseEntrypoint {
|
|
250
|
+
type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
|
|
251
|
+
}
|
|
252
|
+
interface BackgroundEntrypoint extends BaseEntrypoint {
|
|
253
|
+
type: 'background';
|
|
254
|
+
options: {
|
|
255
|
+
persistent?: boolean;
|
|
256
|
+
type?: 'module';
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
interface ContentScriptEntrypoint extends BaseEntrypoint {
|
|
260
|
+
type: 'content-script';
|
|
261
|
+
options: Omit<ContentScriptDefinition, 'main'>;
|
|
262
|
+
}
|
|
263
|
+
interface PopupEntrypoint extends BaseEntrypoint {
|
|
264
|
+
type: 'popup';
|
|
265
|
+
options: {
|
|
266
|
+
/**
|
|
267
|
+
* Defaults to "browser_action" to be equivalent to MV3's "action" key
|
|
268
|
+
*/
|
|
269
|
+
mv2Key?: 'browser_action' | 'page_action';
|
|
270
|
+
defaultIcon?: Record<string, string>;
|
|
271
|
+
defaultTitle?: string;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
interface OptionsEntrypoint extends BaseEntrypoint {
|
|
275
|
+
type: 'options';
|
|
276
|
+
options: {
|
|
277
|
+
openInTab?: boolean;
|
|
278
|
+
browserStyle?: boolean;
|
|
279
|
+
chromeStyle?: boolean;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
|
|
283
|
+
type OnContentScriptStopped = (cb: () => void) => void;
|
|
284
|
+
interface ContentScriptDefinition {
|
|
285
|
+
matches: Manifest.ContentScript['matches'];
|
|
286
|
+
/**
|
|
287
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
288
|
+
* @default "documentIdle"
|
|
289
|
+
*/
|
|
290
|
+
runAt?: Manifest.ContentScript['run_at'];
|
|
291
|
+
/**
|
|
292
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
293
|
+
* @default false
|
|
294
|
+
*/
|
|
295
|
+
matchAboutBlank?: Manifest.ContentScript['match_about_blank'];
|
|
296
|
+
/**
|
|
297
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
298
|
+
* @default []
|
|
299
|
+
*/
|
|
300
|
+
excludeMatches?: Manifest.ContentScript['exclude_matches'];
|
|
301
|
+
/**
|
|
302
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
303
|
+
* @default []
|
|
304
|
+
*/
|
|
305
|
+
includeGlobs?: Manifest.ContentScript['include_globs'];
|
|
306
|
+
/**
|
|
307
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
308
|
+
* @default []
|
|
309
|
+
*/
|
|
310
|
+
excludeGlobs?: Manifest.ContentScript['exclude_globs'];
|
|
311
|
+
/**
|
|
312
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
313
|
+
* @default false
|
|
314
|
+
*/
|
|
315
|
+
allFrames?: Manifest.ContentScript['all_frames'];
|
|
316
|
+
/**
|
|
317
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
318
|
+
* @default false
|
|
319
|
+
*/
|
|
320
|
+
matchOriginAsFallback?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
323
|
+
* @default "ISOLATED"
|
|
324
|
+
*/
|
|
325
|
+
world?: 'ISOLATED' | 'MAIN';
|
|
326
|
+
/**
|
|
327
|
+
* Main function executed when the content script is loaded.
|
|
328
|
+
*/
|
|
329
|
+
main(): void | Promise<void>;
|
|
330
|
+
}
|
|
331
|
+
interface BackgroundScriptDefintition {
|
|
332
|
+
type?: 'module';
|
|
333
|
+
main(): void;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
|
|
337
|
+
* here, they are configured inline.
|
|
338
|
+
*/
|
|
339
|
+
type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
|
|
340
|
+
type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
|
|
341
|
+
interface ConfigEnv {
|
|
342
|
+
mode: string;
|
|
343
|
+
command: 'build' | 'serve';
|
|
344
|
+
/**
|
|
345
|
+
* Browser passed in from the CLI
|
|
346
|
+
*/
|
|
347
|
+
browser: TargetBrowser;
|
|
348
|
+
/**
|
|
349
|
+
* Manifest version passed in from the CLI
|
|
350
|
+
*/
|
|
351
|
+
manifestVersion: 2 | 3;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Configure how the browser starts up.
|
|
355
|
+
*/
|
|
356
|
+
interface ExtensionRunnerConfig {
|
|
357
|
+
/**
|
|
358
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#browser-console
|
|
359
|
+
*/
|
|
360
|
+
openConsole?: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#devtools
|
|
363
|
+
*/
|
|
364
|
+
openDevtools?: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* List of browser names and the binary that should be used to open the browser.
|
|
367
|
+
*/
|
|
368
|
+
binaries?: {
|
|
369
|
+
/**
|
|
370
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
|
|
371
|
+
*/
|
|
372
|
+
chrome?: string;
|
|
373
|
+
/**
|
|
374
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
|
|
375
|
+
*/
|
|
376
|
+
edge?: string;
|
|
377
|
+
/**
|
|
378
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
|
|
379
|
+
*/
|
|
380
|
+
opera?: string;
|
|
381
|
+
/**
|
|
382
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
|
|
383
|
+
*/
|
|
384
|
+
firefox?: 'firefox' | 'beta' | 'nightly' | 'deved' | 'firefoxdeveloperedition' | string;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
|
|
388
|
+
*/
|
|
389
|
+
firefoxProfile?: string;
|
|
390
|
+
/**
|
|
391
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
392
|
+
*/
|
|
393
|
+
chromiumProfile?: string;
|
|
394
|
+
/**
|
|
395
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
396
|
+
*/
|
|
397
|
+
firefoxPrefs?: Record<string, string>;
|
|
398
|
+
/**
|
|
399
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
|
|
400
|
+
*/
|
|
401
|
+
firefoxArgs?: string[];
|
|
402
|
+
/**
|
|
403
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
|
|
404
|
+
*/
|
|
405
|
+
chromiumArgs?: string[];
|
|
406
|
+
/**
|
|
407
|
+
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#start-url
|
|
408
|
+
*/
|
|
409
|
+
startUrls?: string[];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
413
|
+
|
|
414
|
+
var version = "0.4.0";
|
|
415
|
+
|
|
416
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
417
|
+
|
|
418
|
+
declare function defineRunnerConfig(config: ExtensionRunnerConfig): ExtensionRunnerConfig;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Bundles the extension for production. Returns a promise of the build result.
|
|
422
|
+
*/
|
|
423
|
+
declare function build(config: InlineConfig): Promise<BuildOutput>;
|
|
424
|
+
/**
|
|
425
|
+
* Creates a dev server, pre-builds all the files that need to exist to load the extension, and open
|
|
426
|
+
* the browser with the extension installed.
|
|
427
|
+
*/
|
|
428
|
+
declare function createServer(config?: InlineConfig): Promise<WxtDevServer>;
|
|
429
|
+
|
|
430
|
+
export { BackgroundEntrypoint, BackgroundScriptDefintition, BaseEntrypoint, BuildOutput, BuildStepOutput, ConfigEnv, ContentScriptDefinition, ContentScriptEntrypoint, Entrypoint, ExtensionRunnerConfig, GenericEntrypoint, InlineConfig, Logger, OnContentScriptStopped, OptionsEntrypoint, PopupEntrypoint, TargetBrowser, TargetManifestVersion, UserConfig, UserManifest, UserManifestFn, WxtDevServer, WxtInlineViteConfig, build, createServer, defineConfig, defineRunnerConfig, version };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
2
|
import { Manifest, Scripting } from 'webextension-polyfill';
|
|
3
3
|
import { UnimportOptions } from 'unimport';
|
|
4
|
+
import { LogLevel } from 'consola';
|
|
4
5
|
|
|
5
6
|
interface InlineConfig {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Your project's root directory containing the `package.json` used to fill out the
|
|
9
|
+
* `manifest.json`.
|
|
8
10
|
*
|
|
9
|
-
* @default
|
|
10
|
-
* process.cwd()
|
|
11
|
+
* @default process.cwd()
|
|
11
12
|
*/
|
|
12
13
|
root?: string;
|
|
13
14
|
/**
|
|
14
15
|
* Directory containing all source code. Set to `"src"` to move all source code to a `src/`
|
|
15
16
|
* directory.
|
|
16
17
|
*
|
|
17
|
-
* @default
|
|
18
|
-
* "<rootDir>"
|
|
18
|
+
* @default config.root
|
|
19
19
|
*/
|
|
20
20
|
srcDir?: string;
|
|
21
21
|
/**
|
|
22
22
|
* Directory containing files that will be copied to the output directory as-is.
|
|
23
23
|
*
|
|
24
|
-
* @default
|
|
25
|
-
* "<rootDir>/publicDir"
|
|
24
|
+
* @default "${config.root}/public"
|
|
26
25
|
*/
|
|
27
26
|
publicDir?: string;
|
|
28
27
|
/**
|
|
29
|
-
* @default
|
|
30
|
-
* "<srcDir>/entrypoints"
|
|
28
|
+
* @default "${config.srcDir}/entrypoints"
|
|
31
29
|
*/
|
|
32
30
|
entrypointsDir?: string;
|
|
33
31
|
/**
|
|
32
|
+
* > Only available when using the JS API. Not available in `wxt.config.ts` files
|
|
33
|
+
*
|
|
34
34
|
* Path to `"wxt.config.ts"` file or false to disable config file discovery.
|
|
35
35
|
*
|
|
36
|
-
* @default
|
|
37
|
-
* "wxt.config.ts"
|
|
36
|
+
* @default "wxt.config.ts"
|
|
38
37
|
*/
|
|
39
38
|
configFile?: string | false;
|
|
39
|
+
/**
|
|
40
|
+
* Set to `true` to show debug logs. Overriden by the command line `--debug` option.
|
|
41
|
+
*
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
debug?: boolean;
|
|
40
45
|
/**
|
|
41
46
|
* ID of the extension for each store. Used for publishing.
|
|
42
47
|
*/
|
|
@@ -55,7 +60,7 @@ interface InlineConfig {
|
|
|
55
60
|
*/
|
|
56
61
|
imports?: Partial<UnimportOptions>;
|
|
57
62
|
/**
|
|
58
|
-
* Explicitly set a browser to
|
|
63
|
+
* Explicitly set a browser to build for. This will override the default browser for each command,
|
|
59
64
|
* and can be overridden by the command line `--browser` option.
|
|
60
65
|
*
|
|
61
66
|
* @default
|
|
@@ -97,12 +102,12 @@ interface InlineConfig {
|
|
|
97
102
|
*
|
|
98
103
|
* Available template variables:
|
|
99
104
|
*
|
|
100
|
-
* - `{
|
|
101
|
-
* - `{
|
|
102
|
-
* - `{
|
|
103
|
-
* - `{
|
|
105
|
+
* - `{name}` - The project's name converted to kebab-case
|
|
106
|
+
* - `{version}` - The version_name or version from the manifest
|
|
107
|
+
* - `{browser}` - The target browser from the `--browser` CLI flag
|
|
108
|
+
* - `{manifestVersion}` - Either "2" or "3"
|
|
104
109
|
*
|
|
105
|
-
* @default "{
|
|
110
|
+
* @default "{name}-{version}-{browser}.zip"
|
|
106
111
|
*/
|
|
107
112
|
artifactTemplate?: string;
|
|
108
113
|
/**
|
|
@@ -110,22 +115,23 @@ interface InlineConfig {
|
|
|
110
115
|
*
|
|
111
116
|
* Available template variables:
|
|
112
117
|
*
|
|
113
|
-
* - `{
|
|
114
|
-
* - `{
|
|
115
|
-
* - `{
|
|
116
|
-
* - `{
|
|
118
|
+
* - `{name}` - The project's name converted to kebab-case
|
|
119
|
+
* - `{version}` - The version_name or version from the manifest
|
|
120
|
+
* - `{browser}` - The target browser from the `--browser` CLI flag
|
|
121
|
+
* - `{manifestVersion}` - Either "2" or "3"
|
|
117
122
|
*
|
|
118
|
-
* @default "{
|
|
123
|
+
* @default "{name}-{version}-sources.zip"
|
|
119
124
|
*/
|
|
120
125
|
sourcesTemplate?: string;
|
|
121
126
|
/**
|
|
122
|
-
* Override the artifactTemplate's `{
|
|
127
|
+
* Override the artifactTemplate's `{name}` template variable. Defaults to the `package.json`'s
|
|
123
128
|
* name, or if that doesn't exist, the current working directories name.
|
|
124
129
|
*/
|
|
125
130
|
name?: string;
|
|
126
131
|
/**
|
|
127
|
-
* Root directory to ZIP
|
|
128
|
-
*
|
|
132
|
+
* Root directory to ZIP when generating the sources ZIP.
|
|
133
|
+
*
|
|
134
|
+
* @default config.root
|
|
129
135
|
*/
|
|
130
136
|
sourcesRoot?: string;
|
|
131
137
|
/**
|
|
@@ -210,6 +216,7 @@ interface Logger {
|
|
|
210
216
|
error(...args: any[]): void;
|
|
211
217
|
fatal(...args: any[]): void;
|
|
212
218
|
success(...args: any[]): void;
|
|
219
|
+
level: LogLevel;
|
|
213
220
|
}
|
|
214
221
|
interface BaseEntrypoint {
|
|
215
222
|
/**
|
|
@@ -329,7 +336,7 @@ interface BackgroundScriptDefintition {
|
|
|
329
336
|
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
|
|
330
337
|
* here, they are configured inline.
|
|
331
338
|
*/
|
|
332
|
-
type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | '
|
|
339
|
+
type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
|
|
333
340
|
type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
|
|
334
341
|
interface ConfigEnv {
|
|
335
342
|
mode: string;
|
|
@@ -404,7 +411,7 @@ interface ExtensionRunnerConfig {
|
|
|
404
411
|
|
|
405
412
|
type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
406
413
|
|
|
407
|
-
var version = "0.
|
|
414
|
+
var version = "0.4.0";
|
|
408
415
|
|
|
409
416
|
declare function defineConfig(config: UserConfig): UserConfig;
|
|
410
417
|
|