wxt 0.18.10 → 0.18.12
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/README.md +6 -6
- package/dist/{chunk-2V7XZSZQ.js → chunk-6QN6UXBH.js} +161 -91
- package/dist/cli.js +176 -96
- package/dist/client.d.ts +4 -2
- package/dist/client.js +8 -1
- package/dist/{index-Bk-a0SkY.d.ts → define-app-config-bg54F_lV.d.ts} +21 -1
- package/dist/{execa-D7CMCKO2.js → execa-4UBDUBJZ.js} +566 -478
- package/dist/{execa-ATHZH2Y4.js → execa-QLUM2B3W.js} +566 -478
- package/dist/{index-mz3v4Nde.d.cts → index-1N-eQJJh.d.cts} +15 -6
- package/dist/{index-mz3v4Nde.d.ts → index-1N-eQJJh.d.ts} +15 -6
- package/dist/index.cjs +948 -760
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +29 -20
- package/dist/modules.d.cts +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/sandbox.d.ts +2 -1
- package/dist/sandbox.js +6 -0
- package/dist/testing.cjs +127 -63
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +4 -2
- package/dist/virtual/background-entrypoint.js +9 -1
- package/package.json +10 -10
- package/dist/cli.d.ts +0 -2
package/dist/cli.js
CHANGED
|
@@ -46,7 +46,7 @@ var npm = {
|
|
|
46
46
|
overridesKey: "overrides",
|
|
47
47
|
async downloadDependency(id, downloadDir) {
|
|
48
48
|
await ensureDir(downloadDir);
|
|
49
|
-
const { execa } = await import("./execa-
|
|
49
|
+
const { execa } = await import("./execa-QLUM2B3W.js");
|
|
50
50
|
const res = await execa("npm", ["pack", id, "--json"], {
|
|
51
51
|
cwd: downloadDir
|
|
52
52
|
});
|
|
@@ -58,7 +58,7 @@ var npm = {
|
|
|
58
58
|
if (options?.all) {
|
|
59
59
|
args.push("--depth", "Infinity");
|
|
60
60
|
}
|
|
61
|
-
const { execa } = await import("./execa-
|
|
61
|
+
const { execa } = await import("./execa-QLUM2B3W.js");
|
|
62
62
|
const res = await execa("npm", args, { cwd: options?.cwd });
|
|
63
63
|
const project = JSON.parse(res.stdout);
|
|
64
64
|
return flattenNpmListOutput([project]);
|
|
@@ -111,7 +111,7 @@ var bun = {
|
|
|
111
111
|
if (options?.all) {
|
|
112
112
|
args.push("--all");
|
|
113
113
|
}
|
|
114
|
-
const { execa } = await import("./execa-
|
|
114
|
+
const { execa } = await import("./execa-QLUM2B3W.js");
|
|
115
115
|
const res = await execa("bun", args, { cwd: options?.cwd });
|
|
116
116
|
return dedupeDependencies(
|
|
117
117
|
res.stdout.split("\n").slice(1).map((line) => line.trim()).map((line) => /.* (@?\S+)@(\S+)$/.exec(line)).filter((match) => !!match).map(([_, name, version2]) => ({ name, version: version2 }))
|
|
@@ -130,7 +130,7 @@ var yarn = {
|
|
|
130
130
|
if (options?.all) {
|
|
131
131
|
args.push("--depth", "Infinity");
|
|
132
132
|
}
|
|
133
|
-
const { execa } = await import("./execa-
|
|
133
|
+
const { execa } = await import("./execa-QLUM2B3W.js");
|
|
134
134
|
const res = await execa("yarn", args, { cwd: options?.cwd });
|
|
135
135
|
const tree = res.stdout.split("\n").map((line) => JSON.parse(line)).find((line) => line.type === "tree")?.data;
|
|
136
136
|
if (tree == null) throw Error("'yarn list --json' did not output a tree");
|
|
@@ -166,7 +166,7 @@ var pnpm = {
|
|
|
166
166
|
if (typeof process !== "undefined" && process.env.WXT_PNPM_IGNORE_WORKSPACE === "true") {
|
|
167
167
|
args.push("--ignore-workspace");
|
|
168
168
|
}
|
|
169
|
-
const { execa } = await import("./execa-
|
|
169
|
+
const { execa } = await import("./execa-QLUM2B3W.js");
|
|
170
170
|
const res = await execa("pnpm", args, { cwd: options?.cwd });
|
|
171
171
|
const projects = JSON.parse(res.stdout);
|
|
172
172
|
return flattenNpmListOutput(projects);
|
|
@@ -903,6 +903,25 @@ try {
|
|
|
903
903
|
};
|
|
904
904
|
}
|
|
905
905
|
|
|
906
|
+
// src/core/builders/vite/plugins/resolveAppConfig.ts
|
|
907
|
+
import { exists } from "fs-extra";
|
|
908
|
+
import { resolve as resolve6 } from "node:path";
|
|
909
|
+
function resolveAppConfig(config) {
|
|
910
|
+
const virtualModuleId = "virtual:app-config";
|
|
911
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
912
|
+
const appConfigFile = resolve6(config.srcDir, "app.config.ts");
|
|
913
|
+
return {
|
|
914
|
+
name: "wxt:resolve-app-config",
|
|
915
|
+
async resolveId(id) {
|
|
916
|
+
if (id !== virtualModuleId) return;
|
|
917
|
+
return await exists(appConfigFile) ? appConfigFile : resolvedVirtualModuleId;
|
|
918
|
+
},
|
|
919
|
+
load(id) {
|
|
920
|
+
if (id === resolvedVirtualModuleId) return `export default {}`;
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
|
|
906
925
|
// src/core/utils/arrays.ts
|
|
907
926
|
function every(array, predicate) {
|
|
908
927
|
for (let i = 0; i < array.length; i++)
|
|
@@ -975,7 +994,8 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
975
994
|
globals(wxtConfig),
|
|
976
995
|
excludeBrowserPolyfill(wxtConfig),
|
|
977
996
|
defineImportMeta(),
|
|
978
|
-
wxtPluginLoader(wxtConfig)
|
|
997
|
+
wxtPluginLoader(wxtConfig),
|
|
998
|
+
resolveAppConfig(wxtConfig)
|
|
979
999
|
);
|
|
980
1000
|
if (wxtConfig.analysis.enabled) {
|
|
981
1001
|
config.plugins.push(bundleAnalysis(wxtConfig));
|
|
@@ -1127,7 +1147,10 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
1127
1147
|
const config = vite2.mergeConfig(baseConfig, envConfig);
|
|
1128
1148
|
const server2 = await vite2.createServer(config);
|
|
1129
1149
|
await server2.pluginContainer.buildStart({});
|
|
1130
|
-
const node = new ViteNodeServer(
|
|
1150
|
+
const node = new ViteNodeServer(
|
|
1151
|
+
// @ts-ignore: Some weird type error...
|
|
1152
|
+
server2
|
|
1153
|
+
);
|
|
1131
1154
|
installSourcemapsSupport({
|
|
1132
1155
|
getSourceMap: (source) => node.getSourceMap(source)
|
|
1133
1156
|
});
|
|
@@ -1272,8 +1295,10 @@ var unimport_default = defineWxtModule({
|
|
|
1272
1295
|
wxt2.hooks.hook("prepare:types", async (_, entries) => {
|
|
1273
1296
|
await unimport.init();
|
|
1274
1297
|
entries.push(await getImportsDeclarationEntry(unimport));
|
|
1275
|
-
if (
|
|
1276
|
-
entries.push(
|
|
1298
|
+
if (options.eslintrc.enabled === false) return;
|
|
1299
|
+
entries.push(
|
|
1300
|
+
await getEslintConfigEntry(unimport, options.eslintrc.enabled, options)
|
|
1301
|
+
);
|
|
1277
1302
|
});
|
|
1278
1303
|
addViteConfig(wxt2, () => ({
|
|
1279
1304
|
plugins: [vitePlugin(unimport)]
|
|
@@ -1314,15 +1339,33 @@ async function getImportsDeclarationEntry(unimport) {
|
|
|
1314
1339
|
tsReference: true
|
|
1315
1340
|
};
|
|
1316
1341
|
}
|
|
1317
|
-
async function
|
|
1318
|
-
const globals2 = {
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1342
|
+
async function getEslintConfigEntry(unimport, version2, options) {
|
|
1343
|
+
const globals2 = (await unimport.getImports()).map((i) => i.as ?? i.name).filter(Boolean).sort().reduce((globals3, name) => {
|
|
1344
|
+
globals3[name] = options.eslintrc.globalsPropValue;
|
|
1345
|
+
return globals3;
|
|
1346
|
+
}, {});
|
|
1347
|
+
if (version2 <= 8) return getEslint8ConfigEntry(options, globals2);
|
|
1348
|
+
else return getEslint9ConfigEntry(options, globals2);
|
|
1349
|
+
}
|
|
1350
|
+
function getEslint8ConfigEntry(options, globals2) {
|
|
1351
|
+
return {
|
|
1352
|
+
path: options.eslintrc.filePath,
|
|
1353
|
+
text: JSON.stringify({ globals: globals2 }, null, 2) + "\n"
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
function getEslint9ConfigEntry(options, globals2) {
|
|
1323
1357
|
return {
|
|
1324
1358
|
path: options.eslintrc.filePath,
|
|
1325
|
-
text: JSON.stringify(
|
|
1359
|
+
text: `const globals = ${JSON.stringify(globals2, null, 2)}
|
|
1360
|
+
|
|
1361
|
+
export default {
|
|
1362
|
+
name: "wxt/auto-imports",
|
|
1363
|
+
languageOptions: {
|
|
1364
|
+
globals,
|
|
1365
|
+
sourceType: "module",
|
|
1366
|
+
},
|
|
1367
|
+
};
|
|
1368
|
+
`
|
|
1326
1369
|
};
|
|
1327
1370
|
}
|
|
1328
1371
|
|
|
@@ -1379,7 +1422,7 @@ async function getPublicFiles() {
|
|
|
1379
1422
|
|
|
1380
1423
|
// src/core/utils/building/build-entrypoints.ts
|
|
1381
1424
|
import fs4 from "fs-extra";
|
|
1382
|
-
import { dirname as dirname3, resolve as
|
|
1425
|
+
import { dirname as dirname3, resolve as resolve7 } from "path";
|
|
1383
1426
|
import pc from "picocolors";
|
|
1384
1427
|
async function buildEntrypoints(groups, spinner) {
|
|
1385
1428
|
const steps = [];
|
|
@@ -1401,14 +1444,14 @@ async function buildEntrypoints(groups, spinner) {
|
|
|
1401
1444
|
}
|
|
1402
1445
|
async function copyPublicDirectory() {
|
|
1403
1446
|
const files = (await getPublicFiles()).map((file) => ({
|
|
1404
|
-
absoluteSrc:
|
|
1447
|
+
absoluteSrc: resolve7(wxt.config.publicDir, file),
|
|
1405
1448
|
relativeDest: file
|
|
1406
1449
|
}));
|
|
1407
1450
|
await wxt.hooks.callHook("build:publicAssets", wxt, files);
|
|
1408
1451
|
if (files.length === 0) return [];
|
|
1409
1452
|
const publicAssets = [];
|
|
1410
1453
|
for (const file of files) {
|
|
1411
|
-
const absoluteDest =
|
|
1454
|
+
const absoluteDest = resolve7(wxt.config.outDir, file.relativeDest);
|
|
1412
1455
|
await fs4.ensureDir(dirname3(absoluteDest));
|
|
1413
1456
|
if ("absoluteSrc" in file) {
|
|
1414
1457
|
await fs4.copyFile(file.absoluteSrc, absoluteDest);
|
|
@@ -1516,7 +1559,7 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
1516
1559
|
}
|
|
1517
1560
|
|
|
1518
1561
|
// src/core/utils/building/find-entrypoints.ts
|
|
1519
|
-
import { relative as relative3, resolve as
|
|
1562
|
+
import { relative as relative3, resolve as resolve8 } from "path";
|
|
1520
1563
|
import fs5 from "fs-extra";
|
|
1521
1564
|
import { minimatch } from "minimatch";
|
|
1522
1565
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
@@ -1525,14 +1568,14 @@ import glob3 from "fast-glob";
|
|
|
1525
1568
|
import pc2 from "picocolors";
|
|
1526
1569
|
async function findEntrypoints() {
|
|
1527
1570
|
await fs5.mkdir(wxt.config.wxtDir, { recursive: true });
|
|
1528
|
-
await fs5.writeJson(
|
|
1571
|
+
await fs5.writeJson(resolve8(wxt.config.wxtDir, "tsconfig.json"), {});
|
|
1529
1572
|
const relativePaths = await glob3(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
|
|
1530
1573
|
cwd: wxt.config.entrypointsDir
|
|
1531
1574
|
});
|
|
1532
1575
|
relativePaths.sort();
|
|
1533
1576
|
const pathGlobs = Object.keys(PATH_GLOB_TO_TYPE_MAP);
|
|
1534
1577
|
const entrypointInfos = relativePaths.reduce((results, relativePath) => {
|
|
1535
|
-
const inputPath =
|
|
1578
|
+
const inputPath = resolve8(wxt.config.entrypointsDir, relativePath);
|
|
1536
1579
|
const name = getEntrypointName(wxt.config.entrypointsDir, inputPath);
|
|
1537
1580
|
const matchingGlob = pathGlobs.find(
|
|
1538
1581
|
(glob8) => minimatch(relativePath, glob8)
|
|
@@ -1574,7 +1617,7 @@ async function findEntrypoints() {
|
|
|
1574
1617
|
return {
|
|
1575
1618
|
...info,
|
|
1576
1619
|
type,
|
|
1577
|
-
outputDir:
|
|
1620
|
+
outputDir: resolve8(wxt.config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
1578
1621
|
options: {
|
|
1579
1622
|
include: void 0,
|
|
1580
1623
|
exclude: void 0
|
|
@@ -1801,7 +1844,7 @@ async function getContentScriptEntrypoint({
|
|
|
1801
1844
|
type: "content-script",
|
|
1802
1845
|
name,
|
|
1803
1846
|
inputPath,
|
|
1804
|
-
outputDir:
|
|
1847
|
+
outputDir: resolve8(wxt.config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
1805
1848
|
options: resolvePerBrowserOptions(options, wxt.config.browser),
|
|
1806
1849
|
skipped
|
|
1807
1850
|
};
|
|
@@ -1897,7 +1940,7 @@ var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
|
|
|
1897
1940
|
|
|
1898
1941
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
1899
1942
|
import fs6 from "fs-extra";
|
|
1900
|
-
import { dirname as dirname4, relative as relative4, resolve as
|
|
1943
|
+
import { dirname as dirname4, relative as relative4, resolve as resolve9 } from "node:path";
|
|
1901
1944
|
import path5 from "node:path";
|
|
1902
1945
|
|
|
1903
1946
|
// src/core/utils/i18n.ts
|
|
@@ -1956,7 +1999,7 @@ async function generateTypesDir(entrypoints) {
|
|
|
1956
1999
|
entries.push(getMainDeclarationEntry(entries));
|
|
1957
2000
|
const absoluteFileEntries = entries.filter((entry) => "path" in entry).map((entry) => ({
|
|
1958
2001
|
...entry,
|
|
1959
|
-
path:
|
|
2002
|
+
path: resolve9(wxt.config.wxtDir, entry.path)
|
|
1960
2003
|
}));
|
|
1961
2004
|
await Promise.all(
|
|
1962
2005
|
absoluteFileEntries.map(async (file) => {
|
|
@@ -2068,7 +2111,7 @@ function getMainDeclarationEntry(references) {
|
|
|
2068
2111
|
if ("module" in ref) {
|
|
2069
2112
|
return lines.push(`/// <reference types="${ref.module}" />`);
|
|
2070
2113
|
} else if (ref.tsReference) {
|
|
2071
|
-
const absolutePath =
|
|
2114
|
+
const absolutePath = resolve9(wxt.config.wxtDir, ref.path);
|
|
2072
2115
|
const relativePath = relative4(wxt.config.wxtDir, absolutePath);
|
|
2073
2116
|
lines.push(`/// <reference types="./${normalizePath(relativePath)}" />`);
|
|
2074
2117
|
}
|
|
@@ -2121,9 +2164,9 @@ import path6 from "node:path";
|
|
|
2121
2164
|
|
|
2122
2165
|
// src/core/utils/cache.ts
|
|
2123
2166
|
import fs7, { ensureDir as ensureDir3 } from "fs-extra";
|
|
2124
|
-
import { dirname as dirname5, resolve as
|
|
2167
|
+
import { dirname as dirname5, resolve as resolve10 } from "path";
|
|
2125
2168
|
function createFsCache(wxtDir) {
|
|
2126
|
-
const getPath = (key) =>
|
|
2169
|
+
const getPath = (key) => resolve10(wxtDir, "cache", encodeURIComponent(key));
|
|
2127
2170
|
return {
|
|
2128
2171
|
async set(key, value) {
|
|
2129
2172
|
const path11 = getPath(key);
|
|
@@ -2143,31 +2186,23 @@ function createFsCache(wxtDir) {
|
|
|
2143
2186
|
|
|
2144
2187
|
// src/core/utils/building/resolve-config.ts
|
|
2145
2188
|
import defu from "defu";
|
|
2146
|
-
|
|
2147
|
-
// src/core/utils/package.ts
|
|
2148
|
-
import { resolve as resolve10 } from "node:path";
|
|
2149
2189
|
import fs8 from "fs-extra";
|
|
2150
|
-
|
|
2151
|
-
|
|
2190
|
+
import glob4 from "fast-glob";
|
|
2191
|
+
|
|
2192
|
+
// src/core/utils/eslint.ts
|
|
2193
|
+
async function getEslintVersion() {
|
|
2152
2194
|
try {
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
wxt.logger.debug(
|
|
2156
|
-
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
2195
|
+
const require2 = (await import("node:module")).default.createRequire(
|
|
2196
|
+
import.meta.url
|
|
2157
2197
|
);
|
|
2158
|
-
|
|
2198
|
+
const { ESLint } = require2("eslint");
|
|
2199
|
+
return ESLint.version?.split(".") ?? [];
|
|
2200
|
+
} catch (error) {
|
|
2201
|
+
return [];
|
|
2159
2202
|
}
|
|
2160
2203
|
}
|
|
2161
|
-
function isModuleInstalled(name) {
|
|
2162
|
-
return import(
|
|
2163
|
-
/* @vite-ignore */
|
|
2164
|
-
name
|
|
2165
|
-
).then(() => true).catch(() => false);
|
|
2166
|
-
}
|
|
2167
2204
|
|
|
2168
2205
|
// src/core/utils/building/resolve-config.ts
|
|
2169
|
-
import fs9 from "fs-extra";
|
|
2170
|
-
import glob4 from "fast-glob";
|
|
2171
2206
|
async function resolveConfig(inlineConfig, command) {
|
|
2172
2207
|
let userConfig = {};
|
|
2173
2208
|
let userConfigMetadata;
|
|
@@ -2281,7 +2316,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2281
2316
|
srcDir,
|
|
2282
2317
|
typesDir,
|
|
2283
2318
|
wxtDir,
|
|
2284
|
-
zip: resolveZipConfig(root, mergedConfig),
|
|
2319
|
+
zip: resolveZipConfig(root, outBaseDir, mergedConfig),
|
|
2285
2320
|
transformManifest: mergedConfig.transformManifest,
|
|
2286
2321
|
analysis: resolveAnalysisConfig(root, mergedConfig),
|
|
2287
2322
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
@@ -2326,7 +2361,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
2326
2361
|
...builderConfig
|
|
2327
2362
|
};
|
|
2328
2363
|
}
|
|
2329
|
-
function resolveZipConfig(root, mergedConfig) {
|
|
2364
|
+
function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
2330
2365
|
const downloadedPackagesDir = path6.resolve(root, ".wxt/local_modules");
|
|
2331
2366
|
return {
|
|
2332
2367
|
name: void 0,
|
|
@@ -2345,6 +2380,8 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
2345
2380
|
// Tests
|
|
2346
2381
|
"**/__tests__/**",
|
|
2347
2382
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
2383
|
+
// Output directory
|
|
2384
|
+
`${path6.relative(root, outBaseDir)}/**`,
|
|
2348
2385
|
// From user
|
|
2349
2386
|
...mergedConfig.zip?.excludeSources ?? []
|
|
2350
2387
|
],
|
|
@@ -2371,16 +2408,6 @@ function resolveAnalysisConfig(root, mergedConfig) {
|
|
|
2371
2408
|
}
|
|
2372
2409
|
async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
2373
2410
|
if (config.imports === false) return false;
|
|
2374
|
-
const rawEslintEnabled = config.imports?.eslintrc?.enabled;
|
|
2375
|
-
let eslintEnabled;
|
|
2376
|
-
switch (rawEslintEnabled) {
|
|
2377
|
-
case void 0:
|
|
2378
|
-
case "auto":
|
|
2379
|
-
eslintEnabled = await isModuleInstalled("eslint");
|
|
2380
|
-
break;
|
|
2381
|
-
default:
|
|
2382
|
-
eslintEnabled = rawEslintEnabled;
|
|
2383
|
-
}
|
|
2384
2411
|
const defaultOptions = {
|
|
2385
2412
|
debugLog: logger.debug,
|
|
2386
2413
|
imports: [
|
|
@@ -2398,23 +2425,45 @@ async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
|
2398
2425
|
dirsScanOptions: {
|
|
2399
2426
|
cwd: srcDir
|
|
2400
2427
|
},
|
|
2401
|
-
eslintrc:
|
|
2402
|
-
enabled: eslintEnabled,
|
|
2403
|
-
filePath: path6.resolve(wxtDir, "eslintrc-auto-import.json"),
|
|
2404
|
-
globalsPropValue: true
|
|
2405
|
-
}
|
|
2428
|
+
eslintrc: await getUnimportEslintOptions(wxtDir, config.imports?.eslintrc)
|
|
2406
2429
|
};
|
|
2407
2430
|
return defu(
|
|
2408
2431
|
config.imports ?? {},
|
|
2409
2432
|
defaultOptions
|
|
2410
2433
|
);
|
|
2411
2434
|
}
|
|
2435
|
+
async function getUnimportEslintOptions(wxtDir, options) {
|
|
2436
|
+
const rawEslintEnabled = options?.enabled ?? "auto";
|
|
2437
|
+
let eslintEnabled;
|
|
2438
|
+
switch (rawEslintEnabled) {
|
|
2439
|
+
case "auto":
|
|
2440
|
+
const version2 = await getEslintVersion();
|
|
2441
|
+
let major = parseInt(version2[0]);
|
|
2442
|
+
if (major <= 8) eslintEnabled = 8;
|
|
2443
|
+
else if (major >= 9) eslintEnabled = 9;
|
|
2444
|
+
else eslintEnabled = 8;
|
|
2445
|
+
break;
|
|
2446
|
+
case true:
|
|
2447
|
+
eslintEnabled = 8;
|
|
2448
|
+
break;
|
|
2449
|
+
default:
|
|
2450
|
+
eslintEnabled = rawEslintEnabled;
|
|
2451
|
+
}
|
|
2452
|
+
return {
|
|
2453
|
+
enabled: eslintEnabled,
|
|
2454
|
+
filePath: path6.resolve(
|
|
2455
|
+
wxtDir,
|
|
2456
|
+
eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
|
|
2457
|
+
),
|
|
2458
|
+
globalsPropValue: true
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2412
2461
|
async function resolveWxtModuleDir() {
|
|
2413
2462
|
const requireResolve = __require?.resolve ?? (await import("node:module")).default.createRequire(import.meta.url).resolve;
|
|
2414
2463
|
return path6.resolve(requireResolve("wxt"), "../..");
|
|
2415
2464
|
}
|
|
2416
2465
|
async function isDirMissing(dir) {
|
|
2417
|
-
return !await
|
|
2466
|
+
return !await fs8.exists(dir);
|
|
2418
2467
|
}
|
|
2419
2468
|
function logMissingDir(logger, name, expected) {
|
|
2420
2469
|
logger.warn(
|
|
@@ -2529,7 +2578,7 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
2529
2578
|
// src/core/utils/building/import-entrypoint.ts
|
|
2530
2579
|
import createJITI from "jiti";
|
|
2531
2580
|
import { createUnimport as createUnimport2 } from "unimport";
|
|
2532
|
-
import
|
|
2581
|
+
import fs9 from "fs-extra";
|
|
2533
2582
|
import { relative as relative5, resolve as resolve11 } from "node:path";
|
|
2534
2583
|
import { transformSync } from "esbuild";
|
|
2535
2584
|
import { fileURLToPath } from "node:url";
|
|
@@ -2542,7 +2591,7 @@ async function importEntrypointFile(path11) {
|
|
|
2542
2591
|
dirs: []
|
|
2543
2592
|
});
|
|
2544
2593
|
await unimport.init();
|
|
2545
|
-
const text = await
|
|
2594
|
+
const text = await fs9.readFile(path11, "utf-8");
|
|
2546
2595
|
const textNoImports = removeProjectImportStatements(text);
|
|
2547
2596
|
const { code } = await unimport.injectImports(textNoImports);
|
|
2548
2597
|
wxt.logger.debug(
|
|
@@ -2558,6 +2607,13 @@ async function importEntrypointFile(path11) {
|
|
|
2558
2607
|
"webextension-polyfill": resolve11(
|
|
2559
2608
|
wxt.config.wxtModuleDir,
|
|
2560
2609
|
"dist/virtual/mock-browser.js"
|
|
2610
|
+
),
|
|
2611
|
+
// TODO: Resolve this virtual module to some file with
|
|
2612
|
+
// `export default {}` instead of this hack of using another file with
|
|
2613
|
+
// a default export.
|
|
2614
|
+
"virtual:app-config": resolve11(
|
|
2615
|
+
wxt.config.wxtModuleDir,
|
|
2616
|
+
"dist/virtual/mock-browser.js"
|
|
2561
2617
|
)
|
|
2562
2618
|
},
|
|
2563
2619
|
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
@@ -2625,7 +2681,7 @@ import { resolve as resolve12 } from "path";
|
|
|
2625
2681
|
// src/core/utils/log/printFileList.ts
|
|
2626
2682
|
import path7 from "node:path";
|
|
2627
2683
|
import pc3 from "picocolors";
|
|
2628
|
-
import
|
|
2684
|
+
import fs10 from "fs-extra";
|
|
2629
2685
|
import { filesize } from "filesize";
|
|
2630
2686
|
|
|
2631
2687
|
// src/core/utils/log/printTable.ts
|
|
@@ -2663,7 +2719,7 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
2663
2719
|
];
|
|
2664
2720
|
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
2665
2721
|
const color = getChunkColor(file);
|
|
2666
|
-
const stats = await
|
|
2722
|
+
const stats = await fs10.lstat(file);
|
|
2667
2723
|
totalSize += stats.size;
|
|
2668
2724
|
const size = String(filesize(stats.size));
|
|
2669
2725
|
return [
|
|
@@ -2726,7 +2782,7 @@ function getChunkSortWeight(filename) {
|
|
|
2726
2782
|
import pc4 from "picocolors";
|
|
2727
2783
|
|
|
2728
2784
|
// package.json
|
|
2729
|
-
var version = "0.18.
|
|
2785
|
+
var version = "0.18.11";
|
|
2730
2786
|
|
|
2731
2787
|
// src/core/utils/log/printHeader.ts
|
|
2732
2788
|
function printHeader() {
|
|
@@ -2739,7 +2795,7 @@ import glob5 from "fast-glob";
|
|
|
2739
2795
|
|
|
2740
2796
|
// src/core/utils/manifest.ts
|
|
2741
2797
|
import fs12 from "fs-extra";
|
|
2742
|
-
import { resolve as
|
|
2798
|
+
import { resolve as resolve14 } from "path";
|
|
2743
2799
|
|
|
2744
2800
|
// src/core/utils/content-security-policy.ts
|
|
2745
2801
|
var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
@@ -2843,12 +2899,27 @@ function getContentScriptJs(config, entrypoint) {
|
|
|
2843
2899
|
return [getEntrypointBundlePath(entrypoint, config.outDir, ".js")];
|
|
2844
2900
|
}
|
|
2845
2901
|
|
|
2902
|
+
// src/core/utils/package.ts
|
|
2903
|
+
import { resolve as resolve13 } from "node:path";
|
|
2904
|
+
import fs11 from "fs-extra";
|
|
2905
|
+
async function getPackageJson() {
|
|
2906
|
+
const file = resolve13(wxt.config.root, "package.json");
|
|
2907
|
+
try {
|
|
2908
|
+
return await fs11.readJson(file);
|
|
2909
|
+
} catch (err) {
|
|
2910
|
+
wxt.logger.debug(
|
|
2911
|
+
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
2912
|
+
);
|
|
2913
|
+
return {};
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2846
2917
|
// src/core/utils/manifest.ts
|
|
2847
2918
|
import defu2 from "defu";
|
|
2848
2919
|
async function writeManifest(manifest, output) {
|
|
2849
2920
|
const str = wxt.config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
2850
2921
|
await fs12.ensureDir(wxt.config.outDir);
|
|
2851
|
-
await writeFileIfDifferent(
|
|
2922
|
+
await writeFileIfDifferent(resolve14(wxt.config.outDir, "manifest.json"), str);
|
|
2852
2923
|
output.publicAssets.unshift({
|
|
2853
2924
|
type: "asset",
|
|
2854
2925
|
fileName: "manifest.json"
|
|
@@ -3530,12 +3601,12 @@ function printValidationResults({
|
|
|
3530
3601
|
return map;
|
|
3531
3602
|
}, /* @__PURE__ */ new Map());
|
|
3532
3603
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
3533
|
-
|
|
3604
|
+
wxt.logger.log(relative6(cwd, entrypoint.inputPath));
|
|
3534
3605
|
console.log();
|
|
3535
3606
|
errors2.forEach((err) => {
|
|
3536
3607
|
const type = err.type === "error" ? pc5.red("ERROR") : pc5.yellow("WARN");
|
|
3537
3608
|
const recieved = pc5.dim(`(recieved: ${JSON.stringify(err.value)})`);
|
|
3538
|
-
|
|
3609
|
+
wxt.logger.log(` - ${type} ${err.message} ${recieved}`);
|
|
3539
3610
|
});
|
|
3540
3611
|
console.log();
|
|
3541
3612
|
});
|
|
@@ -3552,32 +3623,37 @@ import path8 from "node:path";
|
|
|
3552
3623
|
import glob6 from "fast-glob";
|
|
3553
3624
|
import fs14 from "fs-extra";
|
|
3554
3625
|
import pc6 from "picocolors";
|
|
3555
|
-
async function clean(
|
|
3556
|
-
|
|
3626
|
+
async function clean(config) {
|
|
3627
|
+
if (typeof config === "string") {
|
|
3628
|
+
config = { root: config };
|
|
3629
|
+
}
|
|
3630
|
+
await registerWxt("build", config);
|
|
3631
|
+
wxt.logger.info("Cleaning Project");
|
|
3632
|
+
const root = wxt.config.root;
|
|
3557
3633
|
const tempDirs = [
|
|
3558
3634
|
"node_modules/.vite",
|
|
3559
3635
|
"node_modules/.cache",
|
|
3560
3636
|
"**/.wxt",
|
|
3561
|
-
|
|
3637
|
+
`${path8.relative(root, wxt.config.outBaseDir)}/*`
|
|
3562
3638
|
];
|
|
3563
|
-
|
|
3639
|
+
wxt.logger.debug("Looking for:", tempDirs.map(pc6.cyan).join(", "));
|
|
3564
3640
|
const directories = await glob6(tempDirs, {
|
|
3565
|
-
cwd:
|
|
3641
|
+
cwd: root,
|
|
3566
3642
|
absolute: true,
|
|
3567
3643
|
onlyDirectories: true,
|
|
3568
3644
|
deep: 2
|
|
3569
3645
|
});
|
|
3570
3646
|
if (directories.length === 0) {
|
|
3571
|
-
|
|
3647
|
+
wxt.logger.debug("No generated files found.");
|
|
3572
3648
|
return;
|
|
3573
3649
|
}
|
|
3574
|
-
|
|
3650
|
+
wxt.logger.debug(
|
|
3575
3651
|
"Found:",
|
|
3576
3652
|
directories.map((dir) => pc6.cyan(path8.relative(root, dir))).join(", ")
|
|
3577
3653
|
);
|
|
3578
3654
|
for (const directory of directories) {
|
|
3579
3655
|
await fs14.rm(directory, { force: true, recursive: true });
|
|
3580
|
-
|
|
3656
|
+
wxt.logger.debug("Deleted " + pc6.cyan(path8.relative(root, directory)));
|
|
3581
3657
|
}
|
|
3582
3658
|
}
|
|
3583
3659
|
|
|
@@ -3640,6 +3716,9 @@ function createWebExtRunner() {
|
|
|
3640
3716
|
...userConfig,
|
|
3641
3717
|
target: wxt.config.browser === "firefox" ? "firefox-desktop" : "chromium",
|
|
3642
3718
|
sourceDir: wxt.config.outDir,
|
|
3719
|
+
// Don't add a "Reload Manager" extension alongside dev extension, WXT
|
|
3720
|
+
// already handles reloads intenrally.
|
|
3721
|
+
noReloadManagerExtension: true,
|
|
3643
3722
|
// WXT handles reloads, so disable auto-reload behaviors in web-ext
|
|
3644
3723
|
noReload: true,
|
|
3645
3724
|
noInput: true
|
|
@@ -3840,19 +3919,19 @@ function createFileReloader(server) {
|
|
|
3840
3919
|
switch (changes.type) {
|
|
3841
3920
|
case "extension-reload":
|
|
3842
3921
|
server.reloadExtension();
|
|
3843
|
-
|
|
3922
|
+
wxt.logger.success(`Reloaded extension`);
|
|
3844
3923
|
break;
|
|
3845
3924
|
case "html-reload":
|
|
3846
3925
|
const { reloadedNames } = reloadHtmlPages(
|
|
3847
3926
|
changes.rebuildGroups,
|
|
3848
3927
|
server
|
|
3849
3928
|
);
|
|
3850
|
-
|
|
3929
|
+
wxt.logger.success(`Reloaded: ${getFilenameList(reloadedNames)}`);
|
|
3851
3930
|
break;
|
|
3852
3931
|
case "content-script-reload":
|
|
3853
3932
|
reloadContentScripts(changes.changedSteps, server);
|
|
3854
3933
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => entry.name);
|
|
3855
|
-
|
|
3934
|
+
wxt.logger.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
|
|
3856
3935
|
break;
|
|
3857
3936
|
}
|
|
3858
3937
|
} catch (err) {
|
|
@@ -4131,14 +4210,15 @@ async function zipDir(directory, outputPath, options) {
|
|
|
4131
4210
|
}
|
|
4132
4211
|
}
|
|
4133
4212
|
await options?.additionalWork?.(archive);
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
compression: "
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4213
|
+
await new Promise(
|
|
4214
|
+
(resolve15, reject) => archive.generateNodeStream({
|
|
4215
|
+
type: "nodebuffer",
|
|
4216
|
+
...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
|
|
4217
|
+
compression: "DEFLATE",
|
|
4218
|
+
compressionOptions: { level: wxt.config.zip.compressionLevel }
|
|
4219
|
+
}
|
|
4220
|
+
}).pipe(fs16.createWriteStream(outputPath)).on("error", reject).on("close", resolve15)
|
|
4221
|
+
);
|
|
4142
4222
|
}
|
|
4143
4223
|
async function downloadPrivatePackages() {
|
|
4144
4224
|
const overrides = {};
|
|
@@ -4219,7 +4299,7 @@ function createAliasedCommand(base, name, alias, bin, docsUrl) {
|
|
|
4219
4299
|
const args = process.argv.slice(
|
|
4220
4300
|
process.argv.indexOf(aliasedCommand.name) + 1
|
|
4221
4301
|
);
|
|
4222
|
-
const { execa } = await import("./execa-
|
|
4302
|
+
const { execa } = await import("./execa-QLUM2B3W.js");
|
|
4223
4303
|
await execa(bin, args, {
|
|
4224
4304
|
stdio: "inherit"
|
|
4225
4305
|
});
|
|
@@ -4306,9 +4386,9 @@ cli.command("prepare [root]", "prepare typescript project").option("-c, --config
|
|
|
4306
4386
|
});
|
|
4307
4387
|
})
|
|
4308
4388
|
);
|
|
4309
|
-
cli.command("clean [root]", "clean generated files and caches").alias("cleanup").action(
|
|
4389
|
+
cli.command("clean [root]", "clean generated files and caches").alias("cleanup").option("-c, --config <file>", "use specified config file").action(
|
|
4310
4390
|
wrapAction(async (root, flags) => {
|
|
4311
|
-
await clean(root);
|
|
4391
|
+
await clean({ root, configFile: flags.config, debug: flags.debug });
|
|
4312
4392
|
})
|
|
4313
4393
|
);
|
|
4314
4394
|
cli.command("init [directory]", "initialize a new project").option("-t, --template <template>", "template to use").option("--pm <packageManager>", "which package manager to use").action(
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as ContentScriptContext, a as WxtAppConfig } from './define-app-config-bg54F_lV.js';
|
|
2
2
|
import 'webextension-polyfill';
|
|
3
3
|
|
|
4
4
|
interface IntegratedContentScriptUi<TMounted> extends ContentScriptUi<TMounted> {
|
|
@@ -197,4 +197,6 @@ declare function createIframeUi<TMounted>(ctx: ContentScriptContext, options: If
|
|
|
197
197
|
*/
|
|
198
198
|
declare function createShadowRootUi<TMounted>(ctx: ContentScriptContext, options: ShadowRootContentScriptUiOptions<TMounted>): Promise<ShadowRootContentScriptUi<TMounted>>;
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
declare function useAppConfig(): WxtAppConfig;
|
|
201
|
+
|
|
202
|
+
export { type ContentScriptAnchoredOptions, type ContentScriptAppendMode, ContentScriptContext, type ContentScriptInlinePositioningOptions, type ContentScriptModalPositioningOptions, type ContentScriptOverlayAlignment, type ContentScriptOverlayPositioningOptions, type ContentScriptPositioningOptions, type ContentScriptUi, type ContentScriptUiOptions, type IframeContentScriptUi, type IframeContentScriptUiOptions, type IntegratedContentScriptUi, type IntegratedContentScriptUiOptions, type ShadowRootContentScriptUi, type ShadowRootContentScriptUiOptions, createIframeUi, createIntegratedUi, createShadowRootUi, useAppConfig };
|
package/dist/client.js
CHANGED
|
@@ -397,9 +397,16 @@ async function loadCss() {
|
|
|
397
397
|
return "";
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
+
|
|
401
|
+
// src/client/app-config.ts
|
|
402
|
+
import appConfig from "virtual:app-config";
|
|
403
|
+
function useAppConfig() {
|
|
404
|
+
return appConfig;
|
|
405
|
+
}
|
|
400
406
|
export {
|
|
401
407
|
ContentScriptContext,
|
|
402
408
|
createIframeUi,
|
|
403
409
|
createIntegratedUi,
|
|
404
|
-
createShadowRootUi
|
|
410
|
+
createShadowRootUi,
|
|
411
|
+
useAppConfig
|
|
405
412
|
};
|
|
@@ -271,4 +271,24 @@ type PerBrowserMap<T> = {
|
|
|
271
271
|
};
|
|
272
272
|
type WxtPlugin = () => void;
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
interface WxtAppConfig {
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Runtime app config defined in `<srcDir>/app.config.ts`.
|
|
278
|
+
*
|
|
279
|
+
* You can add fields to this interface via ["Module Augmentation"](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation):
|
|
280
|
+
*
|
|
281
|
+
* ```ts
|
|
282
|
+
* // app.config.ts
|
|
283
|
+
* import 'wxt/sandbox';
|
|
284
|
+
*
|
|
285
|
+
* declare module "wxt/sandbox" {
|
|
286
|
+
* export interface WxtAppConfig {
|
|
287
|
+
* analytics: AnalyticsConfig
|
|
288
|
+
* }
|
|
289
|
+
* }
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare function defineAppConfig(config: WxtAppConfig): WxtAppConfig;
|
|
293
|
+
|
|
294
|
+
export { type BackgroundDefinition as B, type ContentScriptDefinition as C, type UnlistedScriptDefinition as U, type WxtPlugin as W, type WxtAppConfig as a, ContentScriptContext as b, defineAppConfig as d };
|