wxt 0.14.7 → 0.15.1
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-NDW6LQ5D.js → chunk-T57ALCJ4.js} +30 -21
- package/dist/cli.js +48 -23
- package/dist/client.js +4 -2
- package/dist/{external-mJ1bW7iy.d.cts → external-2QTHXYDU.d.cts} +42 -2
- package/dist/{external-mJ1bW7iy.d.ts → external-2QTHXYDU.d.ts} +42 -2
- package/dist/index.cjs +48 -23
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +19 -3
- package/dist/testing.cjs +22 -17
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/virtual/background-entrypoint.js +2 -2
- package/dist/virtual/content-script-isolated-world-entrypoint.js +2 -2
- package/dist/virtual/content-script-main-world-entrypoint.js +1 -1
- package/dist/virtual/reload-html.js +1 -1
- package/dist/virtual/unlisted-script-entrypoint.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.15.1";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -235,42 +235,42 @@ function getUnimportOptions(config) {
|
|
|
235
235
|
function getGlobals(config) {
|
|
236
236
|
return [
|
|
237
237
|
{
|
|
238
|
-
name:
|
|
238
|
+
name: "MANIFEST_VERSION",
|
|
239
239
|
value: config.manifestVersion,
|
|
240
240
|
type: `2 | 3`
|
|
241
241
|
},
|
|
242
242
|
{
|
|
243
|
-
name:
|
|
243
|
+
name: "BROWSER",
|
|
244
244
|
value: config.browser,
|
|
245
245
|
type: `string`
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
|
-
name:
|
|
248
|
+
name: "CHROME",
|
|
249
249
|
value: config.browser === "chrome",
|
|
250
250
|
type: `boolean`
|
|
251
251
|
},
|
|
252
252
|
{
|
|
253
|
-
name:
|
|
253
|
+
name: "FIREFOX",
|
|
254
254
|
value: config.browser === "firefox",
|
|
255
255
|
type: `boolean`
|
|
256
256
|
},
|
|
257
257
|
{
|
|
258
|
-
name:
|
|
258
|
+
name: "SAFARI",
|
|
259
259
|
value: config.browser === "safari",
|
|
260
260
|
type: `boolean`
|
|
261
261
|
},
|
|
262
262
|
{
|
|
263
|
-
name:
|
|
263
|
+
name: "EDGE",
|
|
264
264
|
value: config.browser === "edge",
|
|
265
265
|
type: `boolean`
|
|
266
266
|
},
|
|
267
267
|
{
|
|
268
|
-
name:
|
|
268
|
+
name: "OPERA",
|
|
269
269
|
value: config.browser === "opera",
|
|
270
270
|
type: `boolean`
|
|
271
271
|
},
|
|
272
272
|
{
|
|
273
|
-
name:
|
|
273
|
+
name: "COMMAND",
|
|
274
274
|
value: config.command,
|
|
275
275
|
type: `"build" | "serve"`
|
|
276
276
|
}
|
|
@@ -279,15 +279,12 @@ function getGlobals(config) {
|
|
|
279
279
|
function getEntrypointGlobals(entrypointName) {
|
|
280
280
|
return [
|
|
281
281
|
{
|
|
282
|
-
name:
|
|
282
|
+
name: "ENTRYPOINT",
|
|
283
283
|
value: entrypointName,
|
|
284
284
|
type: `string`
|
|
285
285
|
}
|
|
286
286
|
];
|
|
287
287
|
}
|
|
288
|
-
function surroundInUnderscore(name) {
|
|
289
|
-
return `__${name}__`;
|
|
290
|
-
}
|
|
291
288
|
|
|
292
289
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
293
290
|
import path2 from "node:path";
|
|
@@ -420,7 +417,7 @@ declare module "wxt/browser" {
|
|
|
420
417
|
}
|
|
421
418
|
const overrides = messages.map((message) => {
|
|
422
419
|
return ` /**
|
|
423
|
-
* ${message.description
|
|
420
|
+
* ${message.description || "No message description."}
|
|
424
421
|
*
|
|
425
422
|
* "${message.message}"
|
|
426
423
|
*/
|
|
@@ -444,8 +441,11 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
444
441
|
[
|
|
445
442
|
"// Generated by wxt",
|
|
446
443
|
"export {}",
|
|
447
|
-
"
|
|
448
|
-
...globals2.map((global) => `
|
|
444
|
+
"interface ImportMetaEnv {",
|
|
445
|
+
...globals2.map((global) => ` readonly ${global.name}: ${global.type};`),
|
|
446
|
+
"}",
|
|
447
|
+
"interface ImportMeta {",
|
|
448
|
+
" readonly env: ImportMetaEnv",
|
|
449
449
|
"}"
|
|
450
450
|
].join("\n") + "\n"
|
|
451
451
|
);
|
|
@@ -826,7 +826,11 @@ function unimport(config) {
|
|
|
826
826
|
return;
|
|
827
827
|
if (!ENABLED_EXTENSIONS.has(extname2(id)))
|
|
828
828
|
return;
|
|
829
|
-
|
|
829
|
+
const injected = await unimport2.injectImports(code, id);
|
|
830
|
+
return {
|
|
831
|
+
code: injected.code,
|
|
832
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
833
|
+
};
|
|
830
834
|
}
|
|
831
835
|
};
|
|
832
836
|
}
|
|
@@ -940,7 +944,7 @@ function globals(config) {
|
|
|
940
944
|
config() {
|
|
941
945
|
const define = {};
|
|
942
946
|
for (const global of getGlobals(config)) {
|
|
943
|
-
define[global.name] = JSON.stringify(global.value);
|
|
947
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
944
948
|
}
|
|
945
949
|
return {
|
|
946
950
|
define
|
|
@@ -1006,7 +1010,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
1006
1010
|
const define = {};
|
|
1007
1011
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
1008
1012
|
for (const global of getEntrypointGlobals(name)) {
|
|
1009
|
-
define[global.name] = JSON.stringify(global.value);
|
|
1013
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
1010
1014
|
}
|
|
1011
1015
|
return {
|
|
1012
1016
|
define
|
|
@@ -1035,6 +1039,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1035
1039
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
1036
1040
|
config.build.minify = false;
|
|
1037
1041
|
}
|
|
1042
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
1043
|
+
config.build.sourcemap = "inline";
|
|
1044
|
+
}
|
|
1038
1045
|
config.plugins ??= [];
|
|
1039
1046
|
config.plugins.push(
|
|
1040
1047
|
download(wxtConfig),
|
|
@@ -1397,8 +1404,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1397
1404
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
1398
1405
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
1399
1406
|
sourcesRoot: root,
|
|
1407
|
+
includeSources: [],
|
|
1400
1408
|
...mergedConfig.zip,
|
|
1401
|
-
|
|
1409
|
+
excludeSources: [
|
|
1402
1410
|
"**/node_modules",
|
|
1403
1411
|
// WXT files
|
|
1404
1412
|
"**/web-ext.config.ts",
|
|
@@ -1408,7 +1416,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1408
1416
|
"**/__tests__/**",
|
|
1409
1417
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1410
1418
|
// From user
|
|
1411
|
-
...mergedConfig.zip?.
|
|
1419
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
1412
1420
|
]
|
|
1413
1421
|
};
|
|
1414
1422
|
}
|
|
@@ -1538,6 +1546,7 @@ async function importEntrypointFile(path6, config) {
|
|
|
1538
1546
|
{ cause: err }
|
|
1539
1547
|
);
|
|
1540
1548
|
} else {
|
|
1549
|
+
config.logger.error(err);
|
|
1541
1550
|
throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err });
|
|
1542
1551
|
}
|
|
1543
1552
|
}
|
package/dist/cli.js
CHANGED
|
@@ -5,7 +5,7 @@ import "./chunk-73I7FAJU.js";
|
|
|
5
5
|
import cac from "cac";
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.15.1";
|
|
9
9
|
|
|
10
10
|
// src/core/utils/fs.ts
|
|
11
11
|
import fs from "fs-extra";
|
|
@@ -580,42 +580,42 @@ function getUnimportOptions(config) {
|
|
|
580
580
|
function getGlobals(config) {
|
|
581
581
|
return [
|
|
582
582
|
{
|
|
583
|
-
name:
|
|
583
|
+
name: "MANIFEST_VERSION",
|
|
584
584
|
value: config.manifestVersion,
|
|
585
585
|
type: `2 | 3`
|
|
586
586
|
},
|
|
587
587
|
{
|
|
588
|
-
name:
|
|
588
|
+
name: "BROWSER",
|
|
589
589
|
value: config.browser,
|
|
590
590
|
type: `string`
|
|
591
591
|
},
|
|
592
592
|
{
|
|
593
|
-
name:
|
|
593
|
+
name: "CHROME",
|
|
594
594
|
value: config.browser === "chrome",
|
|
595
595
|
type: `boolean`
|
|
596
596
|
},
|
|
597
597
|
{
|
|
598
|
-
name:
|
|
598
|
+
name: "FIREFOX",
|
|
599
599
|
value: config.browser === "firefox",
|
|
600
600
|
type: `boolean`
|
|
601
601
|
},
|
|
602
602
|
{
|
|
603
|
-
name:
|
|
603
|
+
name: "SAFARI",
|
|
604
604
|
value: config.browser === "safari",
|
|
605
605
|
type: `boolean`
|
|
606
606
|
},
|
|
607
607
|
{
|
|
608
|
-
name:
|
|
608
|
+
name: "EDGE",
|
|
609
609
|
value: config.browser === "edge",
|
|
610
610
|
type: `boolean`
|
|
611
611
|
},
|
|
612
612
|
{
|
|
613
|
-
name:
|
|
613
|
+
name: "OPERA",
|
|
614
614
|
value: config.browser === "opera",
|
|
615
615
|
type: `boolean`
|
|
616
616
|
},
|
|
617
617
|
{
|
|
618
|
-
name:
|
|
618
|
+
name: "COMMAND",
|
|
619
619
|
value: config.command,
|
|
620
620
|
type: `"build" | "serve"`
|
|
621
621
|
}
|
|
@@ -624,15 +624,12 @@ function getGlobals(config) {
|
|
|
624
624
|
function getEntrypointGlobals(entrypointName) {
|
|
625
625
|
return [
|
|
626
626
|
{
|
|
627
|
-
name:
|
|
627
|
+
name: "ENTRYPOINT",
|
|
628
628
|
value: entrypointName,
|
|
629
629
|
type: `string`
|
|
630
630
|
}
|
|
631
631
|
];
|
|
632
632
|
}
|
|
633
|
-
function surroundInUnderscore(name) {
|
|
634
|
-
return `__${name}__`;
|
|
635
|
-
}
|
|
636
633
|
|
|
637
634
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
638
635
|
import path2 from "node:path";
|
|
@@ -765,7 +762,7 @@ declare module "wxt/browser" {
|
|
|
765
762
|
}
|
|
766
763
|
const overrides = messages.map((message) => {
|
|
767
764
|
return ` /**
|
|
768
|
-
* ${message.description
|
|
765
|
+
* ${message.description || "No message description."}
|
|
769
766
|
*
|
|
770
767
|
* "${message.message}"
|
|
771
768
|
*/
|
|
@@ -789,8 +786,11 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
789
786
|
[
|
|
790
787
|
"// Generated by wxt",
|
|
791
788
|
"export {}",
|
|
792
|
-
"
|
|
793
|
-
...globals2.map((global) => `
|
|
789
|
+
"interface ImportMetaEnv {",
|
|
790
|
+
...globals2.map((global) => ` readonly ${global.name}: ${global.type};`),
|
|
791
|
+
"}",
|
|
792
|
+
"interface ImportMeta {",
|
|
793
|
+
" readonly env: ImportMetaEnv",
|
|
794
794
|
"}"
|
|
795
795
|
].join("\n") + "\n"
|
|
796
796
|
);
|
|
@@ -1171,7 +1171,11 @@ function unimport(config) {
|
|
|
1171
1171
|
return;
|
|
1172
1172
|
if (!ENABLED_EXTENSIONS.has(extname2(id)))
|
|
1173
1173
|
return;
|
|
1174
|
-
|
|
1174
|
+
const injected = await unimport2.injectImports(code, id);
|
|
1175
|
+
return {
|
|
1176
|
+
code: injected.code,
|
|
1177
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
1178
|
+
};
|
|
1175
1179
|
}
|
|
1176
1180
|
};
|
|
1177
1181
|
}
|
|
@@ -1282,7 +1286,7 @@ function globals(config) {
|
|
|
1282
1286
|
config() {
|
|
1283
1287
|
const define = {};
|
|
1284
1288
|
for (const global of getGlobals(config)) {
|
|
1285
|
-
define[global.name] = JSON.stringify(global.value);
|
|
1289
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
1286
1290
|
}
|
|
1287
1291
|
return {
|
|
1288
1292
|
define
|
|
@@ -1323,7 +1327,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
1323
1327
|
const define = {};
|
|
1324
1328
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
1325
1329
|
for (const global of getEntrypointGlobals(name)) {
|
|
1326
|
-
define[global.name] = JSON.stringify(global.value);
|
|
1330
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
1327
1331
|
}
|
|
1328
1332
|
return {
|
|
1329
1333
|
define
|
|
@@ -1352,6 +1356,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1352
1356
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
1353
1357
|
config.build.minify = false;
|
|
1354
1358
|
}
|
|
1359
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
1360
|
+
config.build.sourcemap = "inline";
|
|
1361
|
+
}
|
|
1355
1362
|
config.plugins ??= [];
|
|
1356
1363
|
config.plugins.push(
|
|
1357
1364
|
download(wxtConfig),
|
|
@@ -1714,8 +1721,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1714
1721
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
1715
1722
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
1716
1723
|
sourcesRoot: root,
|
|
1724
|
+
includeSources: [],
|
|
1717
1725
|
...mergedConfig.zip,
|
|
1718
|
-
|
|
1726
|
+
excludeSources: [
|
|
1719
1727
|
"**/node_modules",
|
|
1720
1728
|
// WXT files
|
|
1721
1729
|
"**/web-ext.config.ts",
|
|
@@ -1725,7 +1733,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1725
1733
|
"**/__tests__/**",
|
|
1726
1734
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1727
1735
|
// From user
|
|
1728
|
-
...mergedConfig.zip?.
|
|
1736
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
1729
1737
|
]
|
|
1730
1738
|
};
|
|
1731
1739
|
}
|
|
@@ -1855,6 +1863,7 @@ async function importEntrypointFile(path7, config) {
|
|
|
1855
1863
|
{ cause: err }
|
|
1856
1864
|
);
|
|
1857
1865
|
} else {
|
|
1866
|
+
config.logger.error(err);
|
|
1858
1867
|
throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err });
|
|
1859
1868
|
}
|
|
1860
1869
|
}
|
|
@@ -2770,6 +2779,7 @@ function createWslRunner() {
|
|
|
2770
2779
|
}
|
|
2771
2780
|
|
|
2772
2781
|
// src/core/runners/web-ext.ts
|
|
2782
|
+
import defu4 from "defu";
|
|
2773
2783
|
function createWebExtRunner() {
|
|
2774
2784
|
let runner;
|
|
2775
2785
|
return {
|
|
@@ -2800,6 +2810,10 @@ function createWebExtRunner() {
|
|
|
2800
2810
|
} : {
|
|
2801
2811
|
chromiumBinary: wxtUserConfig?.binaries?.[config.browser],
|
|
2802
2812
|
chromiumProfile: wxtUserConfig?.chromiumProfile,
|
|
2813
|
+
chromiumPref: defu4(
|
|
2814
|
+
wxtUserConfig?.chromiumPref,
|
|
2815
|
+
DEFAULT_CHROMIUM_PREFS
|
|
2816
|
+
),
|
|
2803
2817
|
args: wxtUserConfig?.chromiumArgs
|
|
2804
2818
|
}
|
|
2805
2819
|
};
|
|
@@ -2829,6 +2843,16 @@ function createWebExtRunner() {
|
|
|
2829
2843
|
}
|
|
2830
2844
|
var WARN_LOG_LEVEL = 40;
|
|
2831
2845
|
var ERROR_LOG_LEVEL = 50;
|
|
2846
|
+
var DEFAULT_CHROMIUM_PREFS = {
|
|
2847
|
+
devtools: {
|
|
2848
|
+
synced_preferences_sync_disabled: {
|
|
2849
|
+
// Remove content scripts from sourcemap debugger ignore list so stack traces
|
|
2850
|
+
// and log locations show up properly, see:
|
|
2851
|
+
// https://github.com/wxt-dev/wxt/issues/236#issuecomment-1915364520
|
|
2852
|
+
skipContentScripts: false
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
};
|
|
2832
2856
|
|
|
2833
2857
|
// src/core/runners/safari.ts
|
|
2834
2858
|
import { relative as relative8 } from "node:path";
|
|
@@ -3246,10 +3270,11 @@ async function zip(config) {
|
|
|
3246
3270
|
saveTo: sourcesZipPath,
|
|
3247
3271
|
filter(path7) {
|
|
3248
3272
|
const relativePath = relative11(internalConfig.zip.sourcesRoot, path7);
|
|
3249
|
-
|
|
3273
|
+
return internalConfig.zip.includeSources.some(
|
|
3274
|
+
(pattern) => minimatch2(relativePath, pattern)
|
|
3275
|
+
) || !internalConfig.zip.excludeSources.some(
|
|
3250
3276
|
(pattern) => minimatch2(relativePath, pattern)
|
|
3251
3277
|
);
|
|
3252
|
-
return matchedPattern == null;
|
|
3253
3278
|
}
|
|
3254
3279
|
});
|
|
3255
3280
|
zipFiles.push(sourcesZipPath);
|
package/dist/client.js
CHANGED
|
@@ -30,7 +30,7 @@ var WxtLocationChangeEvent = class _WxtLocationChangeEvent extends Event {
|
|
|
30
30
|
static EVENT_NAME = getUniqueEventName("wxt:locationchange");
|
|
31
31
|
};
|
|
32
32
|
function getUniqueEventName(eventName) {
|
|
33
|
-
const entrypointName = typeof
|
|
33
|
+
const entrypointName = typeof import.meta.env === "undefined" ? "build" : import.meta.env.ENTRYPOINT;
|
|
34
34
|
return `${browser.runtime.id}:${entrypointName}:${eventName}`;
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -390,7 +390,9 @@ function mountUi(root, options) {
|
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
async function loadCss() {
|
|
393
|
-
const url = browser.runtime.getURL(
|
|
393
|
+
const url = browser.runtime.getURL(
|
|
394
|
+
`/content-scripts/${import.meta.env.ENTRYPOINT}.css`
|
|
395
|
+
);
|
|
394
396
|
try {
|
|
395
397
|
const res = await fetch(url);
|
|
396
398
|
return await res.text();
|
|
@@ -238,9 +238,22 @@ interface InlineConfig {
|
|
|
238
238
|
* @default config.root
|
|
239
239
|
*/
|
|
240
240
|
sourcesRoot?: string;
|
|
241
|
+
/**
|
|
242
|
+
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to include when
|
|
243
|
+
* creating a ZIP of all your source code for Firefox. Patterns are relative to your
|
|
244
|
+
* `config.zip.sourcesRoot`.
|
|
245
|
+
*
|
|
246
|
+
* This setting overrides `excludeSources`. So if a file matches both lists, it is included in the ZIP.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* [
|
|
250
|
+
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
251
|
+
* ]
|
|
252
|
+
*/
|
|
253
|
+
includeSources?: string[];
|
|
241
254
|
/**
|
|
242
255
|
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
|
|
243
|
-
* creating a ZIP of all your source code for
|
|
256
|
+
* creating a ZIP of all your source code for Firefox. Patterns are relative to your
|
|
244
257
|
* `config.zip.sourcesRoot`.
|
|
245
258
|
*
|
|
246
259
|
* Hidden files, node_modules, and tests are ignored by default.
|
|
@@ -250,7 +263,7 @@ interface InlineConfig {
|
|
|
250
263
|
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
251
264
|
* ]
|
|
252
265
|
*/
|
|
253
|
-
|
|
266
|
+
excludeSources?: string[];
|
|
254
267
|
};
|
|
255
268
|
/**
|
|
256
269
|
* Transform the final manifest before it's written to the file system. Edit the `manifest`
|
|
@@ -675,6 +688,33 @@ interface ExtensionRunnerConfig {
|
|
|
675
688
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
676
689
|
*/
|
|
677
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;
|
|
678
718
|
/**
|
|
679
719
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
680
720
|
*/
|
|
@@ -238,9 +238,22 @@ interface InlineConfig {
|
|
|
238
238
|
* @default config.root
|
|
239
239
|
*/
|
|
240
240
|
sourcesRoot?: string;
|
|
241
|
+
/**
|
|
242
|
+
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to include when
|
|
243
|
+
* creating a ZIP of all your source code for Firefox. Patterns are relative to your
|
|
244
|
+
* `config.zip.sourcesRoot`.
|
|
245
|
+
*
|
|
246
|
+
* This setting overrides `excludeSources`. So if a file matches both lists, it is included in the ZIP.
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* [
|
|
250
|
+
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
251
|
+
* ]
|
|
252
|
+
*/
|
|
253
|
+
includeSources?: string[];
|
|
241
254
|
/**
|
|
242
255
|
* [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
|
|
243
|
-
* creating a ZIP of all your source code for
|
|
256
|
+
* creating a ZIP of all your source code for Firefox. Patterns are relative to your
|
|
244
257
|
* `config.zip.sourcesRoot`.
|
|
245
258
|
*
|
|
246
259
|
* Hidden files, node_modules, and tests are ignored by default.
|
|
@@ -250,7 +263,7 @@ interface InlineConfig {
|
|
|
250
263
|
* "coverage", // Ignore the coverage directory in the `sourcesRoot`
|
|
251
264
|
* ]
|
|
252
265
|
*/
|
|
253
|
-
|
|
266
|
+
excludeSources?: string[];
|
|
254
267
|
};
|
|
255
268
|
/**
|
|
256
269
|
* Transform the final manifest before it's written to the file system. Edit the `manifest`
|
|
@@ -675,6 +688,33 @@ interface ExtensionRunnerConfig {
|
|
|
675
688
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
|
|
676
689
|
*/
|
|
677
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;
|
|
678
718
|
/**
|
|
679
719
|
* @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
|
|
680
720
|
*/
|
package/dist/index.cjs
CHANGED
|
@@ -3000,42 +3000,42 @@ function getUnimportOptions(config) {
|
|
|
3000
3000
|
function getGlobals(config) {
|
|
3001
3001
|
return [
|
|
3002
3002
|
{
|
|
3003
|
-
name:
|
|
3003
|
+
name: "MANIFEST_VERSION",
|
|
3004
3004
|
value: config.manifestVersion,
|
|
3005
3005
|
type: `2 | 3`
|
|
3006
3006
|
},
|
|
3007
3007
|
{
|
|
3008
|
-
name:
|
|
3008
|
+
name: "BROWSER",
|
|
3009
3009
|
value: config.browser,
|
|
3010
3010
|
type: `string`
|
|
3011
3011
|
},
|
|
3012
3012
|
{
|
|
3013
|
-
name:
|
|
3013
|
+
name: "CHROME",
|
|
3014
3014
|
value: config.browser === "chrome",
|
|
3015
3015
|
type: `boolean`
|
|
3016
3016
|
},
|
|
3017
3017
|
{
|
|
3018
|
-
name:
|
|
3018
|
+
name: "FIREFOX",
|
|
3019
3019
|
value: config.browser === "firefox",
|
|
3020
3020
|
type: `boolean`
|
|
3021
3021
|
},
|
|
3022
3022
|
{
|
|
3023
|
-
name:
|
|
3023
|
+
name: "SAFARI",
|
|
3024
3024
|
value: config.browser === "safari",
|
|
3025
3025
|
type: `boolean`
|
|
3026
3026
|
},
|
|
3027
3027
|
{
|
|
3028
|
-
name:
|
|
3028
|
+
name: "EDGE",
|
|
3029
3029
|
value: config.browser === "edge",
|
|
3030
3030
|
type: `boolean`
|
|
3031
3031
|
},
|
|
3032
3032
|
{
|
|
3033
|
-
name:
|
|
3033
|
+
name: "OPERA",
|
|
3034
3034
|
value: config.browser === "opera",
|
|
3035
3035
|
type: `boolean`
|
|
3036
3036
|
},
|
|
3037
3037
|
{
|
|
3038
|
-
name:
|
|
3038
|
+
name: "COMMAND",
|
|
3039
3039
|
value: config.command,
|
|
3040
3040
|
type: `"build" | "serve"`
|
|
3041
3041
|
}
|
|
@@ -3044,15 +3044,12 @@ function getGlobals(config) {
|
|
|
3044
3044
|
function getEntrypointGlobals(entrypointName) {
|
|
3045
3045
|
return [
|
|
3046
3046
|
{
|
|
3047
|
-
name:
|
|
3047
|
+
name: "ENTRYPOINT",
|
|
3048
3048
|
value: entrypointName,
|
|
3049
3049
|
type: `string`
|
|
3050
3050
|
}
|
|
3051
3051
|
];
|
|
3052
3052
|
}
|
|
3053
|
-
function surroundInUnderscore(name) {
|
|
3054
|
-
return `__${name}__`;
|
|
3055
|
-
}
|
|
3056
3053
|
|
|
3057
3054
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
3058
3055
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -3185,7 +3182,7 @@ declare module "wxt/browser" {
|
|
|
3185
3182
|
}
|
|
3186
3183
|
const overrides = messages.map((message) => {
|
|
3187
3184
|
return ` /**
|
|
3188
|
-
* ${message.description
|
|
3185
|
+
* ${message.description || "No message description."}
|
|
3189
3186
|
*
|
|
3190
3187
|
* "${message.message}"
|
|
3191
3188
|
*/
|
|
@@ -3209,8 +3206,11 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
3209
3206
|
[
|
|
3210
3207
|
"// Generated by wxt",
|
|
3211
3208
|
"export {}",
|
|
3212
|
-
"
|
|
3213
|
-
...globals2.map((global3) => `
|
|
3209
|
+
"interface ImportMetaEnv {",
|
|
3210
|
+
...globals2.map((global3) => ` readonly ${global3.name}: ${global3.type};`),
|
|
3211
|
+
"}",
|
|
3212
|
+
"interface ImportMeta {",
|
|
3213
|
+
" readonly env: ImportMetaEnv",
|
|
3214
3214
|
"}"
|
|
3215
3215
|
].join("\n") + "\n"
|
|
3216
3216
|
);
|
|
@@ -3591,7 +3591,11 @@ function unimport(config) {
|
|
|
3591
3591
|
return;
|
|
3592
3592
|
if (!ENABLED_EXTENSIONS.has((0, import_path5.extname)(id)))
|
|
3593
3593
|
return;
|
|
3594
|
-
|
|
3594
|
+
const injected = await unimport2.injectImports(code, id);
|
|
3595
|
+
return {
|
|
3596
|
+
code: injected.code,
|
|
3597
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
3598
|
+
};
|
|
3595
3599
|
}
|
|
3596
3600
|
};
|
|
3597
3601
|
}
|
|
@@ -3702,7 +3706,7 @@ function globals(config) {
|
|
|
3702
3706
|
config() {
|
|
3703
3707
|
const define = {};
|
|
3704
3708
|
for (const global3 of getGlobals(config)) {
|
|
3705
|
-
define[global3.name] = JSON.stringify(global3.value);
|
|
3709
|
+
define[`import.meta.env.${global3.name}`] = JSON.stringify(global3.value);
|
|
3706
3710
|
}
|
|
3707
3711
|
return {
|
|
3708
3712
|
define
|
|
@@ -3746,7 +3750,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
3746
3750
|
const define = {};
|
|
3747
3751
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
3748
3752
|
for (const global3 of getEntrypointGlobals(name)) {
|
|
3749
|
-
define[global3.name] = JSON.stringify(global3.value);
|
|
3753
|
+
define[`import.meta.env.${global3.name}`] = JSON.stringify(global3.value);
|
|
3750
3754
|
}
|
|
3751
3755
|
return {
|
|
3752
3756
|
define
|
|
@@ -3775,6 +3779,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3775
3779
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
3776
3780
|
config.build.minify = false;
|
|
3777
3781
|
}
|
|
3782
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
3783
|
+
config.build.sourcemap = "inline";
|
|
3784
|
+
}
|
|
3778
3785
|
config.plugins ??= [];
|
|
3779
3786
|
config.plugins.push(
|
|
3780
3787
|
download(wxtConfig),
|
|
@@ -4137,8 +4144,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
4137
4144
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
4138
4145
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
4139
4146
|
sourcesRoot: root,
|
|
4147
|
+
includeSources: [],
|
|
4140
4148
|
...mergedConfig.zip,
|
|
4141
|
-
|
|
4149
|
+
excludeSources: [
|
|
4142
4150
|
"**/node_modules",
|
|
4143
4151
|
// WXT files
|
|
4144
4152
|
"**/web-ext.config.ts",
|
|
@@ -4148,7 +4156,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
4148
4156
|
"**/__tests__/**",
|
|
4149
4157
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
4150
4158
|
// From user
|
|
4151
|
-
...mergedConfig.zip?.
|
|
4159
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
4152
4160
|
]
|
|
4153
4161
|
};
|
|
4154
4162
|
}
|
|
@@ -4279,6 +4287,7 @@ async function importEntrypointFile(path10, config) {
|
|
|
4279
4287
|
{ cause: err }
|
|
4280
4288
|
);
|
|
4281
4289
|
} else {
|
|
4290
|
+
config.logger.error(err);
|
|
4282
4291
|
throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err });
|
|
4283
4292
|
}
|
|
4284
4293
|
}
|
|
@@ -4405,7 +4414,7 @@ function getChunkSortWeight(filename) {
|
|
|
4405
4414
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4406
4415
|
|
|
4407
4416
|
// package.json
|
|
4408
|
-
var version = "0.
|
|
4417
|
+
var version = "0.15.1";
|
|
4409
4418
|
|
|
4410
4419
|
// src/core/utils/log/printHeader.ts
|
|
4411
4420
|
var import_consola2 = require("consola");
|
|
@@ -5205,6 +5214,7 @@ function createWslRunner() {
|
|
|
5205
5214
|
}
|
|
5206
5215
|
|
|
5207
5216
|
// src/core/runners/web-ext.ts
|
|
5217
|
+
var import_defu4 = __toESM(require("defu"), 1);
|
|
5208
5218
|
function createWebExtRunner() {
|
|
5209
5219
|
let runner;
|
|
5210
5220
|
return {
|
|
@@ -5235,6 +5245,10 @@ function createWebExtRunner() {
|
|
|
5235
5245
|
} : {
|
|
5236
5246
|
chromiumBinary: wxtUserConfig?.binaries?.[config.browser],
|
|
5237
5247
|
chromiumProfile: wxtUserConfig?.chromiumProfile,
|
|
5248
|
+
chromiumPref: (0, import_defu4.default)(
|
|
5249
|
+
wxtUserConfig?.chromiumPref,
|
|
5250
|
+
DEFAULT_CHROMIUM_PREFS
|
|
5251
|
+
),
|
|
5238
5252
|
args: wxtUserConfig?.chromiumArgs
|
|
5239
5253
|
}
|
|
5240
5254
|
};
|
|
@@ -5264,6 +5278,16 @@ function createWebExtRunner() {
|
|
|
5264
5278
|
}
|
|
5265
5279
|
var WARN_LOG_LEVEL = 40;
|
|
5266
5280
|
var ERROR_LOG_LEVEL = 50;
|
|
5281
|
+
var DEFAULT_CHROMIUM_PREFS = {
|
|
5282
|
+
devtools: {
|
|
5283
|
+
synced_preferences_sync_disabled: {
|
|
5284
|
+
// Remove content scripts from sourcemap debugger ignore list so stack traces
|
|
5285
|
+
// and log locations show up properly, see:
|
|
5286
|
+
// https://github.com/wxt-dev/wxt/issues/236#issuecomment-1915364520
|
|
5287
|
+
skipContentScripts: false
|
|
5288
|
+
}
|
|
5289
|
+
}
|
|
5290
|
+
};
|
|
5267
5291
|
|
|
5268
5292
|
// src/core/runners/safari.ts
|
|
5269
5293
|
var import_node_path16 = require("path");
|
|
@@ -5681,10 +5705,11 @@ async function zip(config) {
|
|
|
5681
5705
|
saveTo: sourcesZipPath,
|
|
5682
5706
|
filter(path10) {
|
|
5683
5707
|
const relativePath = (0, import_node_path20.relative)(internalConfig.zip.sourcesRoot, path10);
|
|
5684
|
-
|
|
5708
|
+
return internalConfig.zip.includeSources.some(
|
|
5709
|
+
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5710
|
+
) || !internalConfig.zip.excludeSources.some(
|
|
5685
5711
|
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5686
5712
|
);
|
|
5687
|
-
return matchedPattern == null;
|
|
5688
5713
|
}
|
|
5689
5714
|
});
|
|
5690
5715
|
zipFiles.push(sourcesZipPath);
|
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.
|
|
65
|
+
var version = "0.15.1";
|
|
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.
|
|
65
|
+
var version = "0.15.1";
|
|
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-T57ALCJ4.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";
|
|
@@ -563,10 +578,11 @@ async function zip(config) {
|
|
|
563
578
|
saveTo: sourcesZipPath,
|
|
564
579
|
filter(path3) {
|
|
565
580
|
const relativePath = relative5(internalConfig.zip.sourcesRoot, path3);
|
|
566
|
-
|
|
581
|
+
return internalConfig.zip.includeSources.some(
|
|
582
|
+
(pattern) => minimatch(relativePath, pattern)
|
|
583
|
+
) || !internalConfig.zip.excludeSources.some(
|
|
567
584
|
(pattern) => minimatch(relativePath, pattern)
|
|
568
585
|
);
|
|
569
|
-
return matchedPattern == null;
|
|
570
586
|
}
|
|
571
587
|
});
|
|
572
588
|
zipFiles.push(sourcesZipPath);
|
package/dist/testing.cjs
CHANGED
|
@@ -376,7 +376,11 @@ function unimport(config) {
|
|
|
376
376
|
return;
|
|
377
377
|
if (!ENABLED_EXTENSIONS.has((0, import_path.extname)(id)))
|
|
378
378
|
return;
|
|
379
|
-
|
|
379
|
+
const injected = await unimport2.injectImports(code, id);
|
|
380
|
+
return {
|
|
381
|
+
code: injected.code,
|
|
382
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
383
|
+
};
|
|
380
384
|
}
|
|
381
385
|
};
|
|
382
386
|
}
|
|
@@ -487,42 +491,42 @@ function bundleAnalysis() {
|
|
|
487
491
|
function getGlobals(config) {
|
|
488
492
|
return [
|
|
489
493
|
{
|
|
490
|
-
name:
|
|
494
|
+
name: "MANIFEST_VERSION",
|
|
491
495
|
value: config.manifestVersion,
|
|
492
496
|
type: `2 | 3`
|
|
493
497
|
},
|
|
494
498
|
{
|
|
495
|
-
name:
|
|
499
|
+
name: "BROWSER",
|
|
496
500
|
value: config.browser,
|
|
497
501
|
type: `string`
|
|
498
502
|
},
|
|
499
503
|
{
|
|
500
|
-
name:
|
|
504
|
+
name: "CHROME",
|
|
501
505
|
value: config.browser === "chrome",
|
|
502
506
|
type: `boolean`
|
|
503
507
|
},
|
|
504
508
|
{
|
|
505
|
-
name:
|
|
509
|
+
name: "FIREFOX",
|
|
506
510
|
value: config.browser === "firefox",
|
|
507
511
|
type: `boolean`
|
|
508
512
|
},
|
|
509
513
|
{
|
|
510
|
-
name:
|
|
514
|
+
name: "SAFARI",
|
|
511
515
|
value: config.browser === "safari",
|
|
512
516
|
type: `boolean`
|
|
513
517
|
},
|
|
514
518
|
{
|
|
515
|
-
name:
|
|
519
|
+
name: "EDGE",
|
|
516
520
|
value: config.browser === "edge",
|
|
517
521
|
type: `boolean`
|
|
518
522
|
},
|
|
519
523
|
{
|
|
520
|
-
name:
|
|
524
|
+
name: "OPERA",
|
|
521
525
|
value: config.browser === "opera",
|
|
522
526
|
type: `boolean`
|
|
523
527
|
},
|
|
524
528
|
{
|
|
525
|
-
name:
|
|
529
|
+
name: "COMMAND",
|
|
526
530
|
value: config.command,
|
|
527
531
|
type: `"build" | "serve"`
|
|
528
532
|
}
|
|
@@ -531,15 +535,12 @@ function getGlobals(config) {
|
|
|
531
535
|
function getEntrypointGlobals(entrypointName) {
|
|
532
536
|
return [
|
|
533
537
|
{
|
|
534
|
-
name:
|
|
538
|
+
name: "ENTRYPOINT",
|
|
535
539
|
value: entrypointName,
|
|
536
540
|
type: `string`
|
|
537
541
|
}
|
|
538
542
|
];
|
|
539
543
|
}
|
|
540
|
-
function surroundInUnderscore(name) {
|
|
541
|
-
return `__${name}__`;
|
|
542
|
-
}
|
|
543
544
|
|
|
544
545
|
// src/core/builders/vite/plugins/globals.ts
|
|
545
546
|
function globals(config) {
|
|
@@ -548,7 +549,7 @@ function globals(config) {
|
|
|
548
549
|
config() {
|
|
549
550
|
const define = {};
|
|
550
551
|
for (const global of getGlobals(config)) {
|
|
551
|
-
define[global.name] = JSON.stringify(global.value);
|
|
552
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
552
553
|
}
|
|
553
554
|
return {
|
|
554
555
|
define
|
|
@@ -614,7 +615,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
614
615
|
const define = {};
|
|
615
616
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
616
617
|
for (const global of getEntrypointGlobals(name)) {
|
|
617
|
-
define[global.name] = JSON.stringify(global.value);
|
|
618
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
618
619
|
}
|
|
619
620
|
return {
|
|
620
621
|
define
|
|
@@ -738,6 +739,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
738
739
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
739
740
|
config.build.minify = false;
|
|
740
741
|
}
|
|
742
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
743
|
+
config.build.sourcemap = "inline";
|
|
744
|
+
}
|
|
741
745
|
config.plugins ??= [];
|
|
742
746
|
config.plugins.push(
|
|
743
747
|
download(wxtConfig),
|
|
@@ -1100,8 +1104,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1100
1104
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
1101
1105
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
1102
1106
|
sourcesRoot: root,
|
|
1107
|
+
includeSources: [],
|
|
1103
1108
|
...mergedConfig.zip,
|
|
1104
|
-
|
|
1109
|
+
excludeSources: [
|
|
1105
1110
|
"**/node_modules",
|
|
1106
1111
|
// WXT files
|
|
1107
1112
|
"**/web-ext.config.ts",
|
|
@@ -1111,7 +1116,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1111
1116
|
"**/__tests__/**",
|
|
1112
1117
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1113
1118
|
// From user
|
|
1114
|
-
...mergedConfig.zip?.
|
|
1119
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
1115
1120
|
]
|
|
1116
1121
|
};
|
|
1117
1122
|
}
|
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
|
@@ -98,7 +98,7 @@ async function reloadContentScriptMv2(contentScript) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
// src/virtual/background-entrypoint.ts
|
|
101
|
-
if (
|
|
101
|
+
if (import.meta.env.COMMAND === "serve") {
|
|
102
102
|
try {
|
|
103
103
|
const ws = setupWebSocket((message) => {
|
|
104
104
|
if (message.event === "wxt:reload-extension")
|
|
@@ -106,7 +106,7 @@ if (__COMMAND__ === "serve") {
|
|
|
106
106
|
if (message.event === "wxt:reload-content-script" && message.data != null)
|
|
107
107
|
reloadContentScript(message.data);
|
|
108
108
|
});
|
|
109
|
-
if (
|
|
109
|
+
if (import.meta.env.MANIFEST_VERSION === 3) {
|
|
110
110
|
ws.addEventListener("open", () => {
|
|
111
111
|
const msg = { type: "custom", event: "wxt:background-initialized" };
|
|
112
112
|
ws.send(JSON.stringify(msg));
|
|
@@ -24,11 +24,11 @@ import { ContentScriptContext } from "wxt/client";
|
|
|
24
24
|
(async () => {
|
|
25
25
|
try {
|
|
26
26
|
const { main, ...options } = definition;
|
|
27
|
-
const ctx = new ContentScriptContext(
|
|
27
|
+
const ctx = new ContentScriptContext(import.meta.env.ENTRYPOINT, options);
|
|
28
28
|
await main(ctx);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
logger.error(
|
|
31
|
-
`The content script "${
|
|
31
|
+
`The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
|
|
32
32
|
err
|
|
33
33
|
);
|
|
34
34
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.1",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -113,8 +113,8 @@
|
|
|
113
113
|
"prompts": "^2.4.2",
|
|
114
114
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
115
115
|
"unimport": "^3.4.0",
|
|
116
|
-
"vite": "^5.0.
|
|
117
|
-
"web-ext-run": "^0.
|
|
116
|
+
"vite": "^5.0.12",
|
|
117
|
+
"web-ext-run": "^0.2.0",
|
|
118
118
|
"webextension-polyfill": "^0.10.0",
|
|
119
119
|
"zip-dir": "^2.0.0"
|
|
120
120
|
},
|