wxt 0.9.2 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
  &bull;
30
- <a href="https://wxt.dev/entrypoints/background.html" target="_blank">Entrypoints</a>
31
- &bull;
32
30
  <a href="https://wxt.dev/api/config.html" target="_blank">Configuration</a>
31
+ &bull;
32
+ <a href="https://wxt.dev/examples.html" target="_blank">Examples</a>
33
33
  </p>
34
34
 
35
35
  ![Example CLI Output](./docs/assets/cli-output.png)
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.9.2";
2
+ var version = "0.10.1";
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"]
@@ -1394,6 +1395,9 @@ async function importEntrypointFile(path7, config) {
1394
1395
  "node_modules/wxt/dist/virtual/mock-browser.js"
1395
1396
  )
1396
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,
1397
1401
  // List of extensions to transform with esbuild
1398
1402
  extensions: [".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"],
1399
1403
  transform(opts) {
@@ -1926,20 +1930,20 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
1926
1930
  function discoverIcons(buildOutput) {
1927
1931
  const icons = [];
1928
1932
  const iconRegex = [
1929
- /^icon-([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
1933
+ /^icon-([0-9]+)\.png$/,
1930
1934
  // icon-16.png
1931
- /^icon-([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/,
1935
+ /^icon-([0-9]+)x[0-9]+\.png$/,
1932
1936
  // icon-16x16.png
1933
- /^icon@([0-9]+)w\.(png|bmp|jpeg|jpg|ico|gif)$/,
1937
+ /^icon@([0-9]+)w\.png$/,
1934
1938
  // icon@16w.png
1935
- /^icon@([0-9]+)h\.(png|bmp|jpeg|jpg|ico|gif)$/,
1939
+ /^icon@([0-9]+)h\.png$/,
1936
1940
  // icon@16h.png
1937
- /^icon@([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
1941
+ /^icon@([0-9]+)\.png$/,
1938
1942
  // icon@16.png
1939
- /^icon[\/\\]([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
1940
- // icon/16.png
1941
- /^icon[\/\\]([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/
1942
- // 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
1943
1947
  ];
1944
1948
  buildOutput.publicAssets.forEach((asset) => {
1945
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.9.2";
2418
+ var version = "0.10.1";
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"]
@@ -4072,6 +4073,9 @@ async function importEntrypointFile(path11, config) {
4072
4073
  "node_modules/wxt/dist/virtual/mock-browser.js"
4073
4074
  )
4074
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,
4075
4079
  // List of extensions to transform with esbuild
4076
4080
  extensions: [".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"],
4077
4081
  transform(opts) {
@@ -4608,20 +4612,20 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
4608
4612
  function discoverIcons(buildOutput) {
4609
4613
  const icons = [];
4610
4614
  const iconRegex = [
4611
- /^icon-([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
4615
+ /^icon-([0-9]+)\.png$/,
4612
4616
  // icon-16.png
4613
- /^icon-([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/,
4617
+ /^icon-([0-9]+)x[0-9]+\.png$/,
4614
4618
  // icon-16x16.png
4615
- /^icon@([0-9]+)w\.(png|bmp|jpeg|jpg|ico|gif)$/,
4619
+ /^icon@([0-9]+)w\.png$/,
4616
4620
  // icon@16w.png
4617
- /^icon@([0-9]+)h\.(png|bmp|jpeg|jpg|ico|gif)$/,
4621
+ /^icon@([0-9]+)h\.png$/,
4618
4622
  // icon@16h.png
4619
- /^icon@([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
4623
+ /^icon@([0-9]+)\.png$/,
4620
4624
  // icon@16.png
4621
- /^icon[\/\\]([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
4622
- // icon/16.png
4623
- /^icon[\/\\]([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/
4624
- // 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
4625
4629
  ];
4626
4630
  buildOutput.publicAssets.forEach((asset) => {
4627
4631
  let size;
@@ -5182,9 +5186,13 @@ async function initialize(options) {
5182
5186
  type: () => options.packageManager == null ? "select" : void 0,
5183
5187
  message: "Package Manager",
5184
5188
  choices: [
5185
- { title: "npm", value: "npm" },
5186
- { title: "pnpm", value: "pnpm" },
5187
- { 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
+ }
5188
5196
  ]
5189
5197
  }
5190
5198
  ],
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"]
@@ -4082,6 +4083,9 @@ async function importEntrypointFile(path11, config) {
4082
4083
  "node_modules/wxt/dist/virtual/mock-browser.js"
4083
4084
  )
4084
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,
4085
4089
  // List of extensions to transform with esbuild
4086
4090
  extensions: [".ts", ".cts", ".mts", ".tsx", ".js", ".cjs", ".mjs", ".jsx"],
4087
4091
  transform(opts) {
@@ -4224,7 +4228,7 @@ function getChunkSortWeight(filename) {
4224
4228
  var import_picocolors3 = __toESM(require("picocolors"), 1);
4225
4229
 
4226
4230
  // package.json
4227
- var version = "0.9.2";
4231
+ var version = "0.10.1";
4228
4232
 
4229
4233
  // src/core/utils/log/printHeader.ts
4230
4234
  var import_consola2 = require("consola");
@@ -4619,20 +4623,20 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
4619
4623
  function discoverIcons(buildOutput) {
4620
4624
  const icons = [];
4621
4625
  const iconRegex = [
4622
- /^icon-([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
4626
+ /^icon-([0-9]+)\.png$/,
4623
4627
  // icon-16.png
4624
- /^icon-([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/,
4628
+ /^icon-([0-9]+)x[0-9]+\.png$/,
4625
4629
  // icon-16x16.png
4626
- /^icon@([0-9]+)w\.(png|bmp|jpeg|jpg|ico|gif)$/,
4630
+ /^icon@([0-9]+)w\.png$/,
4627
4631
  // icon@16w.png
4628
- /^icon@([0-9]+)h\.(png|bmp|jpeg|jpg|ico|gif)$/,
4632
+ /^icon@([0-9]+)h\.png$/,
4629
4633
  // icon@16h.png
4630
- /^icon@([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
4634
+ /^icon@([0-9]+)\.png$/,
4631
4635
  // icon@16.png
4632
- /^icon[\/\\]([0-9]+)\.(png|bmp|jpeg|jpg|ico|gif)$/,
4633
- // icon/16.png
4634
- /^icon[\/\\]([0-9]+)x[0-9]+\.(png|bmp|jpeg|jpg|ico|gif)$/
4635
- // 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
4636
4640
  ];
4637
4641
  buildOutput.publicAssets.forEach((asset) => {
4638
4642
  let size;
@@ -5203,9 +5207,13 @@ async function initialize(options) {
5203
5207
  type: () => options.packageManager == null ? "select" : void 0,
5204
5208
  message: "Package Manager",
5205
5209
  choices: [
5206
- { title: "npm", value: "npm" },
5207
- { title: "pnpm", value: "pnpm" },
5208
- { 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
+ }
5209
5217
  ]
5210
5218
  }
5211
5219
  ],
package/dist/index.d.cts CHANGED
@@ -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.9.2";
64
+ var version = "0.10.1";
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
@@ -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.9.2";
64
+ var version = "0.10.1";
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-OKMB7FJI.js";
18
+ } from "./chunk-U65ZYVCI.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
  ],
@@ -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 };
@@ -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"]
package/dist/testing.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  unimport,
7
7
  webextensionPolyfillAlias,
8
8
  webextensionPolyfillInlineDeps
9
- } from "./chunk-OKMB7FJI.js";
9
+ } from "./chunk-U65ZYVCI.js";
10
10
  import "./chunk-YUG22S6W.js";
11
11
 
12
12
  // src/testing/fake-browser.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.9.2",
4
+ "version": "0.10.1",
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.2.2",
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",
package/dist/cli.d.cts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }