wxt 0.2.1 → 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 +38 -45
- package/dist/index.cjs +37 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +37 -44
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -890,15 +890,15 @@ async function getOptionsEntrypoint(config, path5) {
|
|
|
890
890
|
const { document } = (0, import_linkedom2.parseHTML)(content);
|
|
891
891
|
const openInTabContent = document.querySelector("meta[name='manifest.open_in_tab']")?.getAttribute("content");
|
|
892
892
|
if (openInTabContent) {
|
|
893
|
-
options.openInTab =
|
|
893
|
+
options.openInTab = openInTabContent === "true";
|
|
894
894
|
}
|
|
895
895
|
const chromeStyleContent = document.querySelector("meta[name='manifest.chrome_style']")?.getAttribute("content");
|
|
896
896
|
if (chromeStyleContent) {
|
|
897
|
-
options.chromeStyle =
|
|
897
|
+
options.chromeStyle = chromeStyleContent === "true";
|
|
898
898
|
}
|
|
899
899
|
const browserStyleContent = document.querySelector("meta[name='manifest.browser_style']")?.getAttribute("content");
|
|
900
900
|
if (browserStyleContent) {
|
|
901
|
-
options.browserStyle =
|
|
901
|
+
options.browserStyle = browserStyleContent === "true";
|
|
902
902
|
}
|
|
903
903
|
return {
|
|
904
904
|
type: "options",
|
|
@@ -1188,29 +1188,44 @@ async function writeManifest(manifest, output, config) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
async function generateMainfest(entrypoints, buildOutput, config) {
|
|
1190
1190
|
const pkg = await getPackageJson(config);
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
...config.manifest
|
|
1204
|
-
};
|
|
1191
|
+
const manifest = Object.assign(
|
|
1192
|
+
{
|
|
1193
|
+
manifest_version: config.manifestVersion,
|
|
1194
|
+
name: pkg?.name,
|
|
1195
|
+
description: pkg?.description,
|
|
1196
|
+
version: pkg?.version && simplifyVersion(pkg.version),
|
|
1197
|
+
// Only add the version name to chromium and if the user hasn't specified a custom version.
|
|
1198
|
+
version_name: config.browser !== "firefox" && !config.manifest.version ? pkg?.version : void 0,
|
|
1199
|
+
short_name: pkg?.shortName
|
|
1200
|
+
},
|
|
1201
|
+
config.manifest
|
|
1202
|
+
);
|
|
1205
1203
|
addEntrypoints(manifest, entrypoints, buildOutput, config);
|
|
1206
1204
|
if (config.command === "serve")
|
|
1207
1205
|
addDevModeCsp(manifest, config);
|
|
1208
1206
|
if (config.command === "serve")
|
|
1209
1207
|
addDevModePermissions(manifest, config);
|
|
1208
|
+
if (manifest.name == null)
|
|
1209
|
+
throw Error(
|
|
1210
|
+
"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"
|
|
1211
|
+
);
|
|
1212
|
+
if (manifest.version == null) {
|
|
1213
|
+
throw Error(
|
|
1214
|
+
"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"
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1210
1217
|
return manifest;
|
|
1211
1218
|
}
|
|
1212
1219
|
async function getPackageJson(config) {
|
|
1213
|
-
|
|
1220
|
+
const file = (0, import_path10.resolve)(config.root, "package.json");
|
|
1221
|
+
try {
|
|
1222
|
+
return await import_fs_extra9.default.readJson(file);
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
config.logger.debug(
|
|
1225
|
+
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
1226
|
+
);
|
|
1227
|
+
return {};
|
|
1228
|
+
}
|
|
1214
1229
|
}
|
|
1215
1230
|
function simplifyVersion(versionName) {
|
|
1216
1231
|
const version3 = /^((0|[1-9][0-9]{0,8})([.](0|[1-9][0-9]{0,8})){0,3}).*$/.exec(
|
|
@@ -1652,29 +1667,6 @@ async function rebuild(config, entrypointGroups, existingOutput = {
|
|
|
1652
1667
|
// src/core/server.ts
|
|
1653
1668
|
var vite4 = __toESM(require("vite"), 1);
|
|
1654
1669
|
|
|
1655
|
-
// src/core/utils/findOpenPort.ts
|
|
1656
|
-
var import_node_net = __toESM(require("net"), 1);
|
|
1657
|
-
function findOpenPort(startPort, endPort) {
|
|
1658
|
-
return findOpenPortRecursive(startPort, startPort, endPort);
|
|
1659
|
-
}
|
|
1660
|
-
function findOpenPortRecursive(port, startPort, endPort) {
|
|
1661
|
-
return new Promise((resolve13, reject) => {
|
|
1662
|
-
if (port > endPort)
|
|
1663
|
-
return reject(
|
|
1664
|
-
Error(`Could not find open port between ${startPort}-${endPort}`)
|
|
1665
|
-
);
|
|
1666
|
-
const server = import_node_net.default.createServer();
|
|
1667
|
-
server.listen(port, () => {
|
|
1668
|
-
server.once("close", () => resolve13(port));
|
|
1669
|
-
server.close();
|
|
1670
|
-
});
|
|
1671
|
-
server.on(
|
|
1672
|
-
"error",
|
|
1673
|
-
() => resolve13(findOpenPortRecursive(port + 1, startPort, endPort))
|
|
1674
|
-
);
|
|
1675
|
-
});
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
1670
|
// src/core/runners/createWebExtRunner.ts
|
|
1679
1671
|
function createWebExtRunner() {
|
|
1680
1672
|
let runner;
|
|
@@ -1734,7 +1726,8 @@ var ERROR_LOG_LEVEL = 50;
|
|
|
1734
1726
|
|
|
1735
1727
|
// src/core/server.ts
|
|
1736
1728
|
async function getServerInfo() {
|
|
1737
|
-
const
|
|
1729
|
+
const { default: getPort, portNumbers } = await import("get-port");
|
|
1730
|
+
const port = await getPort({ port: portNumbers(3e3, 3010) });
|
|
1738
1731
|
const hostname = "localhost";
|
|
1739
1732
|
const origin = `http://${hostname}:${port}`;
|
|
1740
1733
|
const serverConfig = {
|
|
@@ -1801,7 +1794,7 @@ function reloadContentScripts(steps, config, server) {
|
|
|
1801
1794
|
const js = [getEntrypointBundlePath(entry, config.outDir, ".js")];
|
|
1802
1795
|
const css = getContentScriptCssFiles([entry], server.currentOutput);
|
|
1803
1796
|
server.reloadContentScript({
|
|
1804
|
-
...
|
|
1797
|
+
...entry.options,
|
|
1805
1798
|
js,
|
|
1806
1799
|
css
|
|
1807
1800
|
});
|
|
@@ -1818,7 +1811,7 @@ function reloadHtmlPages(groups, server, config) {
|
|
|
1818
1811
|
}
|
|
1819
1812
|
|
|
1820
1813
|
// package.json
|
|
1821
|
-
var version2 = "0.2.
|
|
1814
|
+
var version2 = "0.2.3";
|
|
1822
1815
|
|
|
1823
1816
|
// src/core/utils/defineConfig.ts
|
|
1824
1817
|
function defineConfig(config) {
|