wxt 0.2.2 → 0.2.3
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/cli.cjs +37 -44
- package/dist/index.cjs +36 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +36 -43
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -275,10 +275,10 @@ interface BackgroundScriptDefintition {
|
|
|
275
275
|
main(): void;
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
278
|
-
* Manifest customization available in the `wxt.config.ts` file.
|
|
279
|
-
*
|
|
278
|
+
* Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
|
|
279
|
+
* here, they are configured inline.
|
|
280
280
|
*/
|
|
281
|
-
type UserManifest = Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'content_scripts' | '
|
|
281
|
+
type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'action' | 'background' | 'browser_action' | 'chrome_url_overrides' | 'content_scripts' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'page_action' | 'popup' | 'sidepanel' | 'sidebar_action'>>;
|
|
282
282
|
type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
|
|
283
283
|
interface ConfigEnv {
|
|
284
284
|
mode: string;
|
|
@@ -353,7 +353,7 @@ interface ExtensionRunnerConfig {
|
|
|
353
353
|
|
|
354
354
|
type EntrypointGroup = Entrypoint | Entrypoint[];
|
|
355
355
|
|
|
356
|
-
var version = "0.2.
|
|
356
|
+
var version = "0.2.3";
|
|
357
357
|
|
|
358
358
|
declare function defineConfig(config: UserConfig): UserConfig;
|
|
359
359
|
|
package/dist/index.js
CHANGED
|
@@ -850,15 +850,15 @@ async function getOptionsEntrypoint(config, path5) {
|
|
|
850
850
|
const { document } = parseHTML2(content);
|
|
851
851
|
const openInTabContent = document.querySelector("meta[name='manifest.open_in_tab']")?.getAttribute("content");
|
|
852
852
|
if (openInTabContent) {
|
|
853
|
-
options.openInTab =
|
|
853
|
+
options.openInTab = openInTabContent === "true";
|
|
854
854
|
}
|
|
855
855
|
const chromeStyleContent = document.querySelector("meta[name='manifest.chrome_style']")?.getAttribute("content");
|
|
856
856
|
if (chromeStyleContent) {
|
|
857
|
-
options.chromeStyle =
|
|
857
|
+
options.chromeStyle = chromeStyleContent === "true";
|
|
858
858
|
}
|
|
859
859
|
const browserStyleContent = document.querySelector("meta[name='manifest.browser_style']")?.getAttribute("content");
|
|
860
860
|
if (browserStyleContent) {
|
|
861
|
-
options.browserStyle =
|
|
861
|
+
options.browserStyle = browserStyleContent === "true";
|
|
862
862
|
}
|
|
863
863
|
return {
|
|
864
864
|
type: "options",
|
|
@@ -1148,29 +1148,44 @@ async function writeManifest(manifest, output, config) {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
async function generateMainfest(entrypoints, buildOutput, config) {
|
|
1150
1150
|
const pkg = await getPackageJson(config);
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
...config.manifest
|
|
1164
|
-
};
|
|
1151
|
+
const manifest = Object.assign(
|
|
1152
|
+
{
|
|
1153
|
+
manifest_version: config.manifestVersion,
|
|
1154
|
+
name: pkg?.name,
|
|
1155
|
+
description: pkg?.description,
|
|
1156
|
+
version: pkg?.version && simplifyVersion(pkg.version),
|
|
1157
|
+
// Only add the version name to chromium and if the user hasn't specified a custom version.
|
|
1158
|
+
version_name: config.browser !== "firefox" && !config.manifest.version ? pkg?.version : void 0,
|
|
1159
|
+
short_name: pkg?.shortName
|
|
1160
|
+
},
|
|
1161
|
+
config.manifest
|
|
1162
|
+
);
|
|
1165
1163
|
addEntrypoints(manifest, entrypoints, buildOutput, config);
|
|
1166
1164
|
if (config.command === "serve")
|
|
1167
1165
|
addDevModeCsp(manifest, config);
|
|
1168
1166
|
if (config.command === "serve")
|
|
1169
1167
|
addDevModePermissions(manifest, config);
|
|
1168
|
+
if (manifest.name == null)
|
|
1169
|
+
throw Error(
|
|
1170
|
+
"Manifest 'name' is missing. Either:\n1. Set the name in your <root>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
|
|
1171
|
+
);
|
|
1172
|
+
if (manifest.version == null) {
|
|
1173
|
+
throw Error(
|
|
1174
|
+
"Manifest 'version' is missing. Either:\n1. Add a version in your <root>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1170
1177
|
return manifest;
|
|
1171
1178
|
}
|
|
1172
1179
|
async function getPackageJson(config) {
|
|
1173
|
-
|
|
1180
|
+
const file = resolve11(config.root, "package.json");
|
|
1181
|
+
try {
|
|
1182
|
+
return await fs9.readJson(file);
|
|
1183
|
+
} catch (err) {
|
|
1184
|
+
config.logger.debug(
|
|
1185
|
+
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
1186
|
+
);
|
|
1187
|
+
return {};
|
|
1188
|
+
}
|
|
1174
1189
|
}
|
|
1175
1190
|
function simplifyVersion(versionName) {
|
|
1176
1191
|
const version3 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
|
|
@@ -1612,29 +1627,6 @@ async function rebuild(config, entrypointGroups, existingOutput = {
|
|
|
1612
1627
|
// src/core/server.ts
|
|
1613
1628
|
import * as vite4 from "vite";
|
|
1614
1629
|
|
|
1615
|
-
// src/core/utils/findOpenPort.ts
|
|
1616
|
-
import net from "node:net";
|
|
1617
|
-
function findOpenPort(startPort, endPort) {
|
|
1618
|
-
return findOpenPortRecursive(startPort, startPort, endPort);
|
|
1619
|
-
}
|
|
1620
|
-
function findOpenPortRecursive(port, startPort, endPort) {
|
|
1621
|
-
return new Promise((resolve13, reject) => {
|
|
1622
|
-
if (port > endPort)
|
|
1623
|
-
return reject(
|
|
1624
|
-
Error(`Could not find open port between ${startPort}-${endPort}`)
|
|
1625
|
-
);
|
|
1626
|
-
const server = net.createServer();
|
|
1627
|
-
server.listen(port, () => {
|
|
1628
|
-
server.once("close", () => resolve13(port));
|
|
1629
|
-
server.close();
|
|
1630
|
-
});
|
|
1631
|
-
server.on(
|
|
1632
|
-
"error",
|
|
1633
|
-
() => resolve13(findOpenPortRecursive(port + 1, startPort, endPort))
|
|
1634
|
-
);
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
1630
|
// src/core/runners/createWebExtRunner.ts
|
|
1639
1631
|
function createWebExtRunner() {
|
|
1640
1632
|
let runner;
|
|
@@ -1694,7 +1686,8 @@ var ERROR_LOG_LEVEL = 50;
|
|
|
1694
1686
|
|
|
1695
1687
|
// src/core/server.ts
|
|
1696
1688
|
async function getServerInfo() {
|
|
1697
|
-
const
|
|
1689
|
+
const { default: getPort, portNumbers } = await import("get-port");
|
|
1690
|
+
const port = await getPort({ port: portNumbers(3e3, 3010) });
|
|
1698
1691
|
const hostname = "localhost";
|
|
1699
1692
|
const origin = `http://${hostname}:${port}`;
|
|
1700
1693
|
const serverConfig = {
|
|
@@ -1778,7 +1771,7 @@ function reloadHtmlPages(groups, server, config) {
|
|
|
1778
1771
|
}
|
|
1779
1772
|
|
|
1780
1773
|
// package.json
|
|
1781
|
-
var version2 = "0.2.
|
|
1774
|
+
var version2 = "0.2.3";
|
|
1782
1775
|
|
|
1783
1776
|
// src/core/utils/defineConfig.ts
|
|
1784
1777
|
function defineConfig(config) {
|