wxt 0.3.1 → 0.3.2
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 +56 -17
- package/dist/index.cjs +50 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +420 -0
- package/dist/index.d.ts +23 -26
- package/dist/index.js +50 -13
- package/dist/index.js.map +1 -1
- package/package.json +14 -13
package/dist/index.cjs
CHANGED
|
@@ -276,7 +276,7 @@ function getUnimportOptions(config) {
|
|
|
276
276
|
imports: [{ name: "defineConfig", from: "wxt" }],
|
|
277
277
|
presets: [{ package: "wxt/client" }, { package: "wxt/browser" }],
|
|
278
278
|
warn: config.logger.warn,
|
|
279
|
-
dirs: ["
|
|
279
|
+
dirs: ["components", "composables", "hooks", "utils"]
|
|
280
280
|
};
|
|
281
281
|
return (0, import_vite.mergeConfig)(
|
|
282
282
|
defaultOptions,
|
|
@@ -1349,7 +1349,8 @@ async function generateMainfest(entrypoints, buildOutput, config) {
|
|
|
1349
1349
|
version: pkg?.version && simplifyVersion(pkg.version),
|
|
1350
1350
|
// Only add the version name to chromium and if the user hasn't specified a custom version.
|
|
1351
1351
|
version_name: config.browser !== "firefox" && !config.manifest.version ? pkg?.version : void 0,
|
|
1352
|
-
short_name: pkg?.shortName
|
|
1352
|
+
short_name: pkg?.shortName,
|
|
1353
|
+
icons: discoverIcons(buildOutput)
|
|
1353
1354
|
},
|
|
1354
1355
|
config.manifest
|
|
1355
1356
|
);
|
|
@@ -1553,6 +1554,39 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
1553
1554
|
}
|
|
1554
1555
|
}
|
|
1555
1556
|
}
|
|
1557
|
+
function discoverIcons(buildOutput) {
|
|
1558
|
+
const icons = [];
|
|
1559
|
+
const iconRegex = [
|
|
1560
|
+
/^icon-([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
|
|
1561
|
+
// icon-16.png
|
|
1562
|
+
/^icon-([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/,
|
|
1563
|
+
// icon-16x16.png
|
|
1564
|
+
/^icon@([0-9]+)w\.(png|bmp|jpeg|jpg|ico|gif)$/,
|
|
1565
|
+
// icon@16w.png
|
|
1566
|
+
/^icon@([0-9]+)h\.(png|bmp|jpeg|jpg|ico|gif)$/,
|
|
1567
|
+
// icon@16h.png
|
|
1568
|
+
/^icon@([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
|
|
1569
|
+
// icon@16.png
|
|
1570
|
+
/^icon[\/\\]([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
|
|
1571
|
+
// icon/16.png
|
|
1572
|
+
/^icon[\/\\]([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/
|
|
1573
|
+
// icon/16x16.png
|
|
1574
|
+
];
|
|
1575
|
+
buildOutput.publicAssets.forEach((asset) => {
|
|
1576
|
+
let size;
|
|
1577
|
+
for (const regex of iconRegex) {
|
|
1578
|
+
const match = asset.fileName.match(regex);
|
|
1579
|
+
if (match?.[1] != null) {
|
|
1580
|
+
size = match[1];
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
if (size == null)
|
|
1585
|
+
return;
|
|
1586
|
+
icons.push([size, normalizePath2(asset.fileName)]);
|
|
1587
|
+
});
|
|
1588
|
+
return icons.length > 0 ? Object.fromEntries(icons) : void 0;
|
|
1589
|
+
}
|
|
1556
1590
|
function addDevModeCsp(manifest, config) {
|
|
1557
1591
|
const permission = `http://${config.server?.hostname ?? ""}/*`;
|
|
1558
1592
|
const allowedCsp = config.server?.origin ?? "http://localhost:*";
|
|
@@ -1671,7 +1705,7 @@ var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
|
1671
1705
|
var import_filesize = require("filesize");
|
|
1672
1706
|
|
|
1673
1707
|
// src/core/log/printTable.ts
|
|
1674
|
-
function printTable(log, rows, gap = 2) {
|
|
1708
|
+
function printTable(log, header, rows, gap = 2) {
|
|
1675
1709
|
if (rows.length === 0)
|
|
1676
1710
|
return;
|
|
1677
1711
|
const columnWidths = rows.reduce(
|
|
@@ -1693,11 +1727,12 @@ function printTable(log, rows, gap = 2) {
|
|
|
1693
1727
|
if (i !== rows.length - 1)
|
|
1694
1728
|
str += "\n";
|
|
1695
1729
|
});
|
|
1696
|
-
log(
|
|
1730
|
+
log(`${header}
|
|
1731
|
+
${str}`);
|
|
1697
1732
|
}
|
|
1698
1733
|
|
|
1699
1734
|
// src/core/log/printFileList.ts
|
|
1700
|
-
async function printFileList(log, baseDir, files) {
|
|
1735
|
+
async function printFileList(log, header, baseDir, files) {
|
|
1701
1736
|
let totalSize = 0;
|
|
1702
1737
|
const fileRows = await Promise.all(
|
|
1703
1738
|
files.map(async (file, i) => {
|
|
@@ -1716,8 +1751,8 @@ async function printFileList(log, baseDir, files) {
|
|
|
1716
1751
|
];
|
|
1717
1752
|
})
|
|
1718
1753
|
);
|
|
1719
|
-
|
|
1720
|
-
log
|
|
1754
|
+
fileRows.push([`${import_picocolors.default.cyan("\u03A3 Total size:")} ${String((0, import_filesize.filesize)(totalSize))}`]);
|
|
1755
|
+
printTable(log, header, fileRows);
|
|
1721
1756
|
}
|
|
1722
1757
|
var DEFAULT_COLOR = import_picocolors.default.blue;
|
|
1723
1758
|
var CHUNK_COLORS = {
|
|
@@ -1732,7 +1767,7 @@ function getChunkColor(filename) {
|
|
|
1732
1767
|
}
|
|
1733
1768
|
|
|
1734
1769
|
// src/core/log/printBuildSummary.ts
|
|
1735
|
-
async function printBuildSummary(output, config) {
|
|
1770
|
+
async function printBuildSummary(log, header, output, config) {
|
|
1736
1771
|
const chunks = [
|
|
1737
1772
|
...output.steps.flatMap((step) => step.chunks),
|
|
1738
1773
|
...output.publicAssets
|
|
@@ -1745,7 +1780,7 @@ async function printBuildSummary(output, config) {
|
|
|
1745
1780
|
return l.fileName.localeCompare(r.fileName);
|
|
1746
1781
|
});
|
|
1747
1782
|
const files = chunks.map((chunk) => (0, import_path11.resolve)(config.outDir, chunk.fileName));
|
|
1748
|
-
await printFileList(
|
|
1783
|
+
await printFileList(log, header, config.outDir, files);
|
|
1749
1784
|
}
|
|
1750
1785
|
var DEFAULT_SORT_WEIGHT = 100;
|
|
1751
1786
|
var CHUNK_SORT_WEIGHTS = {
|
|
@@ -1776,10 +1811,12 @@ async function buildInternal(config) {
|
|
|
1776
1811
|
const entrypoints = await findEntrypoints(config);
|
|
1777
1812
|
const groups = groupEntrypoints(entrypoints);
|
|
1778
1813
|
const { output } = await rebuild(config, groups, void 0);
|
|
1779
|
-
|
|
1780
|
-
|
|
1814
|
+
await printBuildSummary(
|
|
1815
|
+
config.logger.success,
|
|
1816
|
+
`Built extension in ${formatDuration(Date.now() - startTime)}`,
|
|
1817
|
+
output,
|
|
1818
|
+
config
|
|
1781
1819
|
);
|
|
1782
|
-
await printBuildSummary(output, config);
|
|
1783
1820
|
return output;
|
|
1784
1821
|
}
|
|
1785
1822
|
async function rebuild(config, entrypointGroups, existingOutput = {
|
|
@@ -1967,7 +2004,7 @@ function reloadHtmlPages(groups, server, config) {
|
|
|
1967
2004
|
}
|
|
1968
2005
|
|
|
1969
2006
|
// package.json
|
|
1970
|
-
var version2 = "0.3.
|
|
2007
|
+
var version2 = "0.3.2";
|
|
1971
2008
|
|
|
1972
2009
|
// src/core/utils/defineConfig.ts
|
|
1973
2010
|
function defineConfig(config) {
|