wxt 0.19.16 → 0.19.18
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/client/content-scripts/content-script-context.d.ts +5 -4
- package/dist/client/content-scripts/content-script-context.mjs +0 -18
- package/dist/client/content-scripts/ui/index.mjs +1 -0
- package/dist/core/builders/vite/index.d.ts +1 -1
- package/dist/core/builders/vite/index.mjs +10 -9
- package/dist/core/create-server.mjs +79 -58
- package/dist/core/resolve-config.mjs +11 -4
- package/dist/core/utils/building/detect-dev-changes.d.ts +5 -1
- package/dist/core/utils/building/detect-dev-changes.mjs +5 -0
- package/dist/core/utils/building/find-entrypoints.mjs +46 -55
- package/dist/core/utils/building/group-entrypoints.d.ts +2 -2
- package/dist/core/utils/building/group-entrypoints.mjs +1 -0
- package/dist/core/utils/content-scripts.mjs +1 -1
- package/dist/core/utils/manifest.d.ts +2 -2
- package/dist/core/utils/manifest.mjs +27 -22
- package/dist/core/utils/testing/fake-objects.d.ts +254 -2
- package/dist/core/utils/testing/fake-objects.mjs +8 -4
- package/dist/core/wxt.d.ts +7 -2
- package/dist/core/wxt.mjs +21 -16
- package/dist/types.d.ts +32 -5
- package/dist/version.mjs +1 -1
- package/package.json +3 -3
package/dist/core/wxt.mjs
CHANGED
|
@@ -5,12 +5,11 @@ import { createViteBuilder } from "./builders/vite/index.mjs";
|
|
|
5
5
|
import { builtinModules } from "../builtin-modules/index.mjs";
|
|
6
6
|
import { relative } from "path";
|
|
7
7
|
export let wxt;
|
|
8
|
-
export async function registerWxt(command, inlineConfig = {}
|
|
8
|
+
export async function registerWxt(command, inlineConfig = {}) {
|
|
9
9
|
process.env.NODE_ENV ??= command === "serve" ? "development" : "production";
|
|
10
10
|
const hooks = createHooks();
|
|
11
11
|
const config = await resolveConfig(inlineConfig, command);
|
|
12
|
-
const
|
|
13
|
-
const builder = await createViteBuilder(config, hooks, server);
|
|
12
|
+
const builder = await createViteBuilder(config, hooks, () => wxt.server);
|
|
14
13
|
const pm = await createWxtPackageManager(config.root);
|
|
15
14
|
wxt = {
|
|
16
15
|
config,
|
|
@@ -25,23 +24,18 @@ export async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
25
24
|
},
|
|
26
25
|
pm,
|
|
27
26
|
builder,
|
|
28
|
-
server
|
|
27
|
+
server: void 0
|
|
29
28
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
for (const builtinModule of builtinModules) await initModule(builtinModule);
|
|
39
|
-
for (const userModule of config.userModules) await initModule(userModule);
|
|
40
|
-
wxt.hooks.addHooks(config.hooks);
|
|
29
|
+
await initWxtModules();
|
|
30
|
+
}
|
|
31
|
+
export async function initWxtModules() {
|
|
32
|
+
for (const mod of builtinModules) await initWxtModule(mod);
|
|
33
|
+
for (const mod of wxt.config.userModules) await initWxtModule(mod);
|
|
34
|
+
wxt.hooks.addHooks(wxt.config.hooks);
|
|
41
35
|
if (wxt.config.debug) {
|
|
42
36
|
const order = [
|
|
43
37
|
...builtinModules.map((module) => module.name),
|
|
44
|
-
...config.userModules.map(
|
|
38
|
+
...wxt.config.userModules.map(
|
|
45
39
|
(module) => relative(wxt.config.root, module.id)
|
|
46
40
|
),
|
|
47
41
|
"wxt.config.ts > hooks"
|
|
@@ -54,6 +48,17 @@ export async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
54
48
|
await wxt.hooks.callHook("ready", wxt);
|
|
55
49
|
await wxt.hooks.callHook("config:resolved", wxt);
|
|
56
50
|
}
|
|
51
|
+
async function initWxtModule(module) {
|
|
52
|
+
if (module.hooks) wxt.hooks.addHooks(module.hooks);
|
|
53
|
+
await module.setup?.(
|
|
54
|
+
wxt,
|
|
55
|
+
// @ts-expect-error: Untyped configKey field
|
|
56
|
+
module.configKey ? wxt.config[module.configKey] : void 0
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
export function deinitWxtModules() {
|
|
60
|
+
wxt.hooks.removeAllHooks();
|
|
61
|
+
}
|
|
57
62
|
export function setWxtForTesting(testInstance) {
|
|
58
63
|
wxt = testInstance;
|
|
59
64
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface InlineConfig {
|
|
|
44
44
|
* A list of entrypoint names (`"popup"`, `"options"`, etc.) to build. Will speed up the build if
|
|
45
45
|
* your extension has lots of entrypoints, and you don't need to build all of them to develop a
|
|
46
46
|
* feature.
|
|
47
|
+
* If specified, this completely overrides the `include`/`exclude` option provided per-entrypoint.
|
|
47
48
|
*/
|
|
48
49
|
filterEntrypoints?: string[];
|
|
49
50
|
/**
|
|
@@ -269,7 +270,7 @@ export interface InlineConfig {
|
|
|
269
270
|
analysis?: {
|
|
270
271
|
/**
|
|
271
272
|
* Explicitly include bundle analysis when running `wxt build`. This can be overridden by the
|
|
272
|
-
* command line `--
|
|
273
|
+
* command line `--analyze` option.
|
|
273
274
|
*
|
|
274
275
|
* @default false
|
|
275
276
|
*/
|
|
@@ -552,7 +553,7 @@ export interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
|
|
|
552
553
|
type?: PerBrowserOption<'module'>;
|
|
553
554
|
}
|
|
554
555
|
export interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
555
|
-
matches
|
|
556
|
+
matches?: PerBrowserOption<Manifest.ContentScript['matches']>;
|
|
556
557
|
/**
|
|
557
558
|
* See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
|
|
558
559
|
* @default "documentIdle"
|
|
@@ -682,7 +683,14 @@ export interface BaseEntrypoint {
|
|
|
682
683
|
* subdirectory of it.
|
|
683
684
|
*/
|
|
684
685
|
outputDir: string;
|
|
685
|
-
|
|
686
|
+
/**
|
|
687
|
+
* When true, the entrypoint will not be built by WXT. Normally this is set
|
|
688
|
+
* based on the `filterEntrypoints` config or the entrypoint's
|
|
689
|
+
* `include`/`exclude` options defined inside the file.
|
|
690
|
+
*
|
|
691
|
+
* See https://wxt.dev/guide/essentials/target-different-browsers.html#filtering-entrypoints
|
|
692
|
+
*/
|
|
693
|
+
skipped?: boolean;
|
|
686
694
|
}
|
|
687
695
|
export interface GenericEntrypoint extends BaseEntrypoint {
|
|
688
696
|
type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
|
|
@@ -984,7 +992,8 @@ export interface ServerInfo {
|
|
|
984
992
|
export type HookResult = Promise<void> | void;
|
|
985
993
|
export interface WxtHooks {
|
|
986
994
|
/**
|
|
987
|
-
* Called
|
|
995
|
+
* Called after WXT modules are initialized, when the WXT instance is ready to
|
|
996
|
+
* be used. `wxt.server` isn't available yet, use `server:created` to get it.
|
|
988
997
|
* @param wxt The configured WXT object
|
|
989
998
|
*/
|
|
990
999
|
ready: (wxt: Wxt) => HookResult;
|
|
@@ -1105,6 +1114,24 @@ export interface WxtHooks {
|
|
|
1105
1114
|
* @param zipFiles An array of paths to all created zip files
|
|
1106
1115
|
*/
|
|
1107
1116
|
'zip:done': (wxt: Wxt, zipFiles: string[]) => HookResult;
|
|
1117
|
+
/**
|
|
1118
|
+
* Called when the dev server is created (and `wxt.server` is assigned). Server has not been started yet.
|
|
1119
|
+
* @param wxt The configured WXT object
|
|
1120
|
+
* @param server Same as `wxt.server`, the object WXT uses to control the dev server.
|
|
1121
|
+
*/
|
|
1122
|
+
'server:created': (wxt: Wxt, server: WxtDevServer) => HookResult;
|
|
1123
|
+
/**
|
|
1124
|
+
* Called when the dev server is started.
|
|
1125
|
+
* @param wxt The configured WXT object
|
|
1126
|
+
* @param server Same as `wxt.server`, the object WXT uses to control the dev server.
|
|
1127
|
+
*/
|
|
1128
|
+
'server:started': (wxt: Wxt, server: WxtDevServer) => HookResult;
|
|
1129
|
+
/**
|
|
1130
|
+
* Called when the dev server is stopped.
|
|
1131
|
+
* @param wxt The configured WXT object
|
|
1132
|
+
* @param server Same as `wxt.server`, the object WXT uses to control the dev server.
|
|
1133
|
+
*/
|
|
1134
|
+
'server:closed': (wxt: Wxt, server: WxtDevServer) => HookResult;
|
|
1108
1135
|
}
|
|
1109
1136
|
export interface Wxt {
|
|
1110
1137
|
config: ResolvedConfig;
|
|
@@ -1118,7 +1145,7 @@ export interface Wxt {
|
|
|
1118
1145
|
*/
|
|
1119
1146
|
logger: Logger;
|
|
1120
1147
|
/**
|
|
1121
|
-
* Reload config file and update
|
|
1148
|
+
* Reload config file and update `wxt.config` with the result.
|
|
1122
1149
|
*/
|
|
1123
1150
|
reloadConfig: () => Promise<void>;
|
|
1124
1151
|
/**
|
package/dist/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "0.19.
|
|
1
|
+
export const version = "0.19.18";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.18",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"fast-glob": "^3.3.2",
|
|
90
90
|
"filesize": "^10.1.6",
|
|
91
91
|
"fs-extra": "^11.2.0",
|
|
92
|
-
"get-port": "^
|
|
92
|
+
"get-port-please": "^3.1.2",
|
|
93
93
|
"giget": "^1.2.3",
|
|
94
94
|
"hookable": "^5.5.3",
|
|
95
95
|
"is-wsl": "^3.1.0",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"publish-browser-extension": "^2.2.2",
|
|
112
112
|
"scule": "^1.3.0",
|
|
113
113
|
"unimport": "^3.13.1",
|
|
114
|
-
"vite": "^5.
|
|
114
|
+
"vite": "^5.0.0 || ^6.0.0",
|
|
115
115
|
"vite-node": "^2.1.4",
|
|
116
116
|
"web-ext-run": "^0.2.1",
|
|
117
117
|
"webextension-polyfill": "^0.12.0"
|