wxt 0.15.0 → 0.15.2
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-HSXPP3ZS.js → chunk-QEFFZE4W.js} +65 -25
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +155 -63
- package/dist/{external-jLnyv431.d.cts → external-2QTHXYDU.d.cts} +27 -0
- package/dist/{external-jLnyv431.d.ts → external-2QTHXYDU.d.ts} +27 -0
- package/dist/index.cjs +102 -47
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16 -1
- package/dist/testing.cjs +50 -17
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +5 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.15.
|
|
2
|
+
var version = "0.15.2";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -533,7 +533,7 @@ import consola, { LogLevels } from "consola";
|
|
|
533
533
|
|
|
534
534
|
// src/core/builders/vite/plugins/devHtmlPrerender.ts
|
|
535
535
|
import { parseHTML } from "linkedom";
|
|
536
|
-
import { dirname as dirname3,
|
|
536
|
+
import { dirname as dirname3, relative as relative3, resolve as resolve5 } from "node:path";
|
|
537
537
|
var reactRefreshPreamble = "";
|
|
538
538
|
function devHtmlPrerender(config) {
|
|
539
539
|
const htmlReloadId = "@wxt/reload-html";
|
|
@@ -563,22 +563,9 @@ function devHtmlPrerender(config) {
|
|
|
563
563
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
564
564
|
return;
|
|
565
565
|
const { document } = parseHTML(code);
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (!src)
|
|
570
|
-
return;
|
|
571
|
-
if (isAbsolute(src)) {
|
|
572
|
-
element.setAttribute(attr, server.origin + src);
|
|
573
|
-
} else if (src.startsWith(".")) {
|
|
574
|
-
const abs = resolve5(dirname3(id), src);
|
|
575
|
-
const pathname = relative3(config.root, abs);
|
|
576
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
|
-
pointToDevServer("script[type=module]", "src");
|
|
581
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
566
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
567
|
+
_pointToDevServer("script[type=module]", "src");
|
|
568
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
582
569
|
const reloader = document.createElement("script");
|
|
583
570
|
reloader.src = htmlReloadId;
|
|
584
571
|
reloader.type = "module";
|
|
@@ -644,6 +631,48 @@ function devHtmlPrerender(config) {
|
|
|
644
631
|
}
|
|
645
632
|
];
|
|
646
633
|
}
|
|
634
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
635
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
636
|
+
const src = element.getAttribute(attr);
|
|
637
|
+
if (!src || isUrl(src))
|
|
638
|
+
return;
|
|
639
|
+
let resolvedAbsolutePath;
|
|
640
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
641
|
+
([key]) => src.startsWith(key)
|
|
642
|
+
);
|
|
643
|
+
if (matchingAlias) {
|
|
644
|
+
const [alias, replacement] = matchingAlias;
|
|
645
|
+
resolvedAbsolutePath = resolve5(
|
|
646
|
+
config.root,
|
|
647
|
+
src.replace(alias, replacement)
|
|
648
|
+
);
|
|
649
|
+
} else {
|
|
650
|
+
resolvedAbsolutePath = resolve5(dirname3(id), src);
|
|
651
|
+
}
|
|
652
|
+
if (resolvedAbsolutePath) {
|
|
653
|
+
const relativePath = normalizePath(
|
|
654
|
+
relative3(config.root, resolvedAbsolutePath)
|
|
655
|
+
);
|
|
656
|
+
if (relativePath.startsWith(".")) {
|
|
657
|
+
let path6 = normalizePath(resolvedAbsolutePath);
|
|
658
|
+
if (!path6.startsWith("/"))
|
|
659
|
+
path6 = "/" + path6;
|
|
660
|
+
element.setAttribute(attr, `${server.origin}/@fs${path6}`);
|
|
661
|
+
} else {
|
|
662
|
+
const url = new URL(relativePath, server.origin);
|
|
663
|
+
element.setAttribute(attr, url.href);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function isUrl(str) {
|
|
669
|
+
try {
|
|
670
|
+
new URL(str);
|
|
671
|
+
return true;
|
|
672
|
+
} catch {
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
647
676
|
|
|
648
677
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
649
678
|
function devServerGlobals(config) {
|
|
@@ -2251,8 +2280,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
|
|
|
2251
2280
|
}
|
|
2252
2281
|
|
|
2253
2282
|
// src/core/utils/building/internal-build.ts
|
|
2254
|
-
import
|
|
2255
|
-
import { resolve as resolve12, relative as relative5 } from "node:path";
|
|
2283
|
+
import { relative as relative5 } from "node:path";
|
|
2256
2284
|
|
|
2257
2285
|
// src/core/utils/validation.ts
|
|
2258
2286
|
function validateEntrypoints(entrypoints) {
|
|
@@ -2315,6 +2343,19 @@ var ValidationError = class extends Error {
|
|
|
2315
2343
|
|
|
2316
2344
|
// src/core/utils/building/internal-build.ts
|
|
2317
2345
|
import consola3 from "consola";
|
|
2346
|
+
|
|
2347
|
+
// src/core/utils/exec.ts
|
|
2348
|
+
import managePath from "manage-path";
|
|
2349
|
+
import { resolve as resolve12 } from "node:path";
|
|
2350
|
+
var managedPath = managePath(process.env);
|
|
2351
|
+
var exec = async (config, file, args, options) => {
|
|
2352
|
+
managedPath.restore();
|
|
2353
|
+
managedPath.push(resolve12(config.root, "node_modules/wxt/node_modules/.bin"));
|
|
2354
|
+
const { execa } = await import("./execa-4F7CCWCA.js");
|
|
2355
|
+
return await execa(file, args, options);
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
// src/core/utils/building/internal-build.ts
|
|
2318
2359
|
async function internalBuild(config) {
|
|
2319
2360
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
2320
2361
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
@@ -2363,16 +2404,15 @@ async function internalBuild(config) {
|
|
|
2363
2404
|
return output;
|
|
2364
2405
|
}
|
|
2365
2406
|
async function combineAnalysisStats(config) {
|
|
2366
|
-
const { execaCommand } = await import("./execa-4F7CCWCA.js");
|
|
2367
2407
|
const unixFiles = await glob2(`stats-*.json`, {
|
|
2368
2408
|
cwd: config.outDir,
|
|
2369
2409
|
absolute: true
|
|
2370
2410
|
});
|
|
2371
2411
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2412
|
+
await exec(
|
|
2413
|
+
config,
|
|
2414
|
+
"rollup-plugin-visualizer",
|
|
2415
|
+
[...absolutePaths, "--template", config.analysis.template],
|
|
2376
2416
|
{ cwd: config.root, stdio: "inherit" }
|
|
2377
2417
|
);
|
|
2378
2418
|
}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
2
|
import "./chunk-73I7FAJU.js";
|
|
3
3
|
|
|
4
|
-
// src/cli.ts
|
|
4
|
+
// src/cli/commands.ts
|
|
5
5
|
import cac from "cac";
|
|
6
6
|
|
|
7
|
-
// package.json
|
|
8
|
-
var version = "0.15.0";
|
|
9
|
-
|
|
10
7
|
// src/core/utils/fs.ts
|
|
11
8
|
import fs from "fs-extra";
|
|
12
9
|
import glob from "fast-glob";
|
|
@@ -878,7 +875,7 @@ import consola, { LogLevels } from "consola";
|
|
|
878
875
|
|
|
879
876
|
// src/core/builders/vite/plugins/devHtmlPrerender.ts
|
|
880
877
|
import { parseHTML as parseHTML2 } from "linkedom";
|
|
881
|
-
import { dirname as dirname3,
|
|
878
|
+
import { dirname as dirname3, relative as relative4, resolve as resolve6 } from "node:path";
|
|
882
879
|
var reactRefreshPreamble = "";
|
|
883
880
|
function devHtmlPrerender(config) {
|
|
884
881
|
const htmlReloadId = "@wxt/reload-html";
|
|
@@ -908,22 +905,9 @@ function devHtmlPrerender(config) {
|
|
|
908
905
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
909
906
|
return;
|
|
910
907
|
const { document } = parseHTML2(code);
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
if (!src)
|
|
915
|
-
return;
|
|
916
|
-
if (isAbsolute(src)) {
|
|
917
|
-
element.setAttribute(attr, server.origin + src);
|
|
918
|
-
} else if (src.startsWith(".")) {
|
|
919
|
-
const abs = resolve6(dirname3(id), src);
|
|
920
|
-
const pathname = relative4(config.root, abs);
|
|
921
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
};
|
|
925
|
-
pointToDevServer("script[type=module]", "src");
|
|
926
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
908
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
909
|
+
_pointToDevServer("script[type=module]", "src");
|
|
910
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
927
911
|
const reloader = document.createElement("script");
|
|
928
912
|
reloader.src = htmlReloadId;
|
|
929
913
|
reloader.type = "module";
|
|
@@ -989,6 +973,48 @@ function devHtmlPrerender(config) {
|
|
|
989
973
|
}
|
|
990
974
|
];
|
|
991
975
|
}
|
|
976
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
977
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
978
|
+
const src = element.getAttribute(attr);
|
|
979
|
+
if (!src || isUrl(src))
|
|
980
|
+
return;
|
|
981
|
+
let resolvedAbsolutePath;
|
|
982
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
983
|
+
([key]) => src.startsWith(key)
|
|
984
|
+
);
|
|
985
|
+
if (matchingAlias) {
|
|
986
|
+
const [alias, replacement] = matchingAlias;
|
|
987
|
+
resolvedAbsolutePath = resolve6(
|
|
988
|
+
config.root,
|
|
989
|
+
src.replace(alias, replacement)
|
|
990
|
+
);
|
|
991
|
+
} else {
|
|
992
|
+
resolvedAbsolutePath = resolve6(dirname3(id), src);
|
|
993
|
+
}
|
|
994
|
+
if (resolvedAbsolutePath) {
|
|
995
|
+
const relativePath = normalizePath(
|
|
996
|
+
relative4(config.root, resolvedAbsolutePath)
|
|
997
|
+
);
|
|
998
|
+
if (relativePath.startsWith(".")) {
|
|
999
|
+
let path7 = normalizePath(resolvedAbsolutePath);
|
|
1000
|
+
if (!path7.startsWith("/"))
|
|
1001
|
+
path7 = "/" + path7;
|
|
1002
|
+
element.setAttribute(attr, `${server.origin}/@fs${path7}`);
|
|
1003
|
+
} else {
|
|
1004
|
+
const url = new URL(relativePath, server.origin);
|
|
1005
|
+
element.setAttribute(attr, url.href);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
function isUrl(str) {
|
|
1011
|
+
try {
|
|
1012
|
+
new URL(str);
|
|
1013
|
+
return true;
|
|
1014
|
+
} catch {
|
|
1015
|
+
return false;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
992
1018
|
|
|
993
1019
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
994
1020
|
function devServerGlobals(config) {
|
|
@@ -1988,6 +2014,11 @@ function getChunkSortWeight(filename) {
|
|
|
1988
2014
|
|
|
1989
2015
|
// src/core/utils/log/printHeader.ts
|
|
1990
2016
|
import pc4 from "picocolors";
|
|
2017
|
+
|
|
2018
|
+
// package.json
|
|
2019
|
+
var version = "0.15.2";
|
|
2020
|
+
|
|
2021
|
+
// src/core/utils/log/printHeader.ts
|
|
1991
2022
|
import { consola as consola2 } from "consola";
|
|
1992
2023
|
function printHeader() {
|
|
1993
2024
|
console.log();
|
|
@@ -2572,8 +2603,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
|
|
|
2572
2603
|
}
|
|
2573
2604
|
|
|
2574
2605
|
// src/core/utils/building/internal-build.ts
|
|
2575
|
-
import
|
|
2576
|
-
import { resolve as resolve13, relative as relative6 } from "node:path";
|
|
2606
|
+
import { relative as relative6 } from "node:path";
|
|
2577
2607
|
|
|
2578
2608
|
// src/core/utils/validation.ts
|
|
2579
2609
|
function validateEntrypoints(entrypoints) {
|
|
@@ -2636,6 +2666,19 @@ var ValidationError = class extends Error {
|
|
|
2636
2666
|
|
|
2637
2667
|
// src/core/utils/building/internal-build.ts
|
|
2638
2668
|
import consola3 from "consola";
|
|
2669
|
+
|
|
2670
|
+
// src/core/utils/exec.ts
|
|
2671
|
+
import managePath from "manage-path";
|
|
2672
|
+
import { resolve as resolve13 } from "node:path";
|
|
2673
|
+
var managedPath = managePath(process.env);
|
|
2674
|
+
var exec = async (config, file, args, options) => {
|
|
2675
|
+
managedPath.restore();
|
|
2676
|
+
managedPath.push(resolve13(config.root, "node_modules/wxt/node_modules/.bin"));
|
|
2677
|
+
const { execa } = await import("./execa-Y2EWTC4S.js");
|
|
2678
|
+
return await execa(file, args, options);
|
|
2679
|
+
};
|
|
2680
|
+
|
|
2681
|
+
// src/core/utils/building/internal-build.ts
|
|
2639
2682
|
async function internalBuild(config) {
|
|
2640
2683
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
2641
2684
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
@@ -2684,16 +2727,15 @@ async function internalBuild(config) {
|
|
|
2684
2727
|
return output;
|
|
2685
2728
|
}
|
|
2686
2729
|
async function combineAnalysisStats(config) {
|
|
2687
|
-
const { execaCommand } = await import("./execa-Y2EWTC4S.js");
|
|
2688
2730
|
const unixFiles = await glob3(`stats-*.json`, {
|
|
2689
2731
|
cwd: config.outDir,
|
|
2690
2732
|
absolute: true
|
|
2691
2733
|
});
|
|
2692
2734
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2735
|
+
await exec(
|
|
2736
|
+
config,
|
|
2737
|
+
"rollup-plugin-visualizer",
|
|
2738
|
+
[...absolutePaths, "--template", config.analysis.template],
|
|
2697
2739
|
{ cwd: config.root, stdio: "inherit" }
|
|
2698
2740
|
);
|
|
2699
2741
|
}
|
|
@@ -2779,6 +2821,7 @@ function createWslRunner() {
|
|
|
2779
2821
|
}
|
|
2780
2822
|
|
|
2781
2823
|
// src/core/runners/web-ext.ts
|
|
2824
|
+
import defu4 from "defu";
|
|
2782
2825
|
function createWebExtRunner() {
|
|
2783
2826
|
let runner;
|
|
2784
2827
|
return {
|
|
@@ -2809,6 +2852,10 @@ function createWebExtRunner() {
|
|
|
2809
2852
|
} : {
|
|
2810
2853
|
chromiumBinary: wxtUserConfig?.binaries?.[config.browser],
|
|
2811
2854
|
chromiumProfile: wxtUserConfig?.chromiumProfile,
|
|
2855
|
+
chromiumPref: defu4(
|
|
2856
|
+
wxtUserConfig?.chromiumPref,
|
|
2857
|
+
DEFAULT_CHROMIUM_PREFS
|
|
2858
|
+
),
|
|
2812
2859
|
args: wxtUserConfig?.chromiumArgs
|
|
2813
2860
|
}
|
|
2814
2861
|
};
|
|
@@ -2838,6 +2885,16 @@ function createWebExtRunner() {
|
|
|
2838
2885
|
}
|
|
2839
2886
|
var WARN_LOG_LEVEL = 40;
|
|
2840
2887
|
var ERROR_LOG_LEVEL = 50;
|
|
2888
|
+
var DEFAULT_CHROMIUM_PREFS = {
|
|
2889
|
+
devtools: {
|
|
2890
|
+
synced_preferences_sync_disabled: {
|
|
2891
|
+
// Remove content scripts from sourcemap debugger ignore list so stack traces
|
|
2892
|
+
// and log locations show up properly, see:
|
|
2893
|
+
// https://github.com/wxt-dev/wxt/issues/236#issuecomment-1915364520
|
|
2894
|
+
skipContentScripts: false
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
};
|
|
2841
2898
|
|
|
2842
2899
|
// src/core/runners/safari.ts
|
|
2843
2900
|
import { relative as relative8 } from "node:path";
|
|
@@ -3273,12 +3330,62 @@ async function zip(config) {
|
|
|
3273
3330
|
return zipFiles;
|
|
3274
3331
|
}
|
|
3275
3332
|
|
|
3276
|
-
// src/cli.ts
|
|
3333
|
+
// src/cli/cli-utils.ts
|
|
3277
3334
|
import consola7, { LogLevels as LogLevels2 } from "consola";
|
|
3278
|
-
|
|
3335
|
+
function wrapAction(cb, options) {
|
|
3336
|
+
return async (...args) => {
|
|
3337
|
+
const isDebug = !!args.find((arg) => arg?.debug);
|
|
3338
|
+
if (isDebug) {
|
|
3339
|
+
consola7.level = LogLevels2.debug;
|
|
3340
|
+
}
|
|
3341
|
+
const startTime = Date.now();
|
|
3342
|
+
try {
|
|
3343
|
+
printHeader();
|
|
3344
|
+
const status = await cb(...args);
|
|
3345
|
+
if (!status?.isOngoing && !options?.disableFinishedLog)
|
|
3346
|
+
consola7.success(
|
|
3347
|
+
`Finished in ${formatDuration(Date.now() - startTime)}`
|
|
3348
|
+
);
|
|
3349
|
+
} catch (err) {
|
|
3350
|
+
consola7.fail(
|
|
3351
|
+
`Command failed after ${formatDuration(Date.now() - startTime)}`
|
|
3352
|
+
);
|
|
3353
|
+
if (err instanceof ValidationError) {
|
|
3354
|
+
} else {
|
|
3355
|
+
consola7.error(err);
|
|
3356
|
+
}
|
|
3357
|
+
process.exit(1);
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
}
|
|
3361
|
+
function getArrayFromFlags(flags, name) {
|
|
3362
|
+
const array = [flags[name]].flat();
|
|
3363
|
+
const result = array.filter((item) => item != null);
|
|
3364
|
+
return result.length ? result : void 0;
|
|
3365
|
+
}
|
|
3366
|
+
var aliasCommandNames = /* @__PURE__ */ new Set();
|
|
3367
|
+
function createAliasedCommand(base, name, alias, docsUrl) {
|
|
3368
|
+
const aliasedCommand = base.command(name, `Alias for ${alias} (${docsUrl})`).allowUnknownOptions().action(async () => {
|
|
3369
|
+
try {
|
|
3370
|
+
const config = await getInternalConfig({}, "build");
|
|
3371
|
+
const args = process.argv.slice(
|
|
3372
|
+
process.argv.indexOf(aliasedCommand.name) + 1
|
|
3373
|
+
);
|
|
3374
|
+
await exec(config, alias, args, {
|
|
3375
|
+
stdio: "inherit"
|
|
3376
|
+
});
|
|
3377
|
+
} catch {
|
|
3378
|
+
process.exit(1);
|
|
3379
|
+
}
|
|
3380
|
+
});
|
|
3381
|
+
aliasCommandNames.add(aliasedCommand.name);
|
|
3382
|
+
}
|
|
3383
|
+
function isAliasedCommand(command) {
|
|
3384
|
+
return !!command && aliasCommandNames.has(command.name);
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
// src/cli/commands.ts
|
|
3279
3388
|
var cli = cac("wxt");
|
|
3280
|
-
cli.help();
|
|
3281
|
-
cli.version(version);
|
|
3282
3389
|
cli.option("--debug", "enable debug mode");
|
|
3283
3390
|
cli.command("[root]", "start dev server").option("-c, --config <file>", "use specified config file").option("-m, --mode <mode>", "set env mode").option("-b, --browser <browser>", "specify a browser").option(
|
|
3284
3391
|
"-e, --filter-entrypoint <entrypoint>",
|
|
@@ -3359,35 +3466,20 @@ cli.command("init [directory]", "initialize a new project").option("-t, --templa
|
|
|
3359
3466
|
{ disableFinishedLog: true }
|
|
3360
3467
|
)
|
|
3361
3468
|
);
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
} catch (err) {
|
|
3378
|
-
consola7.fail(
|
|
3379
|
-
`Command failed after ${formatDuration(Date.now() - startTime)}`
|
|
3380
|
-
);
|
|
3381
|
-
if (err instanceof ValidationError) {
|
|
3382
|
-
} else {
|
|
3383
|
-
consola7.error(err);
|
|
3384
|
-
}
|
|
3385
|
-
process.exit(1);
|
|
3386
|
-
}
|
|
3387
|
-
};
|
|
3388
|
-
}
|
|
3389
|
-
function getArrayFromFlags(flags, name) {
|
|
3390
|
-
const array = [flags[name]].flat();
|
|
3391
|
-
const result = array.filter((item) => item != null);
|
|
3392
|
-
return result.length ? result : void 0;
|
|
3469
|
+
createAliasedCommand(
|
|
3470
|
+
cli,
|
|
3471
|
+
"submit",
|
|
3472
|
+
"publish-extension",
|
|
3473
|
+
"https://www.npmjs.com/publish-browser-extension"
|
|
3474
|
+
);
|
|
3475
|
+
var commands_default = cli;
|
|
3476
|
+
|
|
3477
|
+
// src/cli/index.ts
|
|
3478
|
+
process.env.VITE_CJS_IGNORE_WARNING = "true";
|
|
3479
|
+
commands_default.parse(process.argv, { run: false });
|
|
3480
|
+
if (!isAliasedCommand(commands_default.matchedCommand)) {
|
|
3481
|
+
commands_default.help();
|
|
3482
|
+
commands_default.version(version);
|
|
3483
|
+
commands_default.parse(process.argv, { run: false });
|
|
3393
3484
|
}
|
|
3485
|
+
await commands_default.runMatchedCommand();
|
|
@@ -688,6 +688,33 @@ interface ExtensionRunnerConfig {
|
|
|
688
688
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
689
689
|
*/
|
|
690
690
|
chromiumProfile?: string;
|
|
691
|
+
/**
|
|
692
|
+
* An map of chrome preferences from https://chromium.googlesource.com/chromium/src/+/main/chrome/common/pref_names.h
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* // change your downloads directory
|
|
696
|
+
* {
|
|
697
|
+
* download: {
|
|
698
|
+
* default_directory: "/my/custom/dir",
|
|
699
|
+
* },
|
|
700
|
+
* }
|
|
701
|
+
*
|
|
702
|
+
* @default
|
|
703
|
+
* // Enable dev mode and allow content script sourcemaps
|
|
704
|
+
* {
|
|
705
|
+
* devtools: {
|
|
706
|
+
* synced_preferences_sync_disabled: {
|
|
707
|
+
* skipContentScripts: false,
|
|
708
|
+
* },
|
|
709
|
+
* }
|
|
710
|
+
* extensions: {
|
|
711
|
+
* ui: {
|
|
712
|
+
* developer_mode: true,
|
|
713
|
+
* },
|
|
714
|
+
* }
|
|
715
|
+
* }
|
|
716
|
+
*/
|
|
717
|
+
chromiumPref?: string;
|
|
691
718
|
/**
|
|
692
719
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
693
720
|
*/
|
|
@@ -688,6 +688,33 @@ interface ExtensionRunnerConfig {
|
|
|
688
688
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
689
689
|
*/
|
|
690
690
|
chromiumProfile?: string;
|
|
691
|
+
/**
|
|
692
|
+
* An map of chrome preferences from https://chromium.googlesource.com/chromium/src/+/main/chrome/common/pref_names.h
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* // change your downloads directory
|
|
696
|
+
* {
|
|
697
|
+
* download: {
|
|
698
|
+
* default_directory: "/my/custom/dir",
|
|
699
|
+
* },
|
|
700
|
+
* }
|
|
701
|
+
*
|
|
702
|
+
* @default
|
|
703
|
+
* // Enable dev mode and allow content script sourcemaps
|
|
704
|
+
* {
|
|
705
|
+
* devtools: {
|
|
706
|
+
* synced_preferences_sync_disabled: {
|
|
707
|
+
* skipContentScripts: false,
|
|
708
|
+
* },
|
|
709
|
+
* }
|
|
710
|
+
* extensions: {
|
|
711
|
+
* ui: {
|
|
712
|
+
* developer_mode: true,
|
|
713
|
+
* },
|
|
714
|
+
* }
|
|
715
|
+
* }
|
|
716
|
+
*/
|
|
717
|
+
chromiumPref?: string;
|
|
691
718
|
/**
|
|
692
719
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
693
720
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -3328,22 +3328,9 @@ function devHtmlPrerender(config) {
|
|
|
3328
3328
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
3329
3329
|
return;
|
|
3330
3330
|
const { document } = (0, import_linkedom2.parseHTML)(code);
|
|
3331
|
-
const
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
if (!src)
|
|
3335
|
-
return;
|
|
3336
|
-
if ((0, import_node_path4.isAbsolute)(src)) {
|
|
3337
|
-
element.setAttribute(attr, server.origin + src);
|
|
3338
|
-
} else if (src.startsWith(".")) {
|
|
3339
|
-
const abs = (0, import_node_path4.resolve)((0, import_node_path4.dirname)(id), src);
|
|
3340
|
-
const pathname = (0, import_node_path4.relative)(config.root, abs);
|
|
3341
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
3342
|
-
}
|
|
3343
|
-
});
|
|
3344
|
-
};
|
|
3345
|
-
pointToDevServer("script[type=module]", "src");
|
|
3346
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
3331
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
3332
|
+
_pointToDevServer("script[type=module]", "src");
|
|
3333
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
3347
3334
|
const reloader = document.createElement("script");
|
|
3348
3335
|
reloader.src = htmlReloadId;
|
|
3349
3336
|
reloader.type = "module";
|
|
@@ -3409,6 +3396,48 @@ function devHtmlPrerender(config) {
|
|
|
3409
3396
|
}
|
|
3410
3397
|
];
|
|
3411
3398
|
}
|
|
3399
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
3400
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
3401
|
+
const src = element.getAttribute(attr);
|
|
3402
|
+
if (!src || isUrl(src))
|
|
3403
|
+
return;
|
|
3404
|
+
let resolvedAbsolutePath;
|
|
3405
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
3406
|
+
([key]) => src.startsWith(key)
|
|
3407
|
+
);
|
|
3408
|
+
if (matchingAlias) {
|
|
3409
|
+
const [alias, replacement] = matchingAlias;
|
|
3410
|
+
resolvedAbsolutePath = (0, import_node_path4.resolve)(
|
|
3411
|
+
config.root,
|
|
3412
|
+
src.replace(alias, replacement)
|
|
3413
|
+
);
|
|
3414
|
+
} else {
|
|
3415
|
+
resolvedAbsolutePath = (0, import_node_path4.resolve)((0, import_node_path4.dirname)(id), src);
|
|
3416
|
+
}
|
|
3417
|
+
if (resolvedAbsolutePath) {
|
|
3418
|
+
const relativePath = normalizePath(
|
|
3419
|
+
(0, import_node_path4.relative)(config.root, resolvedAbsolutePath)
|
|
3420
|
+
);
|
|
3421
|
+
if (relativePath.startsWith(".")) {
|
|
3422
|
+
let path10 = normalizePath(resolvedAbsolutePath);
|
|
3423
|
+
if (!path10.startsWith("/"))
|
|
3424
|
+
path10 = "/" + path10;
|
|
3425
|
+
element.setAttribute(attr, `${server.origin}/@fs${path10}`);
|
|
3426
|
+
} else {
|
|
3427
|
+
const url2 = new URL(relativePath, server.origin);
|
|
3428
|
+
element.setAttribute(attr, url2.href);
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
});
|
|
3432
|
+
}
|
|
3433
|
+
function isUrl(str) {
|
|
3434
|
+
try {
|
|
3435
|
+
new URL(str);
|
|
3436
|
+
return true;
|
|
3437
|
+
} catch {
|
|
3438
|
+
return false;
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3412
3441
|
|
|
3413
3442
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
3414
3443
|
function devServerGlobals(config) {
|
|
@@ -4414,7 +4443,7 @@ function getChunkSortWeight(filename) {
|
|
|
4414
4443
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4415
4444
|
|
|
4416
4445
|
// package.json
|
|
4417
|
-
var version = "0.15.
|
|
4446
|
+
var version = "0.15.2";
|
|
4418
4447
|
|
|
4419
4448
|
// src/core/utils/log/printHeader.ts
|
|
4420
4449
|
var import_consola2 = require("consola");
|
|
@@ -4997,8 +5026,7 @@ async function rebuild(config, allEntrypoints, entrypointGroups, existingOutput
|
|
|
4997
5026
|
}
|
|
4998
5027
|
|
|
4999
5028
|
// src/core/utils/building/internal-build.ts
|
|
5000
|
-
var
|
|
5001
|
-
var import_node_path13 = require("path");
|
|
5029
|
+
var import_node_path14 = require("path");
|
|
5002
5030
|
|
|
5003
5031
|
// src/core/utils/validation.ts
|
|
5004
5032
|
function validateEntrypoints(entrypoints) {
|
|
@@ -5061,6 +5089,19 @@ var ValidationError = class extends Error {
|
|
|
5061
5089
|
|
|
5062
5090
|
// src/core/utils/building/internal-build.ts
|
|
5063
5091
|
var import_consola3 = __toESM(require("consola"), 1);
|
|
5092
|
+
|
|
5093
|
+
// src/core/utils/exec.ts
|
|
5094
|
+
var import_manage_path = __toESM(require("manage-path"), 1);
|
|
5095
|
+
var import_node_path13 = require("path");
|
|
5096
|
+
var managedPath = (0, import_manage_path.default)(process.env);
|
|
5097
|
+
var exec = async (config, file, args, options) => {
|
|
5098
|
+
managedPath.restore();
|
|
5099
|
+
managedPath.push((0, import_node_path13.resolve)(config.root, "node_modules/wxt/node_modules/.bin"));
|
|
5100
|
+
const { execa: execa2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
|
|
5101
|
+
return await execa2(file, args, options);
|
|
5102
|
+
};
|
|
5103
|
+
|
|
5104
|
+
// src/core/utils/building/internal-build.ts
|
|
5064
5105
|
async function internalBuild(config) {
|
|
5065
5106
|
const verb = config.command === "serve" ? "Pre-rendering" : "Building";
|
|
5066
5107
|
const target = `${config.browser}-mv${config.manifestVersion}`;
|
|
@@ -5109,16 +5150,15 @@ async function internalBuild(config) {
|
|
|
5109
5150
|
return output;
|
|
5110
5151
|
}
|
|
5111
5152
|
async function combineAnalysisStats(config) {
|
|
5112
|
-
const { execaCommand: execaCommand2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
|
|
5113
5153
|
const unixFiles = await (0, import_fast_glob3.default)(`stats-*.json`, {
|
|
5114
5154
|
cwd: config.outDir,
|
|
5115
5155
|
absolute: true
|
|
5116
5156
|
});
|
|
5117
5157
|
const absolutePaths = unixFiles.map(unnormalizePath);
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5158
|
+
await exec(
|
|
5159
|
+
config,
|
|
5160
|
+
"rollup-plugin-visualizer",
|
|
5161
|
+
[...absolutePaths, "--template", config.analysis.template],
|
|
5122
5162
|
{ cwd: config.root, stdio: "inherit" }
|
|
5123
5163
|
);
|
|
5124
5164
|
}
|
|
@@ -5134,7 +5174,7 @@ function printValidationResults(config, { errorCount, errors, warningCount }) {
|
|
|
5134
5174
|
return map;
|
|
5135
5175
|
}, /* @__PURE__ */ new Map());
|
|
5136
5176
|
Array.from(entrypointErrors.entries()).forEach(([entrypoint, errors2]) => {
|
|
5137
|
-
import_consola3.default.log((0,
|
|
5177
|
+
import_consola3.default.log((0, import_node_path14.relative)(cwd, entrypoint.inputPath));
|
|
5138
5178
|
console.log();
|
|
5139
5179
|
errors2.forEach((err) => {
|
|
5140
5180
|
const type = err.type === "error" ? import_picocolors5.default.red("ERROR") : import_picocolors5.default.yellow("WARN");
|
|
@@ -5152,7 +5192,7 @@ async function build(config) {
|
|
|
5152
5192
|
}
|
|
5153
5193
|
|
|
5154
5194
|
// src/core/clean.ts
|
|
5155
|
-
var
|
|
5195
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
5156
5196
|
var import_fast_glob4 = __toESM(require("fast-glob"), 1);
|
|
5157
5197
|
var import_fs_extra13 = __toESM(require("fs-extra"), 1);
|
|
5158
5198
|
var import_consola4 = require("consola");
|
|
@@ -5167,7 +5207,7 @@ async function clean(root = process.cwd()) {
|
|
|
5167
5207
|
];
|
|
5168
5208
|
import_consola4.consola.debug("Looking for:", tempDirs.map(import_picocolors6.default.cyan).join(", "));
|
|
5169
5209
|
const directories = await (0, import_fast_glob4.default)(tempDirs, {
|
|
5170
|
-
cwd:
|
|
5210
|
+
cwd: import_node_path15.default.resolve(root),
|
|
5171
5211
|
absolute: true,
|
|
5172
5212
|
onlyDirectories: true,
|
|
5173
5213
|
deep: 2
|
|
@@ -5178,11 +5218,11 @@ async function clean(root = process.cwd()) {
|
|
|
5178
5218
|
}
|
|
5179
5219
|
import_consola4.consola.debug(
|
|
5180
5220
|
"Found:",
|
|
5181
|
-
directories.map((dir) => import_picocolors6.default.cyan(
|
|
5221
|
+
directories.map((dir) => import_picocolors6.default.cyan(import_node_path15.default.relative(root, dir))).join(", ")
|
|
5182
5222
|
);
|
|
5183
5223
|
for (const directory of directories) {
|
|
5184
5224
|
await import_fs_extra13.default.rm(directory, { force: true, recursive: true });
|
|
5185
|
-
import_consola4.consola.debug("Deleted " + import_picocolors6.default.cyan(
|
|
5225
|
+
import_consola4.consola.debug("Deleted " + import_picocolors6.default.cyan(import_node_path15.default.relative(root, directory)));
|
|
5186
5226
|
}
|
|
5187
5227
|
}
|
|
5188
5228
|
|
|
@@ -5197,12 +5237,12 @@ function defineRunnerConfig(config) {
|
|
|
5197
5237
|
}
|
|
5198
5238
|
|
|
5199
5239
|
// src/core/runners/wsl.ts
|
|
5200
|
-
var
|
|
5240
|
+
var import_node_path16 = require("path");
|
|
5201
5241
|
function createWslRunner() {
|
|
5202
5242
|
return {
|
|
5203
5243
|
async openBrowser(config) {
|
|
5204
5244
|
config.logger.warn(
|
|
5205
|
-
`Cannot open browser when using WSL. Load "${(0,
|
|
5245
|
+
`Cannot open browser when using WSL. Load "${(0, import_node_path16.relative)(
|
|
5206
5246
|
process.cwd(),
|
|
5207
5247
|
config.outDir
|
|
5208
5248
|
)}" as an unpacked extension manually`
|
|
@@ -5214,6 +5254,7 @@ function createWslRunner() {
|
|
|
5214
5254
|
}
|
|
5215
5255
|
|
|
5216
5256
|
// src/core/runners/web-ext.ts
|
|
5257
|
+
var import_defu4 = __toESM(require("defu"), 1);
|
|
5217
5258
|
function createWebExtRunner() {
|
|
5218
5259
|
let runner;
|
|
5219
5260
|
return {
|
|
@@ -5244,6 +5285,10 @@ function createWebExtRunner() {
|
|
|
5244
5285
|
} : {
|
|
5245
5286
|
chromiumBinary: wxtUserConfig?.binaries?.[config.browser],
|
|
5246
5287
|
chromiumProfile: wxtUserConfig?.chromiumProfile,
|
|
5288
|
+
chromiumPref: (0, import_defu4.default)(
|
|
5289
|
+
wxtUserConfig?.chromiumPref,
|
|
5290
|
+
DEFAULT_CHROMIUM_PREFS
|
|
5291
|
+
),
|
|
5247
5292
|
args: wxtUserConfig?.chromiumArgs
|
|
5248
5293
|
}
|
|
5249
5294
|
};
|
|
@@ -5273,14 +5318,24 @@ function createWebExtRunner() {
|
|
|
5273
5318
|
}
|
|
5274
5319
|
var WARN_LOG_LEVEL = 40;
|
|
5275
5320
|
var ERROR_LOG_LEVEL = 50;
|
|
5321
|
+
var DEFAULT_CHROMIUM_PREFS = {
|
|
5322
|
+
devtools: {
|
|
5323
|
+
synced_preferences_sync_disabled: {
|
|
5324
|
+
// Remove content scripts from sourcemap debugger ignore list so stack traces
|
|
5325
|
+
// and log locations show up properly, see:
|
|
5326
|
+
// https://github.com/wxt-dev/wxt/issues/236#issuecomment-1915364520
|
|
5327
|
+
skipContentScripts: false
|
|
5328
|
+
}
|
|
5329
|
+
}
|
|
5330
|
+
};
|
|
5276
5331
|
|
|
5277
5332
|
// src/core/runners/safari.ts
|
|
5278
|
-
var
|
|
5333
|
+
var import_node_path17 = require("path");
|
|
5279
5334
|
function createSafariRunner() {
|
|
5280
5335
|
return {
|
|
5281
5336
|
async openBrowser(config) {
|
|
5282
5337
|
config.logger.warn(
|
|
5283
|
-
`Cannot Safari using web-ext. Load "${(0,
|
|
5338
|
+
`Cannot Safari using web-ext. Load "${(0, import_node_path17.relative)(
|
|
5284
5339
|
process.cwd(),
|
|
5285
5340
|
config.outDir
|
|
5286
5341
|
)}" as an unpacked extension manually`
|
|
@@ -5292,12 +5347,12 @@ function createSafariRunner() {
|
|
|
5292
5347
|
}
|
|
5293
5348
|
|
|
5294
5349
|
// src/core/runners/manual.ts
|
|
5295
|
-
var
|
|
5350
|
+
var import_node_path18 = require("path");
|
|
5296
5351
|
function createManualRunner() {
|
|
5297
5352
|
return {
|
|
5298
5353
|
async openBrowser(config) {
|
|
5299
5354
|
config.logger.info(
|
|
5300
|
-
`Load "${(0,
|
|
5355
|
+
`Load "${(0, import_node_path18.relative)(
|
|
5301
5356
|
process.cwd(),
|
|
5302
5357
|
config.outDir
|
|
5303
5358
|
)}" as an unpacked extension manually`
|
|
@@ -5329,7 +5384,7 @@ async function createExtensionRunner(config) {
|
|
|
5329
5384
|
var import_consola5 = require("consola");
|
|
5330
5385
|
var import_async_mutex = require("async-mutex");
|
|
5331
5386
|
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
5332
|
-
var
|
|
5387
|
+
var import_node_path19 = require("path");
|
|
5333
5388
|
async function createServer(inlineConfig) {
|
|
5334
5389
|
const port = await getPort();
|
|
5335
5390
|
const hostname = "localhost";
|
|
@@ -5446,11 +5501,11 @@ function createFileReloader(options) {
|
|
|
5446
5501
|
return;
|
|
5447
5502
|
}
|
|
5448
5503
|
config.logger.info(
|
|
5449
|
-
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0,
|
|
5504
|
+
`Changed: ${Array.from(new Set(fileChanges)).map((file) => import_picocolors7.default.dim((0, import_node_path19.relative)(config.root, file))).join(", ")}`
|
|
5450
5505
|
);
|
|
5451
5506
|
const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
|
|
5452
5507
|
return import_picocolors7.default.cyan(
|
|
5453
|
-
(0,
|
|
5508
|
+
(0, import_node_path19.relative)(config.outDir, getEntrypointOutputFile(entry, ""))
|
|
5454
5509
|
);
|
|
5455
5510
|
}).join(import_picocolors7.default.dim(", "));
|
|
5456
5511
|
const allEntrypoints = await findEntrypoints(config);
|
|
@@ -5521,7 +5576,7 @@ var import_prompts = __toESM(require("prompts"), 1);
|
|
|
5521
5576
|
var import_consola6 = require("consola");
|
|
5522
5577
|
var import_giget = require("giget");
|
|
5523
5578
|
var import_fs_extra14 = __toESM(require("fs-extra"), 1);
|
|
5524
|
-
var
|
|
5579
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
5525
5580
|
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
5526
5581
|
async function initialize(options) {
|
|
5527
5582
|
import_consola6.consola.info("Initalizing new project");
|
|
@@ -5569,7 +5624,7 @@ async function initialize(options) {
|
|
|
5569
5624
|
input.template ??= defaultTemplate;
|
|
5570
5625
|
input.packageManager ??= options.packageManager;
|
|
5571
5626
|
await cloneProject(input);
|
|
5572
|
-
const cdPath =
|
|
5627
|
+
const cdPath = import_node_path20.default.relative(process.cwd(), import_node_path20.default.resolve(input.directory));
|
|
5573
5628
|
console.log();
|
|
5574
5629
|
import_consola6.consola.log(
|
|
5575
5630
|
`\u2728 WXT project created with the ${TEMPLATE_COLORS[input.template.name]?.(input.template.name) ?? input.template.name} template.`
|
|
@@ -5621,8 +5676,8 @@ async function cloneProject({
|
|
|
5621
5676
|
force: true
|
|
5622
5677
|
});
|
|
5623
5678
|
await import_fs_extra14.default.move(
|
|
5624
|
-
|
|
5625
|
-
|
|
5679
|
+
import_node_path20.default.join(directory, "_gitignore"),
|
|
5680
|
+
import_node_path20.default.join(directory, ".gitignore")
|
|
5626
5681
|
).catch(
|
|
5627
5682
|
(err) => import_consola6.consola.warn("Failed to move _gitignore to .gitignore:", err)
|
|
5628
5683
|
);
|
|
@@ -5655,7 +5710,7 @@ async function prepare(config) {
|
|
|
5655
5710
|
|
|
5656
5711
|
// src/core/zip.ts
|
|
5657
5712
|
var import_zip_dir = __toESM(require("zip-dir"), 1);
|
|
5658
|
-
var
|
|
5713
|
+
var import_node_path21 = require("path");
|
|
5659
5714
|
var import_fs_extra15 = __toESM(require("fs-extra"), 1);
|
|
5660
5715
|
var import_minimatch2 = require("minimatch");
|
|
5661
5716
|
async function zip(config) {
|
|
@@ -5665,7 +5720,7 @@ async function zip(config) {
|
|
|
5665
5720
|
internalConfig.logger.info("Zipping extension...");
|
|
5666
5721
|
const zipFiles = [];
|
|
5667
5722
|
const projectName = internalConfig.zip.name ?? kebabCaseAlphanumeric(
|
|
5668
|
-
(await getPackageJson(internalConfig))?.name || (0,
|
|
5723
|
+
(await getPackageJson(internalConfig))?.name || (0, import_node_path21.dirname)(process.cwd())
|
|
5669
5724
|
);
|
|
5670
5725
|
const applyTemplate = (template) => template.replaceAll("{{name}}", projectName).replaceAll("{{browser}}", internalConfig.browser).replaceAll(
|
|
5671
5726
|
"{{version}}",
|
|
@@ -5673,7 +5728,7 @@ async function zip(config) {
|
|
|
5673
5728
|
).replaceAll("{{manifestVersion}}", `mv${internalConfig.manifestVersion}`);
|
|
5674
5729
|
await import_fs_extra15.default.ensureDir(internalConfig.outBaseDir);
|
|
5675
5730
|
const outZipFilename = applyTemplate(internalConfig.zip.artifactTemplate);
|
|
5676
|
-
const outZipPath = (0,
|
|
5731
|
+
const outZipPath = (0, import_node_path21.resolve)(internalConfig.outBaseDir, outZipFilename);
|
|
5677
5732
|
await (0, import_zip_dir.default)(internalConfig.outDir, {
|
|
5678
5733
|
saveTo: outZipPath
|
|
5679
5734
|
});
|
|
@@ -5682,14 +5737,14 @@ async function zip(config) {
|
|
|
5682
5737
|
const sourcesZipFilename = applyTemplate(
|
|
5683
5738
|
internalConfig.zip.sourcesTemplate
|
|
5684
5739
|
);
|
|
5685
|
-
const sourcesZipPath = (0,
|
|
5740
|
+
const sourcesZipPath = (0, import_node_path21.resolve)(
|
|
5686
5741
|
internalConfig.outBaseDir,
|
|
5687
5742
|
sourcesZipFilename
|
|
5688
5743
|
);
|
|
5689
5744
|
await (0, import_zip_dir.default)(internalConfig.zip.sourcesRoot, {
|
|
5690
5745
|
saveTo: sourcesZipPath,
|
|
5691
5746
|
filter(path10) {
|
|
5692
|
-
const relativePath = (0,
|
|
5747
|
+
const relativePath = (0, import_node_path21.relative)(internalConfig.zip.sourcesRoot, path10);
|
|
5693
5748
|
return internalConfig.zip.includeSources.some(
|
|
5694
5749
|
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5695
5750
|
) || !internalConfig.zip.excludeSources.some(
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-
|
|
2
|
-
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-2QTHXYDU.cjs';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-2QTHXYDU.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.15.
|
|
65
|
+
var version = "0.15.2";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-
|
|
2
|
-
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-2QTHXYDU.js';
|
|
2
|
+
export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-2QTHXYDU.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
62
62
|
*/
|
|
63
63
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
64
64
|
|
|
65
|
-
var version = "0.15.
|
|
65
|
+
var version = "0.15.2";
|
|
66
66
|
|
|
67
67
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
rebuild,
|
|
16
16
|
resolvePerBrowserOption,
|
|
17
17
|
version
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-QEFFZE4W.js";
|
|
19
19
|
import "./chunk-VBXJIVYU.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
@@ -87,6 +87,7 @@ function createWslRunner() {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// src/core/runners/web-ext.ts
|
|
90
|
+
import defu from "defu";
|
|
90
91
|
function createWebExtRunner() {
|
|
91
92
|
let runner;
|
|
92
93
|
return {
|
|
@@ -117,6 +118,10 @@ function createWebExtRunner() {
|
|
|
117
118
|
} : {
|
|
118
119
|
chromiumBinary: wxtUserConfig?.binaries?.[config.browser],
|
|
119
120
|
chromiumProfile: wxtUserConfig?.chromiumProfile,
|
|
121
|
+
chromiumPref: defu(
|
|
122
|
+
wxtUserConfig?.chromiumPref,
|
|
123
|
+
DEFAULT_CHROMIUM_PREFS
|
|
124
|
+
),
|
|
120
125
|
args: wxtUserConfig?.chromiumArgs
|
|
121
126
|
}
|
|
122
127
|
};
|
|
@@ -146,6 +151,16 @@ function createWebExtRunner() {
|
|
|
146
151
|
}
|
|
147
152
|
var WARN_LOG_LEVEL = 40;
|
|
148
153
|
var ERROR_LOG_LEVEL = 50;
|
|
154
|
+
var DEFAULT_CHROMIUM_PREFS = {
|
|
155
|
+
devtools: {
|
|
156
|
+
synced_preferences_sync_disabled: {
|
|
157
|
+
// Remove content scripts from sourcemap debugger ignore list so stack traces
|
|
158
|
+
// and log locations show up properly, see:
|
|
159
|
+
// https://github.com/wxt-dev/wxt/issues/236#issuecomment-1915364520
|
|
160
|
+
skipContentScripts: false
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
149
164
|
|
|
150
165
|
// src/core/runners/safari.ts
|
|
151
166
|
import { relative as relative2 } from "node:path";
|
package/dist/testing.cjs
CHANGED
|
@@ -97,22 +97,9 @@ function devHtmlPrerender(config) {
|
|
|
97
97
|
if (config.command !== "serve" || server == null || !id.endsWith(".html"))
|
|
98
98
|
return;
|
|
99
99
|
const { document } = (0, import_linkedom.parseHTML)(code);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!src)
|
|
104
|
-
return;
|
|
105
|
-
if ((0, import_node_path3.isAbsolute)(src)) {
|
|
106
|
-
element.setAttribute(attr, server.origin + src);
|
|
107
|
-
} else if (src.startsWith(".")) {
|
|
108
|
-
const abs = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(id), src);
|
|
109
|
-
const pathname = (0, import_node_path3.relative)(config.root, abs);
|
|
110
|
-
element.setAttribute(attr, `${server.origin}/${pathname}`);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
pointToDevServer("script[type=module]", "src");
|
|
115
|
-
pointToDevServer("link[rel=stylesheet]", "href");
|
|
100
|
+
const _pointToDevServer = (querySelector, attr) => pointToDevServer(config, server, id, document, querySelector, attr);
|
|
101
|
+
_pointToDevServer("script[type=module]", "src");
|
|
102
|
+
_pointToDevServer("link[rel=stylesheet]", "href");
|
|
116
103
|
const reloader = document.createElement("script");
|
|
117
104
|
reloader.src = htmlReloadId;
|
|
118
105
|
reloader.type = "module";
|
|
@@ -178,6 +165,48 @@ function devHtmlPrerender(config) {
|
|
|
178
165
|
}
|
|
179
166
|
];
|
|
180
167
|
}
|
|
168
|
+
function pointToDevServer(config, server, id, document, querySelector, attr) {
|
|
169
|
+
document.querySelectorAll(querySelector).forEach((element) => {
|
|
170
|
+
const src = element.getAttribute(attr);
|
|
171
|
+
if (!src || isUrl(src))
|
|
172
|
+
return;
|
|
173
|
+
let resolvedAbsolutePath;
|
|
174
|
+
const matchingAlias = Object.entries(config.alias).find(
|
|
175
|
+
([key]) => src.startsWith(key)
|
|
176
|
+
);
|
|
177
|
+
if (matchingAlias) {
|
|
178
|
+
const [alias, replacement] = matchingAlias;
|
|
179
|
+
resolvedAbsolutePath = (0, import_node_path3.resolve)(
|
|
180
|
+
config.root,
|
|
181
|
+
src.replace(alias, replacement)
|
|
182
|
+
);
|
|
183
|
+
} else {
|
|
184
|
+
resolvedAbsolutePath = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(id), src);
|
|
185
|
+
}
|
|
186
|
+
if (resolvedAbsolutePath) {
|
|
187
|
+
const relativePath = normalizePath(
|
|
188
|
+
(0, import_node_path3.relative)(config.root, resolvedAbsolutePath)
|
|
189
|
+
);
|
|
190
|
+
if (relativePath.startsWith(".")) {
|
|
191
|
+
let path6 = normalizePath(resolvedAbsolutePath);
|
|
192
|
+
if (!path6.startsWith("/"))
|
|
193
|
+
path6 = "/" + path6;
|
|
194
|
+
element.setAttribute(attr, `${server.origin}/@fs${path6}`);
|
|
195
|
+
} else {
|
|
196
|
+
const url = new URL(relativePath, server.origin);
|
|
197
|
+
element.setAttribute(attr, url.href);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function isUrl(str) {
|
|
203
|
+
try {
|
|
204
|
+
new URL(str);
|
|
205
|
+
return true;
|
|
206
|
+
} catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
181
210
|
|
|
182
211
|
// src/core/builders/vite/plugins/devServerGlobals.ts
|
|
183
212
|
function devServerGlobals(config) {
|
|
@@ -1170,9 +1199,13 @@ var import_immer = require("immer");
|
|
|
1170
1199
|
var import_defu3 = __toESM(require("defu"), 1);
|
|
1171
1200
|
|
|
1172
1201
|
// src/core/utils/building/internal-build.ts
|
|
1202
|
+
var import_node_path12 = require("path");
|
|
1203
|
+
var import_consola3 = __toESM(require("consola"), 1);
|
|
1204
|
+
|
|
1205
|
+
// src/core/utils/exec.ts
|
|
1173
1206
|
var import_manage_path = __toESM(require("manage-path"), 1);
|
|
1174
1207
|
var import_node_path11 = require("path");
|
|
1175
|
-
var
|
|
1208
|
+
var managedPath = (0, import_manage_path.default)(process.env);
|
|
1176
1209
|
|
|
1177
1210
|
// src/testing/wxt-vitest-plugin.ts
|
|
1178
1211
|
function WxtVitest(inlineConfig) {
|
package/dist/testing.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './external-
|
|
3
|
+
import { I as InlineConfig } from './external-2QTHXYDU.cjs';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
|
|
2
2
|
import * as vite from 'vite';
|
|
3
|
-
import { I as InlineConfig } from './external-
|
|
3
|
+
import { I as InlineConfig } from './external-2QTHXYDU.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.2",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -111,10 +111,11 @@
|
|
|
111
111
|
"ora": "^7.0.1",
|
|
112
112
|
"picocolors": "^1.0.0",
|
|
113
113
|
"prompts": "^2.4.2",
|
|
114
|
+
"publish-browser-extension": "^2.0.0",
|
|
114
115
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
115
116
|
"unimport": "^3.4.0",
|
|
116
|
-
"vite": "^5.0.
|
|
117
|
-
"web-ext-run": "^0.
|
|
117
|
+
"vite": "^5.0.12",
|
|
118
|
+
"web-ext-run": "^0.2.0",
|
|
118
119
|
"webextension-polyfill": "^0.10.0",
|
|
119
120
|
"zip-dir": "^2.0.0"
|
|
120
121
|
},
|
|
@@ -160,7 +161,7 @@
|
|
|
160
161
|
]
|
|
161
162
|
},
|
|
162
163
|
"scripts": {
|
|
163
|
-
"wxt": "tsx src/cli.ts",
|
|
164
|
+
"wxt": "tsx src/cli/index.ts",
|
|
164
165
|
"build": "tsx scripts/build.ts",
|
|
165
166
|
"format": "prettier --write .",
|
|
166
167
|
"format:check": "prettier --check .",
|