wxt 0.18.6 → 0.18.7
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-QOYT5J6A.js → chunk-A3R6ZPUA.js} +99 -170
- package/dist/{chunk-5X3S6AWF.js → chunk-BERPNPEZ.js} +2 -4
- package/dist/{chunk-ZZCTFNQ5.js → chunk-BM6QYGAW.js} +1 -1
- package/dist/{chunk-NAMV4VWQ.js → chunk-KPD5J7PZ.js} +1 -1
- package/dist/{chunk-VBXJIVYU.js → chunk-QGM4M3NI.js} +1 -2
- package/dist/{chunk-73I7FAJU.js → chunk-SGKCDMVR.js} +1 -2
- package/dist/cli.js +120 -208
- package/dist/client.js +12 -24
- package/dist/{execa-QQUOQNS3.js → execa-ATHZH2Y4.js} +1576 -610
- package/dist/{execa-5TSWMF32.js → execa-D7CMCKO2.js} +1576 -610
- package/dist/index.cjs +2144 -1149
- package/dist/index.js +23 -38
- package/dist/modules.cjs +3 -6
- package/dist/modules.js +4 -7
- package/dist/{prompt-Y7B5HSD5.js → prompt-25QIVJDC.js} +28 -55
- package/dist/{prompt-TFJ7OLL7.js → prompt-7BMKNSWS.js} +28 -55
- package/dist/sandbox.js +2 -4
- package/dist/storage.cjs +4 -8
- package/dist/storage.js +6 -10
- package/dist/testing.cjs +35 -69
- package/dist/testing.js +4 -4
- package/dist/virtual/background-entrypoint.js +3 -6
- package/dist/virtual/content-script-isolated-world-entrypoint.js +1 -2
- package/dist/virtual/content-script-main-world-entrypoint.js +1 -2
- package/dist/virtual/reload-html.js +1 -2
- package/dist/virtual/unlisted-script-entrypoint.js +1 -2
- package/package.json +33 -32
package/dist/cli.js
CHANGED
|
@@ -2,10 +2,10 @@ import { createRequire } from 'module';const require = createRequire(import.meta
|
|
|
2
2
|
import {
|
|
3
3
|
LogLevels,
|
|
4
4
|
consola
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KPD5J7PZ.js";
|
|
6
6
|
import {
|
|
7
7
|
__require
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SGKCDMVR.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/commands.ts
|
|
11
11
|
import cac from "cac";
|
|
@@ -46,7 +46,7 @@ var npm = {
|
|
|
46
46
|
overridesKey: "overrides",
|
|
47
47
|
async downloadDependency(id, downloadDir) {
|
|
48
48
|
await ensureDir(downloadDir);
|
|
49
|
-
const { execa } = await import("./execa-
|
|
49
|
+
const { execa } = await import("./execa-ATHZH2Y4.js");
|
|
50
50
|
const res = await execa("npm", ["pack", id, "--json"], {
|
|
51
51
|
cwd: downloadDir
|
|
52
52
|
});
|
|
@@ -58,7 +58,7 @@ var npm = {
|
|
|
58
58
|
if (options?.all) {
|
|
59
59
|
args.push("--depth", "Infinity");
|
|
60
60
|
}
|
|
61
|
-
const { execa } = await import("./execa-
|
|
61
|
+
const { execa } = await import("./execa-ATHZH2Y4.js");
|
|
62
62
|
const res = await execa("npm", args, { cwd: options?.cwd });
|
|
63
63
|
const project = JSON.parse(res.stdout);
|
|
64
64
|
return flattenNpmListOutput([project]);
|
|
@@ -68,10 +68,8 @@ function flattenNpmListOutput(projects) {
|
|
|
68
68
|
const queue = projects.flatMap(
|
|
69
69
|
(project) => {
|
|
70
70
|
const acc = [];
|
|
71
|
-
if (project.dependencies)
|
|
72
|
-
|
|
73
|
-
if (project.devDependencies)
|
|
74
|
-
acc.push(project.devDependencies);
|
|
71
|
+
if (project.dependencies) acc.push(project.dependencies);
|
|
72
|
+
if (project.devDependencies) acc.push(project.devDependencies);
|
|
75
73
|
return acc;
|
|
76
74
|
}
|
|
77
75
|
);
|
|
@@ -82,10 +80,8 @@ function flattenNpmListOutput(projects) {
|
|
|
82
80
|
name,
|
|
83
81
|
version: meta.version
|
|
84
82
|
});
|
|
85
|
-
if (meta.dependencies)
|
|
86
|
-
|
|
87
|
-
if (meta.devDependencies)
|
|
88
|
-
queue.push(meta.devDependencies);
|
|
83
|
+
if (meta.dependencies) queue.push(meta.dependencies);
|
|
84
|
+
if (meta.devDependencies) queue.push(meta.devDependencies);
|
|
89
85
|
});
|
|
90
86
|
}
|
|
91
87
|
return dedupeDependencies(dependencies);
|
|
@@ -115,7 +111,7 @@ var bun = {
|
|
|
115
111
|
if (options?.all) {
|
|
116
112
|
args.push("--all");
|
|
117
113
|
}
|
|
118
|
-
const { execa } = await import("./execa-
|
|
114
|
+
const { execa } = await import("./execa-ATHZH2Y4.js");
|
|
119
115
|
const res = await execa("bun", args, { cwd: options?.cwd });
|
|
120
116
|
return dedupeDependencies(
|
|
121
117
|
res.stdout.split("\n").slice(1).map((line) => line.trim()).map((line) => /.* (@?\S+)@(\S+)$/.exec(line)).filter((match) => !!match).map(([_, name, version2]) => ({ name, version: version2 }))
|
|
@@ -134,11 +130,10 @@ var yarn = {
|
|
|
134
130
|
if (options?.all) {
|
|
135
131
|
args.push("--depth", "Infinity");
|
|
136
132
|
}
|
|
137
|
-
const { execa } = await import("./execa-
|
|
133
|
+
const { execa } = await import("./execa-ATHZH2Y4.js");
|
|
138
134
|
const res = await execa("yarn", args, { cwd: options?.cwd });
|
|
139
135
|
const tree = res.stdout.split("\n").map((line) => JSON.parse(line)).find((line) => line.type === "tree")?.data;
|
|
140
|
-
if (tree == null)
|
|
141
|
-
throw Error("'yarn list --json' did not output a tree");
|
|
136
|
+
if (tree == null) throw Error("'yarn list --json' did not output a tree");
|
|
142
137
|
const queue = [...tree.trees];
|
|
143
138
|
const dependencies = [];
|
|
144
139
|
while (queue.length > 0) {
|
|
@@ -171,7 +166,7 @@ var pnpm = {
|
|
|
171
166
|
if (typeof process !== "undefined" && process.env.WXT_PNPM_IGNORE_WORKSPACE === "true") {
|
|
172
167
|
args.push("--ignore-workspace");
|
|
173
168
|
}
|
|
174
|
-
const { execa } = await import("./execa-
|
|
169
|
+
const { execa } = await import("./execa-ATHZH2Y4.js");
|
|
175
170
|
const res = await execa("pnpm", args, { cwd: options?.cwd });
|
|
176
171
|
const projects = JSON.parse(res.stdout);
|
|
177
172
|
return flattenNpmListOutput(projects);
|
|
@@ -184,8 +179,7 @@ async function createWxtPackageManager(root) {
|
|
|
184
179
|
includeParentDirs: true
|
|
185
180
|
});
|
|
186
181
|
const requirePm = (cb) => {
|
|
187
|
-
if (pm == null)
|
|
188
|
-
throw Error("Could not detect package manager");
|
|
182
|
+
if (pm == null) throw Error("Could not detect package manager");
|
|
189
183
|
return cb(pm);
|
|
190
184
|
};
|
|
191
185
|
return {
|
|
@@ -269,15 +263,16 @@ function isHtmlEntrypoint(entrypoint) {
|
|
|
269
263
|
// src/core/builders/vite/plugins/devHtmlPrerender.ts
|
|
270
264
|
import { parseHTML } from "linkedom";
|
|
271
265
|
import { dirname, relative as relative2, resolve as resolve2 } from "node:path";
|
|
272
|
-
|
|
266
|
+
import { murmurHash } from "ohash";
|
|
267
|
+
var inlineScriptContents = {};
|
|
273
268
|
function devHtmlPrerender(config, server) {
|
|
274
269
|
const htmlReloadId = "@wxt/reload-html";
|
|
275
270
|
const resolvedHtmlReloadId = resolve2(
|
|
276
271
|
config.wxtModuleDir,
|
|
277
272
|
"dist/virtual/reload-html.js"
|
|
278
273
|
);
|
|
279
|
-
const
|
|
280
|
-
const
|
|
274
|
+
const virtualInlineScript = "virtual:wxt-inline-script";
|
|
275
|
+
const resolvedVirtualInlineScript = "\0" + virtualInlineScript;
|
|
281
276
|
return [
|
|
282
277
|
{
|
|
283
278
|
apply: "build",
|
|
@@ -312,23 +307,22 @@ function devHtmlPrerender(config, server) {
|
|
|
312
307
|
},
|
|
313
308
|
// Pass the HTML through the dev server to add dev-mode specific code
|
|
314
309
|
async transformIndexHtml(html, ctx) {
|
|
315
|
-
if (config.command !== "serve" || server == null)
|
|
316
|
-
return;
|
|
310
|
+
if (config.command !== "serve" || server == null) return;
|
|
317
311
|
const originalUrl = `${server.origin}${ctx.path}`;
|
|
318
312
|
const name = getEntrypointName(config.entrypointsDir, ctx.filename);
|
|
319
313
|
const url = `${server.origin}/${name}.html`;
|
|
320
314
|
const serverHtml = await server.transformHtml(url, html, originalUrl);
|
|
321
315
|
const { document } = parseHTML(serverHtml);
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
316
|
+
const inlineScripts = document.querySelectorAll("script:not([src])");
|
|
317
|
+
inlineScripts.forEach((script) => {
|
|
318
|
+
const textContent = script.textContent ?? "";
|
|
319
|
+
const hash = murmurHash(textContent);
|
|
320
|
+
inlineScriptContents[hash] = textContent;
|
|
327
321
|
const virtualScript = document.createElement("script");
|
|
328
322
|
virtualScript.type = "module";
|
|
329
|
-
virtualScript.src = `${server.origin}/${
|
|
330
|
-
|
|
331
|
-
}
|
|
323
|
+
virtualScript.src = `${server.origin}/@id/${virtualInlineScript}?${hash}`;
|
|
324
|
+
script.replaceWith(virtualScript);
|
|
325
|
+
});
|
|
332
326
|
const viteClientScript = document.querySelector(
|
|
333
327
|
"script[src='/@vite/client']"
|
|
334
328
|
);
|
|
@@ -346,16 +340,17 @@ function devHtmlPrerender(config, server) {
|
|
|
346
340
|
name: "wxt:virtualize-react-refresh",
|
|
347
341
|
apply: "serve",
|
|
348
342
|
resolveId(id) {
|
|
349
|
-
if (id
|
|
350
|
-
return
|
|
343
|
+
if (id.startsWith(virtualInlineScript)) {
|
|
344
|
+
return "\0" + id;
|
|
351
345
|
}
|
|
352
346
|
if (id.startsWith("/chunks/")) {
|
|
353
347
|
return "\0noop";
|
|
354
348
|
}
|
|
355
349
|
},
|
|
356
350
|
load(id) {
|
|
357
|
-
if (id
|
|
358
|
-
|
|
351
|
+
if (id.startsWith(resolvedVirtualInlineScript)) {
|
|
352
|
+
const hash = Number(id.substring(id.indexOf("?") + 1));
|
|
353
|
+
return inlineScriptContents[hash];
|
|
359
354
|
}
|
|
360
355
|
if (id === "\0noop") {
|
|
361
356
|
return "";
|
|
@@ -367,8 +362,7 @@ function devHtmlPrerender(config, server) {
|
|
|
367
362
|
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
368
363
|
document.querySelectorAll(querySelector).forEach((element) => {
|
|
369
364
|
const src = element.getAttribute(attr);
|
|
370
|
-
if (!src || isUrl(src))
|
|
371
|
-
return;
|
|
365
|
+
if (!src || isUrl(src)) return;
|
|
372
366
|
let resolvedAbsolutePath;
|
|
373
367
|
const matchingAlias = Object.entries(config.alias).find(
|
|
374
368
|
([key]) => src.startsWith(key)
|
|
@@ -388,8 +382,7 @@ function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
|
388
382
|
);
|
|
389
383
|
if (relativePath.startsWith(".")) {
|
|
390
384
|
let path11 = normalizePath(resolvedAbsolutePath);
|
|
391
|
-
if (!path11.startsWith("/"))
|
|
392
|
-
path11 = "/" + path11;
|
|
385
|
+
if (!path11.startsWith("/")) path11 = "/" + path11;
|
|
393
386
|
element.setAttribute(attr, `${server.origin}/@fs${path11}`);
|
|
394
387
|
} else {
|
|
395
388
|
const url = new URL(relativePath, server.origin);
|
|
@@ -412,8 +405,7 @@ function devServerGlobals(config, server) {
|
|
|
412
405
|
return {
|
|
413
406
|
name: "wxt:dev-server-globals",
|
|
414
407
|
config() {
|
|
415
|
-
if (server == null || config.command == "build")
|
|
416
|
-
return;
|
|
408
|
+
if (server == null || config.command == "build") return;
|
|
417
409
|
return {
|
|
418
410
|
define: {
|
|
419
411
|
__DEV_SERVER_PROTOCOL__: JSON.stringify("ws:"),
|
|
@@ -430,12 +422,9 @@ import dns from "node:dns";
|
|
|
430
422
|
|
|
431
423
|
// src/core/utils/time.ts
|
|
432
424
|
function formatDuration(duration) {
|
|
433
|
-
if (duration < 1e3)
|
|
434
|
-
|
|
435
|
-
if (duration <
|
|
436
|
-
return `${(duration / 1e3).toFixed(3)} s`;
|
|
437
|
-
if (duration < 6e4)
|
|
438
|
-
return `${(duration / 1e3).toFixed(1)} s`;
|
|
425
|
+
if (duration < 1e3) return `${duration} ms`;
|
|
426
|
+
if (duration < 1e4) return `${(duration / 1e3).toFixed(3)} s`;
|
|
427
|
+
if (duration < 6e4) return `${(duration / 1e3).toFixed(1)} s`;
|
|
439
428
|
return `${(duration / 1e3).toFixed(0)} s`;
|
|
440
429
|
}
|
|
441
430
|
function withTimeout(promise, duration) {
|
|
@@ -477,8 +466,7 @@ async function fetchCached(url, config) {
|
|
|
477
466
|
);
|
|
478
467
|
}
|
|
479
468
|
}
|
|
480
|
-
if (!content)
|
|
481
|
-
content = await config.fsCache.get(url) ?? "";
|
|
469
|
+
if (!content) content = await config.fsCache.get(url) ?? "";
|
|
482
470
|
if (!content)
|
|
483
471
|
throw Error(
|
|
484
472
|
`Offline and "${url}" has not been cached. Try again when online.`
|
|
@@ -491,12 +479,10 @@ function download(config) {
|
|
|
491
479
|
return {
|
|
492
480
|
name: "wxt:download",
|
|
493
481
|
resolveId(id) {
|
|
494
|
-
if (id.startsWith("url:"))
|
|
495
|
-
return "\0" + id;
|
|
482
|
+
if (id.startsWith("url:")) return "\0" + id;
|
|
496
483
|
},
|
|
497
484
|
async load(id) {
|
|
498
|
-
if (!id.startsWith("\0url:"))
|
|
499
|
-
return;
|
|
485
|
+
if (!id.startsWith("\0url:")) return;
|
|
500
486
|
const url = id.replace("\0url:", "");
|
|
501
487
|
return await fetchCached(url, config);
|
|
502
488
|
}
|
|
@@ -575,8 +561,7 @@ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
575
561
|
]);
|
|
576
562
|
function unimport(config) {
|
|
577
563
|
const options = config.imports;
|
|
578
|
-
if (options === false)
|
|
579
|
-
return [];
|
|
564
|
+
if (options === false) return [];
|
|
580
565
|
const unimport2 = createUnimport(options);
|
|
581
566
|
return {
|
|
582
567
|
name: "wxt:unimport",
|
|
@@ -584,10 +569,8 @@ function unimport(config) {
|
|
|
584
569
|
await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
|
|
585
570
|
},
|
|
586
571
|
async transform(code, id) {
|
|
587
|
-
if (id.includes("node_modules"))
|
|
588
|
-
|
|
589
|
-
if (!ENABLED_EXTENSIONS.has(extname2(id)))
|
|
590
|
-
return;
|
|
572
|
+
if (id.includes("node_modules")) return;
|
|
573
|
+
if (!ENABLED_EXTENSIONS.has(extname2(id))) return;
|
|
591
574
|
const injected = await unimport2.injectImports(code, id);
|
|
592
575
|
return {
|
|
593
576
|
code: injected.code,
|
|
@@ -624,14 +607,12 @@ function resolveVirtualModules(config) {
|
|
|
624
607
|
name: `wxt:resolve-virtual-${name}`,
|
|
625
608
|
resolveId(id) {
|
|
626
609
|
const index = id.indexOf(virtualId);
|
|
627
|
-
if (index === -1)
|
|
628
|
-
return;
|
|
610
|
+
if (index === -1) return;
|
|
629
611
|
const inputPath = normalizePath(id.substring(index + virtualId.length));
|
|
630
612
|
return resolvedVirtualId + inputPath;
|
|
631
613
|
},
|
|
632
614
|
async load(id) {
|
|
633
|
-
if (!id.startsWith(resolvedVirtualId))
|
|
634
|
-
return;
|
|
615
|
+
if (!id.startsWith(resolvedVirtualId)) return;
|
|
635
616
|
const inputPath = id.replace(resolvedVirtualId, "");
|
|
636
617
|
const template = await fs2.readFile(
|
|
637
618
|
resolve4(config.wxtModuleDir, `dist/virtual/${name}.js`),
|
|
@@ -667,8 +648,7 @@ function noopBackground() {
|
|
|
667
648
|
return {
|
|
668
649
|
name: "wxt:noop-background",
|
|
669
650
|
resolveId(id) {
|
|
670
|
-
if (id === virtualModuleId)
|
|
671
|
-
return resolvedVirtualModuleId;
|
|
651
|
+
if (id === virtualModuleId) return resolvedVirtualModuleId;
|
|
672
652
|
},
|
|
673
653
|
load(id) {
|
|
674
654
|
if (id === resolvedVirtualModuleId) {
|
|
@@ -696,8 +676,7 @@ function cssEntrypoints(entrypoint, config) {
|
|
|
696
676
|
},
|
|
697
677
|
generateBundle(_, bundle) {
|
|
698
678
|
Object.keys(bundle).forEach((file) => {
|
|
699
|
-
if (file.endsWith(".js"))
|
|
700
|
-
delete bundle[file];
|
|
679
|
+
if (file.endsWith(".js")) delete bundle[file];
|
|
701
680
|
});
|
|
702
681
|
}
|
|
703
682
|
};
|
|
@@ -819,8 +798,7 @@ function excludeBrowserPolyfill(config) {
|
|
|
819
798
|
return {
|
|
820
799
|
name: "wxt:exclude-browser-polyfill",
|
|
821
800
|
config() {
|
|
822
|
-
if (config.experimental.includeBrowserPolyfill)
|
|
823
|
-
return;
|
|
801
|
+
if (config.experimental.includeBrowserPolyfill) return;
|
|
824
802
|
return {
|
|
825
803
|
resolve: {
|
|
826
804
|
alias: {
|
|
@@ -895,8 +873,7 @@ function removeEntrypointMainFunction(config, path11) {
|
|
|
895
873
|
return {
|
|
896
874
|
name: "wxt:remove-entrypoint-main-function",
|
|
897
875
|
transform(code, id) {
|
|
898
|
-
if (id === absPath)
|
|
899
|
-
return removeMainFunctionCode(code);
|
|
876
|
+
if (id === absPath) return removeMainFunctionCode(code);
|
|
900
877
|
}
|
|
901
878
|
};
|
|
902
879
|
}
|
|
@@ -911,10 +888,8 @@ function wxtPluginLoader(config) {
|
|
|
911
888
|
return {
|
|
912
889
|
name: "wxt:plugin-loader",
|
|
913
890
|
resolveId(id) {
|
|
914
|
-
if (id === virtualModuleId)
|
|
915
|
-
|
|
916
|
-
if (id === virtualHtmlModuleId)
|
|
917
|
-
return resolvedVirtualHtmlModuleId;
|
|
891
|
+
if (id === virtualModuleId) return resolvedVirtualModuleId;
|
|
892
|
+
if (id === virtualHtmlModuleId) return resolvedVirtualHtmlModuleId;
|
|
918
893
|
},
|
|
919
894
|
load(id) {
|
|
920
895
|
if (id === resolvedVirtualModuleId) {
|
|
@@ -945,7 +920,7 @@ try {
|
|
|
945
920
|
const { document } = parseHTML2(html);
|
|
946
921
|
const script = document.createElement("script");
|
|
947
922
|
script.type = "module";
|
|
948
|
-
script.src = "
|
|
923
|
+
script.src = config.command === "serve" ? `http://${config.dev.server?.hostname}:${config.dev.server?.port}/@id/${virtualHtmlModuleId}` : virtualHtmlModuleId;
|
|
949
924
|
if (document.head == null) {
|
|
950
925
|
const newHead = document.createElement("head");
|
|
951
926
|
document.documentElement.prepend(newHead);
|
|
@@ -960,14 +935,12 @@ try {
|
|
|
960
935
|
// src/core/utils/arrays.ts
|
|
961
936
|
function every(array, predicate) {
|
|
962
937
|
for (let i = 0; i < array.length; i++)
|
|
963
|
-
if (!predicate(array[i], i))
|
|
964
|
-
return false;
|
|
938
|
+
if (!predicate(array[i], i)) return false;
|
|
965
939
|
return true;
|
|
966
940
|
}
|
|
967
941
|
function some(array, predicate) {
|
|
968
942
|
for (let i = 0; i < array.length; i++)
|
|
969
|
-
if (predicate(array[i], i))
|
|
970
|
-
return true;
|
|
943
|
+
if (predicate(array[i], i)) return true;
|
|
971
944
|
return false;
|
|
972
945
|
}
|
|
973
946
|
function toArray(a) {
|
|
@@ -1110,8 +1083,7 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
1110
1083
|
// Include a hash to prevent conflicts
|
|
1111
1084
|
chunkFileNames: "chunks/[name]-[hash].js",
|
|
1112
1085
|
entryFileNames: ({ name }) => {
|
|
1113
|
-
if (htmlEntrypoints.has(name))
|
|
1114
|
-
return "chunks/[name]-[hash].js";
|
|
1086
|
+
if (htmlEntrypoints.has(name)) return "chunks/[name]-[hash].js";
|
|
1115
1087
|
return "[name].js";
|
|
1116
1088
|
},
|
|
1117
1089
|
// We can't control the "name", so we need a hash to prevent conflicts
|
|
@@ -1164,12 +1136,10 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
1164
1136
|
},
|
|
1165
1137
|
async build(group) {
|
|
1166
1138
|
let entryConfig;
|
|
1167
|
-
if (Array.isArray(group))
|
|
1168
|
-
entryConfig = getMultiPageConfig(group);
|
|
1139
|
+
if (Array.isArray(group)) entryConfig = getMultiPageConfig(group);
|
|
1169
1140
|
else if (group.inputPath.endsWith(".css"))
|
|
1170
1141
|
entryConfig = getCssConfig(group);
|
|
1171
|
-
else
|
|
1172
|
-
entryConfig = getLibModeConfig(group);
|
|
1142
|
+
else entryConfig = getLibModeConfig(group);
|
|
1173
1143
|
const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
|
|
1174
1144
|
await hooks.callHook(
|
|
1175
1145
|
"vite:build:extendConfig",
|
|
@@ -1220,10 +1190,8 @@ async function createViteBuilder(wxtConfig, hooks, server) {
|
|
|
1220
1190
|
};
|
|
1221
1191
|
}
|
|
1222
1192
|
function getBuildOutputChunks(result) {
|
|
1223
|
-
if ("on" in result)
|
|
1224
|
-
|
|
1225
|
-
if (Array.isArray(result))
|
|
1226
|
-
return result.flatMap(({ output }) => output);
|
|
1193
|
+
if ("on" in result) throw Error("wxt does not support vite watch mode.");
|
|
1194
|
+
if (Array.isArray(result)) return result.flatMap(({ output }) => output);
|
|
1227
1195
|
return result.output;
|
|
1228
1196
|
}
|
|
1229
1197
|
function getRollupEntry(entrypoint) {
|
|
@@ -1266,8 +1234,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
1266
1234
|
server
|
|
1267
1235
|
};
|
|
1268
1236
|
for (const module of config.modules) {
|
|
1269
|
-
if (module.hooks)
|
|
1270
|
-
wxt.hooks.addHooks(module.hooks);
|
|
1237
|
+
if (module.hooks) wxt.hooks.addHooks(module.hooks);
|
|
1271
1238
|
if (wxt.config.imports !== false && module.imports) {
|
|
1272
1239
|
wxt.config.imports.imports ??= [];
|
|
1273
1240
|
wxt.config.imports.imports.push(...module.imports);
|
|
@@ -1290,8 +1257,7 @@ async function writeFileIfDifferent(file, newContents) {
|
|
|
1290
1257
|
}
|
|
1291
1258
|
}
|
|
1292
1259
|
async function getPublicFiles() {
|
|
1293
|
-
if (!await fs3.exists(wxt.config.publicDir))
|
|
1294
|
-
return [];
|
|
1260
|
+
if (!await fs3.exists(wxt.config.publicDir)) return [];
|
|
1295
1261
|
const files = await glob("**/*", { cwd: wxt.config.publicDir });
|
|
1296
1262
|
return files.map(unnormalizePath);
|
|
1297
1263
|
}
|
|
@@ -1324,8 +1290,7 @@ async function copyPublicDirectory() {
|
|
|
1324
1290
|
relativeDest: file
|
|
1325
1291
|
}));
|
|
1326
1292
|
await wxt.hooks.callHook("build:publicAssets", wxt, files);
|
|
1327
|
-
if (files.length === 0)
|
|
1328
|
-
return [];
|
|
1293
|
+
if (files.length === 0) return [];
|
|
1329
1294
|
const publicAssets = [];
|
|
1330
1295
|
for (const { absoluteSrc, relativeDest } of files) {
|
|
1331
1296
|
const absoluteDest = resolve6(wxt.config.outDir, relativeDest);
|
|
@@ -1345,21 +1310,18 @@ function detectDevChanges(changedFiles, currentOutput) {
|
|
|
1345
1310
|
changedFiles,
|
|
1346
1311
|
(file) => file === wxt.config.userConfigMetadata.configFile
|
|
1347
1312
|
);
|
|
1348
|
-
if (isConfigChange)
|
|
1349
|
-
return { type: "full-restart" };
|
|
1313
|
+
if (isConfigChange) return { type: "full-restart" };
|
|
1350
1314
|
const isRunnerChange = some(
|
|
1351
1315
|
changedFiles,
|
|
1352
1316
|
(file) => file === wxt.config.runnerConfig.configFile
|
|
1353
1317
|
);
|
|
1354
|
-
if (isRunnerChange)
|
|
1355
|
-
return { type: "browser-restart" };
|
|
1318
|
+
if (isRunnerChange) return { type: "browser-restart" };
|
|
1356
1319
|
const changedSteps = new Set(
|
|
1357
1320
|
changedFiles.flatMap(
|
|
1358
1321
|
(changedFile) => findEffectedSteps(changedFile, currentOutput)
|
|
1359
1322
|
)
|
|
1360
1323
|
);
|
|
1361
|
-
if (changedSteps.size === 0)
|
|
1362
|
-
return { type: "no-change" };
|
|
1324
|
+
if (changedSteps.size === 0) return { type: "no-change" };
|
|
1363
1325
|
const unchangedOutput = {
|
|
1364
1326
|
manifest: currentOutput.manifest,
|
|
1365
1327
|
steps: [],
|
|
@@ -1422,14 +1384,12 @@ function findEffectedSteps(changedFile, currentOutput) {
|
|
|
1422
1384
|
);
|
|
1423
1385
|
for (const step of currentOutput.steps) {
|
|
1424
1386
|
const effectedChunk = step.chunks.find((chunk) => isChunkEffected(chunk));
|
|
1425
|
-
if (effectedChunk)
|
|
1426
|
-
changes.push(step);
|
|
1387
|
+
if (effectedChunk) changes.push(step);
|
|
1427
1388
|
}
|
|
1428
1389
|
const effectedAsset = currentOutput.publicAssets.find(
|
|
1429
1390
|
(chunk) => isChunkEffected(chunk)
|
|
1430
1391
|
);
|
|
1431
|
-
if (effectedAsset)
|
|
1432
|
-
changes.push(effectedAsset);
|
|
1392
|
+
if (effectedAsset) changes.push(effectedAsset);
|
|
1433
1393
|
return changes;
|
|
1434
1394
|
}
|
|
1435
1395
|
|
|
@@ -2209,8 +2169,7 @@ async function resolveConfig(inlineConfig, command) {
|
|
|
2209
2169
|
const mergedConfig = await mergeInlineConfig(inlineConfig, userConfig);
|
|
2210
2170
|
const debug = mergedConfig.debug ?? false;
|
|
2211
2171
|
const logger = mergedConfig.logger ?? consola;
|
|
2212
|
-
if (debug)
|
|
2213
|
-
logger.level = LogLevels.debug;
|
|
2172
|
+
if (debug) logger.level = LogLevels.debug;
|
|
2214
2173
|
const browser = mergedConfig.browser ?? "chrome";
|
|
2215
2174
|
const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
|
|
2216
2175
|
const mode = mergedConfig.mode ?? COMMAND_MODES[command];
|
|
@@ -2386,8 +2345,7 @@ function resolveAnalysisConfig(root, mergedConfig) {
|
|
|
2386
2345
|
};
|
|
2387
2346
|
}
|
|
2388
2347
|
async function getUnimportOptions(wxtDir, logger, config) {
|
|
2389
|
-
if (config.imports === false)
|
|
2390
|
-
return false;
|
|
2348
|
+
if (config.imports === false) return false;
|
|
2391
2349
|
const enabledConfig = config.imports?.eslintrc?.enabled;
|
|
2392
2350
|
let enabled;
|
|
2393
2351
|
switch (enabledConfig) {
|
|
@@ -2555,8 +2513,7 @@ import { filesize } from "filesize";
|
|
|
2555
2513
|
|
|
2556
2514
|
// src/core/utils/log/printTable.ts
|
|
2557
2515
|
function printTable(log, header, rows, gap = 2) {
|
|
2558
|
-
if (rows.length === 0)
|
|
2559
|
-
return;
|
|
2516
|
+
if (rows.length === 0) return;
|
|
2560
2517
|
const columnWidths = rows.reduce(
|
|
2561
2518
|
(widths, row) => {
|
|
2562
2519
|
for (let i = 0; i < Math.max(widths.length, row.length); i++) {
|
|
@@ -2570,11 +2527,9 @@ function printTable(log, header, rows, gap = 2) {
|
|
|
2570
2527
|
rows.forEach((row, i) => {
|
|
2571
2528
|
row.forEach((col, j) => {
|
|
2572
2529
|
str += col.padEnd(columnWidths[j], " ");
|
|
2573
|
-
if (j !== row.length - 1)
|
|
2574
|
-
str += "".padEnd(gap, " ");
|
|
2530
|
+
if (j !== row.length - 1) str += "".padEnd(gap, " ");
|
|
2575
2531
|
});
|
|
2576
|
-
if (i !== rows.length - 1)
|
|
2577
|
-
str += "\n";
|
|
2532
|
+
if (i !== rows.length - 1) str += "\n";
|
|
2578
2533
|
});
|
|
2579
2534
|
log(`${header}
|
|
2580
2535
|
${str}`);
|
|
@@ -2628,8 +2583,7 @@ async function printBuildSummary(log, header, output) {
|
|
|
2628
2583
|
const lWeight = getChunkSortWeight(l.fileName);
|
|
2629
2584
|
const rWeight = getChunkSortWeight(r.fileName);
|
|
2630
2585
|
const diff = lWeight - rWeight;
|
|
2631
|
-
if (diff !== 0)
|
|
2632
|
-
return diff;
|
|
2586
|
+
if (diff !== 0) return diff;
|
|
2633
2587
|
return l.fileName.localeCompare(r.fileName);
|
|
2634
2588
|
});
|
|
2635
2589
|
const files = chunks.map(
|
|
@@ -2683,8 +2637,7 @@ var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
|
2683
2637
|
const sections = csp.split(";").map((section) => section.trim());
|
|
2684
2638
|
this.data = sections.reduce((data, section) => {
|
|
2685
2639
|
const [key, ...values] = section.split(" ").map((item) => item.trim());
|
|
2686
|
-
if (key)
|
|
2687
|
-
data[key] = values;
|
|
2640
|
+
if (key) data[key] = values;
|
|
2688
2641
|
return data;
|
|
2689
2642
|
}, {});
|
|
2690
2643
|
} else {
|
|
@@ -2697,8 +2650,7 @@ var ContentSecurityPolicy = class _ContentSecurityPolicy {
|
|
|
2697
2650
|
add(directive, ...newValues) {
|
|
2698
2651
|
const values = this.data[directive] ?? [];
|
|
2699
2652
|
newValues.forEach((newValue) => {
|
|
2700
|
-
if (!values.includes(newValue))
|
|
2701
|
-
values.push(newValue);
|
|
2653
|
+
if (!values.includes(newValue)) values.push(newValue);
|
|
2702
2654
|
});
|
|
2703
2655
|
this.data[directive] = values;
|
|
2704
2656
|
return this;
|
|
@@ -2721,8 +2673,7 @@ function hashContentScriptOptions(options) {
|
|
|
2721
2673
|
void 0
|
|
2722
2674
|
);
|
|
2723
2675
|
Object.keys(simplifiedOptions).forEach((key) => {
|
|
2724
|
-
if (simplifiedOptions[key] == null)
|
|
2725
|
-
delete simplifiedOptions[key];
|
|
2676
|
+
if (simplifiedOptions[key] == null) delete simplifiedOptions[key];
|
|
2726
2677
|
});
|
|
2727
2678
|
const withDefaults = {
|
|
2728
2679
|
exclude_globs: [],
|
|
@@ -2738,10 +2689,8 @@ function hashContentScriptOptions(options) {
|
|
|
2738
2689
|
};
|
|
2739
2690
|
return JSON.stringify(
|
|
2740
2691
|
Object.entries(withDefaults).map(([key, value]) => {
|
|
2741
|
-
if (Array.isArray(value))
|
|
2742
|
-
|
|
2743
|
-
else
|
|
2744
|
-
return [key, value];
|
|
2692
|
+
if (Array.isArray(value)) return [key, value.sort()];
|
|
2693
|
+
else return [key, value];
|
|
2745
2694
|
}).sort((l, r) => l[0].localeCompare(r[0]))
|
|
2746
2695
|
);
|
|
2747
2696
|
}
|
|
@@ -2831,10 +2780,8 @@ async function generateManifest(entrypoints, buildOutput) {
|
|
|
2831
2780
|
manifest.version_name = // Firefox doesn't support version_name
|
|
2832
2781
|
wxt.config.browser === "firefox" || versionName === version2 ? void 0 : versionName;
|
|
2833
2782
|
addEntrypoints(manifest, entrypoints, buildOutput);
|
|
2834
|
-
if (wxt.config.command === "serve")
|
|
2835
|
-
|
|
2836
|
-
if (wxt.config.command === "serve")
|
|
2837
|
-
addDevModePermissions(manifest);
|
|
2783
|
+
if (wxt.config.command === "serve") addDevModeCsp(manifest);
|
|
2784
|
+
if (wxt.config.command === "serve") addDevModePermissions(manifest);
|
|
2838
2785
|
wxt.config.transformManifest?.(manifest);
|
|
2839
2786
|
await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
|
|
2840
2787
|
if (wxt.config.manifestVersion === 2) {
|
|
@@ -3039,10 +2986,8 @@ function addEntrypoints(manifest, entrypoints, buildOutput) {
|
|
|
3039
2986
|
} else {
|
|
3040
2987
|
const hashToEntrypointsMap = contentScripts.filter((cs) => cs.options.registration !== "runtime").reduce((map, script) => {
|
|
3041
2988
|
const hash = hashContentScriptOptions(script.options);
|
|
3042
|
-
if (map.has(hash))
|
|
3043
|
-
|
|
3044
|
-
else
|
|
3045
|
-
map.set(hash, [script]);
|
|
2989
|
+
if (map.has(hash)) map.get(hash)?.push(script);
|
|
2990
|
+
else map.set(hash, [script]);
|
|
3046
2991
|
return map;
|
|
3047
2992
|
}, /* @__PURE__ */ new Map());
|
|
3048
2993
|
const manifestContentScripts = Array.from(
|
|
@@ -3111,8 +3056,7 @@ function discoverIcons(buildOutput) {
|
|
|
3111
3056
|
break;
|
|
3112
3057
|
}
|
|
3113
3058
|
}
|
|
3114
|
-
if (size == null)
|
|
3115
|
-
return;
|
|
3059
|
+
if (size == null) return;
|
|
3116
3060
|
icons.push([size, normalizePath(asset.fileName)]);
|
|
3117
3061
|
});
|
|
3118
3062
|
return icons.length > 0 ? Object.fromEntries(icons) : void 0;
|
|
@@ -3151,8 +3095,7 @@ function addDevModeCsp(manifest) {
|
|
|
3151
3095
|
}
|
|
3152
3096
|
function addDevModePermissions(manifest) {
|
|
3153
3097
|
addPermission(manifest, "tabs");
|
|
3154
|
-
if (wxt.config.manifestVersion === 3)
|
|
3155
|
-
addPermission(manifest, "scripting");
|
|
3098
|
+
if (wxt.config.manifestVersion === 3) addPermission(manifest, "scripting");
|
|
3156
3099
|
}
|
|
3157
3100
|
function getContentScriptCssFiles(contentScripts, contentScriptCssMap) {
|
|
3158
3101
|
const css = [];
|
|
@@ -3160,23 +3103,18 @@ function getContentScriptCssFiles(contentScripts, contentScriptCssMap) {
|
|
|
3160
3103
|
if (script.options.cssInjectionMode === "manual" || script.options.cssInjectionMode === "ui")
|
|
3161
3104
|
return;
|
|
3162
3105
|
const cssFile = contentScriptCssMap[script.name];
|
|
3163
|
-
if (cssFile == null)
|
|
3164
|
-
|
|
3165
|
-
if (cssFile)
|
|
3166
|
-
css.push(cssFile);
|
|
3106
|
+
if (cssFile == null) return;
|
|
3107
|
+
if (cssFile) css.push(cssFile);
|
|
3167
3108
|
});
|
|
3168
|
-
if (css.length > 0)
|
|
3169
|
-
return css;
|
|
3109
|
+
if (css.length > 0) return css;
|
|
3170
3110
|
return void 0;
|
|
3171
3111
|
}
|
|
3172
3112
|
function getContentScriptCssWebAccessibleResources(contentScripts, contentScriptCssMap) {
|
|
3173
3113
|
const resources = [];
|
|
3174
3114
|
contentScripts.forEach((script) => {
|
|
3175
|
-
if (script.options.cssInjectionMode !== "ui")
|
|
3176
|
-
return;
|
|
3115
|
+
if (script.options.cssInjectionMode !== "ui") return;
|
|
3177
3116
|
const cssFile = contentScriptCssMap[script.name];
|
|
3178
|
-
if (cssFile == null)
|
|
3179
|
-
return;
|
|
3117
|
+
if (cssFile == null) return;
|
|
3180
3118
|
resources.push({
|
|
3181
3119
|
resources: [cssFile],
|
|
3182
3120
|
matches: script.options.matches.map(
|
|
@@ -3193,46 +3131,39 @@ function getContentScriptsCssMap(buildOutput, scripts) {
|
|
|
3193
3131
|
const relatedCss = allChunks.find(
|
|
3194
3132
|
(chunk) => chunk.fileName === `content-scripts/${script.name}.css`
|
|
3195
3133
|
);
|
|
3196
|
-
if (relatedCss != null)
|
|
3197
|
-
map[script.name] = relatedCss.fileName;
|
|
3134
|
+
if (relatedCss != null) map[script.name] = relatedCss.fileName;
|
|
3198
3135
|
});
|
|
3199
3136
|
return map;
|
|
3200
3137
|
}
|
|
3201
3138
|
function addPermission(manifest, permission) {
|
|
3202
3139
|
manifest.permissions ??= [];
|
|
3203
|
-
if (manifest.permissions.includes(permission))
|
|
3204
|
-
return;
|
|
3140
|
+
if (manifest.permissions.includes(permission)) return;
|
|
3205
3141
|
manifest.permissions.push(permission);
|
|
3206
3142
|
}
|
|
3207
3143
|
function addHostPermission(manifest, hostPermission) {
|
|
3208
3144
|
manifest.host_permissions ??= [];
|
|
3209
|
-
if (manifest.host_permissions.includes(hostPermission))
|
|
3210
|
-
return;
|
|
3145
|
+
if (manifest.host_permissions.includes(hostPermission)) return;
|
|
3211
3146
|
manifest.host_permissions.push(hostPermission);
|
|
3212
3147
|
}
|
|
3213
3148
|
function stripPathFromMatchPattern(pattern) {
|
|
3214
3149
|
const protocolSepIndex = pattern.indexOf("://");
|
|
3215
|
-
if (protocolSepIndex === -1)
|
|
3216
|
-
return pattern;
|
|
3150
|
+
if (protocolSepIndex === -1) return pattern;
|
|
3217
3151
|
const startOfPath = pattern.indexOf("/", protocolSepIndex + 3);
|
|
3218
3152
|
return pattern.substring(0, startOfPath) + "/*";
|
|
3219
3153
|
}
|
|
3220
3154
|
function convertWebAccessibleResourcesToMv2(manifest) {
|
|
3221
|
-
if (manifest.web_accessible_resources == null)
|
|
3222
|
-
return;
|
|
3155
|
+
if (manifest.web_accessible_resources == null) return;
|
|
3223
3156
|
manifest.web_accessible_resources = Array.from(
|
|
3224
3157
|
new Set(
|
|
3225
3158
|
manifest.web_accessible_resources.flatMap((item) => {
|
|
3226
|
-
if (typeof item === "string")
|
|
3227
|
-
return item;
|
|
3159
|
+
if (typeof item === "string") return item;
|
|
3228
3160
|
return item.resources;
|
|
3229
3161
|
})
|
|
3230
3162
|
)
|
|
3231
3163
|
);
|
|
3232
3164
|
}
|
|
3233
3165
|
function moveHostPermissionsToPermissions(manifest) {
|
|
3234
|
-
if (!manifest.host_permissions?.length)
|
|
3235
|
-
return;
|
|
3166
|
+
if (!manifest.host_permissions?.length) return;
|
|
3236
3167
|
manifest.host_permissions.forEach(
|
|
3237
3168
|
(permission) => addPermission(manifest, permission)
|
|
3238
3169
|
);
|
|
@@ -3244,8 +3175,7 @@ function convertActionToMv2(manifest) {
|
|
|
3244
3175
|
manifest.browser_action = manifest.action;
|
|
3245
3176
|
}
|
|
3246
3177
|
function validateMv3WebAccessbileResources(manifest) {
|
|
3247
|
-
if (manifest.web_accessible_resources == null)
|
|
3248
|
-
return;
|
|
3178
|
+
if (manifest.web_accessible_resources == null) return;
|
|
3249
3179
|
const stringResources = manifest.web_accessible_resources.filter(
|
|
3250
3180
|
(item) => typeof item === "string"
|
|
3251
3181
|
);
|
|
@@ -3307,8 +3237,7 @@ async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
|
|
|
3307
3237
|
const spinner = ora(`Preparing...`).start();
|
|
3308
3238
|
await generateTypesDir(allEntrypoints).catch((err) => {
|
|
3309
3239
|
wxt.logger.warn("Failed to update .wxt directory:", err);
|
|
3310
|
-
if (wxt.config.command === "build")
|
|
3311
|
-
throw err;
|
|
3240
|
+
if (wxt.config.command === "build") throw err;
|
|
3312
3241
|
});
|
|
3313
3242
|
const newOutput = await buildEntrypoints(entrypointGroups, spinner);
|
|
3314
3243
|
const mergedOutput = {
|
|
@@ -3352,10 +3281,8 @@ function validateEntrypoints(entrypoints) {
|
|
|
3352
3281
|
let errorCount = 0;
|
|
3353
3282
|
let warningCount = 0;
|
|
3354
3283
|
for (const err of errors) {
|
|
3355
|
-
if (err.type === "warning")
|
|
3356
|
-
|
|
3357
|
-
else
|
|
3358
|
-
errorCount++;
|
|
3284
|
+
if (err.type === "warning") warningCount++;
|
|
3285
|
+
else errorCount++;
|
|
3359
3286
|
}
|
|
3360
3287
|
return {
|
|
3361
3288
|
errors,
|
|
@@ -3568,10 +3495,8 @@ function createWebExtRunner() {
|
|
|
3568
3495
|
}
|
|
3569
3496
|
const webExtLogger = await import("web-ext-run/util/logger");
|
|
3570
3497
|
webExtLogger.consoleStream.write = ({ level, msg, name }) => {
|
|
3571
|
-
if (level >= ERROR_LOG_LEVEL)
|
|
3572
|
-
|
|
3573
|
-
if (level >= WARN_LOG_LEVEL)
|
|
3574
|
-
wxt.logger.warn(msg);
|
|
3498
|
+
if (level >= ERROR_LOG_LEVEL) wxt.logger.error(name, msg);
|
|
3499
|
+
if (level >= WARN_LOG_LEVEL) wxt.logger.warn(msg);
|
|
3575
3500
|
};
|
|
3576
3501
|
const wxtUserConfig = wxt.config.runnerConfig.config;
|
|
3577
3502
|
const userConfig = {
|
|
@@ -3673,12 +3598,9 @@ async function isWsl() {
|
|
|
3673
3598
|
|
|
3674
3599
|
// src/core/runners/index.ts
|
|
3675
3600
|
async function createExtensionRunner() {
|
|
3676
|
-
if (wxt.config.browser === "safari")
|
|
3677
|
-
|
|
3678
|
-
if (
|
|
3679
|
-
return createWslRunner();
|
|
3680
|
-
if (wxt.config.runnerConfig.config?.disabled)
|
|
3681
|
-
return createManualRunner();
|
|
3601
|
+
if (wxt.config.browser === "safari") return createSafariRunner();
|
|
3602
|
+
if (await isWsl()) return createWslRunner();
|
|
3603
|
+
if (wxt.config.runnerConfig.config?.disabled) return createManualRunner();
|
|
3682
3604
|
return createWebExtRunner();
|
|
3683
3605
|
}
|
|
3684
3606
|
|
|
@@ -3755,8 +3677,7 @@ async function createServer(inlineConfig) {
|
|
|
3755
3677
|
runner = await createExtensionRunner();
|
|
3756
3678
|
};
|
|
3757
3679
|
server.ws.on("wxt:background-initialized", () => {
|
|
3758
|
-
if (server.currentOutput == null)
|
|
3759
|
-
return;
|
|
3680
|
+
if (server.currentOutput == null) return;
|
|
3760
3681
|
reloadContentScripts(server.currentOutput.steps, server);
|
|
3761
3682
|
});
|
|
3762
3683
|
const reloadOnChange = createFileReloader(server);
|
|
@@ -3768,18 +3689,14 @@ function createFileReloader(server) {
|
|
|
3768
3689
|
const changeQueue = [];
|
|
3769
3690
|
return async (event, path11) => {
|
|
3770
3691
|
await wxt.reloadConfig();
|
|
3771
|
-
if (path11.startsWith(wxt.config.outBaseDir))
|
|
3772
|
-
return;
|
|
3692
|
+
if (path11.startsWith(wxt.config.outBaseDir)) return;
|
|
3773
3693
|
changeQueue.push([event, path11]);
|
|
3774
3694
|
await fileChangedMutex.runExclusive(async () => {
|
|
3775
|
-
if (server.currentOutput == null)
|
|
3776
|
-
return;
|
|
3695
|
+
if (server.currentOutput == null) return;
|
|
3777
3696
|
const fileChanges = changeQueue.splice(0, changeQueue.length).map(([_, file]) => file);
|
|
3778
|
-
if (fileChanges.length === 0)
|
|
3779
|
-
return;
|
|
3697
|
+
if (fileChanges.length === 0) return;
|
|
3780
3698
|
const changes = detectDevChanges(fileChanges, server.currentOutput);
|
|
3781
|
-
if (changes.type === "no-change")
|
|
3782
|
-
return;
|
|
3699
|
+
if (changes.type === "no-change") return;
|
|
3783
3700
|
if (changes.type === "full-restart") {
|
|
3784
3701
|
wxt.logger.info("Config changed, restarting server...");
|
|
3785
3702
|
server.restart();
|
|
@@ -3828,11 +3745,9 @@ function createFileReloader(server) {
|
|
|
3828
3745
|
function reloadContentScripts(steps, server) {
|
|
3829
3746
|
if (wxt.config.manifestVersion === 3) {
|
|
3830
3747
|
steps.forEach((step) => {
|
|
3831
|
-
if (server.currentOutput == null)
|
|
3832
|
-
return;
|
|
3748
|
+
if (server.currentOutput == null) return;
|
|
3833
3749
|
const entry = step.entrypoints;
|
|
3834
|
-
if (Array.isArray(entry) || entry.type !== "content-script")
|
|
3835
|
-
return;
|
|
3750
|
+
if (Array.isArray(entry) || entry.type !== "content-script") return;
|
|
3836
3751
|
const js = getContentScriptJs(wxt.config, entry);
|
|
3837
3752
|
const cssMap = getContentScriptsCssMap(server.currentOutput, [entry]);
|
|
3838
3753
|
const css = getContentScriptCssFiles([entry], cssMap);
|
|
@@ -3870,8 +3785,7 @@ function getExternalOutputDependencies(server) {
|
|
|
3870
3785
|
return [];
|
|
3871
3786
|
}
|
|
3872
3787
|
return step.chunks.flatMap((chunk) => {
|
|
3873
|
-
if (chunk.type === "asset")
|
|
3874
|
-
return [];
|
|
3788
|
+
if (chunk.type === "asset") return [];
|
|
3875
3789
|
return chunk.moduleIds;
|
|
3876
3790
|
});
|
|
3877
3791
|
}).filter(
|
|
@@ -3949,8 +3863,7 @@ async function initialize(options) {
|
|
|
3949
3863
|
console.log();
|
|
3950
3864
|
consola.log("Next steps:");
|
|
3951
3865
|
let step = 0;
|
|
3952
|
-
if (cdPath !== "")
|
|
3953
|
-
consola.log(` ${++step}.`, pc8.cyan(`cd ${cdPath}`));
|
|
3866
|
+
if (cdPath !== "") consola.log(` ${++step}.`, pc8.cyan(`cd ${cdPath}`));
|
|
3954
3867
|
consola.log(` ${++step}.`, pc8.cyan(`${input.packageManager} install`));
|
|
3955
3868
|
console.log();
|
|
3956
3869
|
}
|
|
@@ -3964,8 +3877,7 @@ async function listTemplates() {
|
|
|
3964
3877
|
const lWeight = TEMPLATE_SORT_WEIGHT[l.name] ?? Number.MAX_SAFE_INTEGER;
|
|
3965
3878
|
const rWeight = TEMPLATE_SORT_WEIGHT[r.name] ?? Number.MAX_SAFE_INTEGER;
|
|
3966
3879
|
const diff = lWeight - rWeight;
|
|
3967
|
-
if (diff !== 0)
|
|
3968
|
-
return diff;
|
|
3880
|
+
if (diff !== 0) return diff;
|
|
3969
3881
|
return l.name.localeCompare(r.name);
|
|
3970
3882
|
});
|
|
3971
3883
|
} catch (err) {
|
|
@@ -4075,8 +3987,9 @@ async function zipDir(directory, outputPath, options) {
|
|
|
4075
3987
|
cwd: directory,
|
|
4076
3988
|
// Ignore node_modules, otherwise this glob step takes forever
|
|
4077
3989
|
ignore: ["**/node_modules"],
|
|
4078
|
-
onlyFiles: true
|
|
4079
|
-
|
|
3990
|
+
onlyFiles: true
|
|
3991
|
+
// TODO: Fix #738
|
|
3992
|
+
// dot: true,
|
|
4080
3993
|
})).filter((relativePath) => {
|
|
4081
3994
|
return options?.include?.some((pattern) => minimatch2(relativePath, pattern)) || !options?.exclude?.some((pattern) => minimatch2(relativePath, pattern));
|
|
4082
3995
|
});
|
|
@@ -4135,8 +4048,7 @@ async function downloadPrivatePackages() {
|
|
|
4135
4048
|
return { overrides, files };
|
|
4136
4049
|
}
|
|
4137
4050
|
function addOverridesToPackageJson(absolutePackageJsonPath, content, overrides) {
|
|
4138
|
-
if (Object.keys(overrides).length === 0)
|
|
4139
|
-
return content;
|
|
4051
|
+
if (Object.keys(overrides).length === 0) return content;
|
|
4140
4052
|
const packageJsonDir = path10.dirname(absolutePackageJsonPath);
|
|
4141
4053
|
const oldPackage = JSON.parse(content);
|
|
4142
4054
|
const newPackage = {
|
|
@@ -4189,7 +4101,7 @@ function createAliasedCommand(base, name, alias, bin, docsUrl) {
|
|
|
4189
4101
|
const args = process.argv.slice(
|
|
4190
4102
|
process.argv.indexOf(aliasedCommand.name) + 1
|
|
4191
4103
|
);
|
|
4192
|
-
const { execa } = await import("./execa-
|
|
4104
|
+
const { execa } = await import("./execa-ATHZH2Y4.js");
|
|
4193
4105
|
await execa(bin, args, {
|
|
4194
4106
|
stdio: "inherit"
|
|
4195
4107
|
});
|