wxt 0.18.11 → 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-XNTIBS6O.js → chunk-6QN6UXBH.js} +63 -34
- package/dist/cli.js +63 -31
- 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/{index-CER9SLWP.d.ts → index-1N-eQJJh.d.cts} +4 -0
- package/dist/{index-CER9SLWP.d.cts → index-1N-eQJJh.d.ts} +4 -0
- package/dist/index.cjs +172 -140
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +13 -9
- 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 +75 -54
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +4 -2
- package/package.json +2 -2
- package/dist/cli.d.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1083,12 +1083,12 @@ var require_isexe = __commonJS({
|
|
|
1083
1083
|
if (typeof Promise !== "function") {
|
|
1084
1084
|
throw new TypeError("callback not provided");
|
|
1085
1085
|
}
|
|
1086
|
-
return new Promise(function(
|
|
1086
|
+
return new Promise(function(resolve18, reject) {
|
|
1087
1087
|
isexe(path12, options || {}, function(er, is) {
|
|
1088
1088
|
if (er) {
|
|
1089
1089
|
reject(er);
|
|
1090
1090
|
} else {
|
|
1091
|
-
|
|
1091
|
+
resolve18(is);
|
|
1092
1092
|
}
|
|
1093
1093
|
});
|
|
1094
1094
|
});
|
|
@@ -1155,27 +1155,27 @@ var require_which = __commonJS({
|
|
|
1155
1155
|
opt = {};
|
|
1156
1156
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
1157
1157
|
const found = [];
|
|
1158
|
-
const step = (i2) => new Promise((
|
|
1158
|
+
const step = (i2) => new Promise((resolve18, reject) => {
|
|
1159
1159
|
if (i2 === pathEnv.length)
|
|
1160
|
-
return opt.all && found.length ?
|
|
1160
|
+
return opt.all && found.length ? resolve18(found) : reject(getNotFoundError(cmd));
|
|
1161
1161
|
const ppRaw = pathEnv[i2];
|
|
1162
1162
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
1163
1163
|
const pCmd = path12.join(pathPart, cmd);
|
|
1164
1164
|
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
1165
|
-
|
|
1165
|
+
resolve18(subStep(p2, i2, 0));
|
|
1166
1166
|
});
|
|
1167
|
-
const subStep = (p2, i2, ii) => new Promise((
|
|
1167
|
+
const subStep = (p2, i2, ii) => new Promise((resolve18, reject) => {
|
|
1168
1168
|
if (ii === pathExt.length)
|
|
1169
|
-
return
|
|
1169
|
+
return resolve18(step(i2 + 1));
|
|
1170
1170
|
const ext = pathExt[ii];
|
|
1171
1171
|
isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
1172
1172
|
if (!er && is) {
|
|
1173
1173
|
if (opt.all)
|
|
1174
1174
|
found.push(p2 + ext);
|
|
1175
1175
|
else
|
|
1176
|
-
return
|
|
1176
|
+
return resolve18(p2 + ext);
|
|
1177
1177
|
}
|
|
1178
|
-
return
|
|
1178
|
+
return resolve18(subStep(p2, i2, ii + 1));
|
|
1179
1179
|
});
|
|
1180
1180
|
});
|
|
1181
1181
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -2230,8 +2230,8 @@ var init_deferred = __esm({
|
|
|
2230
2230
|
"use strict";
|
|
2231
2231
|
createDeferred = () => {
|
|
2232
2232
|
const methods = {};
|
|
2233
|
-
const promise = new Promise((
|
|
2234
|
-
Object.assign(methods, { resolve:
|
|
2233
|
+
const promise = new Promise((resolve18, reject) => {
|
|
2234
|
+
Object.assign(methods, { resolve: resolve18, reject });
|
|
2235
2235
|
});
|
|
2236
2236
|
return Object.assign(promise, methods);
|
|
2237
2237
|
};
|
|
@@ -7589,11 +7589,11 @@ var init_concurrent = __esm({
|
|
|
7589
7589
|
const promises = weakMap.get(stream);
|
|
7590
7590
|
const promise = createDeferred();
|
|
7591
7591
|
promises.push(promise);
|
|
7592
|
-
const
|
|
7593
|
-
return { resolve:
|
|
7592
|
+
const resolve18 = promise.resolve.bind(promise);
|
|
7593
|
+
return { resolve: resolve18, promises };
|
|
7594
7594
|
};
|
|
7595
|
-
waitForConcurrentStreams = async ({ resolve:
|
|
7596
|
-
|
|
7595
|
+
waitForConcurrentStreams = async ({ resolve: resolve18, promises }, subprocess) => {
|
|
7596
|
+
resolve18();
|
|
7597
7597
|
const [isSubprocessExit] = await Promise.race([
|
|
7598
7598
|
Promise.allSettled([true, subprocess]),
|
|
7599
7599
|
Promise.all([false, ...promises])
|
|
@@ -8744,7 +8744,7 @@ var init_core2 = __esm({
|
|
|
8744
8744
|
|
|
8745
8745
|
// ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
|
|
8746
8746
|
function parseStack(stack) {
|
|
8747
|
-
const cwd = process.cwd() +
|
|
8747
|
+
const cwd = process.cwd() + import_node_path18.sep;
|
|
8748
8748
|
const lines = stack.split("\n").splice(1).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
|
|
8749
8749
|
return lines;
|
|
8750
8750
|
}
|
|
@@ -8752,12 +8752,12 @@ function writeStream(data, stream) {
|
|
|
8752
8752
|
const write = stream.__write || stream.write;
|
|
8753
8753
|
return write.call(stream, data);
|
|
8754
8754
|
}
|
|
8755
|
-
var import_node_util11,
|
|
8755
|
+
var import_node_util11, import_node_path18, bracket, BasicReporter;
|
|
8756
8756
|
var init_consola_06ad8a64 = __esm({
|
|
8757
8757
|
"../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs"() {
|
|
8758
8758
|
"use strict";
|
|
8759
8759
|
import_node_util11 = require("util");
|
|
8760
|
-
|
|
8760
|
+
import_node_path18 = require("path");
|
|
8761
8761
|
bracket = (x) => x ? `[${x}]` : "";
|
|
8762
8762
|
BasicReporter = class {
|
|
8763
8763
|
formatStack(stack, opts) {
|
|
@@ -9160,7 +9160,7 @@ async function prompt(message, opts = {}) {
|
|
|
9160
9160
|
}
|
|
9161
9161
|
throw new Error(`Unknown prompt type: ${opts.type}`);
|
|
9162
9162
|
}
|
|
9163
|
-
var import_node_process11, import_node_readline, import_node_tty3, import_tty, import_node_util12,
|
|
9163
|
+
var import_node_process11, import_node_readline, import_node_tty3, import_tty, import_node_util12, import_node_path19, ESC, CSI, beep, cursor, scroll, erase, src, picocolors, tty4, isColorSupported2, formatter, replaceClose2, createColors2, picocolorsExports, l, m, G, K, Y, v, L, M, T, r, Z, H, q, p, J, b, W, Q, I, w, N, j, X, _, DD, uD, R, V, tD, h2, sD, iD, ED, oD, unicode, s, S_STEP_ACTIVE, S_STEP_CANCEL, S_STEP_ERROR, S_STEP_SUBMIT, S_BAR, S_BAR_END, S_RADIO_ACTIVE, S_RADIO_INACTIVE, S_CHECKBOX_ACTIVE, S_CHECKBOX_SELECTED, S_CHECKBOX_INACTIVE, symbol, text, confirm, select, multiselect;
|
|
9164
9164
|
var init_prompt = __esm({
|
|
9165
9165
|
"../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs"() {
|
|
9166
9166
|
"use strict";
|
|
@@ -9173,7 +9173,7 @@ var init_prompt = __esm({
|
|
|
9173
9173
|
init_core2();
|
|
9174
9174
|
init_consola_06ad8a64();
|
|
9175
9175
|
import_node_util12 = require("util");
|
|
9176
|
-
|
|
9176
|
+
import_node_path19 = require("path");
|
|
9177
9177
|
ESC = "\x1B";
|
|
9178
9178
|
CSI = `${ESC}[`;
|
|
9179
9179
|
beep = "\x07";
|
|
@@ -10189,7 +10189,7 @@ __export(src_exports, {
|
|
|
10189
10189
|
module.exports = __toCommonJS(src_exports);
|
|
10190
10190
|
|
|
10191
10191
|
// src/core/utils/fs.ts
|
|
10192
|
-
var
|
|
10192
|
+
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
10193
10193
|
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
10194
10194
|
|
|
10195
10195
|
// src/core/utils/paths.ts
|
|
@@ -11074,6 +11074,25 @@ try {
|
|
|
11074
11074
|
};
|
|
11075
11075
|
}
|
|
11076
11076
|
|
|
11077
|
+
// src/core/builders/vite/plugins/resolveAppConfig.ts
|
|
11078
|
+
var import_fs_extra4 = require("fs-extra");
|
|
11079
|
+
var import_node_path13 = require("path");
|
|
11080
|
+
function resolveAppConfig(config) {
|
|
11081
|
+
const virtualModuleId = "virtual:app-config";
|
|
11082
|
+
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
11083
|
+
const appConfigFile = (0, import_node_path13.resolve)(config.srcDir, "app.config.ts");
|
|
11084
|
+
return {
|
|
11085
|
+
name: "wxt:resolve-app-config",
|
|
11086
|
+
async resolveId(id) {
|
|
11087
|
+
if (id !== virtualModuleId) return;
|
|
11088
|
+
return await (0, import_fs_extra4.exists)(appConfigFile) ? appConfigFile : resolvedVirtualModuleId;
|
|
11089
|
+
},
|
|
11090
|
+
load(id) {
|
|
11091
|
+
if (id === resolvedVirtualModuleId) return `export default {}`;
|
|
11092
|
+
}
|
|
11093
|
+
};
|
|
11094
|
+
}
|
|
11095
|
+
|
|
11077
11096
|
// src/core/utils/arrays.ts
|
|
11078
11097
|
function every(array, predicate) {
|
|
11079
11098
|
for (let i2 = 0; i2 < array.length; i2++)
|
|
@@ -11143,7 +11162,8 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11143
11162
|
globals(wxtConfig),
|
|
11144
11163
|
excludeBrowserPolyfill(wxtConfig),
|
|
11145
11164
|
defineImportMeta(),
|
|
11146
|
-
wxtPluginLoader(wxtConfig)
|
|
11165
|
+
wxtPluginLoader(wxtConfig),
|
|
11166
|
+
resolveAppConfig(wxtConfig)
|
|
11147
11167
|
);
|
|
11148
11168
|
if (wxtConfig.analysis.enabled) {
|
|
11149
11169
|
config.plugins.push(bundleAnalysis(wxtConfig));
|
|
@@ -11402,7 +11422,7 @@ function getRollupEntry(entrypoint) {
|
|
|
11402
11422
|
// src/modules.ts
|
|
11403
11423
|
var vite = __toESM(require("vite"), 1);
|
|
11404
11424
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
11405
|
-
var
|
|
11425
|
+
var import_node_path14 = require("path");
|
|
11406
11426
|
function defineWxtModule(module2) {
|
|
11407
11427
|
if (typeof module2 === "function") return { setup: module2 };
|
|
11408
11428
|
return module2;
|
|
@@ -11420,7 +11440,7 @@ function addViteConfig(wxt2, viteConfig) {
|
|
|
11420
11440
|
|
|
11421
11441
|
// src/builtin-modules/unimport.ts
|
|
11422
11442
|
var import_unimport = require("unimport");
|
|
11423
|
-
var
|
|
11443
|
+
var import_node_path15 = require("path");
|
|
11424
11444
|
var unimport_default = defineWxtModule({
|
|
11425
11445
|
name: "wxt:built-in:unimport",
|
|
11426
11446
|
setup(wxt2) {
|
|
@@ -11467,7 +11487,7 @@ function vitePlugin(unimport) {
|
|
|
11467
11487
|
name: "wxt:unimport",
|
|
11468
11488
|
async transform(code, id) {
|
|
11469
11489
|
if (id.includes("node_modules")) return;
|
|
11470
|
-
if (!ENABLED_EXTENSIONS.has((0,
|
|
11490
|
+
if (!ENABLED_EXTENSIONS.has((0, import_node_path15.extname)(id))) return;
|
|
11471
11491
|
const injected = await unimport.injectImports(code, id);
|
|
11472
11492
|
return {
|
|
11473
11493
|
code: injected.code,
|
|
@@ -11508,6 +11528,7 @@ function getEslint9ConfigEntry(options, globals2) {
|
|
|
11508
11528
|
text: `const globals = ${JSON.stringify(globals2, null, 2)}
|
|
11509
11529
|
|
|
11510
11530
|
export default {
|
|
11531
|
+
name: "wxt/auto-imports",
|
|
11511
11532
|
languageOptions: {
|
|
11512
11533
|
globals,
|
|
11513
11534
|
sourceType: "module",
|
|
@@ -11557,19 +11578,19 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
11557
11578
|
|
|
11558
11579
|
// src/core/utils/fs.ts
|
|
11559
11580
|
async function writeFileIfDifferent(file, newContents) {
|
|
11560
|
-
const existingContents = await
|
|
11581
|
+
const existingContents = await import_fs_extra5.default.readFile(file, "utf-8").catch(() => void 0);
|
|
11561
11582
|
if (existingContents !== newContents) {
|
|
11562
|
-
await
|
|
11583
|
+
await import_fs_extra5.default.writeFile(file, newContents);
|
|
11563
11584
|
}
|
|
11564
11585
|
}
|
|
11565
11586
|
async function getPublicFiles() {
|
|
11566
|
-
if (!await
|
|
11587
|
+
if (!await import_fs_extra5.default.exists(wxt.config.publicDir)) return [];
|
|
11567
11588
|
const files = await (0, import_fast_glob2.default)("**/*", { cwd: wxt.config.publicDir });
|
|
11568
11589
|
return files.map(unnormalizePath);
|
|
11569
11590
|
}
|
|
11570
11591
|
|
|
11571
11592
|
// src/core/utils/building/build-entrypoints.ts
|
|
11572
|
-
var
|
|
11593
|
+
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
11573
11594
|
var import_path2 = require("path");
|
|
11574
11595
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
11575
11596
|
async function buildEntrypoints(groups, spinner) {
|
|
@@ -11600,11 +11621,11 @@ async function copyPublicDirectory() {
|
|
|
11600
11621
|
const publicAssets = [];
|
|
11601
11622
|
for (const file of files) {
|
|
11602
11623
|
const absoluteDest = (0, import_path2.resolve)(wxt.config.outDir, file.relativeDest);
|
|
11603
|
-
await
|
|
11624
|
+
await import_fs_extra6.default.ensureDir((0, import_path2.dirname)(absoluteDest));
|
|
11604
11625
|
if ("absoluteSrc" in file) {
|
|
11605
|
-
await
|
|
11626
|
+
await import_fs_extra6.default.copyFile(file.absoluteSrc, absoluteDest);
|
|
11606
11627
|
} else {
|
|
11607
|
-
await
|
|
11628
|
+
await import_fs_extra6.default.writeFile(absoluteDest, file.contents, "utf8");
|
|
11608
11629
|
}
|
|
11609
11630
|
publicAssets.push({
|
|
11610
11631
|
type: "asset",
|
|
@@ -11708,15 +11729,15 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
11708
11729
|
|
|
11709
11730
|
// src/core/utils/building/find-entrypoints.ts
|
|
11710
11731
|
var import_path3 = require("path");
|
|
11711
|
-
var
|
|
11732
|
+
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
11712
11733
|
var import_minimatch = require("minimatch");
|
|
11713
11734
|
var import_linkedom3 = require("linkedom");
|
|
11714
11735
|
var import_json5 = __toESM(require("json5"), 1);
|
|
11715
11736
|
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
11716
11737
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
11717
11738
|
async function findEntrypoints() {
|
|
11718
|
-
await
|
|
11719
|
-
await
|
|
11739
|
+
await import_fs_extra7.default.mkdir(wxt.config.wxtDir, { recursive: true });
|
|
11740
|
+
await import_fs_extra7.default.writeJson((0, import_path3.resolve)(wxt.config.wxtDir, "tsconfig.json"), {});
|
|
11720
11741
|
const relativePaths = await (0, import_fast_glob3.default)(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
|
|
11721
11742
|
cwd: wxt.config.entrypointsDir
|
|
11722
11743
|
});
|
|
@@ -12025,7 +12046,7 @@ async function getSidepanelEntrypoint(info) {
|
|
|
12025
12046
|
};
|
|
12026
12047
|
}
|
|
12027
12048
|
async function getHtmlEntrypointOptions(info, keyMap, queries, parsers) {
|
|
12028
|
-
const content = await
|
|
12049
|
+
const content = await import_fs_extra7.default.readFile(info.inputPath, "utf-8");
|
|
12029
12050
|
const { document } = (0, import_linkedom3.parseHTML)(content);
|
|
12030
12051
|
const options = {};
|
|
12031
12052
|
const defaultQuery = (manifestKey) => document.querySelector(`meta[name='manifest.${manifestKey}']`)?.getAttribute("content");
|
|
@@ -12087,9 +12108,9 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
12087
12108
|
var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
|
|
12088
12109
|
|
|
12089
12110
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
12090
|
-
var
|
|
12091
|
-
var
|
|
12092
|
-
var
|
|
12111
|
+
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
12112
|
+
var import_node_path16 = require("path");
|
|
12113
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
12093
12114
|
|
|
12094
12115
|
// src/core/utils/i18n.ts
|
|
12095
12116
|
var predefinedMessages = {
|
|
@@ -12130,7 +12151,7 @@ function parseI18nMessages(messagesJson) {
|
|
|
12130
12151
|
|
|
12131
12152
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
12132
12153
|
async function generateTypesDir(entrypoints) {
|
|
12133
|
-
await
|
|
12154
|
+
await import_fs_extra8.default.ensureDir(wxt.config.typesDir);
|
|
12134
12155
|
const entries = [
|
|
12135
12156
|
// Hard-coded entries
|
|
12136
12157
|
{ module: "wxt/vite-builder-env" }
|
|
@@ -12147,11 +12168,11 @@ async function generateTypesDir(entrypoints) {
|
|
|
12147
12168
|
entries.push(getMainDeclarationEntry(entries));
|
|
12148
12169
|
const absoluteFileEntries = entries.filter((entry) => "path" in entry).map((entry) => ({
|
|
12149
12170
|
...entry,
|
|
12150
|
-
path: (0,
|
|
12171
|
+
path: (0, import_node_path16.resolve)(wxt.config.wxtDir, entry.path)
|
|
12151
12172
|
}));
|
|
12152
12173
|
await Promise.all(
|
|
12153
12174
|
absoluteFileEntries.map(async (file) => {
|
|
12154
|
-
await
|
|
12175
|
+
await import_fs_extra8.default.ensureDir((0, import_node_path16.dirname)(file.path));
|
|
12155
12176
|
await writeFileIfDifferent(file.path, file.text);
|
|
12156
12177
|
})
|
|
12157
12178
|
);
|
|
@@ -12206,13 +12227,13 @@ declare module "wxt/browser" {
|
|
|
12206
12227
|
`;
|
|
12207
12228
|
let messages;
|
|
12208
12229
|
if (defaultLocale) {
|
|
12209
|
-
const defaultLocalePath =
|
|
12230
|
+
const defaultLocalePath = import_node_path17.default.resolve(
|
|
12210
12231
|
wxt.config.publicDir,
|
|
12211
12232
|
"_locales",
|
|
12212
12233
|
defaultLocale,
|
|
12213
12234
|
"messages.json"
|
|
12214
12235
|
);
|
|
12215
|
-
const content = JSON.parse(await
|
|
12236
|
+
const content = JSON.parse(await import_fs_extra8.default.readFile(defaultLocalePath, "utf-8"));
|
|
12216
12237
|
messages = parseI18nMessages(content);
|
|
12217
12238
|
} else {
|
|
12218
12239
|
messages = parseI18nMessages({});
|
|
@@ -12259,8 +12280,8 @@ function getMainDeclarationEntry(references) {
|
|
|
12259
12280
|
if ("module" in ref) {
|
|
12260
12281
|
return lines.push(`/// <reference types="${ref.module}" />`);
|
|
12261
12282
|
} else if (ref.tsReference) {
|
|
12262
|
-
const absolutePath = (0,
|
|
12263
|
-
const relativePath = (0,
|
|
12283
|
+
const absolutePath = (0, import_node_path16.resolve)(wxt.config.wxtDir, ref.path);
|
|
12284
|
+
const relativePath = (0, import_node_path16.relative)(wxt.config.wxtDir, absolutePath);
|
|
12264
12285
|
lines.push(`/// <reference types="./${normalizePath(relativePath)}" />`);
|
|
12265
12286
|
}
|
|
12266
12287
|
});
|
|
@@ -12271,7 +12292,7 @@ function getMainDeclarationEntry(references) {
|
|
|
12271
12292
|
}
|
|
12272
12293
|
async function getTsConfigEntry() {
|
|
12273
12294
|
const dir = wxt.config.wxtDir;
|
|
12274
|
-
const getTsconfigPath = (path12) => normalizePath((0,
|
|
12295
|
+
const getTsconfigPath = (path12) => normalizePath((0, import_node_path16.relative)(dir, path12));
|
|
12275
12296
|
const paths = Object.entries(wxt.config.alias).flatMap(([alias, absolutePath]) => {
|
|
12276
12297
|
const aliasPath = getTsconfigPath(absolutePath);
|
|
12277
12298
|
return [
|
|
@@ -12308,23 +12329,23 @@ ${paths}
|
|
|
12308
12329
|
|
|
12309
12330
|
// src/core/utils/building/resolve-config.ts
|
|
12310
12331
|
var import_c12 = require("c12");
|
|
12311
|
-
var
|
|
12332
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
12312
12333
|
|
|
12313
12334
|
// src/core/utils/cache.ts
|
|
12314
|
-
var
|
|
12335
|
+
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
12315
12336
|
var import_path4 = require("path");
|
|
12316
12337
|
function createFsCache(wxtDir) {
|
|
12317
12338
|
const getPath = (key) => (0, import_path4.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
12318
12339
|
return {
|
|
12319
12340
|
async set(key, value) {
|
|
12320
12341
|
const path12 = getPath(key);
|
|
12321
|
-
await (0,
|
|
12342
|
+
await (0, import_fs_extra9.ensureDir)((0, import_path4.dirname)(path12));
|
|
12322
12343
|
await writeFileIfDifferent(path12, value);
|
|
12323
12344
|
},
|
|
12324
12345
|
async get(key) {
|
|
12325
12346
|
const path12 = getPath(key);
|
|
12326
12347
|
try {
|
|
12327
|
-
return await
|
|
12348
|
+
return await import_fs_extra9.default.readFile(path12, "utf-8");
|
|
12328
12349
|
} catch {
|
|
12329
12350
|
return void 0;
|
|
12330
12351
|
}
|
|
@@ -12340,11 +12361,11 @@ var import_node_process13 = require("process");
|
|
|
12340
12361
|
init_utils2();
|
|
12341
12362
|
var import_node_tty4 = require("tty");
|
|
12342
12363
|
var import_node_util13 = require("util");
|
|
12343
|
-
var
|
|
12364
|
+
var import_node_path20 = require("path");
|
|
12344
12365
|
|
|
12345
12366
|
// src/core/utils/building/resolve-config.ts
|
|
12346
12367
|
var import_defu = __toESM(require("defu"), 1);
|
|
12347
|
-
var
|
|
12368
|
+
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
12348
12369
|
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
12349
12370
|
|
|
12350
12371
|
// src/core/utils/eslint.ts
|
|
@@ -12387,28 +12408,28 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12387
12408
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
12388
12409
|
const mode = mergedConfig.mode ?? COMMAND_MODES[command];
|
|
12389
12410
|
const env2 = { browser, command, manifestVersion, mode };
|
|
12390
|
-
const root =
|
|
12411
|
+
const root = import_node_path21.default.resolve(
|
|
12391
12412
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
12392
12413
|
);
|
|
12393
|
-
const wxtDir =
|
|
12414
|
+
const wxtDir = import_node_path21.default.resolve(root, ".wxt");
|
|
12394
12415
|
const wxtModuleDir = await resolveWxtModuleDir();
|
|
12395
|
-
const srcDir =
|
|
12396
|
-
const entrypointsDir =
|
|
12416
|
+
const srcDir = import_node_path21.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
12417
|
+
const entrypointsDir = import_node_path21.default.resolve(
|
|
12397
12418
|
srcDir,
|
|
12398
12419
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
12399
12420
|
);
|
|
12400
|
-
const modulesDir =
|
|
12421
|
+
const modulesDir = import_node_path21.default.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
|
|
12401
12422
|
if (await isDirMissing(entrypointsDir)) {
|
|
12402
12423
|
logMissingDir(logger, "Entrypoints", entrypointsDir);
|
|
12403
12424
|
}
|
|
12404
12425
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
12405
|
-
const publicDir =
|
|
12426
|
+
const publicDir = import_node_path21.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
12406
12427
|
if (await isDirMissing(publicDir)) {
|
|
12407
12428
|
logMissingDir(logger, "Public", publicDir);
|
|
12408
12429
|
}
|
|
12409
|
-
const typesDir =
|
|
12410
|
-
const outBaseDir =
|
|
12411
|
-
const outDir =
|
|
12430
|
+
const typesDir = import_node_path21.default.resolve(wxtDir, "types");
|
|
12431
|
+
const outBaseDir = import_node_path21.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
12432
|
+
const outDir = import_node_path21.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
12412
12433
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
12413
12434
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
12414
12435
|
name: "web-ext",
|
|
@@ -12425,7 +12446,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12425
12446
|
"~": srcDir,
|
|
12426
12447
|
"@@": root,
|
|
12427
12448
|
"~~": root
|
|
12428
|
-
}).map(([key, value]) => [key,
|
|
12449
|
+
}).map(([key, value]) => [key, import_node_path21.default.resolve(root, value)])
|
|
12429
12450
|
);
|
|
12430
12451
|
let devServerConfig;
|
|
12431
12452
|
if (command === "serve") {
|
|
@@ -12522,7 +12543,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
12522
12543
|
};
|
|
12523
12544
|
}
|
|
12524
12545
|
function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
12525
|
-
const downloadedPackagesDir =
|
|
12546
|
+
const downloadedPackagesDir = import_node_path21.default.resolve(root, ".wxt/local_modules");
|
|
12526
12547
|
return {
|
|
12527
12548
|
name: void 0,
|
|
12528
12549
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
@@ -12541,7 +12562,7 @@ function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
|
12541
12562
|
"**/__tests__/**",
|
|
12542
12563
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
12543
12564
|
// Output directory
|
|
12544
|
-
`${
|
|
12565
|
+
`${import_node_path21.default.relative(root, outBaseDir)}/**`,
|
|
12545
12566
|
// From user
|
|
12546
12567
|
...mergedConfig.zip?.excludeSources ?? []
|
|
12547
12568
|
],
|
|
@@ -12550,12 +12571,12 @@ function resolveZipConfig(root, outBaseDir, mergedConfig) {
|
|
|
12550
12571
|
};
|
|
12551
12572
|
}
|
|
12552
12573
|
function resolveAnalysisConfig(root, mergedConfig) {
|
|
12553
|
-
const analysisOutputFile =
|
|
12574
|
+
const analysisOutputFile = import_node_path21.default.resolve(
|
|
12554
12575
|
root,
|
|
12555
12576
|
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
12556
12577
|
);
|
|
12557
|
-
const analysisOutputDir =
|
|
12558
|
-
const analysisOutputName =
|
|
12578
|
+
const analysisOutputDir = import_node_path21.default.dirname(analysisOutputFile);
|
|
12579
|
+
const analysisOutputName = import_node_path21.default.parse(analysisOutputFile).name;
|
|
12559
12580
|
return {
|
|
12560
12581
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
12561
12582
|
open: mergedConfig.analysis?.open ?? false,
|
|
@@ -12611,7 +12632,7 @@ async function getUnimportEslintOptions(wxtDir, options) {
|
|
|
12611
12632
|
}
|
|
12612
12633
|
return {
|
|
12613
12634
|
enabled: eslintEnabled,
|
|
12614
|
-
filePath:
|
|
12635
|
+
filePath: import_node_path21.default.resolve(
|
|
12615
12636
|
wxtDir,
|
|
12616
12637
|
eslintEnabled === 9 ? "eslint-auto-imports.mjs" : "eslintrc-auto-import.json"
|
|
12617
12638
|
),
|
|
@@ -12620,15 +12641,15 @@ async function getUnimportEslintOptions(wxtDir, options) {
|
|
|
12620
12641
|
}
|
|
12621
12642
|
async function resolveWxtModuleDir() {
|
|
12622
12643
|
const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta2.url).resolve;
|
|
12623
|
-
return
|
|
12644
|
+
return import_node_path21.default.resolve(requireResolve("wxt"), "../..");
|
|
12624
12645
|
}
|
|
12625
12646
|
async function isDirMissing(dir) {
|
|
12626
|
-
return !await
|
|
12647
|
+
return !await import_fs_extra10.default.exists(dir);
|
|
12627
12648
|
}
|
|
12628
12649
|
function logMissingDir(logger, name, expected) {
|
|
12629
12650
|
logger.warn(
|
|
12630
12651
|
`${name} directory not found: ./${normalizePath(
|
|
12631
|
-
|
|
12652
|
+
import_node_path21.default.relative(process.cwd(), expected)
|
|
12632
12653
|
)}`
|
|
12633
12654
|
);
|
|
12634
12655
|
}
|
|
@@ -12672,7 +12693,7 @@ async function resolveWxtUserModules(modulesDir, modules = []) {
|
|
|
12672
12693
|
}).catch(() => []);
|
|
12673
12694
|
const localModules = await Promise.all(
|
|
12674
12695
|
localModulePaths.map(async (file) => {
|
|
12675
|
-
const absolutePath = normalizePath(
|
|
12696
|
+
const absolutePath = normalizePath(import_node_path21.default.resolve(modulesDir, file));
|
|
12676
12697
|
const { config } = await (0, import_c12.loadConfig)({
|
|
12677
12698
|
configFile: absolutePath,
|
|
12678
12699
|
globalRc: false,
|
|
@@ -12738,8 +12759,8 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
12738
12759
|
// src/core/utils/building/import-entrypoint.ts
|
|
12739
12760
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
12740
12761
|
var import_unimport3 = require("unimport");
|
|
12741
|
-
var
|
|
12742
|
-
var
|
|
12762
|
+
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
12763
|
+
var import_node_path22 = require("path");
|
|
12743
12764
|
var import_esbuild = require("esbuild");
|
|
12744
12765
|
var import_node_url3 = require("url");
|
|
12745
12766
|
var import_meta3 = {};
|
|
@@ -12752,7 +12773,7 @@ async function importEntrypointFile(path12) {
|
|
|
12752
12773
|
dirs: []
|
|
12753
12774
|
});
|
|
12754
12775
|
await unimport.init();
|
|
12755
|
-
const text2 = await
|
|
12776
|
+
const text2 = await import_fs_extra11.default.readFile(path12, "utf-8");
|
|
12756
12777
|
const textNoImports = removeProjectImportStatements(text2);
|
|
12757
12778
|
const { code } = await unimport.injectImports(textNoImports);
|
|
12758
12779
|
wxt.logger.debug(
|
|
@@ -12765,7 +12786,14 @@ async function importEntrypointFile(path12) {
|
|
|
12765
12786
|
debug: wxt.config.debug,
|
|
12766
12787
|
esmResolve: true,
|
|
12767
12788
|
alias: {
|
|
12768
|
-
"webextension-polyfill": (0,
|
|
12789
|
+
"webextension-polyfill": (0, import_node_path22.resolve)(
|
|
12790
|
+
wxt.config.wxtModuleDir,
|
|
12791
|
+
"dist/virtual/mock-browser.js"
|
|
12792
|
+
),
|
|
12793
|
+
// TODO: Resolve this virtual module to some file with
|
|
12794
|
+
// `export default {}` instead of this hack of using another file with
|
|
12795
|
+
// a default export.
|
|
12796
|
+
"virtual:app-config": (0, import_node_path22.resolve)(
|
|
12769
12797
|
wxt.config.wxtModuleDir,
|
|
12770
12798
|
"dist/virtual/mock-browser.js"
|
|
12771
12799
|
)
|
|
@@ -12798,7 +12826,7 @@ async function importEntrypointFile(path12) {
|
|
|
12798
12826
|
const res = await jiti(path12);
|
|
12799
12827
|
return res.default;
|
|
12800
12828
|
} catch (err) {
|
|
12801
|
-
const filePath = (0,
|
|
12829
|
+
const filePath = (0, import_node_path22.relative)(wxt.config.root, path12);
|
|
12802
12830
|
if (err instanceof ReferenceError) {
|
|
12803
12831
|
const variableName = err.message.replace(" is not defined", "");
|
|
12804
12832
|
throw Error(
|
|
@@ -12827,15 +12855,15 @@ function getEsbuildOptions(opts) {
|
|
|
12827
12855
|
|
|
12828
12856
|
// src/core/utils/building/internal-build.ts
|
|
12829
12857
|
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
12830
|
-
var
|
|
12858
|
+
var import_fs_extra15 = __toESM(require("fs-extra"), 1);
|
|
12831
12859
|
|
|
12832
12860
|
// src/core/utils/log/printBuildSummary.ts
|
|
12833
12861
|
var import_path5 = require("path");
|
|
12834
12862
|
|
|
12835
12863
|
// src/core/utils/log/printFileList.ts
|
|
12836
|
-
var
|
|
12864
|
+
var import_node_path23 = __toESM(require("path"), 1);
|
|
12837
12865
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
12838
|
-
var
|
|
12866
|
+
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
12839
12867
|
var import_filesize = require("filesize");
|
|
12840
12868
|
|
|
12841
12869
|
// src/core/utils/log/printTable.ts
|
|
@@ -12868,12 +12896,12 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
12868
12896
|
const fileRows = await Promise.all(
|
|
12869
12897
|
files.map(async (file, i2) => {
|
|
12870
12898
|
const parts = [
|
|
12871
|
-
|
|
12872
|
-
|
|
12899
|
+
import_node_path23.default.relative(process.cwd(), baseDir) + import_node_path23.default.sep,
|
|
12900
|
+
import_node_path23.default.relative(baseDir, file)
|
|
12873
12901
|
];
|
|
12874
12902
|
const prefix = i2 === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
12875
12903
|
const color = getChunkColor(file);
|
|
12876
|
-
const stats = await
|
|
12904
|
+
const stats = await import_fs_extra12.default.lstat(file);
|
|
12877
12905
|
totalSize += stats.size;
|
|
12878
12906
|
const size = String((0, import_filesize.filesize)(stats.size));
|
|
12879
12907
|
return [
|
|
@@ -12936,13 +12964,13 @@ function getChunkSortWeight(filename) {
|
|
|
12936
12964
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
12937
12965
|
|
|
12938
12966
|
// package.json
|
|
12939
|
-
var version = "0.18.
|
|
12967
|
+
var version = "0.18.11";
|
|
12940
12968
|
|
|
12941
12969
|
// src/core/utils/building/internal-build.ts
|
|
12942
12970
|
var import_fast_glob5 = __toESM(require("fast-glob"), 1);
|
|
12943
12971
|
|
|
12944
12972
|
// src/core/utils/manifest.ts
|
|
12945
|
-
var
|
|
12973
|
+
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
12946
12974
|
var import_path6 = require("path");
|
|
12947
12975
|
|
|
12948
12976
|
// src/core/utils/content-security-policy.ts
|
|
@@ -13048,12 +13076,12 @@ function getContentScriptJs(config, entrypoint) {
|
|
|
13048
13076
|
}
|
|
13049
13077
|
|
|
13050
13078
|
// src/core/utils/package.ts
|
|
13051
|
-
var
|
|
13052
|
-
var
|
|
13079
|
+
var import_node_path24 = require("path");
|
|
13080
|
+
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
13053
13081
|
async function getPackageJson() {
|
|
13054
|
-
const file = (0,
|
|
13082
|
+
const file = (0, import_node_path24.resolve)(wxt.config.root, "package.json");
|
|
13055
13083
|
try {
|
|
13056
|
-
return await
|
|
13084
|
+
return await import_fs_extra13.default.readJson(file);
|
|
13057
13085
|
} catch (err) {
|
|
13058
13086
|
wxt.logger.debug(
|
|
13059
13087
|
`Failed to read package.json at: ${file}. Returning undefined.`
|
|
@@ -13066,7 +13094,7 @@ async function getPackageJson() {
|
|
|
13066
13094
|
var import_defu2 = __toESM(require("defu"), 1);
|
|
13067
13095
|
async function writeManifest(manifest, output) {
|
|
13068
13096
|
const str = wxt.config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
13069
|
-
await
|
|
13097
|
+
await import_fs_extra14.default.ensureDir(wxt.config.outDir);
|
|
13070
13098
|
await writeFileIfDifferent((0, import_path6.resolve)(wxt.config.outDir, "manifest.json"), str);
|
|
13071
13099
|
output.publicAssets.unshift({
|
|
13072
13100
|
type: "asset",
|
|
@@ -13602,7 +13630,7 @@ async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
|
|
|
13602
13630
|
}
|
|
13603
13631
|
|
|
13604
13632
|
// src/core/utils/building/internal-build.ts
|
|
13605
|
-
var
|
|
13633
|
+
var import_node_path25 = require("path");
|
|
13606
13634
|
|
|
13607
13635
|
// src/core/utils/validation.ts
|
|
13608
13636
|
function validateEntrypoints(entrypoints) {
|
|
@@ -13674,8 +13702,8 @@ async function internalBuild() {
|
|
|
13674
13702
|
)}`
|
|
13675
13703
|
);
|
|
13676
13704
|
const startTime = Date.now();
|
|
13677
|
-
await
|
|
13678
|
-
await
|
|
13705
|
+
await import_fs_extra15.default.rm(wxt.config.outDir, { recursive: true, force: true });
|
|
13706
|
+
await import_fs_extra15.default.ensureDir(wxt.config.outDir);
|
|
13679
13707
|
const entrypoints = await findEntrypoints();
|
|
13680
13708
|
wxt.logger.debug("Detected entrypoints:", entrypoints);
|
|
13681
13709
|
const validationResults = validateEntrypoints(entrypoints);
|
|
@@ -13701,7 +13729,7 @@ async function internalBuild() {
|
|
|
13701
13729
|
}
|
|
13702
13730
|
if (wxt.config.analysis.enabled) {
|
|
13703
13731
|
await combineAnalysisStats();
|
|
13704
|
-
const statsPath = (0,
|
|
13732
|
+
const statsPath = (0, import_node_path25.relative)(wxt.config.root, wxt.config.analysis.outputFile);
|
|
13705
13733
|
wxt.logger.info(
|
|
13706
13734
|
`Analysis complete:
|
|
13707
13735
|
${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow(statsPath)}`
|
|
@@ -13730,7 +13758,7 @@ async function combineAnalysisStats() {
|
|
|
13730
13758
|
filename: wxt.config.analysis.outputFile
|
|
13731
13759
|
});
|
|
13732
13760
|
if (!wxt.config.analysis.keepArtifacts) {
|
|
13733
|
-
await Promise.all(absolutePaths.map((statsFile) =>
|
|
13761
|
+
await Promise.all(absolutePaths.map((statsFile) => import_fs_extra15.default.remove(statsFile)));
|
|
13734
13762
|
}
|
|
13735
13763
|
}
|
|
13736
13764
|
function printValidationResults({
|
|
@@ -13749,7 +13777,7 @@ function printValidationResults({
|
|
|
13749
13777
|
return map;
|
|
13750
13778
|
}, /* @__PURE__ */ new Map());
|
|
13751
13779
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
13752
|
-
wxt.logger.log((0,
|
|
13780
|
+
wxt.logger.log((0, import_node_path25.relative)(cwd, entrypoint.inputPath));
|
|
13753
13781
|
console.log();
|
|
13754
13782
|
errors2.forEach((err) => {
|
|
13755
13783
|
const type = err.type === "error" ? import_picocolors5.default.red("ERROR") : import_picocolors5.default.yellow("WARN");
|
|
@@ -13767,9 +13795,9 @@ async function build(config) {
|
|
|
13767
13795
|
}
|
|
13768
13796
|
|
|
13769
13797
|
// src/core/clean.ts
|
|
13770
|
-
var
|
|
13798
|
+
var import_node_path26 = __toESM(require("path"), 1);
|
|
13771
13799
|
var import_fast_glob6 = __toESM(require("fast-glob"), 1);
|
|
13772
|
-
var
|
|
13800
|
+
var import_fs_extra16 = __toESM(require("fs-extra"), 1);
|
|
13773
13801
|
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
13774
13802
|
async function clean(config) {
|
|
13775
13803
|
if (typeof config === "string") {
|
|
@@ -13782,7 +13810,7 @@ async function clean(config) {
|
|
|
13782
13810
|
"node_modules/.vite",
|
|
13783
13811
|
"node_modules/.cache",
|
|
13784
13812
|
"**/.wxt",
|
|
13785
|
-
`${
|
|
13813
|
+
`${import_node_path26.default.relative(root, wxt.config.outBaseDir)}/*`
|
|
13786
13814
|
];
|
|
13787
13815
|
wxt.logger.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
|
|
13788
13816
|
const directories = await (0, import_fast_glob6.default)(tempDirs, {
|
|
@@ -13797,11 +13825,11 @@ async function clean(config) {
|
|
|
13797
13825
|
}
|
|
13798
13826
|
wxt.logger.debug(
|
|
13799
13827
|
"Found:",
|
|
13800
|
-
directories.map((dir) => import_picocolors6.default.cyan(
|
|
13828
|
+
directories.map((dir) => import_picocolors6.default.cyan(import_node_path26.default.relative(root, dir))).join(", ")
|
|
13801
13829
|
);
|
|
13802
13830
|
for (const directory of directories) {
|
|
13803
|
-
await
|
|
13804
|
-
wxt.logger.debug("Deleted " + import_picocolors6.default.cyan(
|
|
13831
|
+
await import_fs_extra16.default.rm(directory, { force: true, recursive: true });
|
|
13832
|
+
wxt.logger.debug("Deleted " + import_picocolors6.default.cyan(import_node_path26.default.relative(root, directory)));
|
|
13805
13833
|
}
|
|
13806
13834
|
}
|
|
13807
13835
|
|
|
@@ -13816,12 +13844,12 @@ function defineRunnerConfig(config) {
|
|
|
13816
13844
|
}
|
|
13817
13845
|
|
|
13818
13846
|
// src/core/runners/wsl.ts
|
|
13819
|
-
var
|
|
13847
|
+
var import_node_path27 = require("path");
|
|
13820
13848
|
function createWslRunner() {
|
|
13821
13849
|
return {
|
|
13822
13850
|
async openBrowser() {
|
|
13823
13851
|
wxt.logger.warn(
|
|
13824
|
-
`Cannot open browser when using WSL. Load "${(0,
|
|
13852
|
+
`Cannot open browser when using WSL. Load "${(0, import_node_path27.relative)(
|
|
13825
13853
|
process.cwd(),
|
|
13826
13854
|
wxt.config.outDir
|
|
13827
13855
|
)}" as an unpacked extension manually`
|
|
@@ -13874,6 +13902,9 @@ function createWebExtRunner() {
|
|
|
13874
13902
|
...userConfig,
|
|
13875
13903
|
target: wxt.config.browser === "firefox" ? "firefox-desktop" : "chromium",
|
|
13876
13904
|
sourceDir: wxt.config.outDir,
|
|
13905
|
+
// Don't add a "Reload Manager" extension alongside dev extension, WXT
|
|
13906
|
+
// already handles reloads intenrally.
|
|
13907
|
+
noReloadManagerExtension: true,
|
|
13877
13908
|
// WXT handles reloads, so disable auto-reload behaviors in web-ext
|
|
13878
13909
|
noReload: true,
|
|
13879
13910
|
noInput: true
|
|
@@ -13908,12 +13939,12 @@ var DEFAULT_CHROMIUM_PREFS = {
|
|
|
13908
13939
|
};
|
|
13909
13940
|
|
|
13910
13941
|
// src/core/runners/safari.ts
|
|
13911
|
-
var
|
|
13942
|
+
var import_node_path28 = require("path");
|
|
13912
13943
|
function createSafariRunner() {
|
|
13913
13944
|
return {
|
|
13914
13945
|
async openBrowser() {
|
|
13915
13946
|
wxt.logger.warn(
|
|
13916
|
-
`Cannot Safari using web-ext. Load "${(0,
|
|
13947
|
+
`Cannot Safari using web-ext. Load "${(0, import_node_path28.relative)(
|
|
13917
13948
|
process.cwd(),
|
|
13918
13949
|
wxt.config.outDir
|
|
13919
13950
|
)}" as an unpacked extension manually`
|
|
@@ -13925,12 +13956,12 @@ function createSafariRunner() {
|
|
|
13925
13956
|
}
|
|
13926
13957
|
|
|
13927
13958
|
// src/core/runners/manual.ts
|
|
13928
|
-
var
|
|
13959
|
+
var import_node_path29 = require("path");
|
|
13929
13960
|
function createManualRunner() {
|
|
13930
13961
|
return {
|
|
13931
13962
|
async openBrowser() {
|
|
13932
13963
|
wxt.logger.info(
|
|
13933
|
-
`Load "${(0,
|
|
13964
|
+
`Load "${(0, import_node_path29.relative)(
|
|
13934
13965
|
process.cwd(),
|
|
13935
13966
|
wxt.config.outDir
|
|
13936
13967
|
)}" as an unpacked extension manually`
|
|
@@ -13958,7 +13989,7 @@ async function createExtensionRunner() {
|
|
|
13958
13989
|
// src/core/create-server.ts
|
|
13959
13990
|
var import_async_mutex = require("async-mutex");
|
|
13960
13991
|
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
13961
|
-
var
|
|
13992
|
+
var import_node_path30 = require("path");
|
|
13962
13993
|
async function createServer(inlineConfig) {
|
|
13963
13994
|
await registerWxt("serve", inlineConfig, async (config) => {
|
|
13964
13995
|
const { port, hostname } = config.dev.server;
|
|
@@ -14060,7 +14091,7 @@ function createFileReloader(server) {
|
|
|
14060
14091
|
return;
|
|
14061
14092
|
}
|
|
14062
14093
|
wxt.logger.info(
|
|
14063
|
-
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0,
|
|
14094
|
+
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path30.relative)(wxt.config.root, file))).join(", ")}`
|
|
14064
14095
|
);
|
|
14065
14096
|
const allEntrypoints = await findEntrypoints();
|
|
14066
14097
|
try {
|
|
@@ -14148,8 +14179,8 @@ function getExternalOutputDependencies(server) {
|
|
|
14148
14179
|
// src/core/initialize.ts
|
|
14149
14180
|
var import_prompts = __toESM(require("prompts"), 1);
|
|
14150
14181
|
var import_giget = require("giget");
|
|
14151
|
-
var
|
|
14152
|
-
var
|
|
14182
|
+
var import_fs_extra17 = __toESM(require("fs-extra"), 1);
|
|
14183
|
+
var import_node_path31 = __toESM(require("path"), 1);
|
|
14153
14184
|
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
14154
14185
|
async function initialize(options) {
|
|
14155
14186
|
consola.info("Initalizing new project");
|
|
@@ -14196,18 +14227,18 @@ async function initialize(options) {
|
|
|
14196
14227
|
input.directory ??= options.directory;
|
|
14197
14228
|
input.template ??= defaultTemplate;
|
|
14198
14229
|
input.packageManager ??= options.packageManager;
|
|
14199
|
-
const isExists = await
|
|
14230
|
+
const isExists = await import_fs_extra17.default.pathExists(input.directory);
|
|
14200
14231
|
if (isExists) {
|
|
14201
|
-
const isEmpty = (await
|
|
14232
|
+
const isEmpty = (await import_fs_extra17.default.readdir(input.directory)).length === 0;
|
|
14202
14233
|
if (!isEmpty) {
|
|
14203
14234
|
consola.error(
|
|
14204
|
-
`The directory ${
|
|
14235
|
+
`The directory ${import_node_path31.default.resolve(input.directory)} is not empty. Aborted.`
|
|
14205
14236
|
);
|
|
14206
14237
|
process.exit(1);
|
|
14207
14238
|
}
|
|
14208
14239
|
}
|
|
14209
14240
|
await cloneProject(input);
|
|
14210
|
-
const cdPath =
|
|
14241
|
+
const cdPath = import_node_path31.default.relative(process.cwd(), import_node_path31.default.resolve(input.directory));
|
|
14211
14242
|
console.log();
|
|
14212
14243
|
consola.log(
|
|
14213
14244
|
`\u2728 WXT project created with the ${TEMPLATE_COLORS[input.template.name]?.(input.template.name) ?? input.template.name} template.`
|
|
@@ -14249,9 +14280,9 @@ async function cloneProject({
|
|
|
14249
14280
|
dir: directory,
|
|
14250
14281
|
force: true
|
|
14251
14282
|
});
|
|
14252
|
-
await
|
|
14253
|
-
|
|
14254
|
-
|
|
14283
|
+
await import_fs_extra17.default.move(
|
|
14284
|
+
import_node_path31.default.join(directory, "_gitignore"),
|
|
14285
|
+
import_node_path31.default.join(directory, ".gitignore")
|
|
14255
14286
|
).catch(
|
|
14256
14287
|
(err) => consola.warn("Failed to move _gitignore to .gitignore:", err)
|
|
14257
14288
|
);
|
|
@@ -14283,8 +14314,8 @@ async function prepare(config) {
|
|
|
14283
14314
|
}
|
|
14284
14315
|
|
|
14285
14316
|
// src/core/zip.ts
|
|
14286
|
-
var
|
|
14287
|
-
var
|
|
14317
|
+
var import_node_path32 = __toESM(require("path"), 1);
|
|
14318
|
+
var import_fs_extra18 = __toESM(require("fs-extra"), 1);
|
|
14288
14319
|
var import_minimatch2 = require("minimatch");
|
|
14289
14320
|
var import_jszip = __toESM(require("jszip"), 1);
|
|
14290
14321
|
var import_fast_glob7 = __toESM(require("fast-glob"), 1);
|
|
@@ -14295,21 +14326,21 @@ async function zip(config) {
|
|
|
14295
14326
|
wxt.logger.info("Zipping extension...");
|
|
14296
14327
|
const zipFiles = [];
|
|
14297
14328
|
const projectName = wxt.config.zip.name ?? kebabCaseAlphanumeric(
|
|
14298
|
-
(await getPackageJson())?.name ||
|
|
14329
|
+
(await getPackageJson())?.name || import_node_path32.default.dirname(process.cwd())
|
|
14299
14330
|
);
|
|
14300
14331
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", wxt.config.browser).replaceAll(
|
|
14301
14332
|
"{{version}}",
|
|
14302
14333
|
output.manifest.version_name ?? output.manifest.version
|
|
14303
14334
|
).replaceAll("{{mode}}", wxt.config.mode).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
14304
|
-
await
|
|
14335
|
+
await import_fs_extra18.default.ensureDir(wxt.config.outBaseDir);
|
|
14305
14336
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
14306
|
-
const outZipPath =
|
|
14337
|
+
const outZipPath = import_node_path32.default.resolve(wxt.config.outBaseDir, outZipFilename);
|
|
14307
14338
|
await zipDir(wxt.config.outDir, outZipPath);
|
|
14308
14339
|
zipFiles.push(outZipPath);
|
|
14309
14340
|
if (wxt.config.browser === "firefox") {
|
|
14310
14341
|
const { overrides, files: downloadedPackages } = await downloadPrivatePackages();
|
|
14311
14342
|
const sourcesZipFilename = applyTemplate(wxt.config.zip.sourcesTemplate);
|
|
14312
|
-
const sourcesZipPath =
|
|
14343
|
+
const sourcesZipPath = import_node_path32.default.resolve(
|
|
14313
14344
|
wxt.config.outBaseDir,
|
|
14314
14345
|
sourcesZipFilename
|
|
14315
14346
|
);
|
|
@@ -14348,31 +14379,32 @@ async function zipDir(directory, outputPath, options) {
|
|
|
14348
14379
|
const filesToZip = [
|
|
14349
14380
|
...files,
|
|
14350
14381
|
...(options?.additionalFiles ?? []).map(
|
|
14351
|
-
(file) =>
|
|
14382
|
+
(file) => import_node_path32.default.relative(directory, file)
|
|
14352
14383
|
)
|
|
14353
14384
|
];
|
|
14354
14385
|
for (const file of filesToZip) {
|
|
14355
|
-
const absolutePath =
|
|
14386
|
+
const absolutePath = import_node_path32.default.resolve(directory, file);
|
|
14356
14387
|
if (file.endsWith(".json")) {
|
|
14357
|
-
const content = await
|
|
14388
|
+
const content = await import_fs_extra18.default.readFile(absolutePath, "utf-8");
|
|
14358
14389
|
archive.file(
|
|
14359
14390
|
file,
|
|
14360
14391
|
await options?.transform?.(absolutePath, file, content) || content
|
|
14361
14392
|
);
|
|
14362
14393
|
} else {
|
|
14363
|
-
const content = await
|
|
14394
|
+
const content = await import_fs_extra18.default.readFile(absolutePath);
|
|
14364
14395
|
archive.file(file, content);
|
|
14365
14396
|
}
|
|
14366
14397
|
}
|
|
14367
14398
|
await options?.additionalWork?.(archive);
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
compression: "
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14399
|
+
await new Promise(
|
|
14400
|
+
(resolve18, reject) => archive.generateNodeStream({
|
|
14401
|
+
type: "nodebuffer",
|
|
14402
|
+
...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
|
|
14403
|
+
compression: "DEFLATE",
|
|
14404
|
+
compressionOptions: { level: wxt.config.zip.compressionLevel }
|
|
14405
|
+
}
|
|
14406
|
+
}).pipe(import_fs_extra18.default.createWriteStream(outputPath)).on("error", reject).on("close", resolve18)
|
|
14407
|
+
);
|
|
14376
14408
|
}
|
|
14377
14409
|
async function downloadPrivatePackages() {
|
|
14378
14410
|
const overrides = {};
|
|
@@ -14401,14 +14433,14 @@ async function downloadPrivatePackages() {
|
|
|
14401
14433
|
}
|
|
14402
14434
|
function addOverridesToPackageJson(absolutePackageJsonPath, content, overrides) {
|
|
14403
14435
|
if (Object.keys(overrides).length === 0) return content;
|
|
14404
|
-
const packageJsonDir =
|
|
14436
|
+
const packageJsonDir = import_node_path32.default.dirname(absolutePackageJsonPath);
|
|
14405
14437
|
const oldPackage = JSON.parse(content);
|
|
14406
14438
|
const newPackage = {
|
|
14407
14439
|
...oldPackage,
|
|
14408
14440
|
[wxt.pm.overridesKey]: { ...oldPackage[wxt.pm.overridesKey] }
|
|
14409
14441
|
};
|
|
14410
14442
|
Object.entries(overrides).forEach(([key, absolutePath]) => {
|
|
14411
|
-
newPackage[wxt.pm.overridesKey][key] = "file://./" + normalizePath(
|
|
14443
|
+
newPackage[wxt.pm.overridesKey][key] = "file://./" + normalizePath(import_node_path32.default.relative(packageJsonDir, absolutePath));
|
|
14412
14444
|
});
|
|
14413
14445
|
return JSON.stringify(newPackage, null, 2);
|
|
14414
14446
|
}
|