wxt 0.9.1 → 0.10.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/README.md +2 -2
- package/dist/{chunk-2BIYR4TE.js → chunk-4ACVTNQN.js} +48 -12
- package/dist/cli.cjs +55 -15
- package/dist/{external-9e212597.d.ts → external-9115d0fb.d.ts} +25 -0
- package/dist/index.cjs +55 -15
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -4
- package/dist/storage.cjs +136 -0
- package/dist/storage.d.cts +15 -0
- package/dist/storage.d.ts +15 -0
- package/dist/storage.js +103 -0
- package/dist/testing.cjs +35 -2
- 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 +138 -11
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
•
|
|
28
28
|
<a href="https://wxt.dev/guide/installation.html" target="_blank">Installation</a>
|
|
29
29
|
•
|
|
30
|
-
<a href="https://wxt.dev/entrypoints/background.html" target="_blank">Entrypoints</a>
|
|
31
|
-
•
|
|
32
30
|
<a href="https://wxt.dev/api/config.html" target="_blank">Configuration</a>
|
|
31
|
+
•
|
|
32
|
+
<a href="https://wxt.dev/examples.html" target="_blank">Examples</a>
|
|
33
33
|
</p>
|
|
34
34
|
|
|
35
35
|

|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.10.0";
|
|
3
3
|
|
|
4
4
|
// src/core/utils/entrypoints.ts
|
|
5
5
|
import path, { relative, resolve } from "node:path";
|
|
@@ -129,7 +129,8 @@ function getUnimportOptions(config) {
|
|
|
129
129
|
presets: [
|
|
130
130
|
{ package: "wxt/client" },
|
|
131
131
|
{ package: "wxt/browser" },
|
|
132
|
-
{ package: "wxt/sandbox" }
|
|
132
|
+
{ package: "wxt/sandbox" },
|
|
133
|
+
{ package: "wxt/storage" }
|
|
133
134
|
],
|
|
134
135
|
warn: config.logger.warn,
|
|
135
136
|
dirs: ["components", "composables", "hooks", "utils"]
|
|
@@ -563,6 +564,30 @@ function bundleAnalysis() {
|
|
|
563
564
|
});
|
|
564
565
|
}
|
|
565
566
|
|
|
567
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
568
|
+
function excludeBrowserPolyfill(config) {
|
|
569
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
570
|
+
return {
|
|
571
|
+
name: "wxt:exclude-browser-polyfill",
|
|
572
|
+
config() {
|
|
573
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
574
|
+
return;
|
|
575
|
+
return {
|
|
576
|
+
resolve: {
|
|
577
|
+
alias: {
|
|
578
|
+
"webextension-polyfill": virtualId
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
},
|
|
583
|
+
load(id) {
|
|
584
|
+
if (id === virtualId) {
|
|
585
|
+
return "export default chrome";
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
|
|
566
591
|
// src/core/utils/arrays.ts
|
|
567
592
|
function every(array, predicate) {
|
|
568
593
|
for (let i = 0; i < array.length; i++)
|
|
@@ -1159,7 +1184,10 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
1159
1184
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
1160
1185
|
},
|
|
1161
1186
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
1162
|
-
alias
|
|
1187
|
+
alias,
|
|
1188
|
+
experimental: {
|
|
1189
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
1190
|
+
}
|
|
1163
1191
|
};
|
|
1164
1192
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
1165
1193
|
return finalConfig;
|
|
@@ -1220,6 +1248,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
1220
1248
|
alias: {
|
|
1221
1249
|
...userConfig.alias,
|
|
1222
1250
|
...inlineConfig.alias
|
|
1251
|
+
},
|
|
1252
|
+
experimental: {
|
|
1253
|
+
...userConfig.experimental,
|
|
1254
|
+
...inlineConfig.experimental
|
|
1223
1255
|
}
|
|
1224
1256
|
};
|
|
1225
1257
|
}
|
|
@@ -1272,6 +1304,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
1272
1304
|
internalVite.plugins.push(bundleAnalysis());
|
|
1273
1305
|
}
|
|
1274
1306
|
internalVite.plugins.push(globals(finalConfig));
|
|
1307
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
1275
1308
|
return internalVite;
|
|
1276
1309
|
}
|
|
1277
1310
|
|
|
@@ -1362,6 +1395,9 @@ async function importEntrypointFile(path7, config) {
|
|
|
1362
1395
|
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
1363
1396
|
)
|
|
1364
1397
|
},
|
|
1398
|
+
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
1399
|
+
// respect the custom transform function when using it's native bun option.
|
|
1400
|
+
experimentalBun: false,
|
|
1365
1401
|
// List of extensions to transform with esbuild
|
|
1366
1402
|
extensions: [".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"],
|
|
1367
1403
|
transform(opts) {
|
|
@@ -1894,20 +1930,20 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
1894
1930
|
function discoverIcons(buildOutput) {
|
|
1895
1931
|
const icons = [];
|
|
1896
1932
|
const iconRegex = [
|
|
1897
|
-
/^icon-([0-9]+)\.
|
|
1933
|
+
/^icon-([0-9]+)\.png$/,
|
|
1898
1934
|
// icon-16.png
|
|
1899
|
-
/^icon-([0-9]+)x[0-9]+\.
|
|
1935
|
+
/^icon-([0-9]+)x[0-9]+\.png$/,
|
|
1900
1936
|
// icon-16x16.png
|
|
1901
|
-
/^icon@([0-9]+)w\.
|
|
1937
|
+
/^icon@([0-9]+)w\.png$/,
|
|
1902
1938
|
// icon@16w.png
|
|
1903
|
-
/^icon@([0-9]+)h\.
|
|
1939
|
+
/^icon@([0-9]+)h\.png$/,
|
|
1904
1940
|
// icon@16h.png
|
|
1905
|
-
/^icon@([0-9]+)\.
|
|
1941
|
+
/^icon@([0-9]+)\.png$/,
|
|
1906
1942
|
// icon@16.png
|
|
1907
|
-
/^
|
|
1908
|
-
// icon/16.png
|
|
1909
|
-
/^
|
|
1910
|
-
// icon/16x16.png
|
|
1943
|
+
/^icons?[\/\\]([0-9]+)\.png$/,
|
|
1944
|
+
// icon/16.png | icons/16.png
|
|
1945
|
+
/^icons?[\/\\]([0-9]+)x[0-9]+\.png$/
|
|
1946
|
+
// icon/16x16.png | icons/16x16.png
|
|
1911
1947
|
];
|
|
1912
1948
|
buildOutput.publicAssets.forEach((asset) => {
|
|
1913
1949
|
let size;
|
package/dist/cli.cjs
CHANGED
|
@@ -2415,7 +2415,7 @@ var init_execa = __esm({
|
|
|
2415
2415
|
var import_cac = __toESM(require("cac"), 1);
|
|
2416
2416
|
|
|
2417
2417
|
// package.json
|
|
2418
|
-
var version = "0.
|
|
2418
|
+
var version = "0.10.0";
|
|
2419
2419
|
|
|
2420
2420
|
// src/core/utils/building/build-entrypoints.ts
|
|
2421
2421
|
var vite2 = __toESM(require("vite"), 1);
|
|
@@ -2732,7 +2732,8 @@ function getUnimportOptions(config) {
|
|
|
2732
2732
|
presets: [
|
|
2733
2733
|
{ package: "wxt/client" },
|
|
2734
2734
|
{ package: "wxt/browser" },
|
|
2735
|
-
{ package: "wxt/sandbox" }
|
|
2735
|
+
{ package: "wxt/sandbox" },
|
|
2736
|
+
{ package: "wxt/storage" }
|
|
2736
2737
|
],
|
|
2737
2738
|
warn: config.logger.warn,
|
|
2738
2739
|
dirs: ["components", "composables", "hooks", "utils"]
|
|
@@ -2948,6 +2949,30 @@ function globals(config) {
|
|
|
2948
2949
|
// src/core/vite-plugins/webextensionPolyfillAlias.ts
|
|
2949
2950
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
2950
2951
|
|
|
2952
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
2953
|
+
function excludeBrowserPolyfill(config) {
|
|
2954
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
2955
|
+
return {
|
|
2956
|
+
name: "wxt:exclude-browser-polyfill",
|
|
2957
|
+
config() {
|
|
2958
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
2959
|
+
return;
|
|
2960
|
+
return {
|
|
2961
|
+
resolve: {
|
|
2962
|
+
alias: {
|
|
2963
|
+
"webextension-polyfill": virtualId
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
};
|
|
2967
|
+
},
|
|
2968
|
+
load(id) {
|
|
2969
|
+
if (id === virtualId) {
|
|
2970
|
+
return "export default chrome";
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
};
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2951
2976
|
// src/core/utils/fs.ts
|
|
2952
2977
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
2953
2978
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
@@ -3837,7 +3862,10 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
3837
3862
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
3838
3863
|
},
|
|
3839
3864
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
3840
|
-
alias
|
|
3865
|
+
alias,
|
|
3866
|
+
experimental: {
|
|
3867
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
3868
|
+
}
|
|
3841
3869
|
};
|
|
3842
3870
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
3843
3871
|
return finalConfig;
|
|
@@ -3898,6 +3926,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
3898
3926
|
alias: {
|
|
3899
3927
|
...userConfig.alias,
|
|
3900
3928
|
...inlineConfig.alias
|
|
3929
|
+
},
|
|
3930
|
+
experimental: {
|
|
3931
|
+
...userConfig.experimental,
|
|
3932
|
+
...inlineConfig.experimental
|
|
3901
3933
|
}
|
|
3902
3934
|
};
|
|
3903
3935
|
}
|
|
@@ -3950,6 +3982,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
3950
3982
|
internalVite.plugins.push(bundleAnalysis());
|
|
3951
3983
|
}
|
|
3952
3984
|
internalVite.plugins.push(globals(finalConfig));
|
|
3985
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
3953
3986
|
return internalVite;
|
|
3954
3987
|
}
|
|
3955
3988
|
|
|
@@ -4040,6 +4073,9 @@ async function importEntrypointFile(path11, config) {
|
|
|
4040
4073
|
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
4041
4074
|
)
|
|
4042
4075
|
},
|
|
4076
|
+
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
4077
|
+
// respect the custom transform function when using it's native bun option.
|
|
4078
|
+
experimentalBun: false,
|
|
4043
4079
|
// List of extensions to transform with esbuild
|
|
4044
4080
|
extensions: [".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"],
|
|
4045
4081
|
transform(opts) {
|
|
@@ -4576,20 +4612,20 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
4576
4612
|
function discoverIcons(buildOutput) {
|
|
4577
4613
|
const icons = [];
|
|
4578
4614
|
const iconRegex = [
|
|
4579
|
-
/^icon-([0-9]+)\.
|
|
4615
|
+
/^icon-([0-9]+)\.png$/,
|
|
4580
4616
|
// icon-16.png
|
|
4581
|
-
/^icon-([0-9]+)x[0-9]+\.
|
|
4617
|
+
/^icon-([0-9]+)x[0-9]+\.png$/,
|
|
4582
4618
|
// icon-16x16.png
|
|
4583
|
-
/^icon@([0-9]+)w\.
|
|
4619
|
+
/^icon@([0-9]+)w\.png$/,
|
|
4584
4620
|
// icon@16w.png
|
|
4585
|
-
/^icon@([0-9]+)h\.
|
|
4621
|
+
/^icon@([0-9]+)h\.png$/,
|
|
4586
4622
|
// icon@16h.png
|
|
4587
|
-
/^icon@([0-9]+)\.
|
|
4623
|
+
/^icon@([0-9]+)\.png$/,
|
|
4588
4624
|
// icon@16.png
|
|
4589
|
-
/^
|
|
4590
|
-
// icon/16.png
|
|
4591
|
-
/^
|
|
4592
|
-
// icon/16x16.png
|
|
4625
|
+
/^icons?[\/\\]([0-9]+)\.png$/,
|
|
4626
|
+
// icon/16.png | icons/16.png
|
|
4627
|
+
/^icons?[\/\\]([0-9]+)x[0-9]+\.png$/
|
|
4628
|
+
// icon/16x16.png | icons/16x16.png
|
|
4593
4629
|
];
|
|
4594
4630
|
buildOutput.publicAssets.forEach((asset) => {
|
|
4595
4631
|
let size;
|
|
@@ -5150,9 +5186,13 @@ async function initialize(options) {
|
|
|
5150
5186
|
type: () => options.packageManager == null ? "select" : void 0,
|
|
5151
5187
|
message: "Package Manager",
|
|
5152
5188
|
choices: [
|
|
5153
|
-
{ title: "npm", value: "npm" },
|
|
5154
|
-
{ title: "pnpm", value: "pnpm" },
|
|
5155
|
-
{ title: "yarn", value: "yarn" }
|
|
5189
|
+
{ title: import_picocolors7.default.red("npm"), value: "npm" },
|
|
5190
|
+
{ title: import_picocolors7.default.yellow("pnpm"), value: "pnpm" },
|
|
5191
|
+
{ title: import_picocolors7.default.cyan("yarn"), value: "yarn" },
|
|
5192
|
+
{
|
|
5193
|
+
title: `${import_picocolors7.default.magenta("bun")}${import_picocolors7.default.gray(" (experimental)")}`,
|
|
5194
|
+
value: "bun"
|
|
5195
|
+
}
|
|
5156
5196
|
]
|
|
5157
5197
|
}
|
|
5158
5198
|
],
|
|
@@ -284,6 +284,31 @@ interface InlineConfig {
|
|
|
284
284
|
* }
|
|
285
285
|
*/
|
|
286
286
|
alias?: Record<string, string>;
|
|
287
|
+
/**
|
|
288
|
+
* Experimental settings - use with caution.
|
|
289
|
+
*/
|
|
290
|
+
experimental?: {
|
|
291
|
+
/**
|
|
292
|
+
* Whether to use [`webextension-polyfill`](https://www.npmjs.com/package/webextension-polyfill)
|
|
293
|
+
* when importing `browser` from `wxt/browser`.
|
|
294
|
+
*
|
|
295
|
+
* When set to `false`, WXT will export the chrome global instead of the polyfill from
|
|
296
|
+
* `wxt/browser`.
|
|
297
|
+
*
|
|
298
|
+
* You should use `browser` to access the web extension APIs.
|
|
299
|
+
*
|
|
300
|
+
* @experimental This option will remain experimental until Manifest V2 is dead.
|
|
301
|
+
*
|
|
302
|
+
* @default true
|
|
303
|
+
* @example
|
|
304
|
+
* export default defineConfig({
|
|
305
|
+
* experimental: {
|
|
306
|
+
* includeBrowserPolyfill: false
|
|
307
|
+
* }
|
|
308
|
+
* })
|
|
309
|
+
*/
|
|
310
|
+
includeBrowserPolyfill?: boolean;
|
|
311
|
+
};
|
|
287
312
|
}
|
|
288
313
|
interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
|
|
289
314
|
build?: Omit<vite.BuildOptions, 'outDir'>;
|
package/dist/index.cjs
CHANGED
|
@@ -2742,7 +2742,8 @@ function getUnimportOptions(config) {
|
|
|
2742
2742
|
presets: [
|
|
2743
2743
|
{ package: "wxt/client" },
|
|
2744
2744
|
{ package: "wxt/browser" },
|
|
2745
|
-
{ package: "wxt/sandbox" }
|
|
2745
|
+
{ package: "wxt/sandbox" },
|
|
2746
|
+
{ package: "wxt/storage" }
|
|
2746
2747
|
],
|
|
2747
2748
|
warn: config.logger.warn,
|
|
2748
2749
|
dirs: ["components", "composables", "hooks", "utils"]
|
|
@@ -2958,6 +2959,30 @@ function globals(config) {
|
|
|
2958
2959
|
// src/core/vite-plugins/webextensionPolyfillAlias.ts
|
|
2959
2960
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
2960
2961
|
|
|
2962
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
2963
|
+
function excludeBrowserPolyfill(config) {
|
|
2964
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
2965
|
+
return {
|
|
2966
|
+
name: "wxt:exclude-browser-polyfill",
|
|
2967
|
+
config() {
|
|
2968
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
2969
|
+
return;
|
|
2970
|
+
return {
|
|
2971
|
+
resolve: {
|
|
2972
|
+
alias: {
|
|
2973
|
+
"webextension-polyfill": virtualId
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
},
|
|
2978
|
+
load(id) {
|
|
2979
|
+
if (id === virtualId) {
|
|
2980
|
+
return "export default chrome";
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
};
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2961
2986
|
// src/core/utils/fs.ts
|
|
2962
2987
|
var import_fs_extra3 = __toESM(require("fs-extra"), 1);
|
|
2963
2988
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
@@ -3847,7 +3872,10 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
3847
3872
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
3848
3873
|
},
|
|
3849
3874
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
3850
|
-
alias
|
|
3875
|
+
alias,
|
|
3876
|
+
experimental: {
|
|
3877
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
3878
|
+
}
|
|
3851
3879
|
};
|
|
3852
3880
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
3853
3881
|
return finalConfig;
|
|
@@ -3908,6 +3936,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
3908
3936
|
alias: {
|
|
3909
3937
|
...userConfig.alias,
|
|
3910
3938
|
...inlineConfig.alias
|
|
3939
|
+
},
|
|
3940
|
+
experimental: {
|
|
3941
|
+
...userConfig.experimental,
|
|
3942
|
+
...inlineConfig.experimental
|
|
3911
3943
|
}
|
|
3912
3944
|
};
|
|
3913
3945
|
}
|
|
@@ -3960,6 +3992,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
3960
3992
|
internalVite.plugins.push(bundleAnalysis());
|
|
3961
3993
|
}
|
|
3962
3994
|
internalVite.plugins.push(globals(finalConfig));
|
|
3995
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
3963
3996
|
return internalVite;
|
|
3964
3997
|
}
|
|
3965
3998
|
|
|
@@ -4050,6 +4083,9 @@ async function importEntrypointFile(path11, config) {
|
|
|
4050
4083
|
"node_modules/wxt/dist/virtual/mock-browser.js"
|
|
4051
4084
|
)
|
|
4052
4085
|
},
|
|
4086
|
+
// Continue using node to load TS files even if `bun run --bun` is detected. Jiti does not
|
|
4087
|
+
// respect the custom transform function when using it's native bun option.
|
|
4088
|
+
experimentalBun: false,
|
|
4053
4089
|
// List of extensions to transform with esbuild
|
|
4054
4090
|
extensions: [".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"],
|
|
4055
4091
|
transform(opts) {
|
|
@@ -4192,7 +4228,7 @@ function getChunkSortWeight(filename) {
|
|
|
4192
4228
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
4193
4229
|
|
|
4194
4230
|
// package.json
|
|
4195
|
-
var version = "0.
|
|
4231
|
+
var version = "0.10.0";
|
|
4196
4232
|
|
|
4197
4233
|
// src/core/utils/log/printHeader.ts
|
|
4198
4234
|
var import_consola2 = require("consola");
|
|
@@ -4587,20 +4623,20 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
|
|
|
4587
4623
|
function discoverIcons(buildOutput) {
|
|
4588
4624
|
const icons = [];
|
|
4589
4625
|
const iconRegex = [
|
|
4590
|
-
/^icon-([0-9]+)\.
|
|
4626
|
+
/^icon-([0-9]+)\.png$/,
|
|
4591
4627
|
// icon-16.png
|
|
4592
|
-
/^icon-([0-9]+)x[0-9]+\.
|
|
4628
|
+
/^icon-([0-9]+)x[0-9]+\.png$/,
|
|
4593
4629
|
// icon-16x16.png
|
|
4594
|
-
/^icon@([0-9]+)w\.
|
|
4630
|
+
/^icon@([0-9]+)w\.png$/,
|
|
4595
4631
|
// icon@16w.png
|
|
4596
|
-
/^icon@([0-9]+)h\.
|
|
4632
|
+
/^icon@([0-9]+)h\.png$/,
|
|
4597
4633
|
// icon@16h.png
|
|
4598
|
-
/^icon@([0-9]+)\.
|
|
4634
|
+
/^icon@([0-9]+)\.png$/,
|
|
4599
4635
|
// icon@16.png
|
|
4600
|
-
/^
|
|
4601
|
-
// icon/16.png
|
|
4602
|
-
/^
|
|
4603
|
-
// icon/16x16.png
|
|
4636
|
+
/^icons?[\/\\]([0-9]+)\.png$/,
|
|
4637
|
+
// icon/16.png | icons/16.png
|
|
4638
|
+
/^icons?[\/\\]([0-9]+)x[0-9]+\.png$/
|
|
4639
|
+
// icon/16x16.png | icons/16x16.png
|
|
4604
4640
|
];
|
|
4605
4641
|
buildOutput.publicAssets.forEach((asset) => {
|
|
4606
4642
|
let size;
|
|
@@ -5171,9 +5207,13 @@ async function initialize(options) {
|
|
|
5171
5207
|
type: () => options.packageManager == null ? "select" : void 0,
|
|
5172
5208
|
message: "Package Manager",
|
|
5173
5209
|
choices: [
|
|
5174
|
-
{ title: "npm", value: "npm" },
|
|
5175
|
-
{ title: "pnpm", value: "pnpm" },
|
|
5176
|
-
{ title: "yarn", value: "yarn" }
|
|
5210
|
+
{ title: import_picocolors7.default.red("npm"), value: "npm" },
|
|
5211
|
+
{ title: import_picocolors7.default.yellow("pnpm"), value: "pnpm" },
|
|
5212
|
+
{ title: import_picocolors7.default.cyan("yarn"), value: "yarn" },
|
|
5213
|
+
{
|
|
5214
|
+
title: `${import_picocolors7.default.magenta("bun")}${import_picocolors7.default.gray(" (experimental)")}`,
|
|
5215
|
+
value: "bun"
|
|
5216
|
+
}
|
|
5177
5217
|
]
|
|
5178
5218
|
}
|
|
5179
5219
|
],
|
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 { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-9115d0fb.js';
|
|
2
|
+
export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9115d0fb.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -61,6 +61,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
61
61
|
*/
|
|
62
62
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
63
63
|
|
|
64
|
-
var version = "0.
|
|
64
|
+
var version = "0.10.0";
|
|
65
65
|
|
|
66
66
|
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 { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-
|
|
1
|
+
import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-9115d0fb.js';
|
|
2
|
+
export { k as BackgroundDefinition, f as BackgroundEntrypoint, e as BaseEntrypoint, d as BaseEntrypointOptions, b as BuildStepOutput, q as ConfigEnv, j as ContentScriptDefinition, C as ContentScriptEntrypoint, g as Entrypoint, h as EntrypointGroup, n as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, i as OnContentScriptStopped, O as OptionsEntrypoint, m as PerBrowserOption, P as PopupEntrypoint, T as TargetBrowser, c as TargetManifestVersion, l as UnlistedScriptDefinition, o as UserManifest, p as UserManifestFn, a as WxtInlineViteConfig, r as WxtViteConfig } from './external-9115d0fb.js';
|
|
3
3
|
import 'vite';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
@@ -61,6 +61,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
|
|
|
61
61
|
*/
|
|
62
62
|
declare function zip(config?: InlineConfig): Promise<string[]>;
|
|
63
63
|
|
|
64
|
-
var version = "0.
|
|
64
|
+
var version = "0.10.0";
|
|
65
65
|
|
|
66
66
|
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-4ACVTNQN.js";
|
|
19
19
|
import "./chunk-YUG22S6W.js";
|
|
20
20
|
|
|
21
21
|
// src/core/build.ts
|
|
@@ -398,9 +398,13 @@ async function initialize(options) {
|
|
|
398
398
|
type: () => options.packageManager == null ? "select" : void 0,
|
|
399
399
|
message: "Package Manager",
|
|
400
400
|
choices: [
|
|
401
|
-
{ title: "npm", value: "npm" },
|
|
402
|
-
{ title: "pnpm", value: "pnpm" },
|
|
403
|
-
{ title: "yarn", value: "yarn" }
|
|
401
|
+
{ title: pc3.red("npm"), value: "npm" },
|
|
402
|
+
{ title: pc3.yellow("pnpm"), value: "pnpm" },
|
|
403
|
+
{ title: pc3.cyan("yarn"), value: "yarn" },
|
|
404
|
+
{
|
|
405
|
+
title: `${pc3.magenta("bun")}${pc3.gray(" (experimental)")}`,
|
|
406
|
+
value: "bun"
|
|
407
|
+
}
|
|
404
408
|
]
|
|
405
409
|
}
|
|
406
410
|
],
|
package/dist/storage.cjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/storage.ts
|
|
32
|
+
var storage_exports = {};
|
|
33
|
+
__export(storage_exports, {
|
|
34
|
+
storage: () => storage,
|
|
35
|
+
webExtensionDriver: () => webExtensionDriver
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(storage_exports);
|
|
38
|
+
var import_unstorage = require("unstorage");
|
|
39
|
+
var import_webextension_polyfill = __toESM(require("webextension-polyfill"), 1);
|
|
40
|
+
__reExport(storage_exports, require("unstorage"), module.exports);
|
|
41
|
+
var webExtensionDriver = (0, import_unstorage.defineDriver)((opts) => {
|
|
42
|
+
const checkPermission = () => {
|
|
43
|
+
if (import_webextension_polyfill.default.storage == null)
|
|
44
|
+
throw Error(
|
|
45
|
+
"You must request the 'storage' permission to use webExtensionDriver"
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
const _storageListener = (changes) => {
|
|
49
|
+
Object.entries(changes).forEach(([key, { newValue }]) => {
|
|
50
|
+
_listeners.forEach((callback) => {
|
|
51
|
+
callback(newValue ? "update" : "remove", key);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const _listeners = /* @__PURE__ */ new Set();
|
|
56
|
+
return {
|
|
57
|
+
name: "web-extension:" + opts.storageArea,
|
|
58
|
+
async hasItem(key) {
|
|
59
|
+
checkPermission();
|
|
60
|
+
const res = await import_webextension_polyfill.default.storage[opts.storageArea].get(key);
|
|
61
|
+
return res[key] != null;
|
|
62
|
+
},
|
|
63
|
+
async getItem(key) {
|
|
64
|
+
checkPermission();
|
|
65
|
+
const res = await import_webextension_polyfill.default.storage[opts.storageArea].get(key);
|
|
66
|
+
return res[key] ?? null;
|
|
67
|
+
},
|
|
68
|
+
async getItems(items) {
|
|
69
|
+
checkPermission();
|
|
70
|
+
const res = await import_webextension_polyfill.default.storage[opts.storageArea].get(
|
|
71
|
+
items.map((item) => item.key)
|
|
72
|
+
);
|
|
73
|
+
return items.map((item) => ({
|
|
74
|
+
key: item.key,
|
|
75
|
+
value: res[item.key] ?? null
|
|
76
|
+
}));
|
|
77
|
+
},
|
|
78
|
+
async setItem(key, value) {
|
|
79
|
+
checkPermission();
|
|
80
|
+
await import_webextension_polyfill.default.storage[opts.storageArea].set({ [key]: value ?? null });
|
|
81
|
+
},
|
|
82
|
+
async setItems(items) {
|
|
83
|
+
checkPermission();
|
|
84
|
+
const map = items.reduce((map2, item) => {
|
|
85
|
+
map2[item.key] = item.value ?? null;
|
|
86
|
+
return map2;
|
|
87
|
+
}, {});
|
|
88
|
+
await import_webextension_polyfill.default.storage[opts.storageArea].set(map);
|
|
89
|
+
},
|
|
90
|
+
async removeItem(key) {
|
|
91
|
+
checkPermission();
|
|
92
|
+
await import_webextension_polyfill.default.storage[opts.storageArea].remove(key);
|
|
93
|
+
},
|
|
94
|
+
async getKeys() {
|
|
95
|
+
checkPermission();
|
|
96
|
+
const all = await import_webextension_polyfill.default.storage[opts.storageArea].get();
|
|
97
|
+
return Object.keys(all);
|
|
98
|
+
},
|
|
99
|
+
async clear() {
|
|
100
|
+
checkPermission();
|
|
101
|
+
await import_webextension_polyfill.default.storage[opts.storageArea].clear();
|
|
102
|
+
},
|
|
103
|
+
watch(callback) {
|
|
104
|
+
checkPermission();
|
|
105
|
+
_listeners.add(callback);
|
|
106
|
+
if (_listeners.size === 1) {
|
|
107
|
+
import_webextension_polyfill.default.storage[opts.storageArea].onChanged.addListener(
|
|
108
|
+
_storageListener
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return () => {
|
|
112
|
+
_listeners.delete(callback);
|
|
113
|
+
if (_listeners.size === 0) {
|
|
114
|
+
import_webextension_polyfill.default.storage[opts.storageArea].onChanged.removeListener(
|
|
115
|
+
_storageListener
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
function createWebExtensionStorage() {
|
|
123
|
+
const storage2 = (0, import_unstorage.createStorage)();
|
|
124
|
+
storage2.mount("local", webExtensionDriver({ storageArea: "local" }));
|
|
125
|
+
storage2.mount("session", webExtensionDriver({ storageArea: "session" }));
|
|
126
|
+
storage2.mount("sync", webExtensionDriver({ storageArea: "sync" }));
|
|
127
|
+
storage2.mount("managed", webExtensionDriver({ storageArea: "managed" }));
|
|
128
|
+
return storage2;
|
|
129
|
+
}
|
|
130
|
+
var storage = createWebExtensionStorage();
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
storage,
|
|
134
|
+
webExtensionDriver,
|
|
135
|
+
...require("unstorage")
|
|
136
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Driver, Storage } from 'unstorage';
|
|
2
|
+
export * from 'unstorage';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @module wxt/storage
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface WebExtensionDriverOptions {
|
|
9
|
+
storageArea: 'sync' | 'local' | 'managed' | 'session';
|
|
10
|
+
}
|
|
11
|
+
declare const webExtensionDriver: (opts: WebExtensionDriverOptions) => Driver;
|
|
12
|
+
type StorageValue = null | string | number | boolean | object;
|
|
13
|
+
declare const storage: Storage<StorageValue>;
|
|
14
|
+
|
|
15
|
+
export { StorageValue, WebExtensionDriverOptions, storage, webExtensionDriver };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Driver, Storage } from 'unstorage';
|
|
2
|
+
export * from 'unstorage';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @module wxt/storage
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
interface WebExtensionDriverOptions {
|
|
9
|
+
storageArea: 'sync' | 'local' | 'managed' | 'session';
|
|
10
|
+
}
|
|
11
|
+
declare const webExtensionDriver: (opts: WebExtensionDriverOptions) => Driver;
|
|
12
|
+
type StorageValue = null | string | number | boolean | object;
|
|
13
|
+
declare const storage: Storage<StorageValue>;
|
|
14
|
+
|
|
15
|
+
export { StorageValue, WebExtensionDriverOptions, storage, webExtensionDriver };
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import "./chunk-YUG22S6W.js";
|
|
2
|
+
|
|
3
|
+
// src/storage.ts
|
|
4
|
+
import {
|
|
5
|
+
createStorage,
|
|
6
|
+
defineDriver
|
|
7
|
+
} from "unstorage";
|
|
8
|
+
import browser from "webextension-polyfill";
|
|
9
|
+
export * from "unstorage";
|
|
10
|
+
var webExtensionDriver = defineDriver((opts) => {
|
|
11
|
+
const checkPermission = () => {
|
|
12
|
+
if (browser.storage == null)
|
|
13
|
+
throw Error(
|
|
14
|
+
"You must request the 'storage' permission to use webExtensionDriver"
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
const _storageListener = (changes) => {
|
|
18
|
+
Object.entries(changes).forEach(([key, { newValue }]) => {
|
|
19
|
+
_listeners.forEach((callback) => {
|
|
20
|
+
callback(newValue ? "update" : "remove", key);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const _listeners = /* @__PURE__ */ new Set();
|
|
25
|
+
return {
|
|
26
|
+
name: "web-extension:" + opts.storageArea,
|
|
27
|
+
async hasItem(key) {
|
|
28
|
+
checkPermission();
|
|
29
|
+
const res = await browser.storage[opts.storageArea].get(key);
|
|
30
|
+
return res[key] != null;
|
|
31
|
+
},
|
|
32
|
+
async getItem(key) {
|
|
33
|
+
checkPermission();
|
|
34
|
+
const res = await browser.storage[opts.storageArea].get(key);
|
|
35
|
+
return res[key] ?? null;
|
|
36
|
+
},
|
|
37
|
+
async getItems(items) {
|
|
38
|
+
checkPermission();
|
|
39
|
+
const res = await browser.storage[opts.storageArea].get(
|
|
40
|
+
items.map((item) => item.key)
|
|
41
|
+
);
|
|
42
|
+
return items.map((item) => ({
|
|
43
|
+
key: item.key,
|
|
44
|
+
value: res[item.key] ?? null
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
async setItem(key, value) {
|
|
48
|
+
checkPermission();
|
|
49
|
+
await browser.storage[opts.storageArea].set({ [key]: value ?? null });
|
|
50
|
+
},
|
|
51
|
+
async setItems(items) {
|
|
52
|
+
checkPermission();
|
|
53
|
+
const map = items.reduce((map2, item) => {
|
|
54
|
+
map2[item.key] = item.value ?? null;
|
|
55
|
+
return map2;
|
|
56
|
+
}, {});
|
|
57
|
+
await browser.storage[opts.storageArea].set(map);
|
|
58
|
+
},
|
|
59
|
+
async removeItem(key) {
|
|
60
|
+
checkPermission();
|
|
61
|
+
await browser.storage[opts.storageArea].remove(key);
|
|
62
|
+
},
|
|
63
|
+
async getKeys() {
|
|
64
|
+
checkPermission();
|
|
65
|
+
const all = await browser.storage[opts.storageArea].get();
|
|
66
|
+
return Object.keys(all);
|
|
67
|
+
},
|
|
68
|
+
async clear() {
|
|
69
|
+
checkPermission();
|
|
70
|
+
await browser.storage[opts.storageArea].clear();
|
|
71
|
+
},
|
|
72
|
+
watch(callback) {
|
|
73
|
+
checkPermission();
|
|
74
|
+
_listeners.add(callback);
|
|
75
|
+
if (_listeners.size === 1) {
|
|
76
|
+
browser.storage[opts.storageArea].onChanged.addListener(
|
|
77
|
+
_storageListener
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return () => {
|
|
81
|
+
_listeners.delete(callback);
|
|
82
|
+
if (_listeners.size === 0) {
|
|
83
|
+
browser.storage[opts.storageArea].onChanged.removeListener(
|
|
84
|
+
_storageListener
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
function createWebExtensionStorage() {
|
|
92
|
+
const storage2 = createStorage();
|
|
93
|
+
storage2.mount("local", webExtensionDriver({ storageArea: "local" }));
|
|
94
|
+
storage2.mount("session", webExtensionDriver({ storageArea: "session" }));
|
|
95
|
+
storage2.mount("sync", webExtensionDriver({ storageArea: "sync" }));
|
|
96
|
+
storage2.mount("managed", webExtensionDriver({ storageArea: "managed" }));
|
|
97
|
+
return storage2;
|
|
98
|
+
}
|
|
99
|
+
var storage = createWebExtensionStorage();
|
|
100
|
+
export {
|
|
101
|
+
storage,
|
|
102
|
+
webExtensionDriver
|
|
103
|
+
};
|
package/dist/testing.cjs
CHANGED
|
@@ -285,7 +285,8 @@ function getUnimportOptions(config) {
|
|
|
285
285
|
presets: [
|
|
286
286
|
{ package: "wxt/client" },
|
|
287
287
|
{ package: "wxt/browser" },
|
|
288
|
-
{ package: "wxt/sandbox" }
|
|
288
|
+
{ package: "wxt/sandbox" },
|
|
289
|
+
{ package: "wxt/storage" }
|
|
289
290
|
],
|
|
290
291
|
warn: config.logger.warn,
|
|
291
292
|
dirs: ["components", "composables", "hooks", "utils"]
|
|
@@ -504,6 +505,30 @@ function webextensionPolyfillInlineDeps() {
|
|
|
504
505
|
};
|
|
505
506
|
}
|
|
506
507
|
|
|
508
|
+
// src/core/vite-plugins/excludeBrowserPolyfill.ts
|
|
509
|
+
function excludeBrowserPolyfill(config) {
|
|
510
|
+
const virtualId = "virtual:wxt-webextension-polyfill-disabled";
|
|
511
|
+
return {
|
|
512
|
+
name: "wxt:exclude-browser-polyfill",
|
|
513
|
+
config() {
|
|
514
|
+
if (config.experimental.includeBrowserPolyfill)
|
|
515
|
+
return;
|
|
516
|
+
return {
|
|
517
|
+
resolve: {
|
|
518
|
+
alias: {
|
|
519
|
+
"webextension-polyfill": virtualId
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
},
|
|
524
|
+
load(id) {
|
|
525
|
+
if (id === virtualId) {
|
|
526
|
+
return "export default chrome";
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
507
532
|
// src/core/utils/building/build-entrypoints.ts
|
|
508
533
|
var vite2 = __toESM(require("vite"), 1);
|
|
509
534
|
|
|
@@ -687,7 +712,10 @@ async function getInternalConfig(inlineConfig, command) {
|
|
|
687
712
|
template: mergedConfig.analysis?.template ?? "treemap"
|
|
688
713
|
},
|
|
689
714
|
userConfigMetadata: userConfigMetadata ?? {},
|
|
690
|
-
alias
|
|
715
|
+
alias,
|
|
716
|
+
experimental: {
|
|
717
|
+
includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
|
|
718
|
+
}
|
|
691
719
|
};
|
|
692
720
|
finalConfig.vite = (env2) => resolveInternalViteConfig(env2, mergedConfig, finalConfig);
|
|
693
721
|
return finalConfig;
|
|
@@ -748,6 +776,10 @@ function mergeInlineConfig(inlineConfig, userConfig) {
|
|
|
748
776
|
alias: {
|
|
749
777
|
...userConfig.alias,
|
|
750
778
|
...inlineConfig.alias
|
|
779
|
+
},
|
|
780
|
+
experimental: {
|
|
781
|
+
...userConfig.experimental,
|
|
782
|
+
...inlineConfig.experimental
|
|
751
783
|
}
|
|
752
784
|
};
|
|
753
785
|
}
|
|
@@ -800,6 +832,7 @@ async function resolveInternalViteConfig(env, mergedConfig, finalConfig) {
|
|
|
800
832
|
internalVite.plugins.push(bundleAnalysis());
|
|
801
833
|
}
|
|
802
834
|
internalVite.plugins.push(globals(finalConfig));
|
|
835
|
+
internalVite.plugins.push(excludeBrowserPolyfill(finalConfig));
|
|
803
836
|
return internalVite;
|
|
804
837
|
}
|
|
805
838
|
|
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-9115d0fb.js';
|
|
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-9115d0fb.js';
|
|
4
4
|
import 'webextension-polyfill';
|
|
5
5
|
import 'unimport';
|
|
6
6
|
import 'consola';
|
package/dist/testing.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
|
|
1
19
|
// src/virtual/background-entrypoint.ts
|
|
2
20
|
import definition from "virtual:user-background";
|
|
3
21
|
|
|
@@ -47,21 +65,125 @@ function setupWebSocket(onMessage) {
|
|
|
47
65
|
}
|
|
48
66
|
|
|
49
67
|
// src/virtual/background-entrypoint.ts
|
|
50
|
-
import
|
|
68
|
+
import browser4 from "webextension-polyfill";
|
|
51
69
|
|
|
52
|
-
// src/
|
|
70
|
+
// src/storage.ts
|
|
71
|
+
var storage_exports = {};
|
|
72
|
+
__export(storage_exports, {
|
|
73
|
+
storage: () => storage,
|
|
74
|
+
webExtensionDriver: () => webExtensionDriver
|
|
75
|
+
});
|
|
76
|
+
__reExport(storage_exports, unstorage_star);
|
|
77
|
+
import {
|
|
78
|
+
createStorage,
|
|
79
|
+
defineDriver
|
|
80
|
+
} from "unstorage";
|
|
53
81
|
import browser from "webextension-polyfill";
|
|
82
|
+
import * as unstorage_star from "unstorage";
|
|
83
|
+
var webExtensionDriver = defineDriver((opts) => {
|
|
84
|
+
const checkPermission = () => {
|
|
85
|
+
if (browser.storage == null)
|
|
86
|
+
throw Error(
|
|
87
|
+
"You must request the 'storage' permission to use webExtensionDriver"
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
const _storageListener = (changes) => {
|
|
91
|
+
Object.entries(changes).forEach(([key, { newValue }]) => {
|
|
92
|
+
_listeners.forEach((callback) => {
|
|
93
|
+
callback(newValue ? "update" : "remove", key);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const _listeners = /* @__PURE__ */ new Set();
|
|
98
|
+
return {
|
|
99
|
+
name: "web-extension:" + opts.storageArea,
|
|
100
|
+
async hasItem(key) {
|
|
101
|
+
checkPermission();
|
|
102
|
+
const res = await browser.storage[opts.storageArea].get(key);
|
|
103
|
+
return res[key] != null;
|
|
104
|
+
},
|
|
105
|
+
async getItem(key) {
|
|
106
|
+
checkPermission();
|
|
107
|
+
const res = await browser.storage[opts.storageArea].get(key);
|
|
108
|
+
return res[key] ?? null;
|
|
109
|
+
},
|
|
110
|
+
async getItems(items) {
|
|
111
|
+
checkPermission();
|
|
112
|
+
const res = await browser.storage[opts.storageArea].get(
|
|
113
|
+
items.map((item) => item.key)
|
|
114
|
+
);
|
|
115
|
+
return items.map((item) => ({
|
|
116
|
+
key: item.key,
|
|
117
|
+
value: res[item.key] ?? null
|
|
118
|
+
}));
|
|
119
|
+
},
|
|
120
|
+
async setItem(key, value) {
|
|
121
|
+
checkPermission();
|
|
122
|
+
await browser.storage[opts.storageArea].set({ [key]: value ?? null });
|
|
123
|
+
},
|
|
124
|
+
async setItems(items) {
|
|
125
|
+
checkPermission();
|
|
126
|
+
const map = items.reduce((map2, item) => {
|
|
127
|
+
map2[item.key] = item.value ?? null;
|
|
128
|
+
return map2;
|
|
129
|
+
}, {});
|
|
130
|
+
await browser.storage[opts.storageArea].set(map);
|
|
131
|
+
},
|
|
132
|
+
async removeItem(key) {
|
|
133
|
+
checkPermission();
|
|
134
|
+
await browser.storage[opts.storageArea].remove(key);
|
|
135
|
+
},
|
|
136
|
+
async getKeys() {
|
|
137
|
+
checkPermission();
|
|
138
|
+
const all = await browser.storage[opts.storageArea].get();
|
|
139
|
+
return Object.keys(all);
|
|
140
|
+
},
|
|
141
|
+
async clear() {
|
|
142
|
+
checkPermission();
|
|
143
|
+
await browser.storage[opts.storageArea].clear();
|
|
144
|
+
},
|
|
145
|
+
watch(callback) {
|
|
146
|
+
checkPermission();
|
|
147
|
+
_listeners.add(callback);
|
|
148
|
+
if (_listeners.size === 1) {
|
|
149
|
+
browser.storage[opts.storageArea].onChanged.addListener(
|
|
150
|
+
_storageListener
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
return () => {
|
|
154
|
+
_listeners.delete(callback);
|
|
155
|
+
if (_listeners.size === 0) {
|
|
156
|
+
browser.storage[opts.storageArea].onChanged.removeListener(
|
|
157
|
+
_storageListener
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
function createWebExtensionStorage() {
|
|
165
|
+
const storage2 = createStorage();
|
|
166
|
+
storage2.mount("local", webExtensionDriver({ storageArea: "local" }));
|
|
167
|
+
storage2.mount("session", webExtensionDriver({ storageArea: "session" }));
|
|
168
|
+
storage2.mount("sync", webExtensionDriver({ storageArea: "sync" }));
|
|
169
|
+
storage2.mount("managed", webExtensionDriver({ storageArea: "managed" }));
|
|
170
|
+
return storage2;
|
|
171
|
+
}
|
|
172
|
+
var storage = createWebExtensionStorage();
|
|
173
|
+
|
|
174
|
+
// src/client/utils/keep-service-worker-alive.ts
|
|
175
|
+
import browser2 from "webextension-polyfill";
|
|
54
176
|
function keepServiceWorkerAlive() {
|
|
55
177
|
setInterval(async () => {
|
|
56
|
-
await
|
|
178
|
+
await browser2.runtime.getPlatformInfo();
|
|
57
179
|
}, 5e3);
|
|
58
180
|
}
|
|
59
181
|
|
|
60
182
|
// src/client/utils/reload-content-scripts.ts
|
|
61
|
-
import
|
|
183
|
+
import browser3 from "webextension-polyfill";
|
|
62
184
|
import { MatchPattern } from "@webext-core/match-patterns";
|
|
63
185
|
function reloadContentScript(contentScript) {
|
|
64
|
-
const manifest =
|
|
186
|
+
const manifest = browser3.runtime.getManifest();
|
|
65
187
|
if (manifest.manifest_version == 2) {
|
|
66
188
|
void reloadContentScriptMv2(contentScript);
|
|
67
189
|
} else {
|
|
@@ -71,17 +193,17 @@ function reloadContentScript(contentScript) {
|
|
|
71
193
|
async function reloadContentScriptMv3(contentScript) {
|
|
72
194
|
const id = `wxt:${contentScript.js[0]}`;
|
|
73
195
|
logger.log("Reloading content script:", contentScript);
|
|
74
|
-
const registered = await
|
|
196
|
+
const registered = await browser3.scripting.getRegisteredContentScripts();
|
|
75
197
|
logger.debug("Existing scripts:", registered);
|
|
76
198
|
const existing = registered.find((cs) => cs.id === id);
|
|
77
199
|
if (existing) {
|
|
78
200
|
logger.debug("Updating content script", existing);
|
|
79
|
-
await
|
|
201
|
+
await browser3.scripting.updateContentScripts([{ ...contentScript, id }]);
|
|
80
202
|
} else {
|
|
81
203
|
logger.debug("Registering new content script...");
|
|
82
|
-
await
|
|
204
|
+
await browser3.scripting.registerContentScripts([{ ...contentScript, id }]);
|
|
83
205
|
}
|
|
84
|
-
const allTabs = await
|
|
206
|
+
const allTabs = await browser3.tabs.query({});
|
|
85
207
|
const matchPatterns = contentScript.matches.map(
|
|
86
208
|
(match) => new MatchPattern(match)
|
|
87
209
|
);
|
|
@@ -91,7 +213,7 @@ async function reloadContentScriptMv3(contentScript) {
|
|
|
91
213
|
return false;
|
|
92
214
|
return !!matchPatterns.find((pattern) => pattern.includes(url));
|
|
93
215
|
});
|
|
94
|
-
await Promise.all(matchingTabs.map((tab) =>
|
|
216
|
+
await Promise.all(matchingTabs.map((tab) => browser3.tabs.reload(tab.id)));
|
|
95
217
|
}
|
|
96
218
|
async function reloadContentScriptMv2(contentScript) {
|
|
97
219
|
throw Error("TODO: reloadContentScriptMv2");
|
|
@@ -102,7 +224,7 @@ if (__COMMAND__ === "serve") {
|
|
|
102
224
|
try {
|
|
103
225
|
const ws = setupWebSocket((message) => {
|
|
104
226
|
if (message.event === "wxt:reload-extension")
|
|
105
|
-
|
|
227
|
+
browser4.runtime.reload();
|
|
106
228
|
if (message.event === "wxt:reload-content-script" && message.data != null)
|
|
107
229
|
reloadContentScript(message.data);
|
|
108
230
|
});
|
|
@@ -118,6 +240,11 @@ if (__COMMAND__ === "serve") {
|
|
|
118
240
|
}
|
|
119
241
|
}
|
|
120
242
|
try {
|
|
243
|
+
if (import.meta.env.DEV) {
|
|
244
|
+
globalThis.wxt = {
|
|
245
|
+
storage
|
|
246
|
+
};
|
|
247
|
+
}
|
|
121
248
|
const res = definition.main();
|
|
122
249
|
if (res instanceof Promise) {
|
|
123
250
|
console.warn(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.10.0",
|
|
5
5
|
"description": "Next gen framework for developing web extensions",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18",
|
|
@@ -56,11 +56,16 @@
|
|
|
56
56
|
"require": "./dist/testing.cjs",
|
|
57
57
|
"import": "./dist/testing.js",
|
|
58
58
|
"types": "./dist/testing.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./storage": {
|
|
61
|
+
"require": "./dist/storage.cjs",
|
|
62
|
+
"import": "./dist/storage.js",
|
|
63
|
+
"types": "./dist/storage.d.ts"
|
|
59
64
|
}
|
|
60
65
|
},
|
|
61
66
|
"dependencies": {
|
|
62
67
|
"@types/webextension-polyfill": "^0.10.5",
|
|
63
|
-
"@webext-core/fake-browser": "^1.
|
|
68
|
+
"@webext-core/fake-browser": "^1.3.1",
|
|
64
69
|
"@webext-core/isolated-element": "^1.0.4",
|
|
65
70
|
"@webext-core/match-patterns": "^1.0.2",
|
|
66
71
|
"async-mutex": "^0.4.0",
|
|
@@ -84,6 +89,7 @@
|
|
|
84
89
|
"prompts": "^2.4.2",
|
|
85
90
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
86
91
|
"unimport": "^3.4.0",
|
|
92
|
+
"unstorage": "^1.9.0",
|
|
87
93
|
"vite": "^4.0.0 || ^5.0.0-0",
|
|
88
94
|
"web-ext-run": "^0.1.0",
|
|
89
95
|
"webextension-polyfill": "^0.10.0",
|