wxt 0.18.9 → 0.18.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-UA35R5HN.js → chunk-2V7XZSZQ.js} +207 -155
- package/dist/chunk-6XSIWUWF.js +57 -0
- package/dist/cli.js +243 -179
- package/dist/{index-B0efqfEK.d.cts → index-mz3v4Nde.d.cts} +58 -7
- package/dist/{index-B0efqfEK.d.ts → index-mz3v4Nde.d.ts} +58 -7
- package/dist/index.cjs +338 -273
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -1
- package/dist/modules.d.cts +1 -1
- package/dist/modules.d.ts +1 -1
- package/dist/modules.js +8 -49
- package/dist/testing.cjs +187 -99
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +18 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -988,12 +988,12 @@ var require_isexe = __commonJS({
|
|
|
988
988
|
if (typeof Promise !== "function") {
|
|
989
989
|
throw new TypeError("callback not provided");
|
|
990
990
|
}
|
|
991
|
-
return new Promise(function(
|
|
991
|
+
return new Promise(function(resolve17, reject) {
|
|
992
992
|
isexe(path12, options || {}, function(er, is) {
|
|
993
993
|
if (er) {
|
|
994
994
|
reject(er);
|
|
995
995
|
} else {
|
|
996
|
-
|
|
996
|
+
resolve17(is);
|
|
997
997
|
}
|
|
998
998
|
});
|
|
999
999
|
});
|
|
@@ -1060,27 +1060,27 @@ var require_which = __commonJS({
|
|
|
1060
1060
|
opt = {};
|
|
1061
1061
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
1062
1062
|
const found = [];
|
|
1063
|
-
const step = (i2) => new Promise((
|
|
1063
|
+
const step = (i2) => new Promise((resolve17, reject) => {
|
|
1064
1064
|
if (i2 === pathEnv.length)
|
|
1065
|
-
return opt.all && found.length ?
|
|
1065
|
+
return opt.all && found.length ? resolve17(found) : reject(getNotFoundError(cmd));
|
|
1066
1066
|
const ppRaw = pathEnv[i2];
|
|
1067
1067
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
1068
1068
|
const pCmd = path12.join(pathPart, cmd);
|
|
1069
1069
|
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
1070
|
-
|
|
1070
|
+
resolve17(subStep(p2, i2, 0));
|
|
1071
1071
|
});
|
|
1072
|
-
const subStep = (p2, i2, ii) => new Promise((
|
|
1072
|
+
const subStep = (p2, i2, ii) => new Promise((resolve17, reject) => {
|
|
1073
1073
|
if (ii === pathExt.length)
|
|
1074
|
-
return
|
|
1074
|
+
return resolve17(step(i2 + 1));
|
|
1075
1075
|
const ext = pathExt[ii];
|
|
1076
1076
|
isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
1077
1077
|
if (!er && is) {
|
|
1078
1078
|
if (opt.all)
|
|
1079
1079
|
found.push(p2 + ext);
|
|
1080
1080
|
else
|
|
1081
|
-
return
|
|
1081
|
+
return resolve17(p2 + ext);
|
|
1082
1082
|
}
|
|
1083
|
-
return
|
|
1083
|
+
return resolve17(subStep(p2, i2, ii + 1));
|
|
1084
1084
|
});
|
|
1085
1085
|
});
|
|
1086
1086
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -2135,8 +2135,8 @@ var init_deferred = __esm({
|
|
|
2135
2135
|
"use strict";
|
|
2136
2136
|
createDeferred = () => {
|
|
2137
2137
|
const methods = {};
|
|
2138
|
-
const promise = new Promise((
|
|
2139
|
-
Object.assign(methods, { resolve:
|
|
2138
|
+
const promise = new Promise((resolve17, reject) => {
|
|
2139
|
+
Object.assign(methods, { resolve: resolve17, reject });
|
|
2140
2140
|
});
|
|
2141
2141
|
return Object.assign(promise, methods);
|
|
2142
2142
|
};
|
|
@@ -7476,11 +7476,11 @@ var init_concurrent = __esm({
|
|
|
7476
7476
|
const promises = weakMap.get(stream);
|
|
7477
7477
|
const promise = createDeferred();
|
|
7478
7478
|
promises.push(promise);
|
|
7479
|
-
const
|
|
7480
|
-
return { resolve:
|
|
7479
|
+
const resolve17 = promise.resolve.bind(promise);
|
|
7480
|
+
return { resolve: resolve17, promises };
|
|
7481
7481
|
};
|
|
7482
|
-
waitForConcurrentStreams = async ({ resolve:
|
|
7483
|
-
|
|
7482
|
+
waitForConcurrentStreams = async ({ resolve: resolve17, promises }, subprocess) => {
|
|
7483
|
+
resolve17();
|
|
7484
7484
|
const [isSubprocessExit] = await Promise.race([
|
|
7485
7485
|
Promise.allSettled([true, subprocess]),
|
|
7486
7486
|
Promise.all([false, ...promises])
|
|
@@ -8637,7 +8637,7 @@ var init_core2 = __esm({
|
|
|
8637
8637
|
|
|
8638
8638
|
// ../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs
|
|
8639
8639
|
function parseStack(stack) {
|
|
8640
|
-
const cwd = process.cwd() +
|
|
8640
|
+
const cwd = process.cwd() + import_node_path17.sep;
|
|
8641
8641
|
const lines = stack.split("\n").splice(1).map((l2) => l2.trim().replace("file://", "").replace(cwd, ""));
|
|
8642
8642
|
return lines;
|
|
8643
8643
|
}
|
|
@@ -8645,12 +8645,12 @@ function writeStream(data, stream) {
|
|
|
8645
8645
|
const write = stream.__write || stream.write;
|
|
8646
8646
|
return write.call(stream, data);
|
|
8647
8647
|
}
|
|
8648
|
-
var import_node_util11,
|
|
8648
|
+
var import_node_util11, import_node_path17, bracket, BasicReporter;
|
|
8649
8649
|
var init_consola_06ad8a64 = __esm({
|
|
8650
8650
|
"../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/shared/consola.06ad8a64.mjs"() {
|
|
8651
8651
|
"use strict";
|
|
8652
8652
|
import_node_util11 = require("util");
|
|
8653
|
-
|
|
8653
|
+
import_node_path17 = require("path");
|
|
8654
8654
|
bracket = (x) => x ? `[${x}]` : "";
|
|
8655
8655
|
BasicReporter = class {
|
|
8656
8656
|
formatStack(stack, opts) {
|
|
@@ -9053,7 +9053,7 @@ async function prompt(message, opts = {}) {
|
|
|
9053
9053
|
}
|
|
9054
9054
|
throw new Error(`Unknown prompt type: ${opts.type}`);
|
|
9055
9055
|
}
|
|
9056
|
-
var import_node_process11, import_node_readline, import_node_tty3, import_tty, import_node_util12,
|
|
9056
|
+
var import_node_process11, import_node_readline, import_node_tty3, import_tty, import_node_util12, import_node_path18, 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;
|
|
9057
9057
|
var init_prompt = __esm({
|
|
9058
9058
|
"../../node_modules/.pnpm/consola@3.2.3/node_modules/consola/dist/chunks/prompt.mjs"() {
|
|
9059
9059
|
"use strict";
|
|
@@ -9066,7 +9066,7 @@ var init_prompt = __esm({
|
|
|
9066
9066
|
init_core2();
|
|
9067
9067
|
init_consola_06ad8a64();
|
|
9068
9068
|
import_node_util12 = require("util");
|
|
9069
|
-
|
|
9069
|
+
import_node_path18 = require("path");
|
|
9070
9070
|
ESC = "\x1B";
|
|
9071
9071
|
CSI = `${ESC}[`;
|
|
9072
9072
|
beep = "\x07";
|
|
@@ -10083,7 +10083,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
10083
10083
|
|
|
10084
10084
|
// src/core/utils/fs.ts
|
|
10085
10085
|
var import_fs_extra4 = __toESM(require("fs-extra"), 1);
|
|
10086
|
-
var
|
|
10086
|
+
var import_fast_glob2 = __toESM(require("fast-glob"), 1);
|
|
10087
10087
|
|
|
10088
10088
|
// src/core/utils/paths.ts
|
|
10089
10089
|
var import_node_path = __toESM(require("path"), 1);
|
|
@@ -10612,38 +10612,6 @@ async function removeEmptyDirs(dir) {
|
|
|
10612
10612
|
}
|
|
10613
10613
|
}
|
|
10614
10614
|
|
|
10615
|
-
// src/core/builders/vite/plugins/unimport.ts
|
|
10616
|
-
var import_unimport = require("unimport");
|
|
10617
|
-
var import_path = require("path");
|
|
10618
|
-
var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
10619
|
-
".js",
|
|
10620
|
-
".jsx",
|
|
10621
|
-
".ts",
|
|
10622
|
-
".tsx",
|
|
10623
|
-
".vue",
|
|
10624
|
-
".svelte"
|
|
10625
|
-
]);
|
|
10626
|
-
function unimport(config) {
|
|
10627
|
-
const options = config.imports;
|
|
10628
|
-
if (options === false) return [];
|
|
10629
|
-
const unimport2 = (0, import_unimport.createUnimport)(options);
|
|
10630
|
-
return {
|
|
10631
|
-
name: "wxt:unimport",
|
|
10632
|
-
async config() {
|
|
10633
|
-
await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
|
|
10634
|
-
},
|
|
10635
|
-
async transform(code, id) {
|
|
10636
|
-
if (id.includes("node_modules")) return;
|
|
10637
|
-
if (!ENABLED_EXTENSIONS.has((0, import_path.extname)(id))) return;
|
|
10638
|
-
const injected = await unimport2.injectImports(code, id);
|
|
10639
|
-
return {
|
|
10640
|
-
code: injected.code,
|
|
10641
|
-
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
10642
|
-
};
|
|
10643
|
-
}
|
|
10644
|
-
};
|
|
10645
|
-
}
|
|
10646
|
-
|
|
10647
10615
|
// src/core/utils/virtual-modules.ts
|
|
10648
10616
|
var virtualEntrypointTypes = [
|
|
10649
10617
|
"content-script-main-world",
|
|
@@ -10662,7 +10630,7 @@ var virtualModuleNames = [
|
|
|
10662
10630
|
|
|
10663
10631
|
// src/core/builders/vite/plugins/resolveVirtualModules.ts
|
|
10664
10632
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
10665
|
-
var
|
|
10633
|
+
var import_path = require("path");
|
|
10666
10634
|
function resolveVirtualModules(config) {
|
|
10667
10635
|
return virtualModuleNames.map((name) => {
|
|
10668
10636
|
const virtualId = `virtual:wxt-${name}?`;
|
|
@@ -10679,7 +10647,7 @@ function resolveVirtualModules(config) {
|
|
|
10679
10647
|
if (!id.startsWith(resolvedVirtualId)) return;
|
|
10680
10648
|
const inputPath = id.replace(resolvedVirtualId, "");
|
|
10681
10649
|
const template = await import_fs_extra3.default.readFile(
|
|
10682
|
-
(0,
|
|
10650
|
+
(0, import_path.resolve)(config.wxtModuleDir, `dist/virtual/${name}.js`),
|
|
10683
10651
|
"utf-8"
|
|
10684
10652
|
);
|
|
10685
10653
|
return template.replace(`virtual:user-${name}`, inputPath);
|
|
@@ -11039,7 +11007,7 @@ var import_server = require("vite-node/server");
|
|
|
11039
11007
|
var import_client = require("vite-node/client");
|
|
11040
11008
|
var import_source_map = require("vite-node/source-map");
|
|
11041
11009
|
async function createViteBuilder(wxtConfig, hooks, server) {
|
|
11042
|
-
const
|
|
11010
|
+
const vite2 = await import("vite");
|
|
11043
11011
|
const getBaseConfig = async () => {
|
|
11044
11012
|
const config = await wxtConfig.vite(wxtConfig.env);
|
|
11045
11013
|
config.root = wxtConfig.root;
|
|
@@ -11061,7 +11029,6 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11061
11029
|
config.plugins.push(
|
|
11062
11030
|
download(wxtConfig),
|
|
11063
11031
|
devHtmlPrerender(wxtConfig, server),
|
|
11064
|
-
unimport(wxtConfig),
|
|
11065
11032
|
resolveVirtualModules(wxtConfig),
|
|
11066
11033
|
devServerGlobals(wxtConfig, server),
|
|
11067
11034
|
tsconfigPaths(wxtConfig),
|
|
@@ -11184,7 +11151,7 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11184
11151
|
};
|
|
11185
11152
|
return {
|
|
11186
11153
|
name: "Vite",
|
|
11187
|
-
version:
|
|
11154
|
+
version: vite2.version,
|
|
11188
11155
|
async importEntrypoint(path12) {
|
|
11189
11156
|
switch (wxtConfig.experimental.entrypointImporter) {
|
|
11190
11157
|
default:
|
|
@@ -11199,10 +11166,10 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11199
11166
|
removeEntrypointMainFunction(wxtConfig, path12)
|
|
11200
11167
|
]
|
|
11201
11168
|
};
|
|
11202
|
-
const config =
|
|
11203
|
-
const server2 = await
|
|
11169
|
+
const config = vite2.mergeConfig(baseConfig, envConfig);
|
|
11170
|
+
const server2 = await vite2.createServer(config);
|
|
11204
11171
|
await server2.listen();
|
|
11205
|
-
const runtime = await
|
|
11172
|
+
const runtime = await vite2.createViteRuntime(server2, { hmr: false });
|
|
11206
11173
|
const module2 = await runtime.executeUrl(path12);
|
|
11207
11174
|
await server2.close();
|
|
11208
11175
|
return module2.default;
|
|
@@ -11218,8 +11185,8 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11218
11185
|
removeEntrypointMainFunction(wxtConfig, path12)
|
|
11219
11186
|
]
|
|
11220
11187
|
};
|
|
11221
|
-
const config =
|
|
11222
|
-
const server2 = await
|
|
11188
|
+
const config = vite2.mergeConfig(baseConfig, envConfig);
|
|
11189
|
+
const server2 = await vite2.createServer(config);
|
|
11223
11190
|
await server2.pluginContainer.buildStart({});
|
|
11224
11191
|
const node = new import_server.ViteNodeServer(server2);
|
|
11225
11192
|
(0, import_source_map.installSourcemapsSupport)({
|
|
@@ -11250,13 +11217,13 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11250
11217
|
else if (group.inputPath.endsWith(".css"))
|
|
11251
11218
|
entryConfig = getCssConfig(group);
|
|
11252
11219
|
else entryConfig = getLibModeConfig(group);
|
|
11253
|
-
const buildConfig =
|
|
11220
|
+
const buildConfig = vite2.mergeConfig(await getBaseConfig(), entryConfig);
|
|
11254
11221
|
await hooks.callHook(
|
|
11255
11222
|
"vite:build:extendConfig",
|
|
11256
11223
|
toArray(group),
|
|
11257
11224
|
buildConfig
|
|
11258
11225
|
);
|
|
11259
|
-
const result = await
|
|
11226
|
+
const result = await vite2.build(buildConfig);
|
|
11260
11227
|
return {
|
|
11261
11228
|
entrypoints: group,
|
|
11262
11229
|
chunks: getBuildOutputChunks(result)
|
|
@@ -11272,9 +11239,9 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
11272
11239
|
}
|
|
11273
11240
|
};
|
|
11274
11241
|
const baseConfig = await getBaseConfig();
|
|
11275
|
-
const finalConfig =
|
|
11242
|
+
const finalConfig = vite2.mergeConfig(baseConfig, serverConfig);
|
|
11276
11243
|
await hooks.callHook("vite:devServer:extendConfig", finalConfig);
|
|
11277
|
-
const viteServer = await
|
|
11244
|
+
const viteServer = await vite2.createServer(finalConfig);
|
|
11278
11245
|
const server2 = {
|
|
11279
11246
|
async listen() {
|
|
11280
11247
|
await viteServer.listen(info.port);
|
|
@@ -11322,6 +11289,108 @@ function getRollupEntry(entrypoint) {
|
|
|
11322
11289
|
return entrypoint.inputPath;
|
|
11323
11290
|
}
|
|
11324
11291
|
|
|
11292
|
+
// src/modules.ts
|
|
11293
|
+
var vite = __toESM(require("vite"), 1);
|
|
11294
|
+
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
11295
|
+
var import_node_path13 = require("path");
|
|
11296
|
+
function defineWxtModule(module2) {
|
|
11297
|
+
if (typeof module2 === "function") return { setup: module2 };
|
|
11298
|
+
return module2;
|
|
11299
|
+
}
|
|
11300
|
+
function addViteConfig(wxt2, viteConfig) {
|
|
11301
|
+
wxt2.hooks.hook("ready", (wxt3) => {
|
|
11302
|
+
const userVite = wxt3.config.vite;
|
|
11303
|
+
wxt3.config.vite = async (env2) => {
|
|
11304
|
+
const fromUser = await userVite(env2);
|
|
11305
|
+
const fromModule = viteConfig(env2) ?? {};
|
|
11306
|
+
return vite.mergeConfig(fromModule, fromUser);
|
|
11307
|
+
};
|
|
11308
|
+
});
|
|
11309
|
+
}
|
|
11310
|
+
|
|
11311
|
+
// src/builtin-modules/unimport.ts
|
|
11312
|
+
var import_unimport = require("unimport");
|
|
11313
|
+
var import_node_path14 = require("path");
|
|
11314
|
+
var unimport_default = defineWxtModule({
|
|
11315
|
+
name: "wxt:built-in:unimport",
|
|
11316
|
+
setup(wxt2) {
|
|
11317
|
+
const options = wxt2.config.imports;
|
|
11318
|
+
if (options === false) return;
|
|
11319
|
+
let unimport;
|
|
11320
|
+
wxt2.hooks.hook("ready", () => {
|
|
11321
|
+
const addModuleImports = (module2) => {
|
|
11322
|
+
if (!module2.imports) return;
|
|
11323
|
+
options.imports ??= [];
|
|
11324
|
+
options.imports.push(...module2.imports);
|
|
11325
|
+
};
|
|
11326
|
+
wxt2.config.builtinModules.forEach(addModuleImports);
|
|
11327
|
+
wxt2.config.userModules.forEach(addModuleImports);
|
|
11328
|
+
});
|
|
11329
|
+
wxt2.hooks.afterEach((event) => {
|
|
11330
|
+
if (event.name === "ready") {
|
|
11331
|
+
unimport = (0, import_unimport.createUnimport)(options);
|
|
11332
|
+
}
|
|
11333
|
+
});
|
|
11334
|
+
wxt2.hooks.hook("prepare:types", async (_2, entries) => {
|
|
11335
|
+
await unimport.init();
|
|
11336
|
+
entries.push(await getImportsDeclarationEntry(unimport));
|
|
11337
|
+
if (!options.eslintrc.enabled) return;
|
|
11338
|
+
entries.push(await getImportsEslintEntry(unimport, options));
|
|
11339
|
+
});
|
|
11340
|
+
addViteConfig(wxt2, () => ({
|
|
11341
|
+
plugins: [vitePlugin(unimport)]
|
|
11342
|
+
}));
|
|
11343
|
+
}
|
|
11344
|
+
});
|
|
11345
|
+
function vitePlugin(unimport) {
|
|
11346
|
+
const ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
11347
|
+
".js",
|
|
11348
|
+
".jsx",
|
|
11349
|
+
".ts",
|
|
11350
|
+
".tsx",
|
|
11351
|
+
".vue",
|
|
11352
|
+
".svelte"
|
|
11353
|
+
]);
|
|
11354
|
+
return {
|
|
11355
|
+
name: "wxt:unimport",
|
|
11356
|
+
async transform(code, id) {
|
|
11357
|
+
if (id.includes("node_modules")) return;
|
|
11358
|
+
if (!ENABLED_EXTENSIONS.has((0, import_node_path14.extname)(id))) return;
|
|
11359
|
+
const injected = await unimport.injectImports(code, id);
|
|
11360
|
+
return {
|
|
11361
|
+
code: injected.code,
|
|
11362
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
11363
|
+
};
|
|
11364
|
+
}
|
|
11365
|
+
};
|
|
11366
|
+
}
|
|
11367
|
+
async function getImportsDeclarationEntry(unimport) {
|
|
11368
|
+
await unimport.init();
|
|
11369
|
+
return {
|
|
11370
|
+
path: "types/imports.d.ts",
|
|
11371
|
+
text: [
|
|
11372
|
+
"// Generated by wxt",
|
|
11373
|
+
await unimport.generateTypeDeclarations(),
|
|
11374
|
+
""
|
|
11375
|
+
].join("\n"),
|
|
11376
|
+
tsReference: true
|
|
11377
|
+
};
|
|
11378
|
+
}
|
|
11379
|
+
async function getImportsEslintEntry(unimport, options) {
|
|
11380
|
+
const globals2 = {};
|
|
11381
|
+
const eslintrc = { globals: globals2 };
|
|
11382
|
+
(await unimport.getImports()).map((i2) => i2.as ?? i2.name).filter(Boolean).sort().forEach((name) => {
|
|
11383
|
+
eslintrc.globals[name] = options.eslintrc.globalsPropValue;
|
|
11384
|
+
});
|
|
11385
|
+
return {
|
|
11386
|
+
path: options.eslintrc.filePath,
|
|
11387
|
+
text: JSON.stringify(eslintrc, null, 2) + "\n"
|
|
11388
|
+
};
|
|
11389
|
+
}
|
|
11390
|
+
|
|
11391
|
+
// src/builtin-modules/index.ts
|
|
11392
|
+
var builtinModules = [unimport_default];
|
|
11393
|
+
|
|
11325
11394
|
// src/core/wxt.ts
|
|
11326
11395
|
var wxt;
|
|
11327
11396
|
async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
@@ -11343,18 +11412,16 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
11343
11412
|
builder,
|
|
11344
11413
|
server
|
|
11345
11414
|
};
|
|
11346
|
-
|
|
11415
|
+
const initModule = async (module2) => {
|
|
11347
11416
|
if (module2.hooks) wxt.hooks.addHooks(module2.hooks);
|
|
11348
|
-
if (wxt.config.imports !== false && module2.imports) {
|
|
11349
|
-
wxt.config.imports.imports ??= [];
|
|
11350
|
-
wxt.config.imports.imports.push(...module2.imports);
|
|
11351
|
-
}
|
|
11352
11417
|
await module2.setup?.(
|
|
11353
11418
|
wxt,
|
|
11354
11419
|
// @ts-expect-error: Untyped configKey field
|
|
11355
11420
|
module2.configKey ? config[module2.configKey] : void 0
|
|
11356
11421
|
);
|
|
11357
|
-
}
|
|
11422
|
+
};
|
|
11423
|
+
for (const builtinModule of builtinModules) await initModule(builtinModule);
|
|
11424
|
+
for (const userModule of config.userModules) await initModule(userModule);
|
|
11358
11425
|
wxt.hooks.addHooks(config.hooks);
|
|
11359
11426
|
await wxt.hooks.callHook("ready", wxt);
|
|
11360
11427
|
}
|
|
@@ -11368,13 +11435,13 @@ async function writeFileIfDifferent(file, newContents) {
|
|
|
11368
11435
|
}
|
|
11369
11436
|
async function getPublicFiles() {
|
|
11370
11437
|
if (!await import_fs_extra4.default.exists(wxt.config.publicDir)) return [];
|
|
11371
|
-
const files = await (0,
|
|
11438
|
+
const files = await (0, import_fast_glob2.default)("**/*", { cwd: wxt.config.publicDir });
|
|
11372
11439
|
return files.map(unnormalizePath);
|
|
11373
11440
|
}
|
|
11374
11441
|
|
|
11375
11442
|
// src/core/utils/building/build-entrypoints.ts
|
|
11376
11443
|
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
11377
|
-
var
|
|
11444
|
+
var import_path2 = require("path");
|
|
11378
11445
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
11379
11446
|
async function buildEntrypoints(groups, spinner) {
|
|
11380
11447
|
const steps = [];
|
|
@@ -11396,19 +11463,23 @@ async function buildEntrypoints(groups, spinner) {
|
|
|
11396
11463
|
}
|
|
11397
11464
|
async function copyPublicDirectory() {
|
|
11398
11465
|
const files = (await getPublicFiles()).map((file) => ({
|
|
11399
|
-
absoluteSrc: (0,
|
|
11466
|
+
absoluteSrc: (0, import_path2.resolve)(wxt.config.publicDir, file),
|
|
11400
11467
|
relativeDest: file
|
|
11401
11468
|
}));
|
|
11402
11469
|
await wxt.hooks.callHook("build:publicAssets", wxt, files);
|
|
11403
11470
|
if (files.length === 0) return [];
|
|
11404
11471
|
const publicAssets = [];
|
|
11405
|
-
for (const
|
|
11406
|
-
const absoluteDest = (0,
|
|
11407
|
-
await import_fs_extra5.default.ensureDir((0,
|
|
11408
|
-
|
|
11472
|
+
for (const file of files) {
|
|
11473
|
+
const absoluteDest = (0, import_path2.resolve)(wxt.config.outDir, file.relativeDest);
|
|
11474
|
+
await import_fs_extra5.default.ensureDir((0, import_path2.dirname)(absoluteDest));
|
|
11475
|
+
if ("absoluteSrc" in file) {
|
|
11476
|
+
await import_fs_extra5.default.copyFile(file.absoluteSrc, absoluteDest);
|
|
11477
|
+
} else {
|
|
11478
|
+
await import_fs_extra5.default.writeFile(absoluteDest, file.contents, "utf8");
|
|
11479
|
+
}
|
|
11409
11480
|
publicAssets.push({
|
|
11410
11481
|
type: "asset",
|
|
11411
|
-
fileName: relativeDest
|
|
11482
|
+
fileName: file.relativeDest
|
|
11412
11483
|
});
|
|
11413
11484
|
}
|
|
11414
11485
|
return publicAssets;
|
|
@@ -11507,26 +11578,26 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
11507
11578
|
}
|
|
11508
11579
|
|
|
11509
11580
|
// src/core/utils/building/find-entrypoints.ts
|
|
11510
|
-
var
|
|
11581
|
+
var import_path3 = require("path");
|
|
11511
11582
|
var import_fs_extra6 = __toESM(require("fs-extra"), 1);
|
|
11512
11583
|
var import_minimatch = require("minimatch");
|
|
11513
11584
|
var import_linkedom3 = require("linkedom");
|
|
11514
11585
|
var import_json5 = __toESM(require("json5"), 1);
|
|
11515
|
-
var
|
|
11586
|
+
var import_fast_glob3 = __toESM(require("fast-glob"), 1);
|
|
11516
11587
|
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
11517
11588
|
async function findEntrypoints() {
|
|
11518
11589
|
await import_fs_extra6.default.mkdir(wxt.config.wxtDir, { recursive: true });
|
|
11519
|
-
await import_fs_extra6.default.writeJson((0,
|
|
11520
|
-
const relativePaths = await (0,
|
|
11590
|
+
await import_fs_extra6.default.writeJson((0, import_path3.resolve)(wxt.config.wxtDir, "tsconfig.json"), {});
|
|
11591
|
+
const relativePaths = await (0, import_fast_glob3.default)(Object.keys(PATH_GLOB_TO_TYPE_MAP), {
|
|
11521
11592
|
cwd: wxt.config.entrypointsDir
|
|
11522
11593
|
});
|
|
11523
11594
|
relativePaths.sort();
|
|
11524
11595
|
const pathGlobs = Object.keys(PATH_GLOB_TO_TYPE_MAP);
|
|
11525
11596
|
const entrypointInfos = relativePaths.reduce((results, relativePath) => {
|
|
11526
|
-
const inputPath = (0,
|
|
11597
|
+
const inputPath = (0, import_path3.resolve)(wxt.config.entrypointsDir, relativePath);
|
|
11527
11598
|
const name = getEntrypointName(wxt.config.entrypointsDir, inputPath);
|
|
11528
11599
|
const matchingGlob = pathGlobs.find(
|
|
11529
|
-
(
|
|
11600
|
+
(glob8) => (0, import_minimatch.minimatch)(relativePath, glob8)
|
|
11530
11601
|
);
|
|
11531
11602
|
if (matchingGlob) {
|
|
11532
11603
|
const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
|
|
@@ -11565,7 +11636,7 @@ async function findEntrypoints() {
|
|
|
11565
11636
|
return {
|
|
11566
11637
|
...info,
|
|
11567
11638
|
type,
|
|
11568
|
-
outputDir: (0,
|
|
11639
|
+
outputDir: (0, import_path3.resolve)(wxt.config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
11569
11640
|
options: {
|
|
11570
11641
|
include: void 0,
|
|
11571
11642
|
exclude: void 0
|
|
@@ -11639,7 +11710,7 @@ function preventDuplicateEntrypointNames(files) {
|
|
|
11639
11710
|
if (absolutePaths.length > 1) {
|
|
11640
11711
|
lines.push(`- ${name}`);
|
|
11641
11712
|
absolutePaths.forEach((absolutePath) => {
|
|
11642
|
-
lines.push(` - ${(0,
|
|
11713
|
+
lines.push(` - ${(0, import_path3.relative)(wxt.config.root, absolutePath)}`);
|
|
11643
11714
|
});
|
|
11644
11715
|
}
|
|
11645
11716
|
return lines;
|
|
@@ -11792,7 +11863,7 @@ async function getContentScriptEntrypoint({
|
|
|
11792
11863
|
type: "content-script",
|
|
11793
11864
|
name,
|
|
11794
11865
|
inputPath,
|
|
11795
|
-
outputDir: (0,
|
|
11866
|
+
outputDir: (0, import_path3.resolve)(wxt.config.outDir, CONTENT_SCRIPT_OUT_DIR),
|
|
11796
11867
|
options: resolvePerBrowserOptions(options, wxt.config.browser),
|
|
11797
11868
|
skipped
|
|
11798
11869
|
};
|
|
@@ -11887,10 +11958,9 @@ var PATH_GLOB_TO_TYPE_MAP = {
|
|
|
11887
11958
|
var CONTENT_SCRIPT_OUT_DIR = "content-scripts";
|
|
11888
11959
|
|
|
11889
11960
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
11890
|
-
var import_unimport2 = require("unimport");
|
|
11891
11961
|
var import_fs_extra7 = __toESM(require("fs-extra"), 1);
|
|
11892
|
-
var
|
|
11893
|
-
var
|
|
11962
|
+
var import_node_path15 = require("path");
|
|
11963
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
11894
11964
|
|
|
11895
11965
|
// src/core/utils/i18n.ts
|
|
11896
11966
|
var predefinedMessages = {
|
|
@@ -11932,41 +12002,32 @@ function parseI18nMessages(messagesJson) {
|
|
|
11932
12002
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
11933
12003
|
async function generateTypesDir(entrypoints) {
|
|
11934
12004
|
await import_fs_extra7.default.ensureDir(wxt.config.typesDir);
|
|
11935
|
-
const
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
}
|
|
11943
|
-
references.push(await writePathsDeclarationFile(entrypoints));
|
|
11944
|
-
references.push(await writeI18nDeclarationFile());
|
|
11945
|
-
references.push(await writeGlobalsDeclarationFile());
|
|
11946
|
-
const mainReference = await writeMainDeclarationFile(references);
|
|
11947
|
-
await writeTsConfigFile(mainReference);
|
|
11948
|
-
}
|
|
11949
|
-
async function writeImportsDeclarationFile(unimport2) {
|
|
11950
|
-
const filePath = (0, import_path5.resolve)(wxt.config.typesDir, "imports.d.ts");
|
|
11951
|
-
await unimport2.scanImportsFromDir(void 0, { cwd: wxt.config.srcDir });
|
|
11952
|
-
await writeFileIfDifferent(
|
|
11953
|
-
filePath,
|
|
11954
|
-
["// Generated by wxt", await unimport2.generateTypeDeclarations()].join(
|
|
11955
|
-
"\n"
|
|
11956
|
-
) + "\n"
|
|
11957
|
-
);
|
|
11958
|
-
return filePath;
|
|
11959
|
-
}
|
|
11960
|
-
async function writeImportsEslintFile(unimport2, options) {
|
|
11961
|
-
const globals2 = {};
|
|
11962
|
-
const eslintrc = { globals: globals2 };
|
|
11963
|
-
(await unimport2.getImports()).map((i2) => i2.as ?? i2.name).filter(Boolean).sort().forEach((name) => {
|
|
11964
|
-
eslintrc.globals[name] = options.eslintrc.globalsPropValue;
|
|
12005
|
+
const entries = [
|
|
12006
|
+
// Hard-coded entries
|
|
12007
|
+
{ module: "wxt/vite-builder-env" }
|
|
12008
|
+
];
|
|
12009
|
+
wxt.config.userModules.forEach((module2) => {
|
|
12010
|
+
if (module2.type === "node_module" && module2.configKey != null)
|
|
12011
|
+
entries.push({ module: module2.id });
|
|
11965
12012
|
});
|
|
11966
|
-
await
|
|
12013
|
+
entries.push(await getPathsDeclarationEntry(entrypoints));
|
|
12014
|
+
entries.push(await getI18nDeclarationEntry());
|
|
12015
|
+
entries.push(await getGlobalsDeclarationEntry());
|
|
12016
|
+
entries.push(await getTsConfigEntry());
|
|
12017
|
+
await wxt.hooks.callHook("prepare:types", wxt, entries);
|
|
12018
|
+
entries.push(getMainDeclarationEntry(entries));
|
|
12019
|
+
const absoluteFileEntries = entries.filter((entry) => "path" in entry).map((entry) => ({
|
|
12020
|
+
...entry,
|
|
12021
|
+
path: (0, import_node_path15.resolve)(wxt.config.wxtDir, entry.path)
|
|
12022
|
+
}));
|
|
12023
|
+
await Promise.all(
|
|
12024
|
+
absoluteFileEntries.map(async (file) => {
|
|
12025
|
+
await import_fs_extra7.default.ensureDir((0, import_node_path15.dirname)(file.path));
|
|
12026
|
+
await writeFileIfDifferent(file.path, file.text);
|
|
12027
|
+
})
|
|
12028
|
+
);
|
|
11967
12029
|
}
|
|
11968
|
-
async function
|
|
11969
|
-
const filePath = (0, import_path5.resolve)(wxt.config.typesDir, "paths.d.ts");
|
|
12030
|
+
async function getPathsDeclarationEntry(entrypoints) {
|
|
11970
12031
|
const unions = entrypoints.map(
|
|
11971
12032
|
(entry) => getEntrypointBundlePath(
|
|
11972
12033
|
entry,
|
|
@@ -11987,14 +12048,13 @@ declare module "wxt/browser" {
|
|
|
11987
12048
|
}
|
|
11988
12049
|
}
|
|
11989
12050
|
`;
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
template.replace("{{ union }}", unions || " | never")
|
|
11993
|
-
|
|
11994
|
-
|
|
12051
|
+
return {
|
|
12052
|
+
path: "types/paths.d.ts",
|
|
12053
|
+
text: template.replace("{{ union }}", unions || " | never"),
|
|
12054
|
+
tsReference: true
|
|
12055
|
+
};
|
|
11995
12056
|
}
|
|
11996
|
-
async function
|
|
11997
|
-
const filePath = (0, import_path5.resolve)(wxt.config.typesDir, "i18n.d.ts");
|
|
12057
|
+
async function getI18nDeclarationEntry() {
|
|
11998
12058
|
const defaultLocale = wxt.config.manifest.default_locale;
|
|
11999
12059
|
const template = `// Generated by wxt
|
|
12000
12060
|
import "wxt/browser";
|
|
@@ -12017,7 +12077,7 @@ declare module "wxt/browser" {
|
|
|
12017
12077
|
`;
|
|
12018
12078
|
let messages;
|
|
12019
12079
|
if (defaultLocale) {
|
|
12020
|
-
const defaultLocalePath =
|
|
12080
|
+
const defaultLocalePath = import_node_path16.default.resolve(
|
|
12021
12081
|
wxt.config.publicDir,
|
|
12022
12082
|
"_locales",
|
|
12023
12083
|
defaultLocale,
|
|
@@ -12040,18 +12100,17 @@ declare module "wxt/browser" {
|
|
|
12040
12100
|
options?: GetMessageOptions,
|
|
12041
12101
|
): string;`;
|
|
12042
12102
|
});
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
template.replace("{{ overrides }}", overrides.join("\n"))
|
|
12046
|
-
|
|
12047
|
-
|
|
12103
|
+
return {
|
|
12104
|
+
path: "types/i18n.d.ts",
|
|
12105
|
+
text: template.replace("{{ overrides }}", overrides.join("\n")),
|
|
12106
|
+
tsReference: true
|
|
12107
|
+
};
|
|
12048
12108
|
}
|
|
12049
|
-
async function
|
|
12050
|
-
const filePath = (0, import_path5.resolve)(wxt.config.typesDir, "globals.d.ts");
|
|
12109
|
+
async function getGlobalsDeclarationEntry() {
|
|
12051
12110
|
const globals2 = [...getGlobals(wxt.config), ...getEntrypointGlobals("")];
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
[
|
|
12111
|
+
return {
|
|
12112
|
+
path: "types/globals.d.ts",
|
|
12113
|
+
text: [
|
|
12055
12114
|
"// Generated by wxt",
|
|
12056
12115
|
"export {}",
|
|
12057
12116
|
"interface ImportMetaEnv {",
|
|
@@ -12059,36 +12118,31 @@ async function writeGlobalsDeclarationFile() {
|
|
|
12059
12118
|
"}",
|
|
12060
12119
|
"interface ImportMeta {",
|
|
12061
12120
|
" readonly env: ImportMetaEnv",
|
|
12062
|
-
"}"
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12121
|
+
"}",
|
|
12122
|
+
""
|
|
12123
|
+
].join("\n"),
|
|
12124
|
+
tsReference: true
|
|
12125
|
+
};
|
|
12066
12126
|
}
|
|
12067
|
-
|
|
12068
|
-
const
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
...wxt.config.modules.filter(
|
|
12083
|
-
(module2) => module2.type === "node_module" && module2.configKey != null
|
|
12084
|
-
).map((module2) => `/// <reference types="${module2.id}" />`)
|
|
12085
|
-
].join("\n") + "\n"
|
|
12086
|
-
);
|
|
12087
|
-
return filePath;
|
|
12127
|
+
function getMainDeclarationEntry(references) {
|
|
12128
|
+
const lines = ["// Generated by wxt"];
|
|
12129
|
+
references.forEach((ref) => {
|
|
12130
|
+
if ("module" in ref) {
|
|
12131
|
+
return lines.push(`/// <reference types="${ref.module}" />`);
|
|
12132
|
+
} else if (ref.tsReference) {
|
|
12133
|
+
const absolutePath = (0, import_node_path15.resolve)(wxt.config.wxtDir, ref.path);
|
|
12134
|
+
const relativePath = (0, import_node_path15.relative)(wxt.config.wxtDir, absolutePath);
|
|
12135
|
+
lines.push(`/// <reference types="./${normalizePath(relativePath)}" />`);
|
|
12136
|
+
}
|
|
12137
|
+
});
|
|
12138
|
+
return {
|
|
12139
|
+
path: "wxt.d.ts",
|
|
12140
|
+
text: lines.join("\n") + "\n"
|
|
12141
|
+
};
|
|
12088
12142
|
}
|
|
12089
|
-
async function
|
|
12143
|
+
async function getTsConfigEntry() {
|
|
12090
12144
|
const dir = wxt.config.wxtDir;
|
|
12091
|
-
const getTsconfigPath = (path12) => normalizePath((0,
|
|
12145
|
+
const getTsconfigPath = (path12) => normalizePath((0, import_node_path15.relative)(dir, path12));
|
|
12092
12146
|
const paths = Object.entries(wxt.config.alias).flatMap(([alias, absolutePath]) => {
|
|
12093
12147
|
const aliasPath = getTsconfigPath(absolutePath);
|
|
12094
12148
|
return [
|
|
@@ -12096,9 +12150,7 @@ async function writeTsConfigFile(mainReference) {
|
|
|
12096
12150
|
` "${alias}/*": ["${aliasPath}/*"]`
|
|
12097
12151
|
];
|
|
12098
12152
|
}).join(",\n");
|
|
12099
|
-
|
|
12100
|
-
(0, import_path5.resolve)(dir, "tsconfig.json"),
|
|
12101
|
-
`{
|
|
12153
|
+
const text2 = `{
|
|
12102
12154
|
"compilerOptions": {
|
|
12103
12155
|
"target": "ESNext",
|
|
12104
12156
|
"module": "ESNext",
|
|
@@ -12115,26 +12167,29 @@ ${paths}
|
|
|
12115
12167
|
},
|
|
12116
12168
|
"include": [
|
|
12117
12169
|
"${getTsconfigPath(wxt.config.root)}/**/*",
|
|
12118
|
-
"
|
|
12170
|
+
"./wxt.d.ts"
|
|
12119
12171
|
],
|
|
12120
12172
|
"exclude": ["${getTsconfigPath(wxt.config.outBaseDir)}"]
|
|
12121
|
-
}
|
|
12122
|
-
|
|
12173
|
+
}`;
|
|
12174
|
+
return {
|
|
12175
|
+
path: "tsconfig.json",
|
|
12176
|
+
text: text2
|
|
12177
|
+
};
|
|
12123
12178
|
}
|
|
12124
12179
|
|
|
12125
12180
|
// src/core/utils/building/resolve-config.ts
|
|
12126
12181
|
var import_c12 = require("c12");
|
|
12127
|
-
var
|
|
12182
|
+
var import_node_path21 = __toESM(require("path"), 1);
|
|
12128
12183
|
|
|
12129
12184
|
// src/core/utils/cache.ts
|
|
12130
12185
|
var import_fs_extra8 = __toESM(require("fs-extra"), 1);
|
|
12131
|
-
var
|
|
12186
|
+
var import_path4 = require("path");
|
|
12132
12187
|
function createFsCache(wxtDir) {
|
|
12133
|
-
const getPath = (key) => (0,
|
|
12188
|
+
const getPath = (key) => (0, import_path4.resolve)(wxtDir, "cache", encodeURIComponent(key));
|
|
12134
12189
|
return {
|
|
12135
12190
|
async set(key, value) {
|
|
12136
12191
|
const path12 = getPath(key);
|
|
12137
|
-
await (0, import_fs_extra8.ensureDir)((0,
|
|
12192
|
+
await (0, import_fs_extra8.ensureDir)((0, import_path4.dirname)(path12));
|
|
12138
12193
|
await writeFileIfDifferent(path12, value);
|
|
12139
12194
|
},
|
|
12140
12195
|
async get(key) {
|
|
@@ -12156,16 +12211,16 @@ var import_node_process13 = require("process");
|
|
|
12156
12211
|
init_utils2();
|
|
12157
12212
|
var import_node_tty4 = require("tty");
|
|
12158
12213
|
var import_node_util13 = require("util");
|
|
12159
|
-
var
|
|
12214
|
+
var import_node_path19 = require("path");
|
|
12160
12215
|
|
|
12161
12216
|
// src/core/utils/building/resolve-config.ts
|
|
12162
12217
|
var import_defu = __toESM(require("defu"), 1);
|
|
12163
12218
|
|
|
12164
12219
|
// src/core/utils/package.ts
|
|
12165
|
-
var
|
|
12220
|
+
var import_node_path20 = require("path");
|
|
12166
12221
|
var import_fs_extra9 = __toESM(require("fs-extra"), 1);
|
|
12167
12222
|
async function getPackageJson() {
|
|
12168
|
-
const file = (0,
|
|
12223
|
+
const file = (0, import_node_path20.resolve)(wxt.config.root, "package.json");
|
|
12169
12224
|
try {
|
|
12170
12225
|
return await import_fs_extra9.default.readJson(file);
|
|
12171
12226
|
} catch (err) {
|
|
@@ -12184,7 +12239,7 @@ function isModuleInstalled(name) {
|
|
|
12184
12239
|
|
|
12185
12240
|
// src/core/utils/building/resolve-config.ts
|
|
12186
12241
|
var import_fs_extra10 = __toESM(require("fs-extra"), 1);
|
|
12187
|
-
var
|
|
12242
|
+
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
12188
12243
|
var import_meta = {};
|
|
12189
12244
|
async function resolveConfig(inlineConfig, command) {
|
|
12190
12245
|
let userConfig = {};
|
|
@@ -12210,28 +12265,28 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12210
12265
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
12211
12266
|
const mode = mergedConfig.mode ?? COMMAND_MODES[command];
|
|
12212
12267
|
const env2 = { browser, command, manifestVersion, mode };
|
|
12213
|
-
const root =
|
|
12268
|
+
const root = import_node_path21.default.resolve(
|
|
12214
12269
|
inlineConfig.root ?? userConfig.root ?? process.cwd()
|
|
12215
12270
|
);
|
|
12216
|
-
const wxtDir =
|
|
12271
|
+
const wxtDir = import_node_path21.default.resolve(root, ".wxt");
|
|
12217
12272
|
const wxtModuleDir = await resolveWxtModuleDir();
|
|
12218
|
-
const srcDir =
|
|
12219
|
-
const entrypointsDir =
|
|
12273
|
+
const srcDir = import_node_path21.default.resolve(root, mergedConfig.srcDir ?? root);
|
|
12274
|
+
const entrypointsDir = import_node_path21.default.resolve(
|
|
12220
12275
|
srcDir,
|
|
12221
12276
|
mergedConfig.entrypointsDir ?? "entrypoints"
|
|
12222
12277
|
);
|
|
12223
|
-
const modulesDir =
|
|
12278
|
+
const modulesDir = import_node_path21.default.resolve(srcDir, mergedConfig.modulesDir ?? "modules");
|
|
12224
12279
|
if (await isDirMissing(entrypointsDir)) {
|
|
12225
12280
|
logMissingDir(logger, "Entrypoints", entrypointsDir);
|
|
12226
12281
|
}
|
|
12227
12282
|
const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
|
|
12228
|
-
const publicDir =
|
|
12283
|
+
const publicDir = import_node_path21.default.resolve(srcDir, mergedConfig.publicDir ?? "public");
|
|
12229
12284
|
if (await isDirMissing(publicDir)) {
|
|
12230
12285
|
logMissingDir(logger, "Public", publicDir);
|
|
12231
12286
|
}
|
|
12232
|
-
const typesDir =
|
|
12233
|
-
const outBaseDir =
|
|
12234
|
-
const outDir =
|
|
12287
|
+
const typesDir = import_node_path21.default.resolve(wxtDir, "types");
|
|
12288
|
+
const outBaseDir = import_node_path21.default.resolve(root, mergedConfig.outDir ?? ".output");
|
|
12289
|
+
const outDir = import_node_path21.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
|
|
12235
12290
|
const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
|
|
12236
12291
|
const runnerConfig = await (0, import_c12.loadConfig)({
|
|
12237
12292
|
name: "web-ext",
|
|
@@ -12248,7 +12303,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12248
12303
|
"~": srcDir,
|
|
12249
12304
|
"@@": root,
|
|
12250
12305
|
"~~": root
|
|
12251
|
-
}).map(([key, value]) => [key,
|
|
12306
|
+
}).map(([key, value]) => [key, import_node_path21.default.resolve(root, value)])
|
|
12252
12307
|
);
|
|
12253
12308
|
let devServerConfig;
|
|
12254
12309
|
if (command === "serve") {
|
|
@@ -12262,14 +12317,20 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12262
12317
|
hostname: "localhost"
|
|
12263
12318
|
};
|
|
12264
12319
|
}
|
|
12265
|
-
const
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12320
|
+
const userModules = await resolveWxtUserModules(
|
|
12321
|
+
modulesDir,
|
|
12322
|
+
mergedConfig.modules
|
|
12323
|
+
);
|
|
12324
|
+
const moduleOptions = userModules.reduce(
|
|
12325
|
+
(map, module2) => {
|
|
12326
|
+
if (module2.configKey) {
|
|
12327
|
+
map[module2.configKey] = // @ts-expect-error
|
|
12328
|
+
mergedConfig[module2.configKey];
|
|
12329
|
+
}
|
|
12330
|
+
return map;
|
|
12331
|
+
},
|
|
12332
|
+
{}
|
|
12333
|
+
);
|
|
12273
12334
|
return {
|
|
12274
12335
|
browser,
|
|
12275
12336
|
command,
|
|
@@ -12279,7 +12340,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12279
12340
|
filterEntrypoints,
|
|
12280
12341
|
env: env2,
|
|
12281
12342
|
fsCache: createFsCache(wxtDir),
|
|
12282
|
-
imports: await getUnimportOptions(wxtDir, logger, mergedConfig),
|
|
12343
|
+
imports: await getUnimportOptions(wxtDir, srcDir, logger, mergedConfig),
|
|
12283
12344
|
logger,
|
|
12284
12345
|
manifest: await resolveManifestConfig(env2, mergedConfig.manifest),
|
|
12285
12346
|
manifestVersion,
|
|
@@ -12308,7 +12369,8 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
12308
12369
|
},
|
|
12309
12370
|
hooks: mergedConfig.hooks ?? {},
|
|
12310
12371
|
vite: mergedConfig.vite ?? (() => ({})),
|
|
12311
|
-
|
|
12372
|
+
builtinModules,
|
|
12373
|
+
userModules,
|
|
12312
12374
|
plugins: [],
|
|
12313
12375
|
...moduleOptions
|
|
12314
12376
|
};
|
|
@@ -12338,7 +12400,7 @@ async function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
12338
12400
|
};
|
|
12339
12401
|
}
|
|
12340
12402
|
function resolveZipConfig(root, mergedConfig) {
|
|
12341
|
-
const downloadedPackagesDir =
|
|
12403
|
+
const downloadedPackagesDir = import_node_path21.default.resolve(root, ".wxt/local_modules");
|
|
12342
12404
|
return {
|
|
12343
12405
|
name: void 0,
|
|
12344
12406
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
@@ -12364,12 +12426,12 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
12364
12426
|
};
|
|
12365
12427
|
}
|
|
12366
12428
|
function resolveAnalysisConfig(root, mergedConfig) {
|
|
12367
|
-
const analysisOutputFile =
|
|
12429
|
+
const analysisOutputFile = import_node_path21.default.resolve(
|
|
12368
12430
|
root,
|
|
12369
12431
|
mergedConfig.analysis?.outputFile ?? "stats.html"
|
|
12370
12432
|
);
|
|
12371
|
-
const analysisOutputDir =
|
|
12372
|
-
const analysisOutputName =
|
|
12433
|
+
const analysisOutputDir = import_node_path21.default.dirname(analysisOutputFile);
|
|
12434
|
+
const analysisOutputName = import_node_path21.default.parse(analysisOutputFile).name;
|
|
12373
12435
|
return {
|
|
12374
12436
|
enabled: mergedConfig.analysis?.enabled ?? false,
|
|
12375
12437
|
open: mergedConfig.analysis?.open ?? false,
|
|
@@ -12380,17 +12442,17 @@ function resolveAnalysisConfig(root, mergedConfig) {
|
|
|
12380
12442
|
keepArtifacts: mergedConfig.analysis?.keepArtifacts ?? false
|
|
12381
12443
|
};
|
|
12382
12444
|
}
|
|
12383
|
-
async function getUnimportOptions(wxtDir, logger, config) {
|
|
12445
|
+
async function getUnimportOptions(wxtDir, srcDir, logger, config) {
|
|
12384
12446
|
if (config.imports === false) return false;
|
|
12385
|
-
const
|
|
12386
|
-
let
|
|
12387
|
-
switch (
|
|
12447
|
+
const rawEslintEnabled = config.imports?.eslintrc?.enabled;
|
|
12448
|
+
let eslintEnabled;
|
|
12449
|
+
switch (rawEslintEnabled) {
|
|
12388
12450
|
case void 0:
|
|
12389
12451
|
case "auto":
|
|
12390
|
-
|
|
12452
|
+
eslintEnabled = await isModuleInstalled("eslint");
|
|
12391
12453
|
break;
|
|
12392
12454
|
default:
|
|
12393
|
-
|
|
12455
|
+
eslintEnabled = rawEslintEnabled;
|
|
12394
12456
|
}
|
|
12395
12457
|
const defaultOptions = {
|
|
12396
12458
|
debugLog: logger.debug,
|
|
@@ -12406,9 +12468,12 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
12406
12468
|
],
|
|
12407
12469
|
warn: logger.warn,
|
|
12408
12470
|
dirs: ["components", "composables", "hooks", "utils"],
|
|
12471
|
+
dirsScanOptions: {
|
|
12472
|
+
cwd: srcDir
|
|
12473
|
+
},
|
|
12409
12474
|
eslintrc: {
|
|
12410
|
-
enabled,
|
|
12411
|
-
filePath:
|
|
12475
|
+
enabled: eslintEnabled,
|
|
12476
|
+
filePath: import_node_path21.default.resolve(wxtDir, "eslintrc-auto-import.json"),
|
|
12412
12477
|
globalsPropValue: true
|
|
12413
12478
|
}
|
|
12414
12479
|
};
|
|
@@ -12419,7 +12484,7 @@ async function getUnimportOptions(wxtDir, logger, config) {
|
|
|
12419
12484
|
}
|
|
12420
12485
|
async function resolveWxtModuleDir() {
|
|
12421
12486
|
const requireResolve = require?.resolve ?? (await import("module")).default.createRequire(import_meta.url).resolve;
|
|
12422
|
-
return
|
|
12487
|
+
return import_node_path21.default.resolve(requireResolve("wxt"), "../..");
|
|
12423
12488
|
}
|
|
12424
12489
|
async function isDirMissing(dir) {
|
|
12425
12490
|
return !await import_fs_extra10.default.exists(dir);
|
|
@@ -12427,7 +12492,7 @@ async function isDirMissing(dir) {
|
|
|
12427
12492
|
function logMissingDir(logger, name, expected) {
|
|
12428
12493
|
logger.warn(
|
|
12429
12494
|
`${name} directory not found: ./${normalizePath(
|
|
12430
|
-
|
|
12495
|
+
import_node_path21.default.relative(process.cwd(), expected)
|
|
12431
12496
|
)}`
|
|
12432
12497
|
);
|
|
12433
12498
|
}
|
|
@@ -12436,19 +12501,19 @@ var COMMAND_MODES = {
|
|
|
12436
12501
|
serve: "development"
|
|
12437
12502
|
};
|
|
12438
12503
|
async function mergeBuilderConfig(inlineConfig, userConfig) {
|
|
12439
|
-
const
|
|
12440
|
-
if (
|
|
12504
|
+
const vite2 = await import("vite").catch(() => void 0);
|
|
12505
|
+
if (vite2) {
|
|
12441
12506
|
return {
|
|
12442
12507
|
vite: async (env2) => {
|
|
12443
12508
|
const resolvedInlineConfig = await inlineConfig.vite?.(env2) ?? {};
|
|
12444
12509
|
const resolvedUserConfig = await userConfig.vite?.(env2) ?? {};
|
|
12445
|
-
return
|
|
12510
|
+
return vite2.mergeConfig(resolvedUserConfig, resolvedInlineConfig);
|
|
12446
12511
|
}
|
|
12447
12512
|
};
|
|
12448
12513
|
}
|
|
12449
12514
|
throw Error("Builder not found. Make sure vite is installed.");
|
|
12450
12515
|
}
|
|
12451
|
-
async function
|
|
12516
|
+
async function resolveWxtUserModules(modulesDir, modules = []) {
|
|
12452
12517
|
const npmModules = await Promise.all(
|
|
12453
12518
|
modules.map(async (moduleId) => {
|
|
12454
12519
|
const mod = await import(
|
|
@@ -12465,13 +12530,13 @@ async function resolveWxtModules(modulesDir, modules = []) {
|
|
|
12465
12530
|
};
|
|
12466
12531
|
})
|
|
12467
12532
|
);
|
|
12468
|
-
const localModulePaths = await (0,
|
|
12533
|
+
const localModulePaths = await (0, import_fast_glob4.default)(["*.[tj]s", "*/index.[tj]s"], {
|
|
12469
12534
|
cwd: modulesDir,
|
|
12470
12535
|
onlyFiles: true
|
|
12471
12536
|
}).catch(() => []);
|
|
12472
12537
|
const localModules = await Promise.all(
|
|
12473
12538
|
localModulePaths.map(async (file) => {
|
|
12474
|
-
const absolutePath = normalizePath(
|
|
12539
|
+
const absolutePath = normalizePath(import_node_path21.default.resolve(modulesDir, file));
|
|
12475
12540
|
const { config } = await (0, import_c12.loadConfig)({
|
|
12476
12541
|
configFile: absolutePath,
|
|
12477
12542
|
globalRc: false,
|
|
@@ -12538,22 +12603,22 @@ var ENTRY_TYPE_TO_GROUP_MAP = {
|
|
|
12538
12603
|
var import_jiti = __toESM(require("jiti"), 1);
|
|
12539
12604
|
var import_unimport3 = require("unimport");
|
|
12540
12605
|
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
12541
|
-
var
|
|
12606
|
+
var import_node_path22 = require("path");
|
|
12542
12607
|
var import_esbuild = require("esbuild");
|
|
12543
12608
|
var import_node_url3 = require("url");
|
|
12544
12609
|
var import_meta2 = {};
|
|
12545
12610
|
async function importEntrypointFile(path12) {
|
|
12546
12611
|
wxt.logger.debug("Loading file metadata:", path12);
|
|
12547
12612
|
const normalPath = normalizePath(path12);
|
|
12548
|
-
const
|
|
12613
|
+
const unimport = (0, import_unimport3.createUnimport)({
|
|
12549
12614
|
...wxt.config.imports,
|
|
12550
12615
|
// Only allow specific imports, not all from the project
|
|
12551
12616
|
dirs: []
|
|
12552
12617
|
});
|
|
12553
|
-
await
|
|
12618
|
+
await unimport.init();
|
|
12554
12619
|
const text2 = await import_fs_extra11.default.readFile(path12, "utf-8");
|
|
12555
12620
|
const textNoImports = removeProjectImportStatements(text2);
|
|
12556
|
-
const { code } = await
|
|
12621
|
+
const { code } = await unimport.injectImports(textNoImports);
|
|
12557
12622
|
wxt.logger.debug(
|
|
12558
12623
|
["Text:", text2, "No imports:", textNoImports, "Code:", code].join("\n")
|
|
12559
12624
|
);
|
|
@@ -12564,7 +12629,7 @@ async function importEntrypointFile(path12) {
|
|
|
12564
12629
|
debug: wxt.config.debug,
|
|
12565
12630
|
esmResolve: true,
|
|
12566
12631
|
alias: {
|
|
12567
|
-
"webextension-polyfill": (0,
|
|
12632
|
+
"webextension-polyfill": (0, import_node_path22.resolve)(
|
|
12568
12633
|
wxt.config.wxtModuleDir,
|
|
12569
12634
|
"dist/virtual/mock-browser.js"
|
|
12570
12635
|
)
|
|
@@ -12597,7 +12662,7 @@ async function importEntrypointFile(path12) {
|
|
|
12597
12662
|
const res = await jiti(path12);
|
|
12598
12663
|
return res.default;
|
|
12599
12664
|
} catch (err) {
|
|
12600
|
-
const filePath = (0,
|
|
12665
|
+
const filePath = (0, import_node_path22.relative)(wxt.config.root, path12);
|
|
12601
12666
|
if (err instanceof ReferenceError) {
|
|
12602
12667
|
const variableName = err.message.replace(" is not defined", "");
|
|
12603
12668
|
throw Error(
|
|
@@ -12629,10 +12694,10 @@ var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
|
12629
12694
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
12630
12695
|
|
|
12631
12696
|
// src/core/utils/log/printBuildSummary.ts
|
|
12632
|
-
var
|
|
12697
|
+
var import_path5 = require("path");
|
|
12633
12698
|
|
|
12634
12699
|
// src/core/utils/log/printFileList.ts
|
|
12635
|
-
var
|
|
12700
|
+
var import_node_path23 = __toESM(require("path"), 1);
|
|
12636
12701
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
12637
12702
|
var import_fs_extra12 = __toESM(require("fs-extra"), 1);
|
|
12638
12703
|
var import_filesize = require("filesize");
|
|
@@ -12667,8 +12732,8 @@ async function printFileList(log, header, baseDir, files) {
|
|
|
12667
12732
|
const fileRows = await Promise.all(
|
|
12668
12733
|
files.map(async (file, i2) => {
|
|
12669
12734
|
const parts = [
|
|
12670
|
-
|
|
12671
|
-
|
|
12735
|
+
import_node_path23.default.relative(process.cwd(), baseDir) + import_node_path23.default.sep,
|
|
12736
|
+
import_node_path23.default.relative(baseDir, file)
|
|
12672
12737
|
];
|
|
12673
12738
|
const prefix = i2 === files.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
12674
12739
|
const color = getChunkColor(file);
|
|
@@ -12713,7 +12778,7 @@ async function printBuildSummary(log, header, output) {
|
|
|
12713
12778
|
return l2.fileName.localeCompare(r2.fileName);
|
|
12714
12779
|
});
|
|
12715
12780
|
const files = chunks.map(
|
|
12716
|
-
(chunk) => (0,
|
|
12781
|
+
(chunk) => (0, import_path5.resolve)(wxt.config.outDir, chunk.fileName)
|
|
12717
12782
|
);
|
|
12718
12783
|
await printFileList(log, header, wxt.config.outDir, files);
|
|
12719
12784
|
}
|
|
@@ -12735,14 +12800,14 @@ function getChunkSortWeight(filename) {
|
|
|
12735
12800
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
12736
12801
|
|
|
12737
12802
|
// package.json
|
|
12738
|
-
var version = "0.18.
|
|
12803
|
+
var version = "0.18.9";
|
|
12739
12804
|
|
|
12740
12805
|
// src/core/utils/building/internal-build.ts
|
|
12741
|
-
var
|
|
12806
|
+
var import_fast_glob5 = __toESM(require("fast-glob"), 1);
|
|
12742
12807
|
|
|
12743
12808
|
// src/core/utils/manifest.ts
|
|
12744
12809
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
12745
|
-
var
|
|
12810
|
+
var import_path6 = require("path");
|
|
12746
12811
|
|
|
12747
12812
|
// src/core/utils/content-security-policy.ts
|
|
12748
12813
|
var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
@@ -12851,7 +12916,7 @@ var import_defu2 = __toESM(require("defu"), 1);
|
|
|
12851
12916
|
async function writeManifest(manifest, output) {
|
|
12852
12917
|
const str = wxt.config.mode === "production" ? JSON.stringify(manifest) : JSON.stringify(manifest, null, 2);
|
|
12853
12918
|
await import_fs_extra13.default.ensureDir(wxt.config.outDir);
|
|
12854
|
-
await writeFileIfDifferent((0,
|
|
12919
|
+
await writeFileIfDifferent((0, import_path6.resolve)(wxt.config.outDir, "manifest.json"), str);
|
|
12855
12920
|
output.publicAssets.unshift({
|
|
12856
12921
|
type: "asset",
|
|
12857
12922
|
fileName: "manifest.json"
|
|
@@ -13386,7 +13451,7 @@ async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
|
|
|
13386
13451
|
}
|
|
13387
13452
|
|
|
13388
13453
|
// src/core/utils/building/internal-build.ts
|
|
13389
|
-
var
|
|
13454
|
+
var import_node_path24 = require("path");
|
|
13390
13455
|
|
|
13391
13456
|
// src/core/utils/validation.ts
|
|
13392
13457
|
function validateEntrypoints(entrypoints) {
|
|
@@ -13485,7 +13550,7 @@ async function internalBuild() {
|
|
|
13485
13550
|
}
|
|
13486
13551
|
if (wxt.config.analysis.enabled) {
|
|
13487
13552
|
await combineAnalysisStats();
|
|
13488
|
-
const statsPath = (0,
|
|
13553
|
+
const statsPath = (0, import_node_path24.relative)(wxt.config.root, wxt.config.analysis.outputFile);
|
|
13489
13554
|
wxt.logger.info(
|
|
13490
13555
|
`Analysis complete:
|
|
13491
13556
|
${import_picocolors5.default.gray("\u2514\u2500")} ${import_picocolors5.default.yellow(statsPath)}`
|
|
@@ -13503,7 +13568,7 @@ async function internalBuild() {
|
|
|
13503
13568
|
return output;
|
|
13504
13569
|
}
|
|
13505
13570
|
async function combineAnalysisStats() {
|
|
13506
|
-
const unixFiles = await (0,
|
|
13571
|
+
const unixFiles = await (0, import_fast_glob5.default)(`${wxt.config.analysis.outputName}-*.json`, {
|
|
13507
13572
|
cwd: wxt.config.analysis.outputDir,
|
|
13508
13573
|
absolute: true
|
|
13509
13574
|
});
|
|
@@ -13533,7 +13598,7 @@ function printValidationResults({
|
|
|
13533
13598
|
return map;
|
|
13534
13599
|
}, /* @__PURE__ */ new Map());
|
|
13535
13600
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
13536
|
-
consola.log((0,
|
|
13601
|
+
consola.log((0, import_node_path24.relative)(cwd, entrypoint.inputPath));
|
|
13537
13602
|
console.log();
|
|
13538
13603
|
errors2.forEach((err) => {
|
|
13539
13604
|
const type = err.type === "error" ? import_picocolors5.default.red("ERROR") : import_picocolors5.default.yellow("WARN");
|
|
@@ -13551,8 +13616,8 @@ async function build(config) {
|
|
|
13551
13616
|
}
|
|
13552
13617
|
|
|
13553
13618
|
// src/core/clean.ts
|
|
13554
|
-
var
|
|
13555
|
-
var
|
|
13619
|
+
var import_node_path25 = __toESM(require("path"), 1);
|
|
13620
|
+
var import_fast_glob6 = __toESM(require("fast-glob"), 1);
|
|
13556
13621
|
var import_fs_extra15 = __toESM(require("fs-extra"), 1);
|
|
13557
13622
|
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
13558
13623
|
async function clean(root = process.cwd()) {
|
|
@@ -13564,8 +13629,8 @@ async function clean(root = process.cwd()) {
|
|
|
13564
13629
|
".output/*"
|
|
13565
13630
|
];
|
|
13566
13631
|
consola.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
|
|
13567
|
-
const directories = await (0,
|
|
13568
|
-
cwd:
|
|
13632
|
+
const directories = await (0, import_fast_glob6.default)(tempDirs, {
|
|
13633
|
+
cwd: import_node_path25.default.resolve(root),
|
|
13569
13634
|
absolute: true,
|
|
13570
13635
|
onlyDirectories: true,
|
|
13571
13636
|
deep: 2
|
|
@@ -13576,11 +13641,11 @@ async function clean(root = process.cwd()) {
|
|
|
13576
13641
|
}
|
|
13577
13642
|
consola.debug(
|
|
13578
13643
|
"Found:",
|
|
13579
|
-
directories.map((dir) => import_picocolors6.default.cyan(
|
|
13644
|
+
directories.map((dir) => import_picocolors6.default.cyan(import_node_path25.default.relative(root, dir))).join(", ")
|
|
13580
13645
|
);
|
|
13581
13646
|
for (const directory of directories) {
|
|
13582
13647
|
await import_fs_extra15.default.rm(directory, { force: true, recursive: true });
|
|
13583
|
-
consola.debug("Deleted " + import_picocolors6.default.cyan(
|
|
13648
|
+
consola.debug("Deleted " + import_picocolors6.default.cyan(import_node_path25.default.relative(root, directory)));
|
|
13584
13649
|
}
|
|
13585
13650
|
}
|
|
13586
13651
|
|
|
@@ -13595,12 +13660,12 @@ function defineRunnerConfig(config) {
|
|
|
13595
13660
|
}
|
|
13596
13661
|
|
|
13597
13662
|
// src/core/runners/wsl.ts
|
|
13598
|
-
var
|
|
13663
|
+
var import_node_path26 = require("path");
|
|
13599
13664
|
function createWslRunner() {
|
|
13600
13665
|
return {
|
|
13601
13666
|
async openBrowser() {
|
|
13602
13667
|
wxt.logger.warn(
|
|
13603
|
-
`Cannot open browser when using WSL. Load "${(0,
|
|
13668
|
+
`Cannot open browser when using WSL. Load "${(0, import_node_path26.relative)(
|
|
13604
13669
|
process.cwd(),
|
|
13605
13670
|
wxt.config.outDir
|
|
13606
13671
|
)}" as an unpacked extension manually`
|
|
@@ -13687,12 +13752,12 @@ var DEFAULT_CHROMIUM_PREFS = {
|
|
|
13687
13752
|
};
|
|
13688
13753
|
|
|
13689
13754
|
// src/core/runners/safari.ts
|
|
13690
|
-
var
|
|
13755
|
+
var import_node_path27 = require("path");
|
|
13691
13756
|
function createSafariRunner() {
|
|
13692
13757
|
return {
|
|
13693
13758
|
async openBrowser() {
|
|
13694
13759
|
wxt.logger.warn(
|
|
13695
|
-
`Cannot Safari using web-ext. Load "${(0,
|
|
13760
|
+
`Cannot Safari using web-ext. Load "${(0, import_node_path27.relative)(
|
|
13696
13761
|
process.cwd(),
|
|
13697
13762
|
wxt.config.outDir
|
|
13698
13763
|
)}" as an unpacked extension manually`
|
|
@@ -13704,12 +13769,12 @@ function createSafariRunner() {
|
|
|
13704
13769
|
}
|
|
13705
13770
|
|
|
13706
13771
|
// src/core/runners/manual.ts
|
|
13707
|
-
var
|
|
13772
|
+
var import_node_path28 = require("path");
|
|
13708
13773
|
function createManualRunner() {
|
|
13709
13774
|
return {
|
|
13710
13775
|
async openBrowser() {
|
|
13711
13776
|
wxt.logger.info(
|
|
13712
|
-
`Load "${(0,
|
|
13777
|
+
`Load "${(0, import_node_path28.relative)(
|
|
13713
13778
|
process.cwd(),
|
|
13714
13779
|
wxt.config.outDir
|
|
13715
13780
|
)}" as an unpacked extension manually`
|
|
@@ -13737,7 +13802,7 @@ async function createExtensionRunner() {
|
|
|
13737
13802
|
// src/core/create-server.ts
|
|
13738
13803
|
var import_async_mutex = require("async-mutex");
|
|
13739
13804
|
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
13740
|
-
var
|
|
13805
|
+
var import_node_path29 = require("path");
|
|
13741
13806
|
async function createServer(inlineConfig) {
|
|
13742
13807
|
await registerWxt("serve", inlineConfig, async (config) => {
|
|
13743
13808
|
const { port, hostname } = config.dev.server;
|
|
@@ -13839,7 +13904,7 @@ function createFileReloader(server) {
|
|
|
13839
13904
|
return;
|
|
13840
13905
|
}
|
|
13841
13906
|
wxt.logger.info(
|
|
13842
|
-
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0,
|
|
13907
|
+
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path29.relative)(wxt.config.root, file))).join(", ")}`
|
|
13843
13908
|
);
|
|
13844
13909
|
const allEntrypoints = await findEntrypoints();
|
|
13845
13910
|
try {
|
|
@@ -13928,7 +13993,7 @@ function getExternalOutputDependencies(server) {
|
|
|
13928
13993
|
var import_prompts = __toESM(require("prompts"), 1);
|
|
13929
13994
|
var import_giget = require("giget");
|
|
13930
13995
|
var import_fs_extra16 = __toESM(require("fs-extra"), 1);
|
|
13931
|
-
var
|
|
13996
|
+
var import_node_path30 = __toESM(require("path"), 1);
|
|
13932
13997
|
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
13933
13998
|
async function initialize(options) {
|
|
13934
13999
|
consola.info("Initalizing new project");
|
|
@@ -13980,13 +14045,13 @@ async function initialize(options) {
|
|
|
13980
14045
|
const isEmpty = (await import_fs_extra16.default.readdir(input.directory)).length === 0;
|
|
13981
14046
|
if (!isEmpty) {
|
|
13982
14047
|
consola.error(
|
|
13983
|
-
`The directory ${
|
|
14048
|
+
`The directory ${import_node_path30.default.resolve(input.directory)} is not empty. Aborted.`
|
|
13984
14049
|
);
|
|
13985
14050
|
process.exit(1);
|
|
13986
14051
|
}
|
|
13987
14052
|
}
|
|
13988
14053
|
await cloneProject(input);
|
|
13989
|
-
const cdPath =
|
|
14054
|
+
const cdPath = import_node_path30.default.relative(process.cwd(), import_node_path30.default.resolve(input.directory));
|
|
13990
14055
|
console.log();
|
|
13991
14056
|
consola.log(
|
|
13992
14057
|
`\u2728 WXT project created with the ${TEMPLATE_COLORS[input.template.name]?.(input.template.name) ?? input.template.name} template.`
|
|
@@ -14029,8 +14094,8 @@ async function cloneProject({
|
|
|
14029
14094
|
force: true
|
|
14030
14095
|
});
|
|
14031
14096
|
await import_fs_extra16.default.move(
|
|
14032
|
-
|
|
14033
|
-
|
|
14097
|
+
import_node_path30.default.join(directory, "_gitignore"),
|
|
14098
|
+
import_node_path30.default.join(directory, ".gitignore")
|
|
14034
14099
|
).catch(
|
|
14035
14100
|
(err) => consola.warn("Failed to move _gitignore to .gitignore:", err)
|
|
14036
14101
|
);
|
|
@@ -14062,11 +14127,11 @@ async function prepare(config) {
|
|
|
14062
14127
|
}
|
|
14063
14128
|
|
|
14064
14129
|
// src/core/zip.ts
|
|
14065
|
-
var
|
|
14130
|
+
var import_node_path31 = __toESM(require("path"), 1);
|
|
14066
14131
|
var import_fs_extra17 = __toESM(require("fs-extra"), 1);
|
|
14067
14132
|
var import_minimatch2 = require("minimatch");
|
|
14068
14133
|
var import_jszip = __toESM(require("jszip"), 1);
|
|
14069
|
-
var
|
|
14134
|
+
var import_fast_glob7 = __toESM(require("fast-glob"), 1);
|
|
14070
14135
|
async function zip(config) {
|
|
14071
14136
|
await registerWxt("build", config);
|
|
14072
14137
|
const output = await internalBuild();
|
|
@@ -14074,7 +14139,7 @@ async function zip(config) {
|
|
|
14074
14139
|
wxt.logger.info("Zipping extension...");
|
|
14075
14140
|
const zipFiles = [];
|
|
14076
14141
|
const projectName = wxt.config.zip.name ?? kebabCaseAlphanumeric(
|
|
14077
|
-
(await getPackageJson())?.name ||
|
|
14142
|
+
(await getPackageJson())?.name || import_node_path31.default.dirname(process.cwd())
|
|
14078
14143
|
);
|
|
14079
14144
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", wxt.config.browser).replaceAll(
|
|
14080
14145
|
"{{version}}",
|
|
@@ -14082,13 +14147,13 @@ async function zip(config) {
|
|
|
14082
14147
|
).replaceAll("{{mode}}", wxt.config.mode).replaceAll("{{manifestVersion}}", `mv${wxt.config.manifestVersion}`);
|
|
14083
14148
|
await import_fs_extra17.default.ensureDir(wxt.config.outBaseDir);
|
|
14084
14149
|
const outZipFilename = applyTemplate(wxt.config.zip.artifactTemplate);
|
|
14085
|
-
const outZipPath =
|
|
14150
|
+
const outZipPath = import_node_path31.default.resolve(wxt.config.outBaseDir, outZipFilename);
|
|
14086
14151
|
await zipDir(wxt.config.outDir, outZipPath);
|
|
14087
14152
|
zipFiles.push(outZipPath);
|
|
14088
14153
|
if (wxt.config.browser === "firefox") {
|
|
14089
14154
|
const { overrides, files: downloadedPackages } = await downloadPrivatePackages();
|
|
14090
14155
|
const sourcesZipFilename = applyTemplate(wxt.config.zip.sourcesTemplate);
|
|
14091
|
-
const sourcesZipPath =
|
|
14156
|
+
const sourcesZipPath = import_node_path31.default.resolve(
|
|
14092
14157
|
wxt.config.outBaseDir,
|
|
14093
14158
|
sourcesZipFilename
|
|
14094
14159
|
);
|
|
@@ -14114,7 +14179,7 @@ async function zip(config) {
|
|
|
14114
14179
|
}
|
|
14115
14180
|
async function zipDir(directory, outputPath, options) {
|
|
14116
14181
|
const archive = new import_jszip.default();
|
|
14117
|
-
const files = (await (0,
|
|
14182
|
+
const files = (await (0, import_fast_glob7.default)("**/*", {
|
|
14118
14183
|
cwd: directory,
|
|
14119
14184
|
// Ignore node_modules, otherwise this glob step takes forever
|
|
14120
14185
|
ignore: ["**/node_modules"],
|
|
@@ -14127,11 +14192,11 @@ async function zipDir(directory, outputPath, options) {
|
|
|
14127
14192
|
const filesToZip = [
|
|
14128
14193
|
...files,
|
|
14129
14194
|
...(options?.additionalFiles ?? []).map(
|
|
14130
|
-
(file) =>
|
|
14195
|
+
(file) => import_node_path31.default.relative(directory, file)
|
|
14131
14196
|
)
|
|
14132
14197
|
];
|
|
14133
14198
|
for (const file of filesToZip) {
|
|
14134
|
-
const absolutePath =
|
|
14199
|
+
const absolutePath = import_node_path31.default.resolve(directory, file);
|
|
14135
14200
|
if (file.endsWith(".json")) {
|
|
14136
14201
|
const content = await import_fs_extra17.default.readFile(absolutePath, "utf-8");
|
|
14137
14202
|
archive.file(
|
|
@@ -14180,14 +14245,14 @@ async function downloadPrivatePackages() {
|
|
|
14180
14245
|
}
|
|
14181
14246
|
function addOverridesToPackageJson(absolutePackageJsonPath, content, overrides) {
|
|
14182
14247
|
if (Object.keys(overrides).length === 0) return content;
|
|
14183
|
-
const packageJsonDir =
|
|
14248
|
+
const packageJsonDir = import_node_path31.default.dirname(absolutePackageJsonPath);
|
|
14184
14249
|
const oldPackage = JSON.parse(content);
|
|
14185
14250
|
const newPackage = {
|
|
14186
14251
|
...oldPackage,
|
|
14187
14252
|
[wxt.pm.overridesKey]: { ...oldPackage[wxt.pm.overridesKey] }
|
|
14188
14253
|
};
|
|
14189
14254
|
Object.entries(overrides).forEach(([key, absolutePath]) => {
|
|
14190
|
-
newPackage[wxt.pm.overridesKey][key] = "file://./" + normalizePath(
|
|
14255
|
+
newPackage[wxt.pm.overridesKey][key] = "file://./" + normalizePath(import_node_path31.default.relative(packageJsonDir, absolutePath));
|
|
14191
14256
|
});
|
|
14192
14257
|
return JSON.stringify(newPackage, null, 2);
|
|
14193
14258
|
}
|