wxt 0.18.15 → 0.19.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/bin/wxt.mjs +1 -1
- package/dist/browser/chrome.d.ts +17 -0
- package/dist/browser/chrome.mjs +7 -0
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.mjs +2 -0
- package/dist/builtin-modules/index.d.ts +2 -0
- package/dist/builtin-modules/index.mjs +2 -0
- package/dist/builtin-modules/unimport.d.ts +8 -0
- package/dist/builtin-modules/unimport.mjs +99 -0
- package/dist/cli/cli-utils.d.ts +25 -0
- package/dist/cli/cli-utils.mjs +58 -0
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.mjs +104 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.mjs +11 -0
- package/dist/client/app-config.d.ts +2 -0
- package/dist/client/app-config.mjs +4 -0
- package/dist/client/content-scripts/content-script-context.d.ts +114 -0
- package/dist/client/content-scripts/content-script-context.mjs +169 -0
- package/dist/client/content-scripts/custom-events.d.ts +10 -0
- package/dist/client/content-scripts/custom-events.mjs +13 -0
- package/dist/client/content-scripts/index.d.ts +2 -0
- package/dist/client/content-scripts/index.mjs +2 -0
- package/dist/client/content-scripts/location-watcher.d.ts +12 -0
- package/dist/client/content-scripts/location-watcher.mjs +22 -0
- package/dist/client/content-scripts/ui/index.d.ts +23 -0
- package/dist/client/content-scripts/ui/index.mjs +188 -0
- package/dist/{client.d.ts → client/content-scripts/ui/types.d.ts} +17 -45
- package/dist/client/content-scripts/ui/types.mjs +0 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.mjs +2 -0
- package/dist/core/build.d.ts +15 -0
- package/dist/core/build.mjs +6 -0
- package/dist/core/builders/vite/index.d.ts +3 -0
- package/dist/core/builders/vite/index.mjs +285 -0
- package/dist/core/builders/vite/plugins/bundleAnalysis.d.ts +7 -0
- package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +15 -0
- package/dist/core/builders/vite/plugins/cssEntrypoints.d.ts +13 -0
- package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +22 -0
- package/dist/core/builders/vite/plugins/defineImportMeta.d.ts +14 -0
- package/dist/core/builders/vite/plugins/defineImportMeta.mjs +13 -0
- package/dist/core/builders/vite/plugins/devHtmlPrerender.d.ts +7 -0
- package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +140 -0
- package/dist/core/builders/vite/plugins/devServerGlobals.d.ts +6 -0
- package/dist/core/builders/vite/plugins/devServerGlobals.mjs +15 -0
- package/dist/core/builders/vite/plugins/download.d.ts +10 -0
- package/dist/core/builders/vite/plugins/download.mjs +14 -0
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.d.ts +6 -0
- package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +16 -0
- package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +11 -0
- package/dist/core/builders/vite/plugins/extensionApiMock.mjs +26 -0
- package/dist/core/builders/vite/plugins/globals.d.ts +3 -0
- package/dist/core/builders/vite/plugins/globals.mjs +15 -0
- package/dist/core/builders/vite/plugins/index.d.ts +17 -0
- package/dist/core/builders/vite/plugins/index.mjs +17 -0
- package/dist/core/builders/vite/plugins/multipageMove.d.ts +20 -0
- package/dist/core/builders/vite/plugins/multipageMove.mjs +59 -0
- package/dist/core/builders/vite/plugins/noopBackground.d.ts +6 -0
- package/dist/core/builders/vite/plugins/noopBackground.mjs +17 -0
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.d.ts +6 -0
- package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +12 -0
- package/dist/core/builders/vite/plugins/resolveAppConfig.d.ts +6 -0
- package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +26 -0
- package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +10 -0
- package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +15 -0
- package/dist/core/builders/vite/plugins/resolveVirtualModules.d.ts +6 -0
- package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +30 -0
- package/dist/core/builders/vite/plugins/tsconfigPaths.d.ts +3 -0
- package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +12 -0
- package/dist/core/builders/vite/plugins/wxtPluginLoader.d.ts +6 -0
- package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +56 -0
- package/dist/core/clean.d.ts +21 -0
- package/dist/core/clean.mjs +38 -0
- package/dist/core/create-server.d.ts +11 -0
- package/dist/core/create-server.mjs +206 -0
- package/dist/core/define-config.d.ts +2 -0
- package/dist/core/define-config.mjs +3 -0
- package/dist/core/define-runner-config.d.ts +2 -0
- package/dist/core/define-runner-config.mjs +3 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.mjs +8 -0
- package/dist/core/initialize.d.ts +5 -0
- package/dist/core/initialize.mjs +128 -0
- package/dist/core/package-managers/bun.d.ts +2 -0
- package/dist/core/package-managers/bun.mjs +19 -0
- package/dist/core/package-managers/index.d.ts +2 -0
- package/dist/core/package-managers/index.mjs +65 -0
- package/dist/core/package-managers/npm.d.ts +17 -0
- package/dist/core/package-managers/npm.mjs +58 -0
- package/dist/core/package-managers/pnpm.d.ts +2 -0
- package/dist/core/package-managers/pnpm.mjs +21 -0
- package/dist/core/package-managers/types.d.ts +2 -0
- package/dist/core/package-managers/types.mjs +0 -0
- package/dist/core/package-managers/yarn.d.ts +2 -0
- package/dist/core/package-managers/yarn.mjs +31 -0
- package/dist/core/prepare.d.ts +2 -0
- package/dist/core/prepare.mjs +8 -0
- package/dist/core/runners/index.d.ts +2 -0
- package/dist/core/runners/index.mjs +12 -0
- package/dist/core/runners/manual.d.ts +5 -0
- package/dist/core/runners/manual.mjs +16 -0
- package/dist/core/runners/safari.d.ts +5 -0
- package/dist/core/runners/safari.mjs +16 -0
- package/dist/core/runners/web-ext.d.ts +5 -0
- package/dist/core/runners/web-ext.mjs +78 -0
- package/dist/core/runners/wsl.d.ts +5 -0
- package/dist/core/runners/wsl.mjs +16 -0
- package/dist/core/utils/arrays.d.ts +13 -0
- package/dist/{chunk-BERPNPEZ.js → core/utils/arrays.mjs} +6 -10
- package/dist/core/utils/building/build-entrypoints.d.ts +3 -0
- package/dist/core/utils/building/build-entrypoints.mjs +47 -0
- package/dist/core/utils/building/detect-dev-changes.d.ts +57 -0
- package/dist/core/utils/building/detect-dev-changes.mjs +93 -0
- package/dist/core/utils/building/find-entrypoints.d.ts +5 -0
- package/dist/core/utils/building/find-entrypoints.mjs +385 -0
- package/dist/core/utils/building/generate-wxt-dir.d.ts +5 -0
- package/dist/core/utils/building/generate-wxt-dir.mjs +192 -0
- package/dist/core/utils/building/group-entrypoints.d.ts +8 -0
- package/dist/core/utils/building/group-entrypoints.mjs +37 -0
- package/dist/core/utils/building/import-entrypoint.d.ts +16 -0
- package/dist/core/utils/building/import-entrypoint.mjs +97 -0
- package/dist/core/utils/building/index.d.ts +9 -0
- package/dist/core/utils/building/index.mjs +9 -0
- package/dist/core/utils/building/internal-build.d.ts +12 -0
- package/dist/core/utils/building/internal-build.mjs +112 -0
- package/dist/core/utils/building/rebuild.d.ts +23 -0
- package/dist/core/utils/building/rebuild.mjs +39 -0
- package/dist/core/utils/building/resolve-config.d.ts +11 -0
- package/dist/core/utils/building/resolve-config.mjs +364 -0
- package/dist/core/utils/cache.d.ts +8 -0
- package/dist/core/utils/cache.mjs +21 -0
- package/dist/core/utils/cli.d.ts +3 -0
- package/dist/core/utils/cli.mjs +26 -0
- package/dist/core/utils/constants.d.ts +5 -0
- package/dist/core/utils/constants.mjs +1 -0
- package/dist/core/utils/content-scripts.d.ts +11 -0
- package/dist/core/utils/content-scripts.mjs +60 -0
- package/dist/core/utils/content-security-policy.d.ts +14 -0
- package/dist/core/utils/content-security-policy.mjs +39 -0
- package/dist/core/utils/entrypoints.d.ts +25 -0
- package/dist/core/utils/entrypoints.mjs +31 -0
- package/dist/core/utils/eslint.d.ts +1 -0
- package/dist/core/utils/eslint.mjs +11 -0
- package/dist/core/utils/fs.d.ts +13 -0
- package/dist/core/utils/fs.mjs +15 -0
- package/dist/core/utils/globals.d.ts +11 -0
- package/dist/core/utils/globals.mjs +53 -0
- package/dist/core/utils/i18n.d.ts +11 -0
- package/dist/core/utils/i18n.mjs +35 -0
- package/dist/core/utils/log/index.d.ts +4 -0
- package/dist/core/utils/log/index.mjs +4 -0
- package/dist/core/utils/log/printBuildSummary.d.ts +2 -0
- package/dist/core/utils/log/printBuildSummary.mjs +32 -0
- package/dist/core/utils/log/printFileList.d.ts +1 -0
- package/dist/core/utils/log/printFileList.mjs +42 -0
- package/dist/core/utils/log/printHeader.d.ts +1 -0
- package/dist/core/utils/log/printHeader.mjs +7 -0
- package/dist/core/utils/log/printTable.d.ts +1 -0
- package/dist/core/utils/log/printTable.mjs +22 -0
- package/dist/core/utils/manifest.d.ts +44 -0
- package/dist/core/utils/manifest.mjs +512 -0
- package/dist/core/utils/network.d.ts +7 -0
- package/dist/core/utils/network.mjs +38 -0
- package/dist/core/utils/package.d.ts +6 -0
- package/dist/core/utils/package.mjs +14 -0
- package/dist/core/utils/paths.d.ts +11 -0
- package/dist/core/utils/paths.mjs +10 -0
- package/dist/core/utils/strings.d.ts +14 -0
- package/dist/core/utils/strings.mjs +18 -0
- package/dist/core/utils/testing/fake-objects.d.ts +4556 -0
- package/dist/core/utils/testing/fake-objects.mjs +322 -0
- package/dist/core/utils/time.d.ts +9 -0
- package/dist/core/utils/time.mjs +17 -0
- package/dist/core/utils/transform.d.ts +9 -0
- package/dist/core/utils/transform.mjs +17 -0
- package/dist/core/utils/types.d.ts +10 -0
- package/dist/core/utils/types.mjs +0 -0
- package/dist/core/utils/validation.d.ts +15 -0
- package/dist/core/utils/validation.mjs +55 -0
- package/dist/core/utils/virtual-modules.d.ts +22 -0
- package/dist/core/utils/virtual-modules.mjs +14 -0
- package/dist/core/utils/wsl.d.ts +4 -0
- package/dist/core/utils/wsl.mjs +4 -0
- package/dist/core/wxt.d.ts +19 -0
- package/dist/core/wxt.mjs +41 -0
- package/dist/core/zip.d.ts +7 -0
- package/dist/core/zip.mjs +137 -0
- package/dist/index.d.ts +4 -79
- package/dist/index.mjs +3 -0
- package/dist/modules.d.ts +10 -20
- package/dist/{chunk-6XSIWUWF.js → modules.mjs} +7 -16
- package/dist/sandbox/define-app-config.d.ts +19 -0
- package/dist/sandbox/define-app-config.mjs +3 -0
- package/dist/sandbox/define-background.d.ts +3 -0
- package/dist/sandbox/define-background.mjs +4 -0
- package/dist/sandbox/define-content-script.d.ts +2 -0
- package/dist/sandbox/define-content-script.mjs +3 -0
- package/dist/sandbox/define-unlisted-script.d.ts +3 -0
- package/dist/sandbox/define-unlisted-script.mjs +4 -0
- package/dist/sandbox/define-wxt-plugin.d.ts +2 -0
- package/dist/sandbox/define-wxt-plugin.mjs +3 -0
- package/dist/sandbox/dev-server-websocket.d.ts +21 -0
- package/dist/sandbox/dev-server-websocket.mjs +37 -0
- package/dist/sandbox/index.d.ts +11 -0
- package/dist/sandbox/index.mjs +6 -0
- package/dist/sandbox/utils/logger.d.ts +9 -0
- package/dist/sandbox/utils/logger.mjs +15 -0
- package/dist/storage.d.ts +39 -16
- package/dist/{storage.js → storage.mjs} +30 -41
- package/dist/testing/fake-browser.d.ts +1 -0
- package/dist/testing/fake-browser.mjs +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.mjs +2 -0
- package/dist/{testing.d.ts → testing/wxt-vitest-plugin.d.ts} +3 -15
- package/dist/testing/wxt-vitest-plugin.mjs +26 -0
- package/dist/{index-nWRfwAJi.d.cts → types.d.ts} +150 -264
- package/dist/types.mjs +0 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.mjs +1 -0
- package/dist/virtual/{background-entrypoint.js → background-entrypoint.mjs} +31 -40
- package/dist/virtual/{content-script-isolated-world-entrypoint.js → content-script-isolated-world-entrypoint.mjs} +9 -13
- package/dist/virtual/{content-script-main-world-entrypoint.js → content-script-main-world-entrypoint.mjs} +9 -14
- package/dist/virtual/mock-browser.mjs +6 -0
- package/dist/virtual/{reload-html.js → reload-html.mjs} +8 -9
- package/dist/virtual/{unlisted-script-entrypoint.js → unlisted-script-entrypoint.mjs} +8 -12
- package/package.json +47 -57
- package/dist/browser.d.ts +0 -18
- package/dist/browser.js +0 -6
- package/dist/chunk-BM6QYGAW.js +0 -1063
- package/dist/chunk-FNTE2L27.js +0 -7
- package/dist/chunk-FP7RYLVL.js +0 -3617
- package/dist/chunk-KPD5J7PZ.js +0 -1065
- package/dist/chunk-QGM4M3NI.js +0 -37
- package/dist/chunk-SGKCDMVR.js +0 -38
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -4438
- package/dist/client.js +0 -424
- package/dist/define-app-config-bg54F_lV.d.ts +0 -294
- package/dist/execa-4UBDUBJZ.js +0 -7244
- package/dist/execa-QLUM2B3W.js +0 -7245
- package/dist/index-nWRfwAJi.d.ts +0 -1401
- package/dist/index.cjs +0 -14473
- package/dist/index.d.cts +0 -81
- package/dist/index.js +0 -696
- package/dist/modules.cjs +0 -96
- package/dist/modules.d.cts +0 -119
- package/dist/modules.js +0 -17
- package/dist/prompt-25QIVJDC.js +0 -755
- package/dist/prompt-7BMKNSWS.js +0 -754
- package/dist/sandbox.d.ts +0 -16
- package/dist/sandbox.js +0 -36
- package/dist/storage.cjs +0 -439
- package/dist/storage.d.cts +0 -200
- package/dist/testing.cjs +0 -2815
- package/dist/testing.d.cts +0 -30
- package/dist/testing.js +0 -40
- package/dist/virtual/mock-browser.js +0 -6
package/dist/types.mjs
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "{{version}}";
|
package/dist/version.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const version = "0.19.0";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import definition from 'virtual:user-background-entrypoint';
|
|
2
|
+
import { initPlugins } from 'virtual:wxt-plugins';
|
|
3
|
+
import { browser } from 'wxt/browser';
|
|
4
|
+
import { MatchPattern } from 'wxt/sandbox';
|
|
4
5
|
|
|
5
|
-
// src/sandbox/utils/logger.ts
|
|
6
6
|
function print(method, ...args) {
|
|
7
|
-
if (import.meta.env.MODE === "production")
|
|
7
|
+
if (import.meta.env.MODE === "production")
|
|
8
|
+
return;
|
|
8
9
|
if (typeof args[0] === "string") {
|
|
9
10
|
const message = args.shift();
|
|
10
11
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -12,15 +13,14 @@ function print(method, ...args) {
|
|
|
12
13
|
method("[wxt]", ...args);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
const logger = {
|
|
16
17
|
debug: (...args) => print(console.debug, ...args),
|
|
17
18
|
log: (...args) => print(console.log, ...args),
|
|
18
19
|
warn: (...args) => print(console.warn, ...args),
|
|
19
20
|
error: (...args) => print(console.error, ...args)
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
var ws;
|
|
23
|
+
let ws;
|
|
24
24
|
function getDevServerWebSocket() {
|
|
25
25
|
if (import.meta.env.COMMAND !== "serve")
|
|
26
26
|
throw Error(
|
|
@@ -57,24 +57,16 @@ function getDevServerWebSocket() {
|
|
|
57
57
|
return ws;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// src/virtual/background-entrypoint.ts
|
|
61
|
-
import { browser as browser3 } from "wxt/browser";
|
|
62
|
-
|
|
63
|
-
// src/virtual/utils/keep-service-worker-alive.ts
|
|
64
|
-
import { browser } from "wxt/browser";
|
|
65
60
|
function keepServiceWorkerAlive() {
|
|
66
61
|
setInterval(async () => {
|
|
67
62
|
await browser.runtime.getPlatformInfo();
|
|
68
63
|
}, 5e3);
|
|
69
64
|
}
|
|
70
65
|
|
|
71
|
-
// src/virtual/utils/reload-content-scripts.ts
|
|
72
|
-
import { browser as browser2 } from "wxt/browser";
|
|
73
|
-
import { MatchPattern } from "wxt/sandbox";
|
|
74
66
|
function reloadContentScript(payload) {
|
|
75
|
-
const manifest =
|
|
67
|
+
const manifest = browser.runtime.getManifest();
|
|
76
68
|
if (manifest.manifest_version == 2) {
|
|
77
|
-
void reloadContentScriptMv2(
|
|
69
|
+
void reloadContentScriptMv2();
|
|
78
70
|
} else {
|
|
79
71
|
void reloadContentScriptMv3(payload);
|
|
80
72
|
}
|
|
@@ -92,21 +84,21 @@ async function reloadContentScriptMv3({
|
|
|
92
84
|
async function reloadManifestContentScriptMv3(contentScript) {
|
|
93
85
|
const id = `wxt:${contentScript.js[0]}`;
|
|
94
86
|
logger.log("Reloading content script:", contentScript);
|
|
95
|
-
const registered = await
|
|
87
|
+
const registered = await browser.scripting.getRegisteredContentScripts();
|
|
96
88
|
logger.debug("Existing scripts:", registered);
|
|
97
89
|
const existing = registered.find((cs) => cs.id === id);
|
|
98
90
|
if (existing) {
|
|
99
91
|
logger.debug("Updating content script", existing);
|
|
100
|
-
await
|
|
92
|
+
await browser.scripting.updateContentScripts([{ ...contentScript, id }]);
|
|
101
93
|
} else {
|
|
102
94
|
logger.debug("Registering new content script...");
|
|
103
|
-
await
|
|
95
|
+
await browser.scripting.registerContentScripts([{ ...contentScript, id }]);
|
|
104
96
|
}
|
|
105
97
|
await reloadTabsForContentScript(contentScript);
|
|
106
98
|
}
|
|
107
99
|
async function reloadRuntimeContentScriptMv3(contentScript) {
|
|
108
100
|
logger.log("Reloading content script:", contentScript);
|
|
109
|
-
const registered = await
|
|
101
|
+
const registered = await browser.scripting.getRegisteredContentScripts();
|
|
110
102
|
logger.debug("Existing scripts:", registered);
|
|
111
103
|
const matches = registered.filter((cs) => {
|
|
112
104
|
const hasJs = contentScript.js?.find((js) => cs.js?.includes(js));
|
|
@@ -120,23 +112,24 @@ async function reloadRuntimeContentScriptMv3(contentScript) {
|
|
|
120
112
|
);
|
|
121
113
|
return;
|
|
122
114
|
}
|
|
123
|
-
await
|
|
115
|
+
await browser.scripting.updateContentScripts(matches);
|
|
124
116
|
await reloadTabsForContentScript(contentScript);
|
|
125
117
|
}
|
|
126
118
|
async function reloadTabsForContentScript(contentScript) {
|
|
127
|
-
const allTabs = await
|
|
119
|
+
const allTabs = await browser.tabs.query({});
|
|
128
120
|
const matchPatterns = contentScript.matches.map(
|
|
129
121
|
(match) => new MatchPattern(match)
|
|
130
122
|
);
|
|
131
123
|
const matchingTabs = allTabs.filter((tab) => {
|
|
132
124
|
const url = tab.url;
|
|
133
|
-
if (!url)
|
|
125
|
+
if (!url)
|
|
126
|
+
return false;
|
|
134
127
|
return !!matchPatterns.find((pattern) => pattern.includes(url));
|
|
135
128
|
});
|
|
136
129
|
await Promise.all(
|
|
137
130
|
matchingTabs.map(async (tab) => {
|
|
138
131
|
try {
|
|
139
|
-
await
|
|
132
|
+
await browser.tabs.reload(tab.id);
|
|
140
133
|
} catch (err) {
|
|
141
134
|
logger.warn("Failed to reload tab:", err);
|
|
142
135
|
}
|
|
@@ -147,33 +140,32 @@ async function reloadContentScriptMv2(_payload) {
|
|
|
147
140
|
throw Error("TODO: reloadContentScriptMv2");
|
|
148
141
|
}
|
|
149
142
|
|
|
150
|
-
// src/virtual/background-entrypoint.ts
|
|
151
143
|
if (import.meta.env.COMMAND === "serve") {
|
|
152
144
|
try {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
145
|
+
const ws = getDevServerWebSocket();
|
|
146
|
+
ws.addWxtEventListener("wxt:reload-extension", () => {
|
|
147
|
+
browser.runtime.reload();
|
|
156
148
|
});
|
|
157
|
-
|
|
149
|
+
ws.addWxtEventListener("wxt:reload-content-script", (event) => {
|
|
158
150
|
reloadContentScript(event.detail);
|
|
159
151
|
});
|
|
160
152
|
if (import.meta.env.MANIFEST_VERSION === 3) {
|
|
161
|
-
|
|
153
|
+
ws.addEventListener(
|
|
162
154
|
"open",
|
|
163
|
-
() =>
|
|
155
|
+
() => ws.sendCustom("wxt:background-initialized")
|
|
164
156
|
);
|
|
165
157
|
keepServiceWorkerAlive();
|
|
166
158
|
}
|
|
167
159
|
} catch (err) {
|
|
168
160
|
logger.error("Failed to setup web socket connection with dev server", err);
|
|
169
161
|
}
|
|
170
|
-
|
|
162
|
+
browser.commands.onCommand.addListener((command) => {
|
|
171
163
|
if (command === "wxt:reload-extension") {
|
|
172
|
-
|
|
164
|
+
browser.runtime.reload();
|
|
173
165
|
}
|
|
174
166
|
});
|
|
175
167
|
}
|
|
176
|
-
|
|
168
|
+
let result;
|
|
177
169
|
try {
|
|
178
170
|
initPlugins();
|
|
179
171
|
result = definition.main();
|
|
@@ -186,7 +178,6 @@ try {
|
|
|
186
178
|
logger.error("The background crashed on startup!");
|
|
187
179
|
throw err;
|
|
188
180
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
};
|
|
181
|
+
const result$1 = result;
|
|
182
|
+
|
|
183
|
+
export { result$1 as default };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import definition from 'virtual:user-content-script-isolated-world-entrypoint';
|
|
2
|
+
import { ContentScriptContext } from 'wxt/client';
|
|
3
|
+
import { initPlugins } from 'virtual:wxt-plugins';
|
|
3
4
|
|
|
4
|
-
// src/sandbox/utils/logger.ts
|
|
5
5
|
function print(method, ...args) {
|
|
6
|
-
if (import.meta.env.MODE === "production")
|
|
6
|
+
if (import.meta.env.MODE === "production")
|
|
7
|
+
return;
|
|
7
8
|
if (typeof args[0] === "string") {
|
|
8
9
|
const message = args.shift();
|
|
9
10
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -11,17 +12,14 @@ function print(method, ...args) {
|
|
|
11
12
|
method("[wxt]", ...args);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
const logger = {
|
|
15
16
|
debug: (...args) => print(console.debug, ...args),
|
|
16
17
|
log: (...args) => print(console.log, ...args),
|
|
17
18
|
warn: (...args) => print(console.warn, ...args),
|
|
18
19
|
error: (...args) => print(console.error, ...args)
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
import { ContentScriptContext } from "wxt/client";
|
|
23
|
-
import { initPlugins } from "virtual:wxt-plugins";
|
|
24
|
-
var result = (async () => {
|
|
22
|
+
const result = (async () => {
|
|
25
23
|
try {
|
|
26
24
|
initPlugins();
|
|
27
25
|
const { main, ...options } = definition;
|
|
@@ -35,7 +33,5 @@ var result = (async () => {
|
|
|
35
33
|
throw err;
|
|
36
34
|
}
|
|
37
35
|
})();
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
content_script_isolated_world_entrypoint_default as default
|
|
41
|
-
};
|
|
36
|
+
|
|
37
|
+
export { result as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import definition from 'virtual:user-content-script-main-world-entrypoint';
|
|
2
|
+
import { initPlugins } from 'virtual:wxt-plugins';
|
|
3
3
|
|
|
4
|
-
// src/sandbox/utils/logger.ts
|
|
5
4
|
function print(method, ...args) {
|
|
6
|
-
if (import.meta.env.MODE === "production")
|
|
5
|
+
if (import.meta.env.MODE === "production")
|
|
6
|
+
return;
|
|
7
7
|
if (typeof args[0] === "string") {
|
|
8
8
|
const message = args.shift();
|
|
9
9
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -11,20 +11,17 @@ function print(method, ...args) {
|
|
|
11
11
|
method("[wxt]", ...args);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const logger = {
|
|
15
15
|
debug: (...args) => print(console.debug, ...args),
|
|
16
16
|
log: (...args) => print(console.log, ...args),
|
|
17
17
|
warn: (...args) => print(console.warn, ...args),
|
|
18
18
|
error: (...args) => print(console.error, ...args)
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
import { initPlugins } from "virtual:wxt-plugins";
|
|
23
|
-
var result = (async () => {
|
|
21
|
+
const result = (async () => {
|
|
24
22
|
try {
|
|
25
23
|
initPlugins();
|
|
26
|
-
|
|
27
|
-
return await main();
|
|
24
|
+
return await definition.main();
|
|
28
25
|
} catch (err) {
|
|
29
26
|
logger.error(
|
|
30
27
|
`The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
|
|
@@ -33,7 +30,5 @@ var result = (async () => {
|
|
|
33
30
|
throw err;
|
|
34
31
|
}
|
|
35
32
|
})();
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
content_script_main_world_entrypoint_default as default
|
|
39
|
-
};
|
|
33
|
+
|
|
34
|
+
export { result as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// src/sandbox/utils/logger.ts
|
|
2
1
|
function print(method, ...args) {
|
|
3
|
-
if (import.meta.env.MODE === "production")
|
|
2
|
+
if (import.meta.env.MODE === "production")
|
|
3
|
+
return;
|
|
4
4
|
if (typeof args[0] === "string") {
|
|
5
5
|
const message = args.shift();
|
|
6
6
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -8,15 +8,14 @@ function print(method, ...args) {
|
|
|
8
8
|
method("[wxt]", ...args);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const logger = {
|
|
12
12
|
debug: (...args) => print(console.debug, ...args),
|
|
13
13
|
log: (...args) => print(console.log, ...args),
|
|
14
14
|
warn: (...args) => print(console.warn, ...args),
|
|
15
15
|
error: (...args) => print(console.error, ...args)
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
var ws;
|
|
18
|
+
let ws;
|
|
20
19
|
function getDevServerWebSocket() {
|
|
21
20
|
if (import.meta.env.COMMAND !== "serve")
|
|
22
21
|
throw Error(
|
|
@@ -53,12 +52,12 @@ function getDevServerWebSocket() {
|
|
|
53
52
|
return ws;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
// src/virtual/reload-html.ts
|
|
57
55
|
if (import.meta.env.COMMAND === "serve") {
|
|
58
56
|
try {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
if (event.detail === location.pathname.substring(1))
|
|
57
|
+
const ws = getDevServerWebSocket();
|
|
58
|
+
ws.addWxtEventListener("wxt:reload-page", (event) => {
|
|
59
|
+
if (event.detail === location.pathname.substring(1))
|
|
60
|
+
location.reload();
|
|
62
61
|
});
|
|
63
62
|
} catch (err) {
|
|
64
63
|
logger.error("Failed to setup web socket connection with dev server", err);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import definition from 'virtual:user-unlisted-script-entrypoint';
|
|
2
|
+
import { initPlugins } from 'virtual:wxt-plugins';
|
|
3
3
|
|
|
4
|
-
// src/sandbox/utils/logger.ts
|
|
5
4
|
function print(method, ...args) {
|
|
6
|
-
if (import.meta.env.MODE === "production")
|
|
5
|
+
if (import.meta.env.MODE === "production")
|
|
6
|
+
return;
|
|
7
7
|
if (typeof args[0] === "string") {
|
|
8
8
|
const message = args.shift();
|
|
9
9
|
method(`[wxt] ${message}`, ...args);
|
|
@@ -11,16 +11,14 @@ function print(method, ...args) {
|
|
|
11
11
|
method("[wxt]", ...args);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
const logger = {
|
|
15
15
|
debug: (...args) => print(console.debug, ...args),
|
|
16
16
|
log: (...args) => print(console.log, ...args),
|
|
17
17
|
warn: (...args) => print(console.warn, ...args),
|
|
18
18
|
error: (...args) => print(console.error, ...args)
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
import { initPlugins } from "virtual:wxt-plugins";
|
|
23
|
-
var result = (async () => {
|
|
21
|
+
const result = (async () => {
|
|
24
22
|
try {
|
|
25
23
|
initPlugins();
|
|
26
24
|
return await definition.main();
|
|
@@ -32,7 +30,5 @@ var result = (async () => {
|
|
|
32
30
|
throw err;
|
|
33
31
|
}
|
|
34
32
|
})();
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
unlisted_script_entrypoint_default as default
|
|
38
|
-
};
|
|
33
|
+
|
|
34
|
+
export { result as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,64 +30,43 @@
|
|
|
30
30
|
"wxt": "./bin/wxt.mjs",
|
|
31
31
|
"wxt-publish-extension": "./bin/wxt-publish-extension.cjs"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
34
|
-
"module": "./dist/index.js",
|
|
33
|
+
"module": "./dist/index.mjs",
|
|
35
34
|
"types": "./dist/index.d.ts",
|
|
36
35
|
"exports": {
|
|
37
36
|
".": {
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
"default": "./dist/index.js"
|
|
41
|
-
},
|
|
42
|
-
"require": {
|
|
43
|
-
"types": "./dist/index.d.cts",
|
|
44
|
-
"default": "./dist/index.cjs"
|
|
45
|
-
}
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./dist/index.mjs"
|
|
46
39
|
},
|
|
47
40
|
"./client": {
|
|
48
|
-
"types": "./dist/client.d.ts",
|
|
49
|
-
"
|
|
41
|
+
"types": "./dist/client/index.d.ts",
|
|
42
|
+
"default": "./dist/client/index.mjs"
|
|
50
43
|
},
|
|
51
44
|
"./sandbox": {
|
|
52
|
-
"types": "./dist/sandbox.d.ts",
|
|
53
|
-
"
|
|
45
|
+
"types": "./dist/sandbox/index.d.ts",
|
|
46
|
+
"default": "./dist/sandbox/index.mjs"
|
|
54
47
|
},
|
|
55
48
|
"./browser": {
|
|
56
|
-
"types": "./dist/browser.d.ts",
|
|
57
|
-
"
|
|
49
|
+
"types": "./dist/browser/index.d.ts",
|
|
50
|
+
"default": "./dist/browser/index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./browser/chrome": {
|
|
53
|
+
"types": "./dist/browser/chrome.d.ts",
|
|
54
|
+
"import": "./dist/browser/chrome.mjs"
|
|
58
55
|
},
|
|
59
56
|
"./testing": {
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"default": "./dist/testing.js"
|
|
63
|
-
},
|
|
64
|
-
"require": {
|
|
65
|
-
"types": "./dist/testing.d.cts",
|
|
66
|
-
"default": "./dist/testing.cjs"
|
|
67
|
-
}
|
|
57
|
+
"types": "./dist/testing/index.d.ts",
|
|
58
|
+
"default": "./dist/testing/index.mjs"
|
|
68
59
|
},
|
|
69
60
|
"./storage": {
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
"default": "./dist/storage.js"
|
|
73
|
-
},
|
|
74
|
-
"require": {
|
|
75
|
-
"types": "./dist/storage.d.cts",
|
|
76
|
-
"default": "./dist/storage.cjs"
|
|
77
|
-
}
|
|
61
|
+
"types": "./dist/storage.d.ts",
|
|
62
|
+
"default": "./dist/storage.mjs"
|
|
78
63
|
},
|
|
79
64
|
"./vite-builder-env": {
|
|
80
65
|
"types": "./dist/vite-builder-env.d.ts"
|
|
81
66
|
},
|
|
82
67
|
"./modules": {
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
"default": "./dist/modules.js"
|
|
86
|
-
},
|
|
87
|
-
"require": {
|
|
88
|
-
"types": "./dist/modules.d.cts",
|
|
89
|
-
"default": "./dist/modules.cjs"
|
|
90
|
-
}
|
|
68
|
+
"types": "./dist/modules.d.ts",
|
|
69
|
+
"default": "./dist/modules.mjs"
|
|
91
70
|
}
|
|
92
71
|
},
|
|
93
72
|
"dependencies": {
|
|
@@ -96,16 +75,16 @@
|
|
|
96
75
|
"@webext-core/fake-browser": "^1.3.1",
|
|
97
76
|
"@webext-core/isolated-element": "^1.1.2",
|
|
98
77
|
"@webext-core/match-patterns": "^1.0.3",
|
|
99
|
-
"async-mutex": "^0.
|
|
78
|
+
"async-mutex": "^0.5.0",
|
|
100
79
|
"c12": "^1.11.1",
|
|
101
80
|
"cac": "^6.7.14",
|
|
102
81
|
"chokidar": "^3.6.0",
|
|
103
82
|
"ci-info": "^4.0.0",
|
|
104
83
|
"defu": "^6.1.4",
|
|
105
84
|
"dequal": "^2.0.3",
|
|
106
|
-
"esbuild": "^0.
|
|
85
|
+
"esbuild": "^0.23.0",
|
|
107
86
|
"fast-glob": "^3.3.2",
|
|
108
|
-
"filesize": "^10.1.
|
|
87
|
+
"filesize": "^10.1.4",
|
|
109
88
|
"fs-extra": "^11.2.0",
|
|
110
89
|
"get-port": "^7.1.0",
|
|
111
90
|
"giget": "^1.2.3",
|
|
@@ -116,49 +95,60 @@
|
|
|
116
95
|
"jszip": "^3.10.1",
|
|
117
96
|
"linkedom": "^0.18.4",
|
|
118
97
|
"magicast": "^0.3.4",
|
|
119
|
-
"minimatch": "^
|
|
98
|
+
"minimatch": "^10.0.1",
|
|
120
99
|
"natural-compare": "^1.4.0",
|
|
121
100
|
"normalize-path": "^3.0.0",
|
|
122
101
|
"nypm": "^0.3.9",
|
|
123
102
|
"ohash": "^1.1.3",
|
|
124
103
|
"open": "^10.1.0",
|
|
125
|
-
"ora": "^
|
|
104
|
+
"ora": "^8.0.1",
|
|
126
105
|
"picocolors": "^1.0.1",
|
|
127
106
|
"prompts": "^2.4.2",
|
|
128
107
|
"publish-browser-extension": "^2.1.3",
|
|
129
|
-
"unimport": "^3.
|
|
130
|
-
"vite": "^5.3.
|
|
131
|
-
"vite-node": "^
|
|
108
|
+
"unimport": "^3.9.0",
|
|
109
|
+
"vite": "^5.3.4",
|
|
110
|
+
"vite-node": "^2.0.0",
|
|
132
111
|
"web-ext-run": "^0.2.1",
|
|
133
|
-
"webextension-polyfill": "^0.
|
|
112
|
+
"webextension-polyfill": "^0.12.0"
|
|
134
113
|
},
|
|
135
114
|
"devDependencies": {
|
|
136
115
|
"@aklinker1/check": "^1.3.1",
|
|
137
116
|
"@faker-js/faker": "^8.4.1",
|
|
117
|
+
"@types/chrome": "^0.0.268",
|
|
138
118
|
"@types/fs-extra": "^11.0.4",
|
|
139
119
|
"@types/lodash.merge": "^4.6.9",
|
|
140
120
|
"@types/natural-compare": "^1.4.3",
|
|
141
|
-
"@types/node": "^20.14.
|
|
121
|
+
"@types/node": "^20.14.11",
|
|
142
122
|
"@types/normalize-path": "^3.0.2",
|
|
143
123
|
"@types/prompts": "^2.4.9",
|
|
144
124
|
"execa": "^9.3.0",
|
|
145
125
|
"extract-zip": "^2.0.1",
|
|
146
|
-
"happy-dom": "^
|
|
126
|
+
"happy-dom": "^14.12.3",
|
|
147
127
|
"lodash.merge": "^4.6.2",
|
|
148
128
|
"p-map": "^7.0.2",
|
|
149
|
-
"publint": "^0.2.
|
|
150
|
-
"tsup": "^8.1.0",
|
|
129
|
+
"publint": "^0.2.9",
|
|
151
130
|
"tsx": "4.15.7",
|
|
152
|
-
"typescript": "^5.5.
|
|
131
|
+
"typescript": "^5.5.3",
|
|
132
|
+
"unbuild": "^2.0.0",
|
|
133
|
+
"vitest": "^2.0.3",
|
|
134
|
+
"vitest-plugin-random-seed": "^1.1.0"
|
|
135
|
+
},
|
|
136
|
+
"peerDependencies": {
|
|
137
|
+
"@types/chrome": "*"
|
|
138
|
+
},
|
|
139
|
+
"peerDependenciesMeta": {
|
|
140
|
+
"@types/chrome": {
|
|
141
|
+
"optional": true
|
|
142
|
+
}
|
|
153
143
|
},
|
|
154
144
|
"scripts": {
|
|
155
145
|
"wxt": "tsx src/cli/index.ts",
|
|
156
|
-
"build": "buildc --
|
|
146
|
+
"build": "buildc -- unbuild",
|
|
157
147
|
"check": "buildc --deps-only -- run-s -c check:*",
|
|
158
148
|
"check:default": "check",
|
|
159
149
|
"check:tsc-virtual": "tsc --noEmit -p src/virtual",
|
|
160
150
|
"test": "buildc --deps-only -- vitest",
|
|
161
|
-
"test:
|
|
151
|
+
"test:coverage": "pnpm test -- run --coverage",
|
|
162
152
|
"sync-releases": "pnpx changelogen@latest gh release"
|
|
163
153
|
}
|
|
164
154
|
}
|
package/dist/browser.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Browser, Runtime, I18n } from 'webextension-polyfill';
|
|
2
|
-
export { Action, ActivityLog, Alarms, Bookmarks, BrowserAction, BrowserSettings, BrowsingData, CaptivePortal, Clipboard, Commands, ContentScripts, ContextMenus, ContextualIdentities, Cookies, DeclarativeNetRequest, Devtools, Dns, Downloads, Events, Experiments, Extension, ExtensionTypes, Find, GeckoProfiler, History, I18n, Identity, Idle, Management, Manifest, Menus, NetworkStatus, NormandyAddonStudy, Notifications, Omnibox, PageAction, Permissions, Pkcs11, Privacy, Proxy, Runtime, Scripting, Search, Sessions, SidebarAction, Storage, Tabs, Theme, TopSites, Types, Urlbar, UserScripts, WebNavigation, WebRequest, Windows } from 'webextension-polyfill';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @module wxt/browser
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
interface AugmentedBrowser extends Browser {
|
|
9
|
-
runtime: WxtRuntime;
|
|
10
|
-
i18n: WxtI18n;
|
|
11
|
-
}
|
|
12
|
-
interface WxtRuntime extends Runtime.Static {
|
|
13
|
-
}
|
|
14
|
-
interface WxtI18n extends I18n.Static {
|
|
15
|
-
}
|
|
16
|
-
declare const browser: AugmentedBrowser;
|
|
17
|
-
|
|
18
|
-
export { type AugmentedBrowser, type WxtI18n, type WxtRuntime, browser };
|