wxt 0.18.6 → 0.18.8
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/{chunk-5X3S6AWF.js → chunk-BERPNPEZ.js} +2 -4
- package/dist/{chunk-ZZCTFNQ5.js → chunk-BM6QYGAW.js} +1 -1
- package/dist/{chunk-NAMV4VWQ.js → chunk-KPD5J7PZ.js} +1 -1
- package/dist/{chunk-VBXJIVYU.js → chunk-QGM4M3NI.js} +1 -2
- package/dist/{chunk-73I7FAJU.js → chunk-SGKCDMVR.js} +1 -2
- package/dist/{chunk-QOYT5J6A.js → chunk-Z3C7S5VV.js} +117 -182
- package/dist/cli.js +139 -220
- package/dist/client.js +12 -24
- package/dist/{execa-QQUOQNS3.js → execa-ATHZH2Y4.js} +1576 -610
- package/dist/{execa-5TSWMF32.js → execa-D7CMCKO2.js} +1576 -610
- package/dist/index.cjs +2182 -1180
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -38
- package/dist/modules.cjs +8 -12
- package/dist/modules.js +9 -13
- package/dist/{prompt-Y7B5HSD5.js → prompt-25QIVJDC.js} +28 -55
- package/dist/{prompt-TFJ7OLL7.js → prompt-7BMKNSWS.js} +28 -55
- package/dist/sandbox.js +2 -4
- package/dist/storage.cjs +4 -8
- package/dist/storage.js +6 -10
- package/dist/testing.cjs +35 -69
- package/dist/testing.js +4 -4
- package/dist/virtual/background-entrypoint.js +46 -36
- package/dist/virtual/content-script-isolated-world-entrypoint.js +1 -2
- package/dist/virtual/content-script-main-world-entrypoint.js +1 -2
- package/dist/virtual/reload-html.js +38 -31
- package/dist/virtual/unlisted-script-entrypoint.js +1 -2
- package/package.json +33 -32
|
@@ -4,8 +4,7 @@ import { initPlugins } from "virtual:wxt-plugins";
|
|
|
4
4
|
|
|
5
5
|
// src/sandbox/utils/logger.ts
|
|
6
6
|
function print(method, ...args) {
|
|
7
|
-
if (import.meta.env.MODE === "production")
|
|
8
|
-
return;
|
|
7
|
+
if (import.meta.env.MODE === "production") return;
|
|
9
8
|
if (typeof args[0] === "string") {
|
|
10
9
|
const message = args.shift();
|
|
11
10
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -20,30 +19,41 @@ var logger = {
|
|
|
20
19
|
error: (...args) => print(console.error, ...args)
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
// src/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
logger.debug("
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
// src/sandbox/dev-server-websocket.ts
|
|
23
|
+
var ws;
|
|
24
|
+
function getDevServerWebSocket() {
|
|
25
|
+
if (import.meta.env.COMMAND !== "serve")
|
|
26
|
+
throw Error(
|
|
27
|
+
"Must be running WXT dev command to connect to call getDevServerWebSocket()"
|
|
28
|
+
);
|
|
29
|
+
if (ws == null) {
|
|
30
|
+
const serverUrl = `${__DEV_SERVER_PROTOCOL__}//${__DEV_SERVER_HOSTNAME__}:${__DEV_SERVER_PORT__}`;
|
|
31
|
+
logger.debug("Connecting to dev server @", serverUrl);
|
|
32
|
+
ws = new WebSocket(serverUrl, "vite-hmr");
|
|
33
|
+
ws.addWxtEventListener = ws.addEventListener.bind(ws);
|
|
34
|
+
ws.sendCustom = (event, payload) => ws?.send(JSON.stringify({ type: "custom", event, payload }));
|
|
35
|
+
ws.addEventListener("open", () => {
|
|
36
|
+
logger.debug("Connected to dev server");
|
|
37
|
+
});
|
|
38
|
+
ws.addEventListener("close", () => {
|
|
39
|
+
logger.debug("Disconnected from dev server");
|
|
40
|
+
});
|
|
41
|
+
ws.addEventListener("error", (event) => {
|
|
42
|
+
logger.error("Failed to connect to dev server", event);
|
|
43
|
+
});
|
|
44
|
+
ws.addEventListener("message", (e) => {
|
|
45
|
+
try {
|
|
46
|
+
const message = JSON.parse(e.data);
|
|
47
|
+
if (message.type === "custom") {
|
|
48
|
+
ws?.dispatchEvent(
|
|
49
|
+
new CustomEvent(message.event, { detail: message.data })
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
logger.error("Failed to handle message", err);
|
|
42
54
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
47
57
|
return ws;
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -120,8 +130,7 @@ async function reloadTabsForContentScript(contentScript) {
|
|
|
120
130
|
);
|
|
121
131
|
const matchingTabs = allTabs.filter((tab) => {
|
|
122
132
|
const url = tab.url;
|
|
123
|
-
if (!url)
|
|
124
|
-
return false;
|
|
133
|
+
if (!url) return false;
|
|
125
134
|
return !!matchPatterns.find((pattern) => pattern.includes(url));
|
|
126
135
|
});
|
|
127
136
|
await Promise.all(matchingTabs.map((tab) => browser2.tabs.reload(tab.id)));
|
|
@@ -133,17 +142,18 @@ async function reloadContentScriptMv2(_payload) {
|
|
|
133
142
|
// src/virtual/background-entrypoint.ts
|
|
134
143
|
if (import.meta.env.COMMAND === "serve") {
|
|
135
144
|
try {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
const ws2 = getDevServerWebSocket();
|
|
146
|
+
ws2.addWxtEventListener("wxt:reload-extension", () => {
|
|
147
|
+
browser3.runtime.reload();
|
|
148
|
+
});
|
|
149
|
+
ws2.addWxtEventListener("wxt:reload-content-script", (event) => {
|
|
150
|
+
reloadContentScript(event.detail);
|
|
141
151
|
});
|
|
142
152
|
if (import.meta.env.MANIFEST_VERSION === 3) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
ws2.addEventListener(
|
|
154
|
+
"open",
|
|
155
|
+
() => ws2.sendCustom("wxt:background-initialized")
|
|
156
|
+
);
|
|
147
157
|
keepServiceWorkerAlive();
|
|
148
158
|
}
|
|
149
159
|
} catch (err) {
|
|
@@ -3,8 +3,7 @@ import definition from "virtual:user-content-script-isolated-world-entrypoint";
|
|
|
3
3
|
|
|
4
4
|
// src/sandbox/utils/logger.ts
|
|
5
5
|
function print(method, ...args) {
|
|
6
|
-
if (import.meta.env.MODE === "production")
|
|
7
|
-
return;
|
|
6
|
+
if (import.meta.env.MODE === "production") return;
|
|
8
7
|
if (typeof args[0] === "string") {
|
|
9
8
|
const message = args.shift();
|
|
10
9
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -3,8 +3,7 @@ import definition from "virtual:user-content-script-main-world-entrypoint";
|
|
|
3
3
|
|
|
4
4
|
// src/sandbox/utils/logger.ts
|
|
5
5
|
function print(method, ...args) {
|
|
6
|
-
if (import.meta.env.MODE === "production")
|
|
7
|
-
return;
|
|
6
|
+
if (import.meta.env.MODE === "production") return;
|
|
8
7
|
if (typeof args[0] === "string") {
|
|
9
8
|
const message = args.shift();
|
|
10
9
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/sandbox/utils/logger.ts
|
|
2
2
|
function print(method, ...args) {
|
|
3
|
-
if (import.meta.env.MODE === "production")
|
|
4
|
-
return;
|
|
3
|
+
if (import.meta.env.MODE === "production") return;
|
|
5
4
|
if (typeof args[0] === "string") {
|
|
6
5
|
const message = args.shift();
|
|
7
6
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -16,42 +15,50 @@ var logger = {
|
|
|
16
15
|
error: (...args) => print(console.error, ...args)
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
// src/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
logger.debug("
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
// src/sandbox/dev-server-websocket.ts
|
|
19
|
+
var ws;
|
|
20
|
+
function getDevServerWebSocket() {
|
|
21
|
+
if (import.meta.env.COMMAND !== "serve")
|
|
22
|
+
throw Error(
|
|
23
|
+
"Must be running WXT dev command to connect to call getDevServerWebSocket()"
|
|
24
|
+
);
|
|
25
|
+
if (ws == null) {
|
|
26
|
+
const serverUrl = `${__DEV_SERVER_PROTOCOL__}//${__DEV_SERVER_HOSTNAME__}:${__DEV_SERVER_PORT__}`;
|
|
27
|
+
logger.debug("Connecting to dev server @", serverUrl);
|
|
28
|
+
ws = new WebSocket(serverUrl, "vite-hmr");
|
|
29
|
+
ws.addWxtEventListener = ws.addEventListener.bind(ws);
|
|
30
|
+
ws.sendCustom = (event, payload) => ws?.send(JSON.stringify({ type: "custom", event, payload }));
|
|
31
|
+
ws.addEventListener("open", () => {
|
|
32
|
+
logger.debug("Connected to dev server");
|
|
33
|
+
});
|
|
34
|
+
ws.addEventListener("close", () => {
|
|
35
|
+
logger.debug("Disconnected from dev server");
|
|
36
|
+
});
|
|
37
|
+
ws.addEventListener("error", (event) => {
|
|
38
|
+
logger.error("Failed to connect to dev server", event);
|
|
39
|
+
});
|
|
40
|
+
ws.addEventListener("message", (e) => {
|
|
41
|
+
try {
|
|
42
|
+
const message = JSON.parse(e.data);
|
|
43
|
+
if (message.type === "custom") {
|
|
44
|
+
ws?.dispatchEvent(
|
|
45
|
+
new CustomEvent(message.event, { detail: message.data })
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
logger.error("Failed to handle message", err);
|
|
38
50
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
43
53
|
return ws;
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
// src/virtual/reload-html.ts
|
|
47
57
|
if (import.meta.env.COMMAND === "serve") {
|
|
48
58
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
location.reload();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
59
|
+
const ws2 = getDevServerWebSocket();
|
|
60
|
+
ws2.addWxtEventListener("wxt:reload-page", (event) => {
|
|
61
|
+
if (event.detail === location.pathname.substring(1)) location.reload();
|
|
55
62
|
});
|
|
56
63
|
} catch (err) {
|
|
57
64
|
logger.error("Failed to setup web socket connection with dev server", err);
|
|
@@ -3,8 +3,7 @@ import definition from "virtual:user-unlisted-script-entrypoint";
|
|
|
3
3
|
|
|
4
4
|
// src/sandbox/utils/logger.ts
|
|
5
5
|
function print(method, ...args) {
|
|
6
|
-
if (import.meta.env.MODE === "production")
|
|
7
|
-
return;
|
|
6
|
+
if (import.meta.env.MODE === "production") return;
|
|
8
7
|
if (typeof args[0] === "string") {
|
|
9
8
|
const message = args.shift();
|
|
10
9
|
method(`[wxt] ${message}`, ...args);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.8",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -92,71 +92,72 @@
|
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@aklinker1/rollup-plugin-visualizer": "5.12.0",
|
|
95
|
-
"@types/webextension-polyfill": "^0.10.
|
|
95
|
+
"@types/webextension-polyfill": "^0.10.7",
|
|
96
96
|
"@webext-core/fake-browser": "^1.3.1",
|
|
97
97
|
"@webext-core/isolated-element": "^1.1.2",
|
|
98
98
|
"@webext-core/match-patterns": "^1.0.3",
|
|
99
|
-
"async-mutex": "^0.4.
|
|
100
|
-
"c12": "^1.
|
|
99
|
+
"async-mutex": "^0.4.1",
|
|
100
|
+
"c12": "^1.11.1",
|
|
101
101
|
"cac": "^6.7.14",
|
|
102
|
-
"chokidar": "^3.
|
|
102
|
+
"chokidar": "^3.6.0",
|
|
103
103
|
"ci-info": "^4.0.0",
|
|
104
|
-
"defu": "^6.1.
|
|
104
|
+
"defu": "^6.1.4",
|
|
105
105
|
"dequal": "^2.0.3",
|
|
106
|
-
"esbuild": "^0.19.
|
|
107
|
-
"fast-glob": "^3.3.
|
|
108
|
-
"filesize": "^10.
|
|
109
|
-
"fs-extra": "^11.
|
|
110
|
-
"get-port": "^7.
|
|
111
|
-
"giget": "^1.
|
|
106
|
+
"esbuild": "^0.19.12",
|
|
107
|
+
"fast-glob": "^3.3.2",
|
|
108
|
+
"filesize": "^10.1.2",
|
|
109
|
+
"fs-extra": "^11.2.0",
|
|
110
|
+
"get-port": "^7.1.0",
|
|
111
|
+
"giget": "^1.2.3",
|
|
112
112
|
"hookable": "^5.5.3",
|
|
113
|
-
"is-wsl": "^3.
|
|
114
|
-
"jiti": "^1.21.
|
|
113
|
+
"is-wsl": "^3.1.0",
|
|
114
|
+
"jiti": "^1.21.6",
|
|
115
115
|
"json5": "^2.2.3",
|
|
116
116
|
"jszip": "^3.10.1",
|
|
117
|
-
"linkedom": "^0.18.
|
|
117
|
+
"linkedom": "^0.18.3",
|
|
118
118
|
"magicast": "^0.3.4",
|
|
119
|
-
"minimatch": "^9.0.
|
|
119
|
+
"minimatch": "^9.0.4",
|
|
120
120
|
"natural-compare": "^1.4.0",
|
|
121
121
|
"normalize-path": "^3.0.0",
|
|
122
122
|
"nypm": "^0.3.8",
|
|
123
|
+
"ohash": "^1.1.3",
|
|
123
124
|
"open": "^10.1.0",
|
|
124
125
|
"ora": "^7.0.1",
|
|
125
|
-
"picocolors": "^1.0.
|
|
126
|
+
"picocolors": "^1.0.1",
|
|
126
127
|
"prompts": "^2.4.2",
|
|
127
128
|
"publish-browser-extension": "^2.1.3",
|
|
128
|
-
"unimport": "^3.
|
|
129
|
-
"vite": "^5.
|
|
129
|
+
"unimport": "^3.7.2",
|
|
130
|
+
"vite": "^5.3.0",
|
|
130
131
|
"web-ext-run": "^0.2.0",
|
|
131
132
|
"webextension-polyfill": "^0.10.0"
|
|
132
133
|
},
|
|
133
134
|
"devDependencies": {
|
|
134
|
-
"@aklinker1/check": "^1.
|
|
135
|
-
"@faker-js/faker": "^8.
|
|
135
|
+
"@aklinker1/check": "^1.3.1",
|
|
136
|
+
"@faker-js/faker": "^8.4.1",
|
|
136
137
|
"@types/fs-extra": "^11.0.4",
|
|
137
138
|
"@types/lodash.merge": "^4.6.9",
|
|
138
139
|
"@types/natural-compare": "^1.4.3",
|
|
139
|
-
"@types/node": "^20.
|
|
140
|
+
"@types/node": "^20.14.2",
|
|
140
141
|
"@types/normalize-path": "^3.0.2",
|
|
141
142
|
"@types/prompts": "^2.4.9",
|
|
142
|
-
"execa": "^9.
|
|
143
|
+
"execa": "^9.2.0",
|
|
143
144
|
"extract-zip": "^2.0.1",
|
|
144
|
-
"happy-dom": "^13.
|
|
145
|
+
"happy-dom": "^13.10.1",
|
|
145
146
|
"lodash.merge": "^4.6.2",
|
|
146
|
-
"p-map": "^7.0.
|
|
147
|
-
"publint": "^0.2.
|
|
148
|
-
"tsup": "^8.0
|
|
149
|
-
"tsx": "^4.
|
|
147
|
+
"p-map": "^7.0.2",
|
|
148
|
+
"publint": "^0.2.8",
|
|
149
|
+
"tsup": "^8.1.0",
|
|
150
|
+
"tsx": "^4.15.4",
|
|
150
151
|
"typescript": "^5.4.5"
|
|
151
152
|
},
|
|
152
153
|
"scripts": {
|
|
153
154
|
"wxt": "tsx src/cli/index.ts",
|
|
154
|
-
"build": "tsx scripts/build.ts",
|
|
155
|
-
"check": "run-s -c check:*",
|
|
155
|
+
"build": "buildc -- tsx scripts/build.ts",
|
|
156
|
+
"check": "buildc --deps-only -- run-s -c check:*",
|
|
156
157
|
"check:default": "check",
|
|
157
158
|
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
|
|
158
|
-
"test": "vitest",
|
|
159
|
-
"test:e2e": "vitest -r e2e",
|
|
159
|
+
"test": "buildc --deps-only -- vitest",
|
|
160
|
+
"test:e2e": "buildc --deps-only -- vitest -r e2e",
|
|
160
161
|
"sync-releases": "pnpx changelogen@latest gh release"
|
|
161
162
|
}
|
|
162
163
|
}
|