wxt 0.16.3 → 0.16.5
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 +2 -5
- package/dist/{chunk-4IVGHIAG.js → chunk-N5MSLHHE.js} +104 -64
- package/dist/cli.js +119 -79
- package/dist/{index-wltPoSyr.d.cts → index-znx-ff-l.d.cts} +8 -0
- package/dist/{index-wltPoSyr.d.ts → index-znx-ff-l.d.ts} +8 -0
- package/dist/index.cjs +181 -141
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/testing.cjs +40 -37
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,7 @@ var require_windows = __commonJS({
|
|
|
40
40
|
module2.exports = isexe;
|
|
41
41
|
isexe.sync = sync;
|
|
42
42
|
var fs16 = require("fs");
|
|
43
|
-
function checkPathExt(
|
|
43
|
+
function checkPathExt(path11, options) {
|
|
44
44
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
45
45
|
if (!pathext) {
|
|
46
46
|
return true;
|
|
@@ -51,25 +51,25 @@ var require_windows = __commonJS({
|
|
|
51
51
|
}
|
|
52
52
|
for (var i = 0; i < pathext.length; i++) {
|
|
53
53
|
var p = pathext[i].toLowerCase();
|
|
54
|
-
if (p &&
|
|
54
|
+
if (p && path11.substr(-p.length).toLowerCase() === p) {
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
|
-
function checkStat(stat,
|
|
60
|
+
function checkStat(stat, path11, options) {
|
|
61
61
|
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
|
-
return checkPathExt(
|
|
64
|
+
return checkPathExt(path11, options);
|
|
65
65
|
}
|
|
66
|
-
function isexe(
|
|
67
|
-
fs16.stat(
|
|
68
|
-
cb(er, er ? false : checkStat(stat,
|
|
66
|
+
function isexe(path11, options, cb) {
|
|
67
|
+
fs16.stat(path11, function(er, stat) {
|
|
68
|
+
cb(er, er ? false : checkStat(stat, path11, options));
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function sync(
|
|
72
|
-
return checkStat(fs16.statSync(
|
|
71
|
+
function sync(path11, options) {
|
|
72
|
+
return checkStat(fs16.statSync(path11), path11, options);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
});
|
|
@@ -81,13 +81,13 @@ var require_mode = __commonJS({
|
|
|
81
81
|
module2.exports = isexe;
|
|
82
82
|
isexe.sync = sync;
|
|
83
83
|
var fs16 = require("fs");
|
|
84
|
-
function isexe(
|
|
85
|
-
fs16.stat(
|
|
84
|
+
function isexe(path11, options, cb) {
|
|
85
|
+
fs16.stat(path11, function(er, stat) {
|
|
86
86
|
cb(er, er ? false : checkStat(stat, options));
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
function sync(
|
|
90
|
-
return checkStat(fs16.statSync(
|
|
89
|
+
function sync(path11, options) {
|
|
90
|
+
return checkStat(fs16.statSync(path11), options);
|
|
91
91
|
}
|
|
92
92
|
function checkStat(stat, options) {
|
|
93
93
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -121,7 +121,7 @@ var require_isexe = __commonJS({
|
|
|
121
121
|
}
|
|
122
122
|
module2.exports = isexe;
|
|
123
123
|
isexe.sync = sync;
|
|
124
|
-
function isexe(
|
|
124
|
+
function isexe(path11, options, cb) {
|
|
125
125
|
if (typeof options === "function") {
|
|
126
126
|
cb = options;
|
|
127
127
|
options = {};
|
|
@@ -131,7 +131,7 @@ var require_isexe = __commonJS({
|
|
|
131
131
|
throw new TypeError("callback not provided");
|
|
132
132
|
}
|
|
133
133
|
return new Promise(function(resolve15, reject) {
|
|
134
|
-
isexe(
|
|
134
|
+
isexe(path11, options || {}, function(er, is) {
|
|
135
135
|
if (er) {
|
|
136
136
|
reject(er);
|
|
137
137
|
} else {
|
|
@@ -140,7 +140,7 @@ var require_isexe = __commonJS({
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
core(
|
|
143
|
+
core(path11, options || {}, function(er, is) {
|
|
144
144
|
if (er) {
|
|
145
145
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
146
146
|
er = null;
|
|
@@ -150,9 +150,9 @@ var require_isexe = __commonJS({
|
|
|
150
150
|
cb(er, is);
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
function sync(
|
|
153
|
+
function sync(path11, options) {
|
|
154
154
|
try {
|
|
155
|
-
return core.sync(
|
|
155
|
+
return core.sync(path11, options || {});
|
|
156
156
|
} catch (er) {
|
|
157
157
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
158
158
|
return false;
|
|
@@ -169,7 +169,7 @@ var require_which = __commonJS({
|
|
|
169
169
|
"node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module2) {
|
|
170
170
|
"use strict";
|
|
171
171
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
172
|
-
var
|
|
172
|
+
var path11 = require("path");
|
|
173
173
|
var COLON = isWindows ? ";" : ":";
|
|
174
174
|
var isexe = require_isexe();
|
|
175
175
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -207,7 +207,7 @@ var require_which = __commonJS({
|
|
|
207
207
|
return opt.all && found.length ? resolve15(found) : reject(getNotFoundError(cmd));
|
|
208
208
|
const ppRaw = pathEnv[i];
|
|
209
209
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
210
|
-
const pCmd =
|
|
210
|
+
const pCmd = path11.join(pathPart, cmd);
|
|
211
211
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
212
212
|
resolve15(subStep(p, i, 0));
|
|
213
213
|
});
|
|
@@ -234,7 +234,7 @@ var require_which = __commonJS({
|
|
|
234
234
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
235
235
|
const ppRaw = pathEnv[i];
|
|
236
236
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
237
|
-
const pCmd =
|
|
237
|
+
const pCmd = path11.join(pathPart, cmd);
|
|
238
238
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
239
239
|
for (let j = 0; j < pathExt.length; j++) {
|
|
240
240
|
const cur = p + pathExt[j];
|
|
@@ -282,7 +282,7 @@ var require_path_key = __commonJS({
|
|
|
282
282
|
var require_resolveCommand = __commonJS({
|
|
283
283
|
"node_modules/.pnpm/cross-spawn@7.0.3/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
|
|
284
284
|
"use strict";
|
|
285
|
-
var
|
|
285
|
+
var path11 = require("path");
|
|
286
286
|
var which = require_which();
|
|
287
287
|
var getPathKey = require_path_key();
|
|
288
288
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -300,7 +300,7 @@ var require_resolveCommand = __commonJS({
|
|
|
300
300
|
try {
|
|
301
301
|
resolved = which.sync(parsed.command, {
|
|
302
302
|
path: env[getPathKey({ env })],
|
|
303
|
-
pathExt: withoutPathExt ?
|
|
303
|
+
pathExt: withoutPathExt ? path11.delimiter : void 0
|
|
304
304
|
});
|
|
305
305
|
} catch (e) {
|
|
306
306
|
} finally {
|
|
@@ -309,7 +309,7 @@ var require_resolveCommand = __commonJS({
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
if (resolved) {
|
|
312
|
-
resolved =
|
|
312
|
+
resolved = path11.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
313
313
|
}
|
|
314
314
|
return resolved;
|
|
315
315
|
}
|
|
@@ -363,8 +363,8 @@ var require_shebang_command = __commonJS({
|
|
|
363
363
|
if (!match) {
|
|
364
364
|
return null;
|
|
365
365
|
}
|
|
366
|
-
const [
|
|
367
|
-
const binary =
|
|
366
|
+
const [path11, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
367
|
+
const binary = path11.split("/").pop();
|
|
368
368
|
if (binary === "env") {
|
|
369
369
|
return argument;
|
|
370
370
|
}
|
|
@@ -399,7 +399,7 @@ var require_readShebang = __commonJS({
|
|
|
399
399
|
var require_parse = __commonJS({
|
|
400
400
|
"node_modules/.pnpm/cross-spawn@7.0.3/node_modules/cross-spawn/lib/parse.js"(exports, module2) {
|
|
401
401
|
"use strict";
|
|
402
|
-
var
|
|
402
|
+
var path11 = require("path");
|
|
403
403
|
var resolveCommand = require_resolveCommand();
|
|
404
404
|
var escape = require_escape();
|
|
405
405
|
var readShebang = require_readShebang();
|
|
@@ -424,7 +424,7 @@ var require_parse = __commonJS({
|
|
|
424
424
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
425
425
|
if (parsed.options.forceShell || needsShell) {
|
|
426
426
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
427
|
-
parsed.command =
|
|
427
|
+
parsed.command = path11.normalize(parsed.command);
|
|
428
428
|
parsed.command = escape.command(parsed.command);
|
|
429
429
|
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
430
430
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -578,29 +578,29 @@ function npmRunPath(options = {}) {
|
|
|
578
578
|
} = options;
|
|
579
579
|
let previous;
|
|
580
580
|
const cwdString = cwd instanceof URL ? import_node_url2.default.fileURLToPath(cwd) : cwd;
|
|
581
|
-
let cwdPath =
|
|
581
|
+
let cwdPath = import_node_path12.default.resolve(cwdString);
|
|
582
582
|
const result = [];
|
|
583
583
|
while (previous !== cwdPath) {
|
|
584
|
-
result.push(
|
|
584
|
+
result.push(import_node_path12.default.join(cwdPath, "node_modules/.bin"));
|
|
585
585
|
previous = cwdPath;
|
|
586
|
-
cwdPath =
|
|
586
|
+
cwdPath = import_node_path12.default.resolve(cwdPath, "..");
|
|
587
587
|
}
|
|
588
|
-
result.push(
|
|
589
|
-
return [...result, path_].join(
|
|
588
|
+
result.push(import_node_path12.default.resolve(cwdString, execPath, ".."));
|
|
589
|
+
return [...result, path_].join(import_node_path12.default.delimiter);
|
|
590
590
|
}
|
|
591
591
|
function npmRunPathEnv({ env = import_node_process.default.env, ...options } = {}) {
|
|
592
592
|
env = { ...env };
|
|
593
|
-
const
|
|
594
|
-
options.path = env[
|
|
595
|
-
env[
|
|
593
|
+
const path11 = pathKey({ env });
|
|
594
|
+
options.path = env[path11];
|
|
595
|
+
env[path11] = npmRunPath(options);
|
|
596
596
|
return env;
|
|
597
597
|
}
|
|
598
|
-
var import_node_process,
|
|
598
|
+
var import_node_process, import_node_path12, import_node_url2;
|
|
599
599
|
var init_npm_run_path = __esm({
|
|
600
600
|
"node_modules/.pnpm/npm-run-path@5.1.0/node_modules/npm-run-path/index.js"() {
|
|
601
601
|
"use strict";
|
|
602
602
|
import_node_process = __toESM(require("process"), 1);
|
|
603
|
-
|
|
603
|
+
import_node_path12 = __toESM(require("path"), 1);
|
|
604
604
|
import_node_url2 = __toESM(require("url"), 1);
|
|
605
605
|
init_path_key();
|
|
606
606
|
}
|
|
@@ -2337,12 +2337,12 @@ function execaNode(scriptPath, args, options = {}) {
|
|
|
2337
2337
|
}
|
|
2338
2338
|
);
|
|
2339
2339
|
}
|
|
2340
|
-
var import_node_buffer2,
|
|
2340
|
+
var import_node_buffer2, import_node_path13, import_node_child_process3, import_node_process4, import_cross_spawn, DEFAULT_MAX_BUFFER, getEnv, handleArguments, handleOutput, normalizeScriptStdin, normalizeScriptOptions, $;
|
|
2341
2341
|
var init_execa = __esm({
|
|
2342
2342
|
"node_modules/.pnpm/execa@8.0.1/node_modules/execa/index.js"() {
|
|
2343
2343
|
"use strict";
|
|
2344
2344
|
import_node_buffer2 = require("buffer");
|
|
2345
|
-
|
|
2345
|
+
import_node_path13 = __toESM(require("path"), 1);
|
|
2346
2346
|
import_node_child_process3 = __toESM(require("child_process"), 1);
|
|
2347
2347
|
import_node_process4 = __toESM(require("process"), 1);
|
|
2348
2348
|
import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
@@ -2388,7 +2388,7 @@ var init_execa = __esm({
|
|
|
2388
2388
|
};
|
|
2389
2389
|
options.env = getEnv(options);
|
|
2390
2390
|
options.stdio = normalizeStdio(options);
|
|
2391
|
-
if (import_node_process4.default.platform === "win32" &&
|
|
2391
|
+
if (import_node_process4.default.platform === "win32" && import_node_path13.default.basename(file, ".exe") === "cmd") {
|
|
2392
2392
|
args.unshift("/q");
|
|
2393
2393
|
}
|
|
2394
2394
|
return { file, args, options, parsed };
|
|
@@ -2434,11 +2434,11 @@ var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
|
2434
2434
|
// src/core/utils/paths.ts
|
|
2435
2435
|
var import_node_path = __toESM(require("path"), 1);
|
|
2436
2436
|
var import_normalize_path = __toESM(require("normalize-path"), 1);
|
|
2437
|
-
function normalizePath(
|
|
2438
|
-
return (0, import_normalize_path.default)(
|
|
2437
|
+
function normalizePath(path11) {
|
|
2438
|
+
return (0, import_normalize_path.default)(path11);
|
|
2439
2439
|
}
|
|
2440
|
-
function unnormalizePath(
|
|
2441
|
-
return import_node_path.default.normalize(
|
|
2440
|
+
function unnormalizePath(path11) {
|
|
2441
|
+
return import_node_path.default.normalize(path11);
|
|
2442
2442
|
}
|
|
2443
2443
|
var CSS_EXTENSIONS = ["css", "scss", "sass", "less", "styl", "stylus"];
|
|
2444
2444
|
var CSS_EXTENSIONS_PATTERN = `+(${CSS_EXTENSIONS.join("|")})`;
|
|
@@ -2491,6 +2491,7 @@ async function buildEntrypoints(groups, spinner) {
|
|
|
2491
2491
|
try {
|
|
2492
2492
|
steps.push(await wxt.config.builder.build(group));
|
|
2493
2493
|
} catch (err) {
|
|
2494
|
+
wxt.logger.error(err);
|
|
2494
2495
|
throw Error(`Failed to build ${groupNames.join(", ")}`, { cause: err });
|
|
2495
2496
|
}
|
|
2496
2497
|
}
|
|
@@ -3170,7 +3171,7 @@ async function writePathsDeclarationFile(entrypoints) {
|
|
|
3170
3171
|
wxt.config.outDir,
|
|
3171
3172
|
entry.inputPath.endsWith(".html") ? ".html" : ".js"
|
|
3172
3173
|
)
|
|
3173
|
-
).concat(await getPublicFiles()).map(normalizePath).map((
|
|
3174
|
+
).concat(await getPublicFiles()).map(normalizePath).map((path11) => ` | "/${path11}"`).sort().join("\n");
|
|
3174
3175
|
const template = `// Generated by wxt
|
|
3175
3176
|
import "wxt/browser";
|
|
3176
3177
|
|
|
@@ -3278,7 +3279,7 @@ async function writeMainDeclarationFile(references) {
|
|
|
3278
3279
|
}
|
|
3279
3280
|
async function writeTsConfigFile(mainReference) {
|
|
3280
3281
|
const dir = wxt.config.wxtDir;
|
|
3281
|
-
const getTsconfigPath = (
|
|
3282
|
+
const getTsconfigPath = (path11) => normalizePath((0, import_path3.relative)(dir, path11));
|
|
3282
3283
|
const paths = Object.entries(wxt.config.alias).flatMap(([alias, absolutePath]) => {
|
|
3283
3284
|
const aliasPath = getTsconfigPath(absolutePath);
|
|
3284
3285
|
return [
|
|
@@ -3314,7 +3315,7 @@ ${paths}
|
|
|
3314
3315
|
|
|
3315
3316
|
// src/core/utils/building/resolve-config.ts
|
|
3316
3317
|
var import_c12 = require("c12");
|
|
3317
|
-
var
|
|
3318
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
3318
3319
|
|
|
3319
3320
|
// src/core/utils/cache.ts
|
|
3320
3321
|
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
@@ -3323,14 +3324,14 @@ function createFsCache(wxtDir) {
|
|
|
3323
3324
|
const getPath = (key) => (0, import_path4.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
3324
3325
|
return {
|
|
3325
3326
|
async set(key, value) {
|
|
3326
|
-
const
|
|
3327
|
-
await (0, import_fs_extra5.ensureDir)((0, import_path4.dirname)(
|
|
3328
|
-
await writeFileIfDifferent(
|
|
3327
|
+
const path11 = getPath(key);
|
|
3328
|
+
await (0, import_fs_extra5.ensureDir)((0, import_path4.dirname)(path11));
|
|
3329
|
+
await writeFileIfDifferent(path11, value);
|
|
3329
3330
|
},
|
|
3330
3331
|
async get(key) {
|
|
3331
|
-
const
|
|
3332
|
+
const path11 = getPath(key);
|
|
3332
3333
|
try {
|
|
3333
|
-
return await import_fs_extra5.default.readFile(
|
|
3334
|
+
return await import_fs_extra5.default.readFile(path11, "utf-8");
|
|
3334
3335
|
} catch {
|
|
3335
3336
|
return void 0;
|
|
3336
3337
|
}
|
|
@@ -3464,10 +3465,10 @@ function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
|
3464
3465
|
(0, import_node_path4.relative)(config.root, resolvedAbsolutePath)
|
|
3465
3466
|
);
|
|
3466
3467
|
if (relativePath.startsWith(".")) {
|
|
3467
|
-
let
|
|
3468
|
-
if (!
|
|
3469
|
-
|
|
3470
|
-
element.setAttribute(attr, `${server.origin}/@fs${
|
|
3468
|
+
let path11 = normalizePath(resolvedAbsolutePath);
|
|
3469
|
+
if (!path11.startsWith("/"))
|
|
3470
|
+
path11 = "/" + path11;
|
|
3471
|
+
element.setAttribute(attr, `${server.origin}/@fs${path11}`);
|
|
3471
3472
|
} else {
|
|
3472
3473
|
const url2 = new URL(relativePath, server.origin);
|
|
3473
3474
|
element.setAttribute(attr, url2.href);
|
|
@@ -3764,12 +3765,12 @@ function cssEntrypoints(entrypoint, config) {
|
|
|
3764
3765
|
|
|
3765
3766
|
// src/core/builders/vite/plugins/bundleAnalysis.ts
|
|
3766
3767
|
var import_rollup_plugin_visualizer = require("rollup-plugin-visualizer");
|
|
3768
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
3767
3769
|
var increment = 0;
|
|
3768
|
-
function bundleAnalysis() {
|
|
3770
|
+
function bundleAnalysis(config) {
|
|
3769
3771
|
return (0, import_rollup_plugin_visualizer.visualizer)({
|
|
3770
|
-
emitFile: true,
|
|
3771
3772
|
template: "raw-data",
|
|
3772
|
-
filename: `stats-${increment++}.json`
|
|
3773
|
+
filename: import_node_path6.default.resolve(config.outDir, `stats-${increment++}.json`)
|
|
3773
3774
|
});
|
|
3774
3775
|
}
|
|
3775
3776
|
|
|
@@ -3790,7 +3791,7 @@ function globals(config) {
|
|
|
3790
3791
|
}
|
|
3791
3792
|
|
|
3792
3793
|
// src/core/builders/vite/plugins/webextensionPolyfillMock.ts
|
|
3793
|
-
var
|
|
3794
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
3794
3795
|
|
|
3795
3796
|
// src/core/builders/vite/plugins/excludeBrowserPolyfill.ts
|
|
3796
3797
|
function excludeBrowserPolyfill(config) {
|
|
@@ -3888,7 +3889,7 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3888
3889
|
defineImportMeta()
|
|
3889
3890
|
);
|
|
3890
3891
|
if (wxtConfig.analysis.enabled) {
|
|
3891
|
-
config.plugins.push(bundleAnalysis());
|
|
3892
|
+
config.plugins.push(bundleAnalysis(wxtConfig));
|
|
3892
3893
|
}
|
|
3893
3894
|
return config;
|
|
3894
3895
|
};
|
|
@@ -4089,20 +4090,20 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4089
4090
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
4090
4091
|
const mode = mergedConfig.mode ?? (command === "build" ? "production" : "development");
|
|
4091
4092
|
const env = { browser, command, manifestVersion, mode };
|
|
4092
|
-
const root =
|
|
4093
|
+
const root = import_node_path8.default.resolve(
|
|
4093
4094
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
4094
4095
|
);
|
|
4095
|
-
const wxtDir =
|
|
4096
|
-
const srcDir =
|
|
4097
|
-
const entrypointsDir =
|
|
4096
|
+
const wxtDir = import_node_path8.default.resolve(root, ".wxt");
|
|
4097
|
+
const srcDir = import_node_path8.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
4098
|
+
const entrypointsDir = import_node_path8.default.resolve(
|
|
4098
4099
|
srcDir,
|
|
4099
4100
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
4100
4101
|
);
|
|
4101
4102
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
4102
|
-
const publicDir =
|
|
4103
|
-
const typesDir =
|
|
4104
|
-
const outBaseDir =
|
|
4105
|
-
const outDir =
|
|
4103
|
+
const publicDir = import_node_path8.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
4104
|
+
const typesDir = import_node_path8.default.resolve(wxtDir, "types");
|
|
4105
|
+
const outBaseDir = import_node_path8.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
4106
|
+
const outDir = import_node_path8.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
4106
4107
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
4107
4108
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
4108
4109
|
name: "web-ext",
|
|
@@ -4119,7 +4120,7 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4119
4120
|
"~": srcDir,
|
|
4120
4121
|
"@@": root,
|
|
4121
4122
|
"~~": root
|
|
4122
|
-
}).map(([key, value]) => [key,
|
|
4123
|
+
}).map(([key, value]) => [key, import_node_path8.default.resolve(root, value)])
|
|
4123
4124
|
);
|
|
4124
4125
|
const finalConfig = {
|
|
4125
4126
|
browser,
|
|
@@ -4149,7 +4150,11 @@ async function resolveConfig(inlineConfig, command, server) {
|
|
|
4149
4150
|
},
|
|
4150
4151
|
analysis: {
|
|
4151
4152
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
4152
|
-
template: mergedConfig.analysis?.template ?? "treemap"
|
|
4153
|
+
template: mergedConfig.analysis?.template ?? "treemap",
|
|
4154
|
+
outputFile: import_node_path8.default.resolve(
|
|
4155
|
+
root,
|
|
4156
|
+
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
4157
|
+
)
|
|
4153
4158
|
},
|
|
4154
4159
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
4155
4160
|
alias,
|
|
@@ -4219,8 +4224,8 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
4219
4224
|
outDir: inlineConfig.outDir ?? userConfig.outDir,
|
|
4220
4225
|
zip: zip2,
|
|
4221
4226
|
analysis: {
|
|
4222
|
-
|
|
4223
|
-
|
|
4227
|
+
...userConfig.analysis,
|
|
4228
|
+
...inlineConfig.analysis
|
|
4224
4229
|
},
|
|
4225
4230
|
alias: {
|
|
4226
4231
|
...userConfig.alias,
|
|
@@ -4305,7 +4310,7 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
4305
4310
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
4306
4311
|
var import_unimport5 = require("unimport");
|
|
4307
4312
|
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
4308
|
-
var
|
|
4313
|
+
var import_node_path9 = require("path");
|
|
4309
4314
|
|
|
4310
4315
|
// src/core/utils/strings.ts
|
|
4311
4316
|
function kebabCaseAlphanumeric(str) {
|
|
@@ -4328,16 +4333,16 @@ ${noImports}`;
|
|
|
4328
4333
|
var import_esbuild = require("esbuild");
|
|
4329
4334
|
var import_node_url = require("url");
|
|
4330
4335
|
var import_meta = {};
|
|
4331
|
-
async function importEntrypointFile(
|
|
4332
|
-
wxt.logger.debug("Loading file metadata:",
|
|
4333
|
-
const normalPath = normalizePath(
|
|
4336
|
+
async function importEntrypointFile(path11) {
|
|
4337
|
+
wxt.logger.debug("Loading file metadata:", path11);
|
|
4338
|
+
const normalPath = normalizePath(path11);
|
|
4334
4339
|
const unimport2 = (0, import_unimport5.createUnimport)({
|
|
4335
4340
|
...getUnimportOptions(wxt.config),
|
|
4336
4341
|
// Only allow specific imports, not all from the project
|
|
4337
4342
|
dirs: []
|
|
4338
4343
|
});
|
|
4339
4344
|
await unimport2.init();
|
|
4340
|
-
const text = await import_fs_extra8.default.readFile(
|
|
4345
|
+
const text = await import_fs_extra8.default.readFile(path11, "utf-8");
|
|
4341
4346
|
const textNoImports = removeProjectImportStatements(text);
|
|
4342
4347
|
const { code } = await unimport2.injectImports(textNoImports);
|
|
4343
4348
|
wxt.logger.debug(
|
|
@@ -4350,7 +4355,7 @@ async function importEntrypointFile(path10) {
|
|
|
4350
4355
|
debug: wxt.config.debug,
|
|
4351
4356
|
esmResolve: true,
|
|
4352
4357
|
alias: {
|
|
4353
|
-
"webextension-polyfill": (0,
|
|
4358
|
+
"webextension-polyfill": (0, import_node_path9.resolve)(
|
|
4354
4359
|
wxt.config.root,
|
|
4355
4360
|
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
4356
4361
|
)
|
|
@@ -4380,10 +4385,10 @@ async function importEntrypointFile(path10) {
|
|
|
4380
4385
|
}
|
|
4381
4386
|
);
|
|
4382
4387
|
try {
|
|
4383
|
-
const res = await jiti(
|
|
4388
|
+
const res = await jiti(path11);
|
|
4384
4389
|
return res.default;
|
|
4385
4390
|
} catch (err) {
|
|
4386
|
-
const filePath = (0,
|
|
4391
|
+
const filePath = (0, import_node_path9.relative)(wxt.config.root, path11);
|
|
4387
4392
|
if (err instanceof ReferenceError) {
|
|
4388
4393
|
const variableName = err.message.replace(" is not defined", "");
|
|
4389
4394
|
throw Error(
|
|
@@ -4413,7 +4418,7 @@ var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
|
4413
4418
|
var import_path7 = require("path");
|
|
4414
4419
|
|
|
4415
4420
|
// src/core/utils/log/printFileList.ts
|
|
4416
|
-
var
|
|
4421
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
4417
4422
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
4418
4423
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
4419
4424
|
var import_filesize = require("filesize");
|
|
@@ -4451,8 +4456,8 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
4451
4456
|
const fileRows = await Promise.all(
|
|
4452
4457
|
files.map(async (file, i) => {
|
|
4453
4458
|
const parts = [
|
|
4454
|
-
|
|
4455
|
-
|
|
4459
|
+
import_node_path10.default.relative(process.cwd(), baseDir) + import_node_path10.default.sep,
|
|
4460
|
+
import_node_path10.default.relative(baseDir, file)
|
|
4456
4461
|
];
|
|
4457
4462
|
const prefix = i === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
4458
4463
|
const color = getChunkColor(file);
|
|
@@ -4520,7 +4525,7 @@ function getChunkSortWeight(filename) {
|
|
|
4520
4525
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4521
4526
|
|
|
4522
4527
|
// package.json
|
|
4523
|
-
var version = "0.16.
|
|
4528
|
+
var version = "0.16.5";
|
|
4524
4529
|
|
|
4525
4530
|
// src/core/utils/log/printHeader.ts
|
|
4526
4531
|
var import_consola2 = require("consola");
|
|
@@ -4634,10 +4639,10 @@ function mapWxtOptionsToContentScript(options) {
|
|
|
4634
4639
|
}
|
|
4635
4640
|
|
|
4636
4641
|
// src/core/utils/package.ts
|
|
4637
|
-
var
|
|
4642
|
+
var import_node_path11 = require("path");
|
|
4638
4643
|
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
4639
4644
|
async function getPackageJson() {
|
|
4640
|
-
const file = (0,
|
|
4645
|
+
const file = (0, import_node_path11.resolve)(wxt.config.root, "package.json");
|
|
4641
4646
|
try {
|
|
4642
4647
|
return await import_fs_extra10.default.readJson(file);
|
|
4643
4648
|
} catch (err) {
|
|
@@ -4649,7 +4654,6 @@ async function getPackageJson() {
|
|
|
4649
4654
|
}
|
|
4650
4655
|
|
|
4651
4656
|
// src/core/utils/manifest.ts
|
|
4652
|
-
var import_immer = require("immer");
|
|
4653
4657
|
var import_defu3 = __toESM(require("defu"), 1);
|
|
4654
4658
|
async function writeManifest(manifest, output) {
|
|
4655
4659
|
const str = wxt.config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
@@ -4680,7 +4684,7 @@ async function generateManifest(entrypoints, buildOutput) {
|
|
|
4680
4684
|
icons: discoverIcons(buildOutput)
|
|
4681
4685
|
};
|
|
4682
4686
|
const userManifest = wxt.config.manifest;
|
|
4683
|
-
|
|
4687
|
+
let manifest = (0, import_defu3.default)(
|
|
4684
4688
|
userManifest,
|
|
4685
4689
|
baseManifest
|
|
4686
4690
|
);
|
|
@@ -4707,19 +4711,24 @@ async function generateManifest(entrypoints, buildOutput) {
|
|
|
4707
4711
|
addDevModeCsp(manifest);
|
|
4708
4712
|
if (wxt.config.command === "serve")
|
|
4709
4713
|
addDevModePermissions(manifest);
|
|
4710
|
-
|
|
4711
|
-
await wxt.hooks.callHook("build:manifestGenerated", wxt,
|
|
4712
|
-
if (
|
|
4714
|
+
wxt.config.transformManifest(manifest);
|
|
4715
|
+
await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
|
|
4716
|
+
if (wxt.config.manifestVersion === 2)
|
|
4717
|
+
convertWebAccessibleResourcesToMv2(manifest);
|
|
4718
|
+
if (wxt.config.manifestVersion === 3) {
|
|
4719
|
+
validateMv3WebAccessbileResources(manifest);
|
|
4720
|
+
}
|
|
4721
|
+
if (manifest.name == null)
|
|
4713
4722
|
throw Error(
|
|
4714
4723
|
"Manifest 'name' is missing. Either:\n1. Set the name in your <rootDir>/package.json\n2. Set a name via the manifest option in your wxt.config.ts"
|
|
4715
4724
|
);
|
|
4716
|
-
if (
|
|
4725
|
+
if (manifest.version == null) {
|
|
4717
4726
|
throw Error(
|
|
4718
4727
|
"Manifest 'version' is missing. Either:\n1. Add a version in your <rootDir>/package.json\n2. Pass the version via the manifest option in your wxt.config.ts"
|
|
4719
4728
|
);
|
|
4720
4729
|
}
|
|
4721
4730
|
return {
|
|
4722
|
-
manifest
|
|
4731
|
+
manifest,
|
|
4723
4732
|
warnings
|
|
4724
4733
|
};
|
|
4725
4734
|
}
|
|
@@ -5022,17 +5031,13 @@ function getContentScriptCssWebAccessibleResources(contentScripts, contentScript
|
|
|
5022
5031
|
const cssFile = contentScriptCssMap[script.name];
|
|
5023
5032
|
if (cssFile == null)
|
|
5024
5033
|
return;
|
|
5025
|
-
|
|
5026
|
-
resources
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
wxt.config.browser
|
|
5033
|
-
).map((matchPattern) => stripPathFromMatchPattern(matchPattern))
|
|
5034
|
-
});
|
|
5035
|
-
}
|
|
5034
|
+
resources.push({
|
|
5035
|
+
resources: [cssFile],
|
|
5036
|
+
matches: resolvePerBrowserOption(
|
|
5037
|
+
script.options.matches,
|
|
5038
|
+
wxt.config.browser
|
|
5039
|
+
).map((matchPattern) => stripPathFromMatchPattern(matchPattern))
|
|
5040
|
+
});
|
|
5036
5041
|
});
|
|
5037
5042
|
return resources;
|
|
5038
5043
|
}
|
|
@@ -5067,6 +5072,33 @@ function stripPathFromMatchPattern(pattern) {
|
|
|
5067
5072
|
const startOfPath = pattern.indexOf("/", protocolSepIndex + 3);
|
|
5068
5073
|
return pattern.substring(0, startOfPath) + "/*";
|
|
5069
5074
|
}
|
|
5075
|
+
function convertWebAccessibleResourcesToMv2(manifest) {
|
|
5076
|
+
if (manifest.web_accessible_resources == null)
|
|
5077
|
+
return;
|
|
5078
|
+
manifest.web_accessible_resources = Array.from(
|
|
5079
|
+
new Set(
|
|
5080
|
+
manifest.web_accessible_resources.flatMap((item) => {
|
|
5081
|
+
if (typeof item === "string")
|
|
5082
|
+
return item;
|
|
5083
|
+
return item.resources;
|
|
5084
|
+
})
|
|
5085
|
+
)
|
|
5086
|
+
);
|
|
5087
|
+
}
|
|
5088
|
+
function validateMv3WebAccessbileResources(manifest) {
|
|
5089
|
+
if (manifest.web_accessible_resources == null)
|
|
5090
|
+
return;
|
|
5091
|
+
const stringResources = manifest.web_accessible_resources.filter(
|
|
5092
|
+
(item) => typeof item === "string"
|
|
5093
|
+
);
|
|
5094
|
+
if (stringResources.length > 0) {
|
|
5095
|
+
throw Error(
|
|
5096
|
+
`Non-MV3 web_accessible_resources detected: ${JSON.stringify(
|
|
5097
|
+
stringResources
|
|
5098
|
+
)}. When manually defining web_accessible_resources, define them as MV3 objects ({ matches: [...], resources: [...] }), and WXT will automatically convert them to MV2 when necessary.`
|
|
5099
|
+
);
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5070
5102
|
|
|
5071
5103
|
// src/core/utils/building/rebuild.ts
|
|
5072
5104
|
async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
|
|
@@ -5107,7 +5139,7 @@ async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
|
|
|
5107
5139
|
}
|
|
5108
5140
|
|
|
5109
5141
|
// src/core/utils/building/internal-build.ts
|
|
5110
|
-
var
|
|
5142
|
+
var import_node_path15 = require("path");
|
|
5111
5143
|
|
|
5112
5144
|
// src/core/utils/validation.ts
|
|
5113
5145
|
function validateEntrypoints(entrypoints) {
|
|
@@ -5173,12 +5205,12 @@ var import_consola3 = __toESM(require("consola"), 1);
|
|
|
5173
5205
|
|
|
5174
5206
|
// src/core/utils/exec.ts
|
|
5175
5207
|
var import_manage_path = __toESM(require("manage-path"), 1);
|
|
5176
|
-
var
|
|
5208
|
+
var import_node_path14 = require("path");
|
|
5177
5209
|
var managedPath = (0, import_manage_path.default)(process.env);
|
|
5178
5210
|
var exec = async (file, args, options) => {
|
|
5179
5211
|
managedPath.restore();
|
|
5180
5212
|
managedPath.push(
|
|
5181
|
-
(0,
|
|
5213
|
+
(0, import_node_path14.resolve)(wxt.config.root, "node_modules/wxt/node_modules/.bin")
|
|
5182
5214
|
);
|
|
5183
5215
|
const { execa: execa2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
|
|
5184
5216
|
return await execa2(file, args, options);
|
|
@@ -5222,9 +5254,10 @@ async function internalBuild() {
|
|
|
5222
5254
|
}
|
|
5223
5255
|
if (wxt.config.analysis.enabled) {
|
|
5224
5256
|
await combineAnalysisStats();
|
|
5257
|
+
const statsPath = (0, import_node_path15.relative)(wxt.config.root, wxt.config.analysis.outputFile);
|
|
5225
5258
|
wxt.logger.info(
|
|
5226
5259
|
`Analysis complete:
|
|
5227
|
-
${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow(
|
|
5260
|
+
${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow(statsPath)}`
|
|
5228
5261
|
);
|
|
5229
5262
|
}
|
|
5230
5263
|
return output;
|
|
@@ -5237,9 +5270,16 @@ async function combineAnalysisStats() {
|
|
|
5237
5270
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
5238
5271
|
await exec(
|
|
5239
5272
|
"rollup-plugin-visualizer",
|
|
5240
|
-
[
|
|
5273
|
+
[
|
|
5274
|
+
...absolutePaths,
|
|
5275
|
+
"--template",
|
|
5276
|
+
wxt.config.analysis.template,
|
|
5277
|
+
"--filename",
|
|
5278
|
+
wxt.config.analysis.outputFile
|
|
5279
|
+
],
|
|
5241
5280
|
{ cwd: wxt.config.root, stdio: "inherit" }
|
|
5242
5281
|
);
|
|
5282
|
+
await Promise.all(absolutePaths.map((statsFile) => import_fs_extra12.default.remove(statsFile)));
|
|
5243
5283
|
}
|
|
5244
5284
|
function printValidationResults({
|
|
5245
5285
|
errorCount,
|
|
@@ -5257,7 +5297,7 @@ function printValidationResults({
|
|
|
5257
5297
|
return map;
|
|
5258
5298
|
}, /* @__PURE__ */ new Map());
|
|
5259
5299
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
5260
|
-
import_consola3.default.log((0,
|
|
5300
|
+
import_consola3.default.log((0, import_node_path15.relative)(cwd, entrypoint.inputPath));
|
|
5261
5301
|
console.log();
|
|
5262
5302
|
errors2.forEach((err) => {
|
|
5263
5303
|
const type = err.type === "error" ? import_picocolors5.default.red("ERROR") : import_picocolors5.default.yellow("WARN");
|
|
@@ -5275,7 +5315,7 @@ async function build(config) {
|
|
|
5275
5315
|
}
|
|
5276
5316
|
|
|
5277
5317
|
// src/core/clean.ts
|
|
5278
|
-
var
|
|
5318
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
5279
5319
|
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
5280
5320
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
5281
5321
|
var import_consola4 = require("consola");
|
|
@@ -5290,7 +5330,7 @@ async function clean(root = process.cwd()) {
|
|
|
5290
5330
|
];
|
|
5291
5331
|
import_consola4.consola.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
|
|
5292
5332
|
const directories = await (0, import_fast_glob4.default)(tempDirs, {
|
|
5293
|
-
cwd:
|
|
5333
|
+
cwd: import_node_path16.default.resolve(root),
|
|
5294
5334
|
absolute: true,
|
|
5295
5335
|
onlyDirectories: true,
|
|
5296
5336
|
deep: 2
|
|
@@ -5301,11 +5341,11 @@ async function clean(root = process.cwd()) {
|
|
|
5301
5341
|
}
|
|
5302
5342
|
import_consola4.consola.debug(
|
|
5303
5343
|
"Found:",
|
|
5304
|
-
directories.map((dir) => import_picocolors6.default.cyan(
|
|
5344
|
+
directories.map((dir) => import_picocolors6.default.cyan(import_node_path16.default.relative(root, dir))).join(", ")
|
|
5305
5345
|
);
|
|
5306
5346
|
for (const directory of directories) {
|
|
5307
5347
|
await import_fs_extra13.default.rm(directory, { force: true, recursive: true });
|
|
5308
|
-
import_consola4.consola.debug("Deleted " + import_picocolors6.default.cyan(
|
|
5348
|
+
import_consola4.consola.debug("Deleted " + import_picocolors6.default.cyan(import_node_path16.default.relative(root, directory)));
|
|
5309
5349
|
}
|
|
5310
5350
|
}
|
|
5311
5351
|
|
|
@@ -5320,12 +5360,12 @@ function defineRunnerConfig(config) {
|
|
|
5320
5360
|
}
|
|
5321
5361
|
|
|
5322
5362
|
// src/core/runners/wsl.ts
|
|
5323
|
-
var
|
|
5363
|
+
var import_node_path17 = require("path");
|
|
5324
5364
|
function createWslRunner() {
|
|
5325
5365
|
return {
|
|
5326
5366
|
async openBrowser() {
|
|
5327
5367
|
wxt.logger.warn(
|
|
5328
|
-
`Cannot open browser when using WSL. Load "${(0,
|
|
5368
|
+
`Cannot open browser when using WSL. Load "${(0, import_node_path17.relative)(
|
|
5329
5369
|
process.cwd(),
|
|
5330
5370
|
wxt.config.outDir
|
|
5331
5371
|
)}" as an unpacked extension manually`
|
|
@@ -5413,12 +5453,12 @@ var DEFAULT_CHROMIUM_PREFS = {
|
|
|
5413
5453
|
};
|
|
5414
5454
|
|
|
5415
5455
|
// src/core/runners/safari.ts
|
|
5416
|
-
var
|
|
5456
|
+
var import_node_path18 = require("path");
|
|
5417
5457
|
function createSafariRunner() {
|
|
5418
5458
|
return {
|
|
5419
5459
|
async openBrowser() {
|
|
5420
5460
|
wxt.logger.warn(
|
|
5421
|
-
`Cannot Safari using web-ext. Load "${(0,
|
|
5461
|
+
`Cannot Safari using web-ext. Load "${(0, import_node_path18.relative)(
|
|
5422
5462
|
process.cwd(),
|
|
5423
5463
|
wxt.config.outDir
|
|
5424
5464
|
)}" as an unpacked extension manually`
|
|
@@ -5430,12 +5470,12 @@ function createSafariRunner() {
|
|
|
5430
5470
|
}
|
|
5431
5471
|
|
|
5432
5472
|
// src/core/runners/manual.ts
|
|
5433
|
-
var
|
|
5473
|
+
var import_node_path19 = require("path");
|
|
5434
5474
|
function createManualRunner() {
|
|
5435
5475
|
return {
|
|
5436
5476
|
async openBrowser() {
|
|
5437
5477
|
wxt.logger.info(
|
|
5438
|
-
`Load "${(0,
|
|
5478
|
+
`Load "${(0, import_node_path19.relative)(
|
|
5439
5479
|
process.cwd(),
|
|
5440
5480
|
wxt.config.outDir
|
|
5441
5481
|
)}" as an unpacked extension manually`
|
|
@@ -5467,7 +5507,7 @@ async function createExtensionRunner() {
|
|
|
5467
5507
|
var import_consola5 = require("consola");
|
|
5468
5508
|
var import_async_mutex = require("async-mutex");
|
|
5469
5509
|
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
5470
|
-
var
|
|
5510
|
+
var import_node_path20 = require("path");
|
|
5471
5511
|
async function createServer(inlineConfig) {
|
|
5472
5512
|
const port = await getPort();
|
|
5473
5513
|
const hostname = "localhost";
|
|
@@ -5514,8 +5554,8 @@ async function createServer(inlineConfig) {
|
|
|
5514
5554
|
reloadContentScript(contentScript) {
|
|
5515
5555
|
server.ws.send("wxt:reload-content-script", contentScript);
|
|
5516
5556
|
},
|
|
5517
|
-
reloadPage(
|
|
5518
|
-
server.ws.send("wxt:reload-page",
|
|
5557
|
+
reloadPage(path11) {
|
|
5558
|
+
server.ws.send("wxt:reload-page", path11);
|
|
5519
5559
|
},
|
|
5520
5560
|
reloadExtension() {
|
|
5521
5561
|
server.ws.send("wxt:reload-extension");
|
|
@@ -5546,11 +5586,11 @@ async function getPort() {
|
|
|
5546
5586
|
function createFileReloader(server) {
|
|
5547
5587
|
const fileChangedMutex = new import_async_mutex.Mutex();
|
|
5548
5588
|
const changeQueue = [];
|
|
5549
|
-
return async (event,
|
|
5589
|
+
return async (event, path11) => {
|
|
5550
5590
|
await wxt.reloadConfig();
|
|
5551
|
-
if (
|
|
5591
|
+
if (path11.startsWith(wxt.config.outBaseDir))
|
|
5552
5592
|
return;
|
|
5553
|
-
changeQueue.push([event,
|
|
5593
|
+
changeQueue.push([event, path11]);
|
|
5554
5594
|
await fileChangedMutex.runExclusive(async () => {
|
|
5555
5595
|
if (server.currentOutput == null)
|
|
5556
5596
|
return;
|
|
@@ -5571,7 +5611,7 @@ function createFileReloader(server) {
|
|
|
5571
5611
|
return;
|
|
5572
5612
|
}
|
|
5573
5613
|
wxt.logger.info(
|
|
5574
|
-
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0,
|
|
5614
|
+
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path20.relative)(wxt.config.root, file))).join(", ")}`
|
|
5575
5615
|
);
|
|
5576
5616
|
const allEntrypoints = await findEntrypoints();
|
|
5577
5617
|
const { output: newOutput } = await rebuild(
|
|
@@ -5640,8 +5680,8 @@ function reloadContentScripts(steps, server) {
|
|
|
5640
5680
|
function reloadHtmlPages(groups, server) {
|
|
5641
5681
|
const htmlEntries = groups.flat().filter((entry) => entry.inputPath.endsWith(".html"));
|
|
5642
5682
|
htmlEntries.forEach((entry) => {
|
|
5643
|
-
const
|
|
5644
|
-
server.reloadPage(
|
|
5683
|
+
const path11 = getEntrypointBundlePath(entry, wxt.config.outDir, ".html");
|
|
5684
|
+
server.reloadPage(path11);
|
|
5645
5685
|
});
|
|
5646
5686
|
return {
|
|
5647
5687
|
reloadedNames: htmlEntries.map((entry) => entry.name)
|
|
@@ -5658,7 +5698,7 @@ var import_prompts = __toESM(require("prompts"), 1);
|
|
|
5658
5698
|
var import_consola6 = require("consola");
|
|
5659
5699
|
var import_giget = require("giget");
|
|
5660
5700
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
5661
|
-
var
|
|
5701
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
5662
5702
|
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
5663
5703
|
async function initialize(options) {
|
|
5664
5704
|
import_consola6.consola.info("Initalizing new project");
|
|
@@ -5706,7 +5746,7 @@ async function initialize(options) {
|
|
|
5706
5746
|
input.template ??= defaultTemplate;
|
|
5707
5747
|
input.packageManager ??= options.packageManager;
|
|
5708
5748
|
await cloneProject(input);
|
|
5709
|
-
const cdPath =
|
|
5749
|
+
const cdPath = import_node_path21.default.relative(process.cwd(), import_node_path21.default.resolve(input.directory));
|
|
5710
5750
|
console.log();
|
|
5711
5751
|
import_consola6.consola.log(
|
|
5712
5752
|
`\u2728 WXT project created with the ${TEMPLATE_COLORS[input.template.name]?.(input.template.name) ?? input.template.name} template.`
|
|
@@ -5750,8 +5790,8 @@ async function cloneProject({
|
|
|
5750
5790
|
force: true
|
|
5751
5791
|
});
|
|
5752
5792
|
await import_fs_extra14.default.move(
|
|
5753
|
-
|
|
5754
|
-
|
|
5793
|
+
import_node_path21.default.join(directory, "_gitignore"),
|
|
5794
|
+
import_node_path21.default.join(directory, ".gitignore")
|
|
5755
5795
|
).catch(
|
|
5756
5796
|
(err) => import_consola6.consola.warn("Failed to move _gitignore to .gitignore:", err)
|
|
5757
5797
|
);
|
|
@@ -5784,7 +5824,7 @@ async function prepare(config) {
|
|
|
5784
5824
|
|
|
5785
5825
|
// src/core/zip.ts
|
|
5786
5826
|
var import_zip_dir = __toESM(require("zip-dir"), 1);
|
|
5787
|
-
var
|
|
5827
|
+
var import_node_path22 = require("path");
|
|
5788
5828
|
var import_fs_extra15 = __toESM(require("fs-extra"), 1);
|
|
5789
5829
|
var import_minimatch2 = require("minimatch");
|
|
5790
5830
|
async function zip(config) {
|
|
@@ -5794,7 +5834,7 @@ async function zip(config) {
|
|
|
5794
5834
|
wxt.logger.info("Zipping extension...");
|
|
5795
5835
|
const zipFiles = [];
|
|
5796
5836
|
const projectName = wxt.config.zip.name ?? kebabCaseAlphanumeric(
|
|
5797
|
-
(await getPackageJson())?.name || (0,
|
|
5837
|
+
(await getPackageJson())?.name || (0, import_node_path22.dirname)(process.cwd())
|
|
5798
5838
|
);
|
|
5799
5839
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", wxt.config.browser).replaceAll(
|
|
5800
5840
|
"{{version}}",
|
|
@@ -5802,18 +5842,18 @@ async function zip(config) {
|
|
|
5802
5842
|
).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
5803
5843
|
await import_fs_extra15.default.ensureDir(wxt.config.outBaseDir);
|
|
5804
5844
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
5805
|
-
const outZipPath = (0,
|
|
5845
|
+
const outZipPath = (0, import_node_path22.resolve)(wxt.config.outBaseDir, outZipFilename);
|
|
5806
5846
|
await (0, import_zip_dir.default)(wxt.config.outDir, {
|
|
5807
5847
|
saveTo: outZipPath
|
|
5808
5848
|
});
|
|
5809
5849
|
zipFiles.push(outZipPath);
|
|
5810
5850
|
if (wxt.config.browser === "firefox") {
|
|
5811
5851
|
const sourcesZipFilename = applyTemplate(wxt.config.zip.sourcesTemplate);
|
|
5812
|
-
const sourcesZipPath = (0,
|
|
5852
|
+
const sourcesZipPath = (0, import_node_path22.resolve)(wxt.config.outBaseDir, sourcesZipFilename);
|
|
5813
5853
|
await (0, import_zip_dir.default)(wxt.config.zip.sourcesRoot, {
|
|
5814
5854
|
saveTo: sourcesZipPath,
|
|
5815
|
-
filter(
|
|
5816
|
-
const relativePath = (0,
|
|
5855
|
+
filter(path11) {
|
|
5856
|
+
const relativePath = (0, import_node_path22.relative)(wxt.config.zip.sourcesRoot, path11);
|
|
5817
5857
|
return wxt.config.zip.includeSources.some(
|
|
5818
5858
|
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5819
5859
|
) || !wxt.config.zip.excludeSources.some(
|