wxt 0.14.6 → 0.15.0
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-XDRW7AKZ.js → chunk-HSXPP3ZS.js} +40 -26
- package/dist/cli.js +43 -28
- package/dist/client.js +4 -2
- package/dist/{external-mJ1bW7iy.d.cts → external-jLnyv431.d.cts} +15 -2
- package/dist/{external-mJ1bW7iy.d.ts → external-jLnyv431.d.ts} +15 -2
- package/dist/index.cjs +43 -28
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -3
- package/dist/storage.cjs +11 -1
- package/dist/storage.js +11 -1
- 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 +2 -2
- package/dist/cli.d.ts +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.15.0";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/arrays.ts
|
|
5
5
|
function every(array, predicate) {
|
|
@@ -173,9 +173,14 @@ async function buildEntrypoints(groups, config, spinner) {
|
|
|
173
173
|
const steps = [];
|
|
174
174
|
for (let i = 0; i < groups.length; i++) {
|
|
175
175
|
const group = groups[i];
|
|
176
|
-
const groupNames = [group].flat().map((e) => e.name)
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
const groupNames = [group].flat().map((e) => e.name);
|
|
177
|
+
const groupNameColored = groupNames.join(pc.dim(", "));
|
|
178
|
+
spinner.text = pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
|
|
179
|
+
try {
|
|
180
|
+
steps.push(await config.builder.build(group));
|
|
181
|
+
} catch (err) {
|
|
182
|
+
throw Error(`Failed to build ${groupNames.join(", ")}`, { cause: err });
|
|
183
|
+
}
|
|
179
184
|
}
|
|
180
185
|
const publicAssets = await copyPublicDirectory(config);
|
|
181
186
|
return { publicAssets, steps };
|
|
@@ -230,42 +235,42 @@ function getUnimportOptions(config) {
|
|
|
230
235
|
function getGlobals(config) {
|
|
231
236
|
return [
|
|
232
237
|
{
|
|
233
|
-
name:
|
|
238
|
+
name: "MANIFEST_VERSION",
|
|
234
239
|
value: config.manifestVersion,
|
|
235
240
|
type: `2 | 3`
|
|
236
241
|
},
|
|
237
242
|
{
|
|
238
|
-
name:
|
|
243
|
+
name: "BROWSER",
|
|
239
244
|
value: config.browser,
|
|
240
245
|
type: `string`
|
|
241
246
|
},
|
|
242
247
|
{
|
|
243
|
-
name:
|
|
248
|
+
name: "CHROME",
|
|
244
249
|
value: config.browser === "chrome",
|
|
245
250
|
type: `boolean`
|
|
246
251
|
},
|
|
247
252
|
{
|
|
248
|
-
name:
|
|
253
|
+
name: "FIREFOX",
|
|
249
254
|
value: config.browser === "firefox",
|
|
250
255
|
type: `boolean`
|
|
251
256
|
},
|
|
252
257
|
{
|
|
253
|
-
name:
|
|
258
|
+
name: "SAFARI",
|
|
254
259
|
value: config.browser === "safari",
|
|
255
260
|
type: `boolean`
|
|
256
261
|
},
|
|
257
262
|
{
|
|
258
|
-
name:
|
|
263
|
+
name: "EDGE",
|
|
259
264
|
value: config.browser === "edge",
|
|
260
265
|
type: `boolean`
|
|
261
266
|
},
|
|
262
267
|
{
|
|
263
|
-
name:
|
|
268
|
+
name: "OPERA",
|
|
264
269
|
value: config.browser === "opera",
|
|
265
270
|
type: `boolean`
|
|
266
271
|
},
|
|
267
272
|
{
|
|
268
|
-
name:
|
|
273
|
+
name: "COMMAND",
|
|
269
274
|
value: config.command,
|
|
270
275
|
type: `"build" | "serve"`
|
|
271
276
|
}
|
|
@@ -274,15 +279,12 @@ function getGlobals(config) {
|
|
|
274
279
|
function getEntrypointGlobals(entrypointName) {
|
|
275
280
|
return [
|
|
276
281
|
{
|
|
277
|
-
name:
|
|
282
|
+
name: "ENTRYPOINT",
|
|
278
283
|
value: entrypointName,
|
|
279
284
|
type: `string`
|
|
280
285
|
}
|
|
281
286
|
];
|
|
282
287
|
}
|
|
283
|
-
function surroundInUnderscore(name) {
|
|
284
|
-
return `__${name}__`;
|
|
285
|
-
}
|
|
286
288
|
|
|
287
289
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
288
290
|
import path2 from "node:path";
|
|
@@ -415,7 +417,7 @@ declare module "wxt/browser" {
|
|
|
415
417
|
}
|
|
416
418
|
const overrides = messages.map((message) => {
|
|
417
419
|
return ` /**
|
|
418
|
-
* ${message.description
|
|
420
|
+
* ${message.description || "No message description."}
|
|
419
421
|
*
|
|
420
422
|
* "${message.message}"
|
|
421
423
|
*/
|
|
@@ -439,8 +441,11 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
439
441
|
[
|
|
440
442
|
"// Generated by wxt",
|
|
441
443
|
"export {}",
|
|
442
|
-
"
|
|
443
|
-
...globals2.map((global) => `
|
|
444
|
+
"interface ImportMetaEnv {",
|
|
445
|
+
...globals2.map((global) => ` readonly ${global.name}: ${global.type};`),
|
|
446
|
+
"}",
|
|
447
|
+
"interface ImportMeta {",
|
|
448
|
+
" readonly env: ImportMetaEnv",
|
|
444
449
|
"}"
|
|
445
450
|
].join("\n") + "\n"
|
|
446
451
|
);
|
|
@@ -821,7 +826,11 @@ function unimport(config) {
|
|
|
821
826
|
return;
|
|
822
827
|
if (!ENABLED_EXTENSIONS.has(extname2(id)))
|
|
823
828
|
return;
|
|
824
|
-
|
|
829
|
+
const injected = await unimport2.injectImports(code, id);
|
|
830
|
+
return {
|
|
831
|
+
code: injected.code,
|
|
832
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
833
|
+
};
|
|
825
834
|
}
|
|
826
835
|
};
|
|
827
836
|
}
|
|
@@ -935,7 +944,7 @@ function globals(config) {
|
|
|
935
944
|
config() {
|
|
936
945
|
const define = {};
|
|
937
946
|
for (const global of getGlobals(config)) {
|
|
938
|
-
define[global.name] = JSON.stringify(global.value);
|
|
947
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
939
948
|
}
|
|
940
949
|
return {
|
|
941
950
|
define
|
|
@@ -1001,7 +1010,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
1001
1010
|
const define = {};
|
|
1002
1011
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
1003
1012
|
for (const global of getEntrypointGlobals(name)) {
|
|
1004
|
-
define[global.name] = JSON.stringify(global.value);
|
|
1013
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
1005
1014
|
}
|
|
1006
1015
|
return {
|
|
1007
1016
|
define
|
|
@@ -1030,6 +1039,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1030
1039
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
1031
1040
|
config.build.minify = false;
|
|
1032
1041
|
}
|
|
1042
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
1043
|
+
config.build.sourcemap = "inline";
|
|
1044
|
+
}
|
|
1033
1045
|
config.plugins ??= [];
|
|
1034
1046
|
config.plugins.push(
|
|
1035
1047
|
download(wxtConfig),
|
|
@@ -1392,8 +1404,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1392
1404
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
1393
1405
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
1394
1406
|
sourcesRoot: root,
|
|
1407
|
+
includeSources: [],
|
|
1395
1408
|
...mergedConfig.zip,
|
|
1396
|
-
|
|
1409
|
+
excludeSources: [
|
|
1397
1410
|
"**/node_modules",
|
|
1398
1411
|
// WXT files
|
|
1399
1412
|
"**/web-ext.config.ts",
|
|
@@ -1403,7 +1416,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1403
1416
|
"**/__tests__/**",
|
|
1404
1417
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1405
1418
|
// From user
|
|
1406
|
-
...mergedConfig.zip?.
|
|
1419
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
1407
1420
|
]
|
|
1408
1421
|
};
|
|
1409
1422
|
}
|
|
@@ -1525,15 +1538,16 @@ async function importEntrypointFile(path6, config) {
|
|
|
1525
1538
|
const res = await jiti(path6);
|
|
1526
1539
|
return res.default;
|
|
1527
1540
|
} catch (err) {
|
|
1541
|
+
const filePath = relative4(config.root, path6);
|
|
1528
1542
|
if (err instanceof ReferenceError) {
|
|
1529
1543
|
const variableName = err.message.replace(" is not defined", "");
|
|
1530
|
-
const filePath = relative4(config.root, path6);
|
|
1531
1544
|
throw Error(
|
|
1532
1545
|
`${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`,
|
|
1533
1546
|
{ cause: err }
|
|
1534
1547
|
);
|
|
1535
1548
|
} else {
|
|
1536
|
-
|
|
1549
|
+
config.logger.error(err);
|
|
1550
|
+
throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err });
|
|
1537
1551
|
}
|
|
1538
1552
|
}
|
|
1539
1553
|
}
|
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.0";
|
|
9
9
|
|
|
10
10
|
// src/core/utils/fs.ts
|
|
11
11
|
import fs from "fs-extra";
|
|
@@ -45,9 +45,14 @@ async function buildEntrypoints(groups, config, spinner) {
|
|
|
45
45
|
const steps = [];
|
|
46
46
|
for (let i = 0; i < groups.length; i++) {
|
|
47
47
|
const group = groups[i];
|
|
48
|
-
const groupNames = [group].flat().map((e) => e.name)
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const groupNames = [group].flat().map((e) => e.name);
|
|
49
|
+
const groupNameColored = groupNames.join(pc.dim(", "));
|
|
50
|
+
spinner.text = pc.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
|
|
51
|
+
try {
|
|
52
|
+
steps.push(await config.builder.build(group));
|
|
53
|
+
} catch (err) {
|
|
54
|
+
throw Error(`Failed to build ${groupNames.join(", ")}`, { cause: err });
|
|
55
|
+
}
|
|
51
56
|
}
|
|
52
57
|
const publicAssets = await copyPublicDirectory(config);
|
|
53
58
|
return { publicAssets, steps };
|
|
@@ -575,42 +580,42 @@ function getUnimportOptions(config) {
|
|
|
575
580
|
function getGlobals(config) {
|
|
576
581
|
return [
|
|
577
582
|
{
|
|
578
|
-
name:
|
|
583
|
+
name: "MANIFEST_VERSION",
|
|
579
584
|
value: config.manifestVersion,
|
|
580
585
|
type: `2 | 3`
|
|
581
586
|
},
|
|
582
587
|
{
|
|
583
|
-
name:
|
|
588
|
+
name: "BROWSER",
|
|
584
589
|
value: config.browser,
|
|
585
590
|
type: `string`
|
|
586
591
|
},
|
|
587
592
|
{
|
|
588
|
-
name:
|
|
593
|
+
name: "CHROME",
|
|
589
594
|
value: config.browser === "chrome",
|
|
590
595
|
type: `boolean`
|
|
591
596
|
},
|
|
592
597
|
{
|
|
593
|
-
name:
|
|
598
|
+
name: "FIREFOX",
|
|
594
599
|
value: config.browser === "firefox",
|
|
595
600
|
type: `boolean`
|
|
596
601
|
},
|
|
597
602
|
{
|
|
598
|
-
name:
|
|
603
|
+
name: "SAFARI",
|
|
599
604
|
value: config.browser === "safari",
|
|
600
605
|
type: `boolean`
|
|
601
606
|
},
|
|
602
607
|
{
|
|
603
|
-
name:
|
|
608
|
+
name: "EDGE",
|
|
604
609
|
value: config.browser === "edge",
|
|
605
610
|
type: `boolean`
|
|
606
611
|
},
|
|
607
612
|
{
|
|
608
|
-
name:
|
|
613
|
+
name: "OPERA",
|
|
609
614
|
value: config.browser === "opera",
|
|
610
615
|
type: `boolean`
|
|
611
616
|
},
|
|
612
617
|
{
|
|
613
|
-
name:
|
|
618
|
+
name: "COMMAND",
|
|
614
619
|
value: config.command,
|
|
615
620
|
type: `"build" | "serve"`
|
|
616
621
|
}
|
|
@@ -619,15 +624,12 @@ function getGlobals(config) {
|
|
|
619
624
|
function getEntrypointGlobals(entrypointName) {
|
|
620
625
|
return [
|
|
621
626
|
{
|
|
622
|
-
name:
|
|
627
|
+
name: "ENTRYPOINT",
|
|
623
628
|
value: entrypointName,
|
|
624
629
|
type: `string`
|
|
625
630
|
}
|
|
626
631
|
];
|
|
627
632
|
}
|
|
628
|
-
function surroundInUnderscore(name) {
|
|
629
|
-
return `__${name}__`;
|
|
630
|
-
}
|
|
631
633
|
|
|
632
634
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
633
635
|
import path2 from "node:path";
|
|
@@ -760,7 +762,7 @@ declare module "wxt/browser" {
|
|
|
760
762
|
}
|
|
761
763
|
const overrides = messages.map((message) => {
|
|
762
764
|
return ` /**
|
|
763
|
-
* ${message.description
|
|
765
|
+
* ${message.description || "No message description."}
|
|
764
766
|
*
|
|
765
767
|
* "${message.message}"
|
|
766
768
|
*/
|
|
@@ -784,8 +786,11 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
784
786
|
[
|
|
785
787
|
"// Generated by wxt",
|
|
786
788
|
"export {}",
|
|
787
|
-
"
|
|
788
|
-
...globals2.map((global) => `
|
|
789
|
+
"interface ImportMetaEnv {",
|
|
790
|
+
...globals2.map((global) => ` readonly ${global.name}: ${global.type};`),
|
|
791
|
+
"}",
|
|
792
|
+
"interface ImportMeta {",
|
|
793
|
+
" readonly env: ImportMetaEnv",
|
|
789
794
|
"}"
|
|
790
795
|
].join("\n") + "\n"
|
|
791
796
|
);
|
|
@@ -1166,7 +1171,11 @@ function unimport(config) {
|
|
|
1166
1171
|
return;
|
|
1167
1172
|
if (!ENABLED_EXTENSIONS.has(extname2(id)))
|
|
1168
1173
|
return;
|
|
1169
|
-
|
|
1174
|
+
const injected = await unimport2.injectImports(code, id);
|
|
1175
|
+
return {
|
|
1176
|
+
code: injected.code,
|
|
1177
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
1178
|
+
};
|
|
1170
1179
|
}
|
|
1171
1180
|
};
|
|
1172
1181
|
}
|
|
@@ -1277,7 +1286,7 @@ function globals(config) {
|
|
|
1277
1286
|
config() {
|
|
1278
1287
|
const define = {};
|
|
1279
1288
|
for (const global of getGlobals(config)) {
|
|
1280
|
-
define[global.name] = JSON.stringify(global.value);
|
|
1289
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
1281
1290
|
}
|
|
1282
1291
|
return {
|
|
1283
1292
|
define
|
|
@@ -1318,7 +1327,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
1318
1327
|
const define = {};
|
|
1319
1328
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
1320
1329
|
for (const global of getEntrypointGlobals(name)) {
|
|
1321
|
-
define[global.name] = JSON.stringify(global.value);
|
|
1330
|
+
define[`import.meta.env.${global.name}`] = JSON.stringify(global.value);
|
|
1322
1331
|
}
|
|
1323
1332
|
return {
|
|
1324
1333
|
define
|
|
@@ -1347,6 +1356,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
1347
1356
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
1348
1357
|
config.build.minify = false;
|
|
1349
1358
|
}
|
|
1359
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
1360
|
+
config.build.sourcemap = "inline";
|
|
1361
|
+
}
|
|
1350
1362
|
config.plugins ??= [];
|
|
1351
1363
|
config.plugins.push(
|
|
1352
1364
|
download(wxtConfig),
|
|
@@ -1709,8 +1721,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1709
1721
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
1710
1722
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
1711
1723
|
sourcesRoot: root,
|
|
1724
|
+
includeSources: [],
|
|
1712
1725
|
...mergedConfig.zip,
|
|
1713
|
-
|
|
1726
|
+
excludeSources: [
|
|
1714
1727
|
"**/node_modules",
|
|
1715
1728
|
// WXT files
|
|
1716
1729
|
"**/web-ext.config.ts",
|
|
@@ -1720,7 +1733,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
1720
1733
|
"**/__tests__/**",
|
|
1721
1734
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
1722
1735
|
// From user
|
|
1723
|
-
...mergedConfig.zip?.
|
|
1736
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
1724
1737
|
]
|
|
1725
1738
|
};
|
|
1726
1739
|
}
|
|
@@ -1842,15 +1855,16 @@ async function importEntrypointFile(path7, config) {
|
|
|
1842
1855
|
const res = await jiti(path7);
|
|
1843
1856
|
return res.default;
|
|
1844
1857
|
} catch (err) {
|
|
1858
|
+
const filePath = relative5(config.root, path7);
|
|
1845
1859
|
if (err instanceof ReferenceError) {
|
|
1846
1860
|
const variableName = err.message.replace(" is not defined", "");
|
|
1847
|
-
const filePath = relative5(config.root, path7);
|
|
1848
1861
|
throw Error(
|
|
1849
1862
|
`${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`,
|
|
1850
1863
|
{ cause: err }
|
|
1851
1864
|
);
|
|
1852
1865
|
} else {
|
|
1853
|
-
|
|
1866
|
+
config.logger.error(err);
|
|
1867
|
+
throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err });
|
|
1854
1868
|
}
|
|
1855
1869
|
}
|
|
1856
1870
|
}
|
|
@@ -3241,10 +3255,11 @@ async function zip(config) {
|
|
|
3241
3255
|
saveTo: sourcesZipPath,
|
|
3242
3256
|
filter(path7) {
|
|
3243
3257
|
const relativePath = relative11(internalConfig.zip.sourcesRoot, path7);
|
|
3244
|
-
|
|
3258
|
+
return internalConfig.zip.includeSources.some(
|
|
3259
|
+
(pattern) => minimatch2(relativePath, pattern)
|
|
3260
|
+
) || !internalConfig.zip.excludeSources.some(
|
|
3245
3261
|
(pattern) => minimatch2(relativePath, pattern)
|
|
3246
3262
|
);
|
|
3247
|
-
return matchedPattern == null;
|
|
3248
3263
|
}
|
|
3249
3264
|
});
|
|
3250
3265
|
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`
|
|
@@ -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`
|
package/dist/index.cjs
CHANGED
|
@@ -2465,9 +2465,14 @@ async function buildEntrypoints(groups, config, spinner) {
|
|
|
2465
2465
|
const steps = [];
|
|
2466
2466
|
for (let i = 0; i < groups.length; i++) {
|
|
2467
2467
|
const group = groups[i];
|
|
2468
|
-
const groupNames = [group].flat().map((e) => e.name)
|
|
2469
|
-
|
|
2470
|
-
|
|
2468
|
+
const groupNames = [group].flat().map((e) => e.name);
|
|
2469
|
+
const groupNameColored = groupNames.join(import_picocolors.default.dim(", "));
|
|
2470
|
+
spinner.text = import_picocolors.default.dim(`[${i + 1}/${groups.length}]`) + ` ${groupNameColored}`;
|
|
2471
|
+
try {
|
|
2472
|
+
steps.push(await config.builder.build(group));
|
|
2473
|
+
} catch (err) {
|
|
2474
|
+
throw Error(`Failed to build ${groupNames.join(", ")}`, { cause: err });
|
|
2475
|
+
}
|
|
2471
2476
|
}
|
|
2472
2477
|
const publicAssets = await copyPublicDirectory(config);
|
|
2473
2478
|
return { publicAssets, steps };
|
|
@@ -2995,42 +3000,42 @@ function getUnimportOptions(config) {
|
|
|
2995
3000
|
function getGlobals(config) {
|
|
2996
3001
|
return [
|
|
2997
3002
|
{
|
|
2998
|
-
name:
|
|
3003
|
+
name: "MANIFEST_VERSION",
|
|
2999
3004
|
value: config.manifestVersion,
|
|
3000
3005
|
type: `2 | 3`
|
|
3001
3006
|
},
|
|
3002
3007
|
{
|
|
3003
|
-
name:
|
|
3008
|
+
name: "BROWSER",
|
|
3004
3009
|
value: config.browser,
|
|
3005
3010
|
type: `string`
|
|
3006
3011
|
},
|
|
3007
3012
|
{
|
|
3008
|
-
name:
|
|
3013
|
+
name: "CHROME",
|
|
3009
3014
|
value: config.browser === "chrome",
|
|
3010
3015
|
type: `boolean`
|
|
3011
3016
|
},
|
|
3012
3017
|
{
|
|
3013
|
-
name:
|
|
3018
|
+
name: "FIREFOX",
|
|
3014
3019
|
value: config.browser === "firefox",
|
|
3015
3020
|
type: `boolean`
|
|
3016
3021
|
},
|
|
3017
3022
|
{
|
|
3018
|
-
name:
|
|
3023
|
+
name: "SAFARI",
|
|
3019
3024
|
value: config.browser === "safari",
|
|
3020
3025
|
type: `boolean`
|
|
3021
3026
|
},
|
|
3022
3027
|
{
|
|
3023
|
-
name:
|
|
3028
|
+
name: "EDGE",
|
|
3024
3029
|
value: config.browser === "edge",
|
|
3025
3030
|
type: `boolean`
|
|
3026
3031
|
},
|
|
3027
3032
|
{
|
|
3028
|
-
name:
|
|
3033
|
+
name: "OPERA",
|
|
3029
3034
|
value: config.browser === "opera",
|
|
3030
3035
|
type: `boolean`
|
|
3031
3036
|
},
|
|
3032
3037
|
{
|
|
3033
|
-
name:
|
|
3038
|
+
name: "COMMAND",
|
|
3034
3039
|
value: config.command,
|
|
3035
3040
|
type: `"build" | "serve"`
|
|
3036
3041
|
}
|
|
@@ -3039,15 +3044,12 @@ function getGlobals(config) {
|
|
|
3039
3044
|
function getEntrypointGlobals(entrypointName) {
|
|
3040
3045
|
return [
|
|
3041
3046
|
{
|
|
3042
|
-
name:
|
|
3047
|
+
name: "ENTRYPOINT",
|
|
3043
3048
|
value: entrypointName,
|
|
3044
3049
|
type: `string`
|
|
3045
3050
|
}
|
|
3046
3051
|
];
|
|
3047
3052
|
}
|
|
3048
|
-
function surroundInUnderscore(name) {
|
|
3049
|
-
return `__${name}__`;
|
|
3050
|
-
}
|
|
3051
3053
|
|
|
3052
3054
|
// src/core/utils/building/generate-wxt-dir.ts
|
|
3053
3055
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -3180,7 +3182,7 @@ declare module "wxt/browser" {
|
|
|
3180
3182
|
}
|
|
3181
3183
|
const overrides = messages.map((message) => {
|
|
3182
3184
|
return ` /**
|
|
3183
|
-
* ${message.description
|
|
3185
|
+
* ${message.description || "No message description."}
|
|
3184
3186
|
*
|
|
3185
3187
|
* "${message.message}"
|
|
3186
3188
|
*/
|
|
@@ -3204,8 +3206,11 @@ async function writeGlobalsDeclarationFile(config) {
|
|
|
3204
3206
|
[
|
|
3205
3207
|
"// Generated by wxt",
|
|
3206
3208
|
"export {}",
|
|
3207
|
-
"
|
|
3208
|
-
...globals2.map((global3) => `
|
|
3209
|
+
"interface ImportMetaEnv {",
|
|
3210
|
+
...globals2.map((global3) => ` readonly ${global3.name}: ${global3.type};`),
|
|
3211
|
+
"}",
|
|
3212
|
+
"interface ImportMeta {",
|
|
3213
|
+
" readonly env: ImportMetaEnv",
|
|
3209
3214
|
"}"
|
|
3210
3215
|
].join("\n") + "\n"
|
|
3211
3216
|
);
|
|
@@ -3586,7 +3591,11 @@ function unimport(config) {
|
|
|
3586
3591
|
return;
|
|
3587
3592
|
if (!ENABLED_EXTENSIONS.has((0, import_path5.extname)(id)))
|
|
3588
3593
|
return;
|
|
3589
|
-
|
|
3594
|
+
const injected = await unimport2.injectImports(code, id);
|
|
3595
|
+
return {
|
|
3596
|
+
code: injected.code,
|
|
3597
|
+
map: injected.s.generateMap({ hires: "boundary", source: id })
|
|
3598
|
+
};
|
|
3590
3599
|
}
|
|
3591
3600
|
};
|
|
3592
3601
|
}
|
|
@@ -3697,7 +3706,7 @@ function globals(config) {
|
|
|
3697
3706
|
config() {
|
|
3698
3707
|
const define = {};
|
|
3699
3708
|
for (const global3 of getGlobals(config)) {
|
|
3700
|
-
define[global3.name] = JSON.stringify(global3.value);
|
|
3709
|
+
define[`import.meta.env.${global3.name}`] = JSON.stringify(global3.value);
|
|
3701
3710
|
}
|
|
3702
3711
|
return {
|
|
3703
3712
|
define
|
|
@@ -3741,7 +3750,7 @@ function entrypointGroupGlobals(entrypointGroup) {
|
|
|
3741
3750
|
const define = {};
|
|
3742
3751
|
let name = Array.isArray(entrypointGroup) ? "html" : entrypointGroup.name;
|
|
3743
3752
|
for (const global3 of getEntrypointGlobals(name)) {
|
|
3744
|
-
define[global3.name] = JSON.stringify(global3.value);
|
|
3753
|
+
define[`import.meta.env.${global3.name}`] = JSON.stringify(global3.value);
|
|
3745
3754
|
}
|
|
3746
3755
|
return {
|
|
3747
3756
|
define
|
|
@@ -3770,6 +3779,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
|
|
|
3770
3779
|
if (config.build.minify == null && wxtConfig.command === "serve") {
|
|
3771
3780
|
config.build.minify = false;
|
|
3772
3781
|
}
|
|
3782
|
+
if (config.build.sourcemap == null && wxtConfig.command === "serve") {
|
|
3783
|
+
config.build.sourcemap = "inline";
|
|
3784
|
+
}
|
|
3773
3785
|
config.plugins ??= [];
|
|
3774
3786
|
config.plugins.push(
|
|
3775
3787
|
download(wxtConfig),
|
|
@@ -4132,8 +4144,9 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
4132
4144
|
sourcesTemplate: "{{name}}-{{version}}-sources.zip",
|
|
4133
4145
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
4134
4146
|
sourcesRoot: root,
|
|
4147
|
+
includeSources: [],
|
|
4135
4148
|
...mergedConfig.zip,
|
|
4136
|
-
|
|
4149
|
+
excludeSources: [
|
|
4137
4150
|
"**/node_modules",
|
|
4138
4151
|
// WXT files
|
|
4139
4152
|
"**/web-ext.config.ts",
|
|
@@ -4143,7 +4156,7 @@ function resolveInternalZipConfig(root, mergedConfig) {
|
|
|
4143
4156
|
"**/__tests__/**",
|
|
4144
4157
|
"**/*.+(test|spec).?(c|m)+(j|t)s?(x)",
|
|
4145
4158
|
// From user
|
|
4146
|
-
...mergedConfig.zip?.
|
|
4159
|
+
...mergedConfig.zip?.excludeSources ?? []
|
|
4147
4160
|
]
|
|
4148
4161
|
};
|
|
4149
4162
|
}
|
|
@@ -4266,15 +4279,16 @@ async function importEntrypointFile(path10, config) {
|
|
|
4266
4279
|
const res = await jiti(path10);
|
|
4267
4280
|
return res.default;
|
|
4268
4281
|
} catch (err) {
|
|
4282
|
+
const filePath = (0, import_node_path8.relative)(config.root, path10);
|
|
4269
4283
|
if (err instanceof ReferenceError) {
|
|
4270
4284
|
const variableName = err.message.replace(" is not defined", "");
|
|
4271
|
-
const filePath = (0, import_node_path8.relative)(config.root, path10);
|
|
4272
4285
|
throw Error(
|
|
4273
4286
|
`${filePath}: Cannot use imported variable "${variableName}" outside the main function. See https://wxt.dev/guide/entrypoints.html#side-effects`,
|
|
4274
4287
|
{ cause: err }
|
|
4275
4288
|
);
|
|
4276
4289
|
} else {
|
|
4277
|
-
|
|
4290
|
+
config.logger.error(err);
|
|
4291
|
+
throw Error(`Failed to load entrypoint: ${filePath}`, { cause: err });
|
|
4278
4292
|
}
|
|
4279
4293
|
}
|
|
4280
4294
|
}
|
|
@@ -4400,7 +4414,7 @@ function getChunkSortWeight(filename) {
|
|
|
4400
4414
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4401
4415
|
|
|
4402
4416
|
// package.json
|
|
4403
|
-
var version = "0.
|
|
4417
|
+
var version = "0.15.0";
|
|
4404
4418
|
|
|
4405
4419
|
// src/core/utils/log/printHeader.ts
|
|
4406
4420
|
var import_consola2 = require("consola");
|
|
@@ -5676,10 +5690,11 @@ async function zip(config) {
|
|
|
5676
5690
|
saveTo: sourcesZipPath,
|
|
5677
5691
|
filter(path10) {
|
|
5678
5692
|
const relativePath = (0, import_node_path20.relative)(internalConfig.zip.sourcesRoot, path10);
|
|
5679
|
-
|
|
5693
|
+
return internalConfig.zip.includeSources.some(
|
|
5694
|
+
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5695
|
+
) || !internalConfig.zip.excludeSources.some(
|
|
5680
5696
|
(pattern) => (0, import_minimatch2.minimatch)(relativePath, pattern)
|
|
5681
5697
|
);
|
|
5682
|
-
return matchedPattern == null;
|
|
5683
5698
|
}
|
|
5684
5699
|
});
|
|
5685
5700
|
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-jLnyv431.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-jLnyv431.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.0";
|
|
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-jLnyv431.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-jLnyv431.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.0";
|
|
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-HSXPP3ZS.js";
|
|
19
19
|
import "./chunk-VBXJIVYU.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
@@ -563,10 +563,11 @@ async function zip(config) {
|
|
|
563
563
|
saveTo: sourcesZipPath,
|
|
564
564
|
filter(path3) {
|
|
565
565
|
const relativePath = relative5(internalConfig.zip.sourcesRoot, path3);
|
|
566
|
-
|
|
566
|
+
return internalConfig.zip.includeSources.some(
|
|
567
|
+
(pattern) => minimatch(relativePath, pattern)
|
|
568
|
+
) || !internalConfig.zip.excludeSources.some(
|
|
567
569
|
(pattern) => minimatch(relativePath, pattern)
|
|
568
570
|
);
|
|
569
|
-
return matchedPattern == null;
|
|
570
571
|
}
|
|
571
572
|
});
|
|
572
573
|
zipFiles.push(sourcesZipPath);
|
package/dist/storage.cjs
CHANGED
|
@@ -295,10 +295,20 @@ function createStorage() {
|
|
|
295
295
|
}
|
|
296
296
|
function createDriver(storageArea) {
|
|
297
297
|
const getStorageArea = () => {
|
|
298
|
-
if (browser.
|
|
298
|
+
if (browser.runtime == null) {
|
|
299
|
+
throw Error(
|
|
300
|
+
[
|
|
301
|
+
"'wxt/storage' must be loaded in a web extension environment",
|
|
302
|
+
"\n - If thrown during a build, see https://github.com/wxt-dev/wxt/issues/371",
|
|
303
|
+
" - If thrown during tests, mock 'wxt/browser' correctly. See https://wxt.dev/guide/testing.html\n"
|
|
304
|
+
].join("\n")
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
if (browser.storage == null) {
|
|
299
308
|
throw Error(
|
|
300
309
|
"You must add the 'storage' permission to your manifest to use 'wxt/storage'"
|
|
301
310
|
);
|
|
311
|
+
}
|
|
302
312
|
return browser.storage[storageArea];
|
|
303
313
|
};
|
|
304
314
|
const watchListeners = /* @__PURE__ */ new Set();
|
package/dist/storage.js
CHANGED
|
@@ -261,10 +261,20 @@ function createStorage() {
|
|
|
261
261
|
}
|
|
262
262
|
function createDriver(storageArea) {
|
|
263
263
|
const getStorageArea = () => {
|
|
264
|
-
if (browser.
|
|
264
|
+
if (browser.runtime == null) {
|
|
265
|
+
throw Error(
|
|
266
|
+
[
|
|
267
|
+
"'wxt/storage' must be loaded in a web extension environment",
|
|
268
|
+
"\n - If thrown during a build, see https://github.com/wxt-dev/wxt/issues/371",
|
|
269
|
+
" - If thrown during tests, mock 'wxt/browser' correctly. See https://wxt.dev/guide/testing.html\n"
|
|
270
|
+
].join("\n")
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
if (browser.storage == null) {
|
|
265
274
|
throw Error(
|
|
266
275
|
"You must add the 'storage' permission to your manifest to use 'wxt/storage'"
|
|
267
276
|
);
|
|
277
|
+
}
|
|
268
278
|
return browser.storage[storageArea];
|
|
269
279
|
};
|
|
270
280
|
const watchListeners = /* @__PURE__ */ new Set();
|
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-jLnyv431.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-jLnyv431.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.0",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
115
115
|
"unimport": "^3.4.0",
|
|
116
116
|
"vite": "^5.0.0",
|
|
117
|
-
"web-ext-run": "^0.1.
|
|
117
|
+
"web-ext-run": "^0.1.2",
|
|
118
118
|
"webextension-polyfill": "^0.10.0",
|
|
119
119
|
"zip-dir": "^2.0.0"
|
|
120
120
|
},
|
package/dist/cli.d.ts
DELETED