wxt 0.17.11 → 0.17.13-alpha1
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/README.md +2 -0
- package/dist/{chunk-XFXYT75Z.js → chunk-YWGLK5GM.js} +42 -27
- package/dist/cli.js +68 -49
- package/dist/client.d.ts +1 -1
- package/dist/client.js +12 -3
- package/dist/{index-mYGv2dqk.d.ts → index-Aan1uu3v.d.ts} +17 -5
- package/dist/{index-2A45qoLY.d.cts → index-INepal5k.d.cts} +44 -6
- package/dist/{index-2A45qoLY.d.ts → index-INepal5k.d.ts} +44 -6
- package/dist/index.cjs +65 -46
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -2
- package/dist/sandbox.d.ts +1 -1
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/virtual/content-script-isolated-world-entrypoint.js +7 -2
- package/dist/virtual/content-script-main-world-entrypoint.js +7 -2
- package/dist/virtual/unlisted-script-entrypoint.js +7 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
<a href="https://wxt.dev/api/config.html" target="_blank">Configuration</a>
|
|
30
30
|
•
|
|
31
31
|
<a href="https://wxt.dev/examples.html" target="_blank">Examples</a>
|
|
32
|
+
•
|
|
33
|
+
<a href="https://discord.gg/ZFsZqGery9" target="_blank">Discord</a>
|
|
32
34
|
</p>
|
|
33
35
|
|
|
34
36
|

|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-VBXJIVYU.js";
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
|
-
var version = "0.17.
|
|
11
|
+
var version = "0.17.13-alpha1";
|
|
12
12
|
|
|
13
13
|
// src/core/utils/paths.ts
|
|
14
14
|
import systemPath from "node:path";
|
|
@@ -655,6 +655,26 @@ function defineImportMeta() {
|
|
|
655
655
|
};
|
|
656
656
|
}
|
|
657
657
|
|
|
658
|
+
// src/core/utils/strings.ts
|
|
659
|
+
function kebabCaseAlphanumeric(str) {
|
|
660
|
+
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
661
|
+
}
|
|
662
|
+
function safeVarName(str) {
|
|
663
|
+
return "_" + kebabCaseAlphanumeric(str).replace("-", "_");
|
|
664
|
+
}
|
|
665
|
+
function removeImportStatements(text) {
|
|
666
|
+
return text.replace(
|
|
667
|
+
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
|
668
|
+
""
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
function removeProjectImportStatements(text) {
|
|
672
|
+
const noImports = removeImportStatements(text);
|
|
673
|
+
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
674
|
+
|
|
675
|
+
${noImports}`;
|
|
676
|
+
}
|
|
677
|
+
|
|
658
678
|
// src/core/utils/fs.ts
|
|
659
679
|
import fs3 from "fs-extra";
|
|
660
680
|
import glob from "fast-glob";
|
|
@@ -1602,6 +1622,7 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
1602
1622
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
1603
1623
|
sourcesRoot: root,
|
|
1604
1624
|
includeSources: [],
|
|
1625
|
+
compressionLevel: 9,
|
|
1605
1626
|
...mergedConfig.zip,
|
|
1606
1627
|
excludeSources: [
|
|
1607
1628
|
"**/node_modules",
|
|
@@ -1750,25 +1771,6 @@ import createJITI from "jiti";
|
|
|
1750
1771
|
import { createUnimport as createUnimport3 } from "unimport";
|
|
1751
1772
|
import fs10 from "fs-extra";
|
|
1752
1773
|
import { relative as relative5, resolve as resolve10 } from "node:path";
|
|
1753
|
-
|
|
1754
|
-
// src/core/utils/strings.ts
|
|
1755
|
-
function kebabCaseAlphanumeric(str) {
|
|
1756
|
-
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
1757
|
-
}
|
|
1758
|
-
function removeImportStatements(text) {
|
|
1759
|
-
return text.replace(
|
|
1760
|
-
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
|
1761
|
-
""
|
|
1762
|
-
);
|
|
1763
|
-
}
|
|
1764
|
-
function removeProjectImportStatements(text) {
|
|
1765
|
-
const noImports = removeImportStatements(text);
|
|
1766
|
-
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
1767
|
-
|
|
1768
|
-
${noImports}`;
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
// src/core/utils/building/import-entrypoint.ts
|
|
1772
1774
|
import { transformSync } from "esbuild";
|
|
1773
1775
|
import { fileURLToPath } from "node:url";
|
|
1774
1776
|
async function importEntrypointFile(path8) {
|
|
@@ -2994,7 +2996,7 @@ var packageManagers = {
|
|
|
2994
2996
|
};
|
|
2995
2997
|
|
|
2996
2998
|
// src/core/builders/vite/index.ts
|
|
2997
|
-
async function createViteBuilder(wxtConfig, server) {
|
|
2999
|
+
async function createViteBuilder(wxtConfig, hooks, server) {
|
|
2998
3000
|
const vite = await import("vite");
|
|
2999
3001
|
const getBaseConfig = async () => {
|
|
3000
3002
|
const config = await wxtConfig.vite(wxtConfig.env);
|
|
@@ -3039,14 +3041,22 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
3039
3041
|
if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
|
|
3040
3042
|
plugins.push(cssEntrypoints(entrypoint, wxtConfig));
|
|
3041
3043
|
}
|
|
3044
|
+
const iifeReturnValueName = safeVarName(entrypoint.name);
|
|
3042
3045
|
const libMode = {
|
|
3043
3046
|
mode: wxtConfig.mode,
|
|
3044
3047
|
plugins,
|
|
3048
|
+
esbuild: {
|
|
3049
|
+
// Add a footer with the returned value so it can return values to `scripting.executeScript`
|
|
3050
|
+
// Footer is added apart of esbuild to make sure it's not minified. It
|
|
3051
|
+
// get's removed if added to `build.rollupOptions.output.footer`
|
|
3052
|
+
// See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
|
|
3053
|
+
footer: iifeReturnValueName + ";"
|
|
3054
|
+
},
|
|
3045
3055
|
build: {
|
|
3046
3056
|
lib: {
|
|
3047
3057
|
entry,
|
|
3048
3058
|
formats: ["iife"],
|
|
3049
|
-
name:
|
|
3059
|
+
name: iifeReturnValueName,
|
|
3050
3060
|
fileName: entrypoint.name
|
|
3051
3061
|
},
|
|
3052
3062
|
rollupOptions: {
|
|
@@ -3142,6 +3152,11 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
3142
3152
|
else
|
|
3143
3153
|
entryConfig = getLibModeConfig(group);
|
|
3144
3154
|
const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
|
|
3155
|
+
await hooks.callHook(
|
|
3156
|
+
"vite:build:extendConfig",
|
|
3157
|
+
toArray(group),
|
|
3158
|
+
buildConfig
|
|
3159
|
+
);
|
|
3145
3160
|
const result = await vite.build(buildConfig);
|
|
3146
3161
|
return {
|
|
3147
3162
|
entrypoints: group,
|
|
@@ -3158,9 +3173,9 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
3158
3173
|
}
|
|
3159
3174
|
};
|
|
3160
3175
|
const baseConfig = await getBaseConfig();
|
|
3161
|
-
const
|
|
3162
|
-
|
|
3163
|
-
);
|
|
3176
|
+
const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
|
|
3177
|
+
await hooks.callHook("vite:devServer:extendConfig", finalConfig);
|
|
3178
|
+
const viteServer = await vite.createServer(finalConfig);
|
|
3164
3179
|
const server2 = {
|
|
3165
3180
|
async listen() {
|
|
3166
3181
|
await viteServer.listen(info.port);
|
|
@@ -3216,7 +3231,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
3216
3231
|
const hooks = createHooks();
|
|
3217
3232
|
const config = await resolveConfig(inlineConfig, command);
|
|
3218
3233
|
const server = await getServer?.(config);
|
|
3219
|
-
const builder = await createViteBuilder(config, server);
|
|
3234
|
+
const builder = await createViteBuilder(config, hooks, server);
|
|
3220
3235
|
const pm = await createWxtPackageManager(config.root);
|
|
3221
3236
|
wxt = {
|
|
3222
3237
|
config,
|
|
@@ -3246,6 +3261,7 @@ export {
|
|
|
3246
3261
|
tsconfigPaths,
|
|
3247
3262
|
globals,
|
|
3248
3263
|
webextensionPolyfillMock,
|
|
3264
|
+
kebabCaseAlphanumeric,
|
|
3249
3265
|
wxt,
|
|
3250
3266
|
registerWxt,
|
|
3251
3267
|
detectDevChanges,
|
|
@@ -3253,7 +3269,6 @@ export {
|
|
|
3253
3269
|
generateTypesDir,
|
|
3254
3270
|
getPackageJson,
|
|
3255
3271
|
resolveConfig,
|
|
3256
|
-
kebabCaseAlphanumeric,
|
|
3257
3272
|
printFileList,
|
|
3258
3273
|
version,
|
|
3259
3274
|
mapWxtOptionsToRegisteredContentScript,
|
package/dist/cli.js
CHANGED
|
@@ -840,8 +840,48 @@ function defineImportMeta() {
|
|
|
840
840
|
};
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
+
// src/core/utils/arrays.ts
|
|
844
|
+
function every(array, predicate) {
|
|
845
|
+
for (let i = 0; i < array.length; i++)
|
|
846
|
+
if (!predicate(array[i], i))
|
|
847
|
+
return false;
|
|
848
|
+
return true;
|
|
849
|
+
}
|
|
850
|
+
function some(array, predicate) {
|
|
851
|
+
for (let i = 0; i < array.length; i++)
|
|
852
|
+
if (predicate(array[i], i))
|
|
853
|
+
return true;
|
|
854
|
+
return false;
|
|
855
|
+
}
|
|
856
|
+
function toArray(a) {
|
|
857
|
+
return Array.isArray(a) ? a : [a];
|
|
858
|
+
}
|
|
859
|
+
function filterTruthy(array) {
|
|
860
|
+
return array.filter((item) => !!item);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/core/utils/strings.ts
|
|
864
|
+
function kebabCaseAlphanumeric(str) {
|
|
865
|
+
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
866
|
+
}
|
|
867
|
+
function safeVarName(str) {
|
|
868
|
+
return "_" + kebabCaseAlphanumeric(str).replace("-", "_");
|
|
869
|
+
}
|
|
870
|
+
function removeImportStatements(text) {
|
|
871
|
+
return text.replace(
|
|
872
|
+
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
|
873
|
+
""
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
function removeProjectImportStatements(text) {
|
|
877
|
+
const noImports = removeImportStatements(text);
|
|
878
|
+
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
879
|
+
|
|
880
|
+
${noImports}`;
|
|
881
|
+
}
|
|
882
|
+
|
|
843
883
|
// src/core/builders/vite/index.ts
|
|
844
|
-
async function createViteBuilder(wxtConfig, server) {
|
|
884
|
+
async function createViteBuilder(wxtConfig, hooks, server) {
|
|
845
885
|
const vite = await import("vite");
|
|
846
886
|
const getBaseConfig = async () => {
|
|
847
887
|
const config = await wxtConfig.vite(wxtConfig.env);
|
|
@@ -886,14 +926,22 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
886
926
|
if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
|
|
887
927
|
plugins.push(cssEntrypoints(entrypoint, wxtConfig));
|
|
888
928
|
}
|
|
929
|
+
const iifeReturnValueName = safeVarName(entrypoint.name);
|
|
889
930
|
const libMode = {
|
|
890
931
|
mode: wxtConfig.mode,
|
|
891
932
|
plugins,
|
|
933
|
+
esbuild: {
|
|
934
|
+
// Add a footer with the returned value so it can return values to `scripting.executeScript`
|
|
935
|
+
// Footer is added apart of esbuild to make sure it's not minified. It
|
|
936
|
+
// get's removed if added to `build.rollupOptions.output.footer`
|
|
937
|
+
// See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
|
|
938
|
+
footer: iifeReturnValueName + ";"
|
|
939
|
+
},
|
|
892
940
|
build: {
|
|
893
941
|
lib: {
|
|
894
942
|
entry,
|
|
895
943
|
formats: ["iife"],
|
|
896
|
-
name:
|
|
944
|
+
name: iifeReturnValueName,
|
|
897
945
|
fileName: entrypoint.name
|
|
898
946
|
},
|
|
899
947
|
rollupOptions: {
|
|
@@ -989,6 +1037,11 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
989
1037
|
else
|
|
990
1038
|
entryConfig = getLibModeConfig(group);
|
|
991
1039
|
const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
|
|
1040
|
+
await hooks.callHook(
|
|
1041
|
+
"vite:build:extendConfig",
|
|
1042
|
+
toArray(group),
|
|
1043
|
+
buildConfig
|
|
1044
|
+
);
|
|
992
1045
|
const result = await vite.build(buildConfig);
|
|
993
1046
|
return {
|
|
994
1047
|
entrypoints: group,
|
|
@@ -1005,9 +1058,9 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
1005
1058
|
}
|
|
1006
1059
|
};
|
|
1007
1060
|
const baseConfig = await getBaseConfig();
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
);
|
|
1061
|
+
const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
|
|
1062
|
+
await hooks.callHook("vite:devServer:extendConfig", finalConfig);
|
|
1063
|
+
const viteServer = await vite.createServer(finalConfig);
|
|
1011
1064
|
const server2 = {
|
|
1012
1065
|
async listen() {
|
|
1013
1066
|
await viteServer.listen(info.port);
|
|
@@ -1063,7 +1116,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
1063
1116
|
const hooks = createHooks();
|
|
1064
1117
|
const config = await resolveConfig(inlineConfig, command);
|
|
1065
1118
|
const server = await getServer?.(config);
|
|
1066
|
-
const builder = await createViteBuilder(config, server);
|
|
1119
|
+
const builder = await createViteBuilder(config, hooks, server);
|
|
1067
1120
|
const pm = await createWxtPackageManager(config.root);
|
|
1068
1121
|
wxt = {
|
|
1069
1122
|
config,
|
|
@@ -1100,28 +1153,6 @@ async function getPublicFiles() {
|
|
|
1100
1153
|
import fs4 from "fs-extra";
|
|
1101
1154
|
import { dirname as dirname3, resolve as resolve5 } from "path";
|
|
1102
1155
|
import pc from "picocolors";
|
|
1103
|
-
|
|
1104
|
-
// src/core/utils/arrays.ts
|
|
1105
|
-
function every(array, predicate) {
|
|
1106
|
-
for (let i = 0; i < array.length; i++)
|
|
1107
|
-
if (!predicate(array[i], i))
|
|
1108
|
-
return false;
|
|
1109
|
-
return true;
|
|
1110
|
-
}
|
|
1111
|
-
function some(array, predicate) {
|
|
1112
|
-
for (let i = 0; i < array.length; i++)
|
|
1113
|
-
if (predicate(array[i], i))
|
|
1114
|
-
return true;
|
|
1115
|
-
return false;
|
|
1116
|
-
}
|
|
1117
|
-
function toArray(a) {
|
|
1118
|
-
return Array.isArray(a) ? a : [a];
|
|
1119
|
-
}
|
|
1120
|
-
function filterTruthy(array) {
|
|
1121
|
-
return array.filter((item) => !!item);
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
// src/core/utils/building/build-entrypoints.ts
|
|
1125
1156
|
async function buildEntrypoints(groups, spinner) {
|
|
1126
1157
|
const steps = [];
|
|
1127
1158
|
for (let i = 0; i < groups.length; i++) {
|
|
@@ -2049,6 +2080,7 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
2049
2080
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
2050
2081
|
sourcesRoot: root,
|
|
2051
2082
|
includeSources: [],
|
|
2083
|
+
compressionLevel: 9,
|
|
2052
2084
|
...mergedConfig.zip,
|
|
2053
2085
|
excludeSources: [
|
|
2054
2086
|
"**/node_modules",
|
|
@@ -2197,25 +2229,6 @@ import createJITI from "jiti";
|
|
|
2197
2229
|
import { createUnimport as createUnimport3 } from "unimport";
|
|
2198
2230
|
import fs10 from "fs-extra";
|
|
2199
2231
|
import { relative as relative5, resolve as resolve10 } from "node:path";
|
|
2200
|
-
|
|
2201
|
-
// src/core/utils/strings.ts
|
|
2202
|
-
function kebabCaseAlphanumeric(str) {
|
|
2203
|
-
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
2204
|
-
}
|
|
2205
|
-
function removeImportStatements(text) {
|
|
2206
|
-
return text.replace(
|
|
2207
|
-
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
|
2208
|
-
""
|
|
2209
|
-
);
|
|
2210
|
-
}
|
|
2211
|
-
function removeProjectImportStatements(text) {
|
|
2212
|
-
const noImports = removeImportStatements(text);
|
|
2213
|
-
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
2214
|
-
|
|
2215
|
-
${noImports}`;
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
// src/core/utils/building/import-entrypoint.ts
|
|
2219
2232
|
import { transformSync } from "esbuild";
|
|
2220
2233
|
import { fileURLToPath } from "node:url";
|
|
2221
2234
|
async function importEntrypointFile(path10) {
|
|
@@ -2415,7 +2428,7 @@ function getChunkSortWeight(filename) {
|
|
|
2415
2428
|
import pc4 from "picocolors";
|
|
2416
2429
|
|
|
2417
2430
|
// package.json
|
|
2418
|
-
var version = "0.17.
|
|
2431
|
+
var version = "0.17.13-alpha1";
|
|
2419
2432
|
|
|
2420
2433
|
// src/core/utils/log/printHeader.ts
|
|
2421
2434
|
import { consola as consola2 } from "consola";
|
|
@@ -3849,7 +3862,13 @@ async function zipDir(directory, outputPath, options) {
|
|
|
3849
3862
|
}
|
|
3850
3863
|
}
|
|
3851
3864
|
await options?.additionalWork?.(archive);
|
|
3852
|
-
const buffer = await archive.generateAsync({
|
|
3865
|
+
const buffer = await archive.generateAsync({
|
|
3866
|
+
type: "base64",
|
|
3867
|
+
...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
|
|
3868
|
+
compression: "DEFLATE",
|
|
3869
|
+
compressionOptions: { level: wxt.config.zip.compressionLevel }
|
|
3870
|
+
}
|
|
3871
|
+
});
|
|
3853
3872
|
await fs16.writeFile(outputPath, buffer, "base64");
|
|
3854
3873
|
}
|
|
3855
3874
|
async function downloadPrivatePackages() {
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -244,10 +244,13 @@ function createIntegratedUi(ctx, options) {
|
|
|
244
244
|
const remove = () => {
|
|
245
245
|
options.onRemove?.(mounted);
|
|
246
246
|
wrapper.remove();
|
|
247
|
+
mounted = void 0;
|
|
247
248
|
};
|
|
248
249
|
ctx.onInvalidated(remove);
|
|
249
250
|
return {
|
|
250
|
-
mounted
|
|
251
|
+
get mounted() {
|
|
252
|
+
return mounted;
|
|
253
|
+
},
|
|
251
254
|
wrapper,
|
|
252
255
|
mount,
|
|
253
256
|
remove
|
|
@@ -268,10 +271,13 @@ function createIframeUi(ctx, options) {
|
|
|
268
271
|
const remove = () => {
|
|
269
272
|
options.onRemove?.(mounted);
|
|
270
273
|
wrapper.remove();
|
|
274
|
+
mounted = void 0;
|
|
271
275
|
};
|
|
272
276
|
ctx.onInvalidated(remove);
|
|
273
277
|
return {
|
|
274
|
-
mounted
|
|
278
|
+
get mounted() {
|
|
279
|
+
return mounted;
|
|
280
|
+
},
|
|
275
281
|
iframe,
|
|
276
282
|
wrapper,
|
|
277
283
|
mount,
|
|
@@ -308,6 +314,7 @@ async function createShadowRootUi(ctx, options) {
|
|
|
308
314
|
shadowHost.remove();
|
|
309
315
|
while (uiContainer.lastChild)
|
|
310
316
|
uiContainer.removeChild(uiContainer.lastChild);
|
|
317
|
+
mounted = void 0;
|
|
311
318
|
};
|
|
312
319
|
ctx.onInvalidated(remove);
|
|
313
320
|
return {
|
|
@@ -316,7 +323,9 @@ async function createShadowRootUi(ctx, options) {
|
|
|
316
323
|
uiContainer,
|
|
317
324
|
mount,
|
|
318
325
|
remove,
|
|
319
|
-
mounted
|
|
326
|
+
get mounted() {
|
|
327
|
+
return mounted;
|
|
328
|
+
}
|
|
320
329
|
};
|
|
321
330
|
}
|
|
322
331
|
function applyPosition(root, positionedElement, options) {
|
|
@@ -205,8 +205,8 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
|
205
205
|
* - `"manifest"`: The content script will be added to the `content_scripts` entry in the
|
|
206
206
|
* manifest. This is the normal and most well known way of registering a content script.
|
|
207
207
|
* - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
|
|
208
|
-
* responsible for using the scripting API to register the content script
|
|
209
|
-
* runtime.
|
|
208
|
+
* responsible for using the scripting API to register/execute the content script
|
|
209
|
+
* dynamically at runtime.
|
|
210
210
|
*
|
|
211
211
|
* @default "manifest"
|
|
212
212
|
*/
|
|
@@ -228,14 +228,22 @@ interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptE
|
|
|
228
228
|
interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
|
|
229
229
|
/**
|
|
230
230
|
* Main function executed when the content script is loaded.
|
|
231
|
+
*
|
|
232
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
233
|
+
* values returned from this function will be returned in the `executeScript`
|
|
234
|
+
* result as well. Otherwise returning a value does nothing.
|
|
231
235
|
*/
|
|
232
|
-
main(ctx: ContentScriptContext):
|
|
236
|
+
main(ctx: ContentScriptContext): any | Promise<any>;
|
|
233
237
|
}
|
|
234
238
|
interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
235
239
|
/**
|
|
236
240
|
* Main function executed when the content script is loaded.
|
|
241
|
+
*
|
|
242
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
243
|
+
* values returned from this function will be returned in the `executeScript`
|
|
244
|
+
* result as well. Otherwise returning a value does nothing.
|
|
237
245
|
*/
|
|
238
|
-
main():
|
|
246
|
+
main(): any | Promise<any>;
|
|
239
247
|
}
|
|
240
248
|
type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
241
249
|
interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
@@ -247,8 +255,12 @@ interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
|
247
255
|
interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
248
256
|
/**
|
|
249
257
|
* Main function executed when the unlisted script is ran.
|
|
258
|
+
*
|
|
259
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
260
|
+
* values returned from this function will be returned in the `executeScript`
|
|
261
|
+
* result as well. Otherwise returning a value does nothing.
|
|
250
262
|
*/
|
|
251
|
-
main():
|
|
263
|
+
main(): any | Promise<any>;
|
|
252
264
|
}
|
|
253
265
|
/**
|
|
254
266
|
* Either a single value or a map of different browsers to the value for that browser.
|
|
@@ -320,6 +320,14 @@ interface InlineConfig {
|
|
|
320
320
|
* ["@scope/package-name@1.1.3", "package-name@^2"]
|
|
321
321
|
*/
|
|
322
322
|
downloadPackages?: string[];
|
|
323
|
+
/**
|
|
324
|
+
* Compression level to use when zipping files.
|
|
325
|
+
*
|
|
326
|
+
* Levels: 0 (no compression) to 9 (maximum compression).
|
|
327
|
+
*
|
|
328
|
+
* @default 9
|
|
329
|
+
*/
|
|
330
|
+
compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
323
331
|
};
|
|
324
332
|
/**
|
|
325
333
|
* @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
|
|
@@ -647,8 +655,8 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
|
647
655
|
* - `"manifest"`: The content script will be added to the `content_scripts` entry in the
|
|
648
656
|
* manifest. This is the normal and most well known way of registering a content script.
|
|
649
657
|
* - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
|
|
650
|
-
* responsible for using the scripting API to register the content script
|
|
651
|
-
* runtime.
|
|
658
|
+
* responsible for using the scripting API to register/execute the content script
|
|
659
|
+
* dynamically at runtime.
|
|
652
660
|
*
|
|
653
661
|
* @default "manifest"
|
|
654
662
|
*/
|
|
@@ -753,14 +761,22 @@ type OnContentScriptStopped = (cb: () => void) => void;
|
|
|
753
761
|
interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
|
|
754
762
|
/**
|
|
755
763
|
* Main function executed when the content script is loaded.
|
|
764
|
+
*
|
|
765
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
766
|
+
* values returned from this function will be returned in the `executeScript`
|
|
767
|
+
* result as well. Otherwise returning a value does nothing.
|
|
756
768
|
*/
|
|
757
|
-
main(ctx: ContentScriptContext):
|
|
769
|
+
main(ctx: ContentScriptContext): any | Promise<any>;
|
|
758
770
|
}
|
|
759
771
|
interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
760
772
|
/**
|
|
761
773
|
* Main function executed when the content script is loaded.
|
|
774
|
+
*
|
|
775
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
776
|
+
* values returned from this function will be returned in the `executeScript`
|
|
777
|
+
* result as well. Otherwise returning a value does nothing.
|
|
762
778
|
*/
|
|
763
|
-
main():
|
|
779
|
+
main(): any | Promise<any>;
|
|
764
780
|
}
|
|
765
781
|
type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
766
782
|
interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
@@ -772,8 +788,12 @@ interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
|
772
788
|
interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
773
789
|
/**
|
|
774
790
|
* Main function executed when the unlisted script is ran.
|
|
791
|
+
*
|
|
792
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
793
|
+
* values returned from this function will be returned in the `executeScript`
|
|
794
|
+
* result as well. Otherwise returning a value does nothing.
|
|
775
795
|
*/
|
|
776
|
-
main():
|
|
796
|
+
main(): any | Promise<any>;
|
|
777
797
|
}
|
|
778
798
|
/**
|
|
779
799
|
* Either a single value or a map of different browsers to the value for that browser.
|
|
@@ -967,6 +987,23 @@ interface ServerInfo {
|
|
|
967
987
|
origin: string;
|
|
968
988
|
}
|
|
969
989
|
type HookResult = Promise<void> | void;
|
|
990
|
+
interface WxtHooks {
|
|
991
|
+
/**
|
|
992
|
+
* Called when WXT has created Vite's config for a build step. Useful if you
|
|
993
|
+
* want to add plugins or update the vite config per entrypoint group.
|
|
994
|
+
*
|
|
995
|
+
* @param entrypoints The list of entrypoints being built with the provided config.
|
|
996
|
+
* @param viteConfig The config that will be used for the dev server.
|
|
997
|
+
*/
|
|
998
|
+
'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
|
|
999
|
+
/**
|
|
1000
|
+
* Called when WXT has created Vite's config for the dev server. Useful if
|
|
1001
|
+
* you want to add plugins or update the vite config per entrypoint group.
|
|
1002
|
+
*
|
|
1003
|
+
* @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
|
|
1004
|
+
*/
|
|
1005
|
+
'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
|
|
1006
|
+
}
|
|
970
1007
|
interface WxtHooks {
|
|
971
1008
|
/**
|
|
972
1009
|
* Called after WXT initialization, when the WXT instance is ready to work.
|
|
@@ -1067,6 +1104,7 @@ interface ResolvedConfig {
|
|
|
1067
1104
|
sourcesRoot: string;
|
|
1068
1105
|
downloadedPackagesDir: string;
|
|
1069
1106
|
downloadPackages: string[];
|
|
1107
|
+
compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
1070
1108
|
};
|
|
1071
1109
|
/**
|
|
1072
1110
|
* @deprecated Use `build:manifestGenerated` hook instead.
|
|
@@ -1185,4 +1223,4 @@ interface Dependency {
|
|
|
1185
1223
|
version: string;
|
|
1186
1224
|
}
|
|
1187
1225
|
|
|
1188
|
-
export type { EslintGlobalsPropValue as $,
|
|
1226
|
+
export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
|
|
@@ -320,6 +320,14 @@ interface InlineConfig {
|
|
|
320
320
|
* ["@scope/package-name@1.1.3", "package-name@^2"]
|
|
321
321
|
*/
|
|
322
322
|
downloadPackages?: string[];
|
|
323
|
+
/**
|
|
324
|
+
* Compression level to use when zipping files.
|
|
325
|
+
*
|
|
326
|
+
* Levels: 0 (no compression) to 9 (maximum compression).
|
|
327
|
+
*
|
|
328
|
+
* @default 9
|
|
329
|
+
*/
|
|
330
|
+
compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
323
331
|
};
|
|
324
332
|
/**
|
|
325
333
|
* @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
|
|
@@ -647,8 +655,8 @@ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
|
|
|
647
655
|
* - `"manifest"`: The content script will be added to the `content_scripts` entry in the
|
|
648
656
|
* manifest. This is the normal and most well known way of registering a content script.
|
|
649
657
|
* - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
|
|
650
|
-
* responsible for using the scripting API to register the content script
|
|
651
|
-
* runtime.
|
|
658
|
+
* responsible for using the scripting API to register/execute the content script
|
|
659
|
+
* dynamically at runtime.
|
|
652
660
|
*
|
|
653
661
|
* @default "manifest"
|
|
654
662
|
*/
|
|
@@ -753,14 +761,22 @@ type OnContentScriptStopped = (cb: () => void) => void;
|
|
|
753
761
|
interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
|
|
754
762
|
/**
|
|
755
763
|
* Main function executed when the content script is loaded.
|
|
764
|
+
*
|
|
765
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
766
|
+
* values returned from this function will be returned in the `executeScript`
|
|
767
|
+
* result as well. Otherwise returning a value does nothing.
|
|
756
768
|
*/
|
|
757
|
-
main(ctx: ContentScriptContext):
|
|
769
|
+
main(ctx: ContentScriptContext): any | Promise<any>;
|
|
758
770
|
}
|
|
759
771
|
interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
|
|
760
772
|
/**
|
|
761
773
|
* Main function executed when the content script is loaded.
|
|
774
|
+
*
|
|
775
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
776
|
+
* values returned from this function will be returned in the `executeScript`
|
|
777
|
+
* result as well. Otherwise returning a value does nothing.
|
|
762
778
|
*/
|
|
763
|
-
main():
|
|
779
|
+
main(): any | Promise<any>;
|
|
764
780
|
}
|
|
765
781
|
type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
|
|
766
782
|
interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
@@ -772,8 +788,12 @@ interface BackgroundDefinition extends BackgroundEntrypointOptions {
|
|
|
772
788
|
interface UnlistedScriptDefinition extends BaseEntrypointOptions {
|
|
773
789
|
/**
|
|
774
790
|
* Main function executed when the unlisted script is ran.
|
|
791
|
+
*
|
|
792
|
+
* When running a content script with `browser.scripting.executeScript`,
|
|
793
|
+
* values returned from this function will be returned in the `executeScript`
|
|
794
|
+
* result as well. Otherwise returning a value does nothing.
|
|
775
795
|
*/
|
|
776
|
-
main():
|
|
796
|
+
main(): any | Promise<any>;
|
|
777
797
|
}
|
|
778
798
|
/**
|
|
779
799
|
* Either a single value or a map of different browsers to the value for that browser.
|
|
@@ -967,6 +987,23 @@ interface ServerInfo {
|
|
|
967
987
|
origin: string;
|
|
968
988
|
}
|
|
969
989
|
type HookResult = Promise<void> | void;
|
|
990
|
+
interface WxtHooks {
|
|
991
|
+
/**
|
|
992
|
+
* Called when WXT has created Vite's config for a build step. Useful if you
|
|
993
|
+
* want to add plugins or update the vite config per entrypoint group.
|
|
994
|
+
*
|
|
995
|
+
* @param entrypoints The list of entrypoints being built with the provided config.
|
|
996
|
+
* @param viteConfig The config that will be used for the dev server.
|
|
997
|
+
*/
|
|
998
|
+
'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
|
|
999
|
+
/**
|
|
1000
|
+
* Called when WXT has created Vite's config for the dev server. Useful if
|
|
1001
|
+
* you want to add plugins or update the vite config per entrypoint group.
|
|
1002
|
+
*
|
|
1003
|
+
* @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
|
|
1004
|
+
*/
|
|
1005
|
+
'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
|
|
1006
|
+
}
|
|
970
1007
|
interface WxtHooks {
|
|
971
1008
|
/**
|
|
972
1009
|
* Called after WXT initialization, when the WXT instance is ready to work.
|
|
@@ -1067,6 +1104,7 @@ interface ResolvedConfig {
|
|
|
1067
1104
|
sourcesRoot: string;
|
|
1068
1105
|
downloadedPackagesDir: string;
|
|
1069
1106
|
downloadPackages: string[];
|
|
1107
|
+
compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
1070
1108
|
};
|
|
1071
1109
|
/**
|
|
1072
1110
|
* @deprecated Use `build:manifestGenerated` hook instead.
|
|
@@ -1185,4 +1223,4 @@ interface Dependency {
|
|
|
1185
1223
|
version: string;
|
|
1186
1224
|
}
|
|
1187
1225
|
|
|
1188
|
-
export type { EslintGlobalsPropValue as $,
|
|
1226
|
+
export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
|
package/dist/index.cjs
CHANGED
|
@@ -3257,8 +3257,45 @@ function defineImportMeta() {
|
|
|
3257
3257
|
};
|
|
3258
3258
|
}
|
|
3259
3259
|
|
|
3260
|
+
// src/core/utils/arrays.ts
|
|
3261
|
+
function every(array, predicate) {
|
|
3262
|
+
for (let i = 0; i < array.length; i++)
|
|
3263
|
+
if (!predicate(array[i], i))
|
|
3264
|
+
return false;
|
|
3265
|
+
return true;
|
|
3266
|
+
}
|
|
3267
|
+
function some(array, predicate) {
|
|
3268
|
+
for (let i = 0; i < array.length; i++)
|
|
3269
|
+
if (predicate(array[i], i))
|
|
3270
|
+
return true;
|
|
3271
|
+
return false;
|
|
3272
|
+
}
|
|
3273
|
+
function toArray(a) {
|
|
3274
|
+
return Array.isArray(a) ? a : [a];
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
// src/core/utils/strings.ts
|
|
3278
|
+
function kebabCaseAlphanumeric(str) {
|
|
3279
|
+
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
3280
|
+
}
|
|
3281
|
+
function safeVarName(str) {
|
|
3282
|
+
return "_" + kebabCaseAlphanumeric(str).replace("-", "_");
|
|
3283
|
+
}
|
|
3284
|
+
function removeImportStatements(text) {
|
|
3285
|
+
return text.replace(
|
|
3286
|
+
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
|
3287
|
+
""
|
|
3288
|
+
);
|
|
3289
|
+
}
|
|
3290
|
+
function removeProjectImportStatements(text) {
|
|
3291
|
+
const noImports = removeImportStatements(text);
|
|
3292
|
+
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
3293
|
+
|
|
3294
|
+
${noImports}`;
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3260
3297
|
// src/core/builders/vite/index.ts
|
|
3261
|
-
async function createViteBuilder(wxtConfig, server) {
|
|
3298
|
+
async function createViteBuilder(wxtConfig, hooks, server) {
|
|
3262
3299
|
const vite = await import("vite");
|
|
3263
3300
|
const getBaseConfig = async () => {
|
|
3264
3301
|
const config = await wxtConfig.vite(wxtConfig.env);
|
|
@@ -3303,14 +3340,22 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
3303
3340
|
if (entrypoint.type === "content-script-style" || entrypoint.type === "unlisted-style") {
|
|
3304
3341
|
plugins.push(cssEntrypoints(entrypoint, wxtConfig));
|
|
3305
3342
|
}
|
|
3343
|
+
const iifeReturnValueName = safeVarName(entrypoint.name);
|
|
3306
3344
|
const libMode = {
|
|
3307
3345
|
mode: wxtConfig.mode,
|
|
3308
3346
|
plugins,
|
|
3347
|
+
esbuild: {
|
|
3348
|
+
// Add a footer with the returned value so it can return values to `scripting.executeScript`
|
|
3349
|
+
// Footer is added apart of esbuild to make sure it's not minified. It
|
|
3350
|
+
// get's removed if added to `build.rollupOptions.output.footer`
|
|
3351
|
+
// See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/executeScript#return_value
|
|
3352
|
+
footer: iifeReturnValueName + ";"
|
|
3353
|
+
},
|
|
3309
3354
|
build: {
|
|
3310
3355
|
lib: {
|
|
3311
3356
|
entry,
|
|
3312
3357
|
formats: ["iife"],
|
|
3313
|
-
name:
|
|
3358
|
+
name: iifeReturnValueName,
|
|
3314
3359
|
fileName: entrypoint.name
|
|
3315
3360
|
},
|
|
3316
3361
|
rollupOptions: {
|
|
@@ -3406,6 +3451,11 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
3406
3451
|
else
|
|
3407
3452
|
entryConfig = getLibModeConfig(group);
|
|
3408
3453
|
const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
|
|
3454
|
+
await hooks.callHook(
|
|
3455
|
+
"vite:build:extendConfig",
|
|
3456
|
+
toArray(group),
|
|
3457
|
+
buildConfig
|
|
3458
|
+
);
|
|
3409
3459
|
const result = await vite.build(buildConfig);
|
|
3410
3460
|
return {
|
|
3411
3461
|
entrypoints: group,
|
|
@@ -3422,9 +3472,9 @@ async function createViteBuilder(wxtConfig, server) {
|
|
|
3422
3472
|
}
|
|
3423
3473
|
};
|
|
3424
3474
|
const baseConfig = await getBaseConfig();
|
|
3425
|
-
const
|
|
3426
|
-
|
|
3427
|
-
);
|
|
3475
|
+
const finalConfig = vite.mergeConfig(baseConfig, serverConfig);
|
|
3476
|
+
await hooks.callHook("vite:devServer:extendConfig", finalConfig);
|
|
3477
|
+
const viteServer = await vite.createServer(finalConfig);
|
|
3428
3478
|
const server2 = {
|
|
3429
3479
|
async listen() {
|
|
3430
3480
|
await viteServer.listen(info.port);
|
|
@@ -3480,7 +3530,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
|
|
|
3480
3530
|
const hooks = (0, import_hookable.createHooks)();
|
|
3481
3531
|
const config = await resolveConfig(inlineConfig, command);
|
|
3482
3532
|
const server = await getServer?.(config);
|
|
3483
|
-
const builder = await createViteBuilder(config, server);
|
|
3533
|
+
const builder = await createViteBuilder(config, hooks, server);
|
|
3484
3534
|
const pm = await createWxtPackageManager(config.root);
|
|
3485
3535
|
wxt = {
|
|
3486
3536
|
config,
|
|
@@ -3517,25 +3567,6 @@ async function getPublicFiles() {
|
|
|
3517
3567
|
var import_fs_extra5 = __toESM(require("fs-extra"), 1);
|
|
3518
3568
|
var import_path3 = require("path");
|
|
3519
3569
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
3520
|
-
|
|
3521
|
-
// src/core/utils/arrays.ts
|
|
3522
|
-
function every(array, predicate) {
|
|
3523
|
-
for (let i = 0; i < array.length; i++)
|
|
3524
|
-
if (!predicate(array[i], i))
|
|
3525
|
-
return false;
|
|
3526
|
-
return true;
|
|
3527
|
-
}
|
|
3528
|
-
function some(array, predicate) {
|
|
3529
|
-
for (let i = 0; i < array.length; i++)
|
|
3530
|
-
if (predicate(array[i], i))
|
|
3531
|
-
return true;
|
|
3532
|
-
return false;
|
|
3533
|
-
}
|
|
3534
|
-
function toArray(a) {
|
|
3535
|
-
return Array.isArray(a) ? a : [a];
|
|
3536
|
-
}
|
|
3537
|
-
|
|
3538
|
-
// src/core/utils/building/build-entrypoints.ts
|
|
3539
3570
|
async function buildEntrypoints(groups, spinner) {
|
|
3540
3571
|
const steps = [];
|
|
3541
3572
|
for (let i = 0; i < groups.length; i++) {
|
|
@@ -4464,6 +4495,7 @@ function resolveZipConfig(root, mergedConfig) {
|
|
|
4464
4495
|
artifactTemplate: "{{name}}-{{version}}-{{browser}}.zip",
|
|
4465
4496
|
sourcesRoot: root,
|
|
4466
4497
|
includeSources: [],
|
|
4498
|
+
compressionLevel: 9,
|
|
4467
4499
|
...mergedConfig.zip,
|
|
4468
4500
|
excludeSources: [
|
|
4469
4501
|
"**/node_modules",
|
|
@@ -4612,25 +4644,6 @@ var import_jiti = __toESM(require("jiti"), 1);
|
|
|
4612
4644
|
var import_unimport3 = require("unimport");
|
|
4613
4645
|
var import_fs_extra11 = __toESM(require("fs-extra"), 1);
|
|
4614
4646
|
var import_node_path13 = require("path");
|
|
4615
|
-
|
|
4616
|
-
// src/core/utils/strings.ts
|
|
4617
|
-
function kebabCaseAlphanumeric(str) {
|
|
4618
|
-
return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
|
|
4619
|
-
}
|
|
4620
|
-
function removeImportStatements(text) {
|
|
4621
|
-
return text.replace(
|
|
4622
|
-
/(import\s?[{\w][\s\S]*?from\s?["'][\s\S]*?["'];?|import\s?["'][\s\S]*?["'];?)/gm,
|
|
4623
|
-
""
|
|
4624
|
-
);
|
|
4625
|
-
}
|
|
4626
|
-
function removeProjectImportStatements(text) {
|
|
4627
|
-
const noImports = removeImportStatements(text);
|
|
4628
|
-
return `import { defineUnlistedScript, defineContentScript, defineBackground } from 'wxt/sandbox';
|
|
4629
|
-
|
|
4630
|
-
${noImports}`;
|
|
4631
|
-
}
|
|
4632
|
-
|
|
4633
|
-
// src/core/utils/building/import-entrypoint.ts
|
|
4634
4647
|
var import_esbuild = require("esbuild");
|
|
4635
4648
|
var import_node_url2 = require("url");
|
|
4636
4649
|
var import_meta2 = {};
|
|
@@ -4831,7 +4844,7 @@ function getChunkSortWeight(filename) {
|
|
|
4831
4844
|
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
4832
4845
|
|
|
4833
4846
|
// package.json
|
|
4834
|
-
var version = "0.17.
|
|
4847
|
+
var version = "0.17.13-alpha1";
|
|
4835
4848
|
|
|
4836
4849
|
// src/core/utils/log/printHeader.ts
|
|
4837
4850
|
var import_consola2 = require("consola");
|
|
@@ -6271,7 +6284,13 @@ async function zipDir(directory, outputPath, options) {
|
|
|
6271
6284
|
}
|
|
6272
6285
|
}
|
|
6273
6286
|
await options?.additionalWork?.(archive);
|
|
6274
|
-
const buffer = await archive.generateAsync({
|
|
6287
|
+
const buffer = await archive.generateAsync({
|
|
6288
|
+
type: "base64",
|
|
6289
|
+
...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
|
|
6290
|
+
compression: "DEFLATE",
|
|
6291
|
+
compressionOptions: { level: wxt.config.zip.compressionLevel }
|
|
6292
|
+
}
|
|
6293
|
+
});
|
|
6275
6294
|
await import_fs_extra17.default.writeFile(outputPath, buffer, "base64");
|
|
6276
6295
|
}
|
|
6277
6296
|
async function downloadPrivatePackages() {
|
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 './index-
|
|
2
|
-
export {
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-INepal5k.cjs';
|
|
2
|
+
export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a4 as WxtPackageManager, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-INepal5k.cjs';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
67
67
|
|
|
68
|
-
var version = "0.17.
|
|
68
|
+
var version = "0.17.13-alpha1";
|
|
69
69
|
|
|
70
70
|
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 './index-
|
|
2
|
-
export {
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './index-INepal5k.js';
|
|
2
|
+
export { x as BackgroundDefinition, n as BackgroundEntrypoint, i as BackgroundEntrypointOptions, j as BaseContentScriptEntrypointOptions, m as BaseEntrypoint, h as BaseEntrypointOptions, e as BuildStepOutput, J as ConfigEnv, w as ContentScriptDefinition, C as ContentScriptEntrypoint, a5 as Dependency, r as Entrypoint, s as EntrypointGroup, $ as EslintGlobalsPropValue, a0 as Eslintrc, _ as ExtensionRunner, Z as FsCache, G as GenericEntrypoint, X as HookResult, u as IsolatedWorldContentScriptDefinition, k as IsolatedWorldContentScriptEntrypointOptions, L as Logger, v as MainWorldContentScriptDefinition, M as MainWorldContentScriptEntrypointOptions, t as OnContentScriptStopped, p as OptionsEntrypoint, l as OptionsEntrypointOptions, d as OutputAsset, c as OutputChunk, O as OutputFile, A as PerBrowserMap, z as PerBrowserOption, o as PopupEntrypoint, P as PopupEntrypointOptions, f as ReloadContentScriptPayload, R as ResolvedConfig, a1 as ResolvedEslintrc, D as ResolvedPerBrowserOptions, V as ServerInfo, q as SidepanelEntrypoint, S as SidepanelEntrypointOptions, T as TargetBrowser, g as TargetManifestVersion, y as UnlistedScriptDefinition, F as UserManifest, H as UserManifestFn, Y as Wxt, N as WxtBuilder, Q as WxtBuilderServer, K as WxtCommand, b as WxtHooks, a4 as WxtPackageManager, a3 as WxtResolvedUnimportOptions, a2 as WxtUnimportOptions, a as WxtViteConfig } from './index-INepal5k.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -65,6 +65,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
65
65
|
*/
|
|
66
66
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
67
67
|
|
|
68
|
-
var version = "0.17.
|
|
68
|
+
var version = "0.17.13-alpha1";
|
|
69
69
|
|
|
70
70
|
export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
unnormalizePath,
|
|
20
20
|
version,
|
|
21
21
|
wxt
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-YWGLK5GM.js";
|
|
23
23
|
import "./chunk-5X3S6AWF.js";
|
|
24
24
|
import "./chunk-VBXJIVYU.js";
|
|
25
25
|
|
|
@@ -641,7 +641,13 @@ async function zipDir(directory, outputPath, options) {
|
|
|
641
641
|
}
|
|
642
642
|
}
|
|
643
643
|
await options?.additionalWork?.(archive);
|
|
644
|
-
const buffer = await archive.generateAsync({
|
|
644
|
+
const buffer = await archive.generateAsync({
|
|
645
|
+
type: "base64",
|
|
646
|
+
...wxt.config.zip.compressionLevel === 0 ? { compression: "STORE" } : {
|
|
647
|
+
compression: "DEFLATE",
|
|
648
|
+
compressionOptions: { level: wxt.config.zip.compressionLevel }
|
|
649
|
+
}
|
|
650
|
+
});
|
|
645
651
|
await fs3.writeFile(outputPath, buffer, "base64");
|
|
646
652
|
}
|
|
647
653
|
async function downloadPrivatePackages() {
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './index-
|
|
1
|
+
import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './index-Aan1uu3v.js';
|
|
2
2
|
export * from '@webext-core/match-patterns';
|
|
3
3
|
import 'webextension-polyfill';
|
|
4
4
|
|
package/dist/testing.cjs
CHANGED
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 './index-
|
|
3
|
+
import { I as InlineConfig } from './index-INepal5k.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 './index-
|
|
3
|
+
import { I as InlineConfig } from './index-INepal5k.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED
|
@@ -21,15 +21,20 @@ var logger = {
|
|
|
21
21
|
|
|
22
22
|
// src/virtual/content-script-isolated-world-entrypoint.ts
|
|
23
23
|
import { ContentScriptContext } from "wxt/client";
|
|
24
|
-
(async () => {
|
|
24
|
+
var result = (async () => {
|
|
25
25
|
try {
|
|
26
26
|
const { main, ...options } = definition;
|
|
27
27
|
const ctx = new ContentScriptContext(import.meta.env.ENTRYPOINT, options);
|
|
28
|
-
await main(ctx);
|
|
28
|
+
return await main(ctx);
|
|
29
29
|
} catch (err) {
|
|
30
30
|
logger.error(
|
|
31
31
|
`The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
|
|
32
32
|
err
|
|
33
33
|
);
|
|
34
|
+
throw err;
|
|
34
35
|
}
|
|
35
36
|
})();
|
|
37
|
+
var content_script_isolated_world_entrypoint_default = result;
|
|
38
|
+
export {
|
|
39
|
+
content_script_isolated_world_entrypoint_default as default
|
|
40
|
+
};
|
|
@@ -20,14 +20,19 @@ var logger = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
// src/virtual/content-script-main-world-entrypoint.ts
|
|
23
|
-
(async () => {
|
|
23
|
+
var result = (async () => {
|
|
24
24
|
try {
|
|
25
25
|
const { main } = definition;
|
|
26
|
-
await main();
|
|
26
|
+
return await main();
|
|
27
27
|
} catch (err) {
|
|
28
28
|
logger.error(
|
|
29
29
|
`The content script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
|
|
30
30
|
err
|
|
31
31
|
);
|
|
32
|
+
throw err;
|
|
32
33
|
}
|
|
33
34
|
})();
|
|
35
|
+
var content_script_main_world_entrypoint_default = result;
|
|
36
|
+
export {
|
|
37
|
+
content_script_main_world_entrypoint_default as default
|
|
38
|
+
};
|
|
@@ -20,13 +20,18 @@ var logger = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
// src/virtual/unlisted-script-entrypoint.ts
|
|
23
|
-
(async () => {
|
|
23
|
+
var result = (async () => {
|
|
24
24
|
try {
|
|
25
|
-
await definition.main();
|
|
25
|
+
return await definition.main();
|
|
26
26
|
} catch (err) {
|
|
27
27
|
logger.error(
|
|
28
28
|
`The unlisted script "${import.meta.env.ENTRYPOINT}" crashed on startup!`,
|
|
29
29
|
err
|
|
30
30
|
);
|
|
31
|
+
throw err;
|
|
31
32
|
}
|
|
32
33
|
})();
|
|
34
|
+
var unlisted_script_entrypoint_default = result;
|
|
35
|
+
export {
|
|
36
|
+
unlisted_script_entrypoint_default as default
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.13-alpha1",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"prompts": "^2.4.2",
|
|
121
121
|
"publish-browser-extension": "^2.1.3",
|
|
122
122
|
"unimport": "^3.4.0",
|
|
123
|
-
"vite": "^5.
|
|
123
|
+
"vite": "^5.2.8",
|
|
124
124
|
"web-ext-run": "^0.2.0",
|
|
125
125
|
"webextension-polyfill": "^0.10.0"
|
|
126
126
|
},
|