wxt 0.12.1 → 0.12.2-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/dist/browser.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Browser, Runtime, I18n } from 'webextension-polyfill';
2
+ export { Action, ActivityLog, Alarms, Bookmarks, BrowserAction, BrowserSettings, BrowsingData, CaptivePortal, Clipboard, Commands, ContentScripts, ContextMenus, ContextualIdentities, Cookies, DeclarativeNetRequest, Devtools, Dns, Downloads, Events, Experiments, Extension, ExtensionTypes, Find, GeckoProfiler, History, I18n, Identity, Idle, Management, Manifest, Menus, NetworkStatus, NormandyAddonStudy, Notifications, Omnibox, PageAction, Permissions, Pkcs11, Privacy, Proxy, Runtime, Scripting, Search, Sessions, SidebarAction, Storage, Tabs, Theme, TopSites, Types, Urlbar, UserScripts, WebNavigation, WebRequest, Windows } from 'webextension-polyfill';
2
3
 
3
4
  /**
4
5
  * @module wxt/browser
package/dist/browser.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  browser
3
3
  } from "./chunk-FNTE2L27.js";
4
+ import "./chunk-M6BUQN66.js";
4
5
  export {
5
6
  browser
6
7
  };
@@ -0,0 +1,22 @@
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
+
19
+ export {
20
+ __export,
21
+ __reExport
22
+ };
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.12.1";
2
+ var version = "0.12.2-alpha1";
3
3
 
4
4
  // src/core/utils/arrays.ts
5
5
  function every(array, predicate) {
@@ -951,7 +951,7 @@ function webextensionPolyfillInlineDeps() {
951
951
  return {
952
952
  name: "wxt:testing-inline-deps",
953
953
  config() {
954
- const wxtModules = ["wxt/browser", "wxt/client"];
954
+ const wxtModules = ["wxt/browser"];
955
955
  return {
956
956
  test: {
957
957
  server: {
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import "./chunk-VBXJIVYU.js";
4
4
  import cac from "cac";
5
5
 
6
6
  // package.json
7
- var version = "0.12.1";
7
+ var version = "0.12.2-alpha1";
8
8
 
9
9
  // src/core/utils/fs.ts
10
10
  import fs from "fs-extra";
package/dist/client.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  browser
3
3
  } from "./chunk-FNTE2L27.js";
4
+ import "./chunk-M6BUQN66.js";
4
5
 
5
6
  // src/client/utils/logger.ts
6
7
  function print(method, ...args) {
@@ -364,12 +365,11 @@ async function loadCss() {
364
365
  }
365
366
 
366
367
  // src/client/content-scripts/content-script-iframe.ts
367
- import browser2 from "webextension-polyfill";
368
368
  function createContentScriptIframe(ctx, options) {
369
369
  const wrapper = document.createElement("div");
370
370
  wrapper.classList.add("wxt-iframe-wrapper");
371
371
  const iframe = document.createElement("iframe");
372
- iframe.src = browser2.runtime.getURL(options.page);
372
+ iframe.src = browser.runtime.getURL(options.page);
373
373
  wrapper.appendChild(iframe);
374
374
  const mount = () => {
375
375
  applyContentScriptUiPosition(wrapper, iframe, options);
package/dist/index.cjs CHANGED
@@ -4334,7 +4334,7 @@ function getChunkSortWeight(filename) {
4334
4334
  var import_picocolors3 = __toESM(require("picocolors"), 1);
4335
4335
 
4336
4336
  // package.json
4337
- var version = "0.12.1";
4337
+ var version = "0.12.2-alpha1";
4338
4338
 
4339
4339
  // src/core/utils/log/printHeader.ts
4340
4340
  var import_consola2 = require("consola");
package/dist/index.d.cts CHANGED
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.12.1";
65
+ var version = "0.12.2-alpha1";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.d.ts CHANGED
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.12.1";
65
+ var version = "0.12.2-alpha1";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  rebuild,
16
16
  resolvePerBrowserOption,
17
17
  version
18
- } from "./chunk-ENVSDI4C.js";
18
+ } from "./chunk-UX5XHE4P.js";
19
19
  import "./chunk-VBXJIVYU.js";
20
20
 
21
21
  // src/core/build.ts
package/dist/sandbox.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { U as UnlistedScriptDefinition, B as BackgroundDefinition, C as ContentScriptDefinition } from './external-TYmXqKVq.js';
2
+ export * from '@webext-core/match-patterns';
2
3
  import 'webextension-polyfill';
3
4
 
4
5
  declare function defineUnlistedScript(main: () => void): UnlistedScriptDefinition;
package/dist/sandbox.js CHANGED
@@ -1,3 +1,16 @@
1
+ import {
2
+ __export,
3
+ __reExport
4
+ } from "./chunk-M6BUQN66.js";
5
+
6
+ // src/sandbox/index.ts
7
+ var sandbox_exports = {};
8
+ __export(sandbox_exports, {
9
+ defineBackground: () => defineBackground,
10
+ defineContentScript: () => defineContentScript,
11
+ defineUnlistedScript: () => defineUnlistedScript
12
+ });
13
+
1
14
  // src/sandbox/define-unlisted-script.ts
2
15
  function defineUnlistedScript(arg) {
3
16
  if (typeof arg === "function")
@@ -16,6 +29,14 @@ function defineBackground(arg) {
16
29
  function defineContentScript(definition) {
17
30
  return definition;
18
31
  }
32
+
33
+ // src/sandbox/match-patterns.ts
34
+ var match_patterns_exports = {};
35
+ __reExport(match_patterns_exports, match_patterns_star);
36
+ import * as match_patterns_star from "@webext-core/match-patterns";
37
+
38
+ // src/sandbox/index.ts
39
+ __reExport(sandbox_exports, match_patterns_exports);
19
40
  export {
20
41
  defineBackground,
21
42
  defineContentScript,
package/dist/storage.cjs CHANGED
@@ -36,11 +36,16 @@ __export(storage_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(storage_exports);
38
38
  var import_unstorage = require("unstorage");
39
+
40
+ // src/browser.ts
39
41
  var import_webextension_polyfill = __toESM(require("webextension-polyfill"), 1);
42
+ var browser = import_webextension_polyfill.default;
43
+
44
+ // src/storage.ts
40
45
  __reExport(storage_exports, require("unstorage"), module.exports);
41
46
  var webExtensionDriver = (0, import_unstorage.defineDriver)((opts) => {
42
47
  const checkPermission = () => {
43
- if (import_webextension_polyfill.default.storage == null)
48
+ if (browser.storage == null)
44
49
  throw Error(
45
50
  "You must request the 'storage' permission to use webExtensionDriver"
46
51
  );
@@ -57,17 +62,17 @@ var webExtensionDriver = (0, import_unstorage.defineDriver)((opts) => {
57
62
  name: "web-extension:" + opts.storageArea,
58
63
  async hasItem(key) {
59
64
  checkPermission();
60
- const res = await import_webextension_polyfill.default.storage[opts.storageArea].get(key);
65
+ const res = await browser.storage[opts.storageArea].get(key);
61
66
  return res[key] != null;
62
67
  },
63
68
  async getItem(key) {
64
69
  checkPermission();
65
- const res = await import_webextension_polyfill.default.storage[opts.storageArea].get(key);
70
+ const res = await browser.storage[opts.storageArea].get(key);
66
71
  return res[key] ?? null;
67
72
  },
68
73
  async getItems(items) {
69
74
  checkPermission();
70
- const res = await import_webextension_polyfill.default.storage[opts.storageArea].get(
75
+ const res = await browser.storage[opts.storageArea].get(
71
76
  items.map((item) => item.key)
72
77
  );
73
78
  return items.map((item) => ({
@@ -77,7 +82,7 @@ var webExtensionDriver = (0, import_unstorage.defineDriver)((opts) => {
77
82
  },
78
83
  async setItem(key, value) {
79
84
  checkPermission();
80
- await import_webextension_polyfill.default.storage[opts.storageArea].set({ [key]: value ?? null });
85
+ await browser.storage[opts.storageArea].set({ [key]: value ?? null });
81
86
  },
82
87
  async setItems(items) {
83
88
  checkPermission();
@@ -85,33 +90,33 @@ var webExtensionDriver = (0, import_unstorage.defineDriver)((opts) => {
85
90
  map2[item.key] = item.value ?? null;
86
91
  return map2;
87
92
  }, {});
88
- await import_webextension_polyfill.default.storage[opts.storageArea].set(map);
93
+ await browser.storage[opts.storageArea].set(map);
89
94
  },
90
95
  async removeItem(key) {
91
96
  checkPermission();
92
- await import_webextension_polyfill.default.storage[opts.storageArea].remove(key);
97
+ await browser.storage[opts.storageArea].remove(key);
93
98
  },
94
99
  async getKeys() {
95
100
  checkPermission();
96
- const all = await import_webextension_polyfill.default.storage[opts.storageArea].get();
101
+ const all = await browser.storage[opts.storageArea].get();
97
102
  return Object.keys(all);
98
103
  },
99
104
  async clear() {
100
105
  checkPermission();
101
- await import_webextension_polyfill.default.storage[opts.storageArea].clear();
106
+ await browser.storage[opts.storageArea].clear();
102
107
  },
103
108
  watch(callback) {
104
109
  checkPermission();
105
110
  _listeners.add(callback);
106
111
  if (_listeners.size === 1) {
107
- import_webextension_polyfill.default.storage[opts.storageArea].onChanged.addListener(
112
+ browser.storage[opts.storageArea].onChanged.addListener(
108
113
  _storageListener
109
114
  );
110
115
  }
111
116
  return () => {
112
117
  _listeners.delete(callback);
113
118
  if (_listeners.size === 0) {
114
- import_webextension_polyfill.default.storage[opts.storageArea].onChanged.removeListener(
119
+ browser.storage[opts.storageArea].onChanged.removeListener(
115
120
  _storageListener
116
121
  );
117
122
  }
package/dist/storage.js CHANGED
@@ -5,7 +5,12 @@ import {
5
5
  createStorage,
6
6
  defineDriver
7
7
  } from "unstorage";
8
- import browser from "webextension-polyfill";
8
+
9
+ // src/browser.ts
10
+ import originalBrowser from "webextension-polyfill";
11
+ var browser = originalBrowser;
12
+
13
+ // src/storage.ts
9
14
  export * from "unstorage";
10
15
  var webExtensionDriver = defineDriver((opts) => {
11
16
  const checkPermission = () => {
package/dist/testing.cjs CHANGED
@@ -582,7 +582,7 @@ function webextensionPolyfillInlineDeps() {
582
582
  return {
583
583
  name: "wxt:testing-inline-deps",
584
584
  config() {
585
- const wxtModules = ["wxt/browser", "wxt/client"];
585
+ const wxtModules = ["wxt/browser"];
586
586
  return {
587
587
  test: {
588
588
  server: {
package/dist/testing.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  unimport,
7
7
  webextensionPolyfillAlias,
8
8
  webextensionPolyfillInlineDeps
9
- } from "./chunk-ENVSDI4C.js";
9
+ } from "./chunk-UX5XHE4P.js";
10
10
  import "./chunk-VBXJIVYU.js";
11
11
 
12
12
  // src/testing/fake-browser.ts
@@ -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
 
@@ -46,22 +64,55 @@ function setupWebSocket(onMessage) {
46
64
  return ws;
47
65
  }
48
66
 
49
- // src/virtual/background-entrypoint.ts
50
- import browser3 from "webextension-polyfill";
67
+ // src/browser.ts
68
+ import originalBrowser from "webextension-polyfill";
69
+ var browser = originalBrowser;
51
70
 
52
71
  // src/client/utils/keep-service-worker-alive.ts
53
- import browser from "webextension-polyfill";
54
72
  function keepServiceWorkerAlive() {
55
73
  setInterval(async () => {
56
74
  await browser.runtime.getPlatformInfo();
57
75
  }, 5e3);
58
76
  }
59
77
 
78
+ // src/sandbox/index.ts
79
+ var sandbox_exports = {};
80
+ __export(sandbox_exports, {
81
+ defineBackground: () => defineBackground,
82
+ defineContentScript: () => defineContentScript,
83
+ defineUnlistedScript: () => defineUnlistedScript
84
+ });
85
+
86
+ // src/sandbox/define-unlisted-script.ts
87
+ function defineUnlistedScript(arg) {
88
+ if (typeof arg === "function")
89
+ return { main: arg };
90
+ return arg;
91
+ }
92
+
93
+ // src/sandbox/define-background.ts
94
+ function defineBackground(arg) {
95
+ if (typeof arg === "function")
96
+ return { main: arg };
97
+ return arg;
98
+ }
99
+
100
+ // src/sandbox/define-content-script.ts
101
+ function defineContentScript(definition2) {
102
+ return definition2;
103
+ }
104
+
105
+ // src/sandbox/match-patterns.ts
106
+ var match_patterns_exports = {};
107
+ __reExport(match_patterns_exports, match_patterns_star);
108
+ import * as match_patterns_star from "@webext-core/match-patterns";
109
+
110
+ // src/sandbox/index.ts
111
+ __reExport(sandbox_exports, match_patterns_exports);
112
+
60
113
  // src/client/utils/reload-content-scripts.ts
61
- import browser2 from "webextension-polyfill";
62
- import { MatchPattern } from "@webext-core/match-patterns";
63
114
  function reloadContentScript(contentScript) {
64
- const manifest = browser2.runtime.getManifest();
115
+ const manifest = browser.runtime.getManifest();
65
116
  if (manifest.manifest_version == 2) {
66
117
  void reloadContentScriptMv2(contentScript);
67
118
  } else {
@@ -71,19 +122,19 @@ function reloadContentScript(contentScript) {
71
122
  async function reloadContentScriptMv3(contentScript) {
72
123
  const id = `wxt:${contentScript.js[0]}`;
73
124
  logger.log("Reloading content script:", contentScript);
74
- const registered = await browser2.scripting.getRegisteredContentScripts();
125
+ const registered = await browser.scripting.getRegisteredContentScripts();
75
126
  logger.debug("Existing scripts:", registered);
76
127
  const existing = registered.find((cs) => cs.id === id);
77
128
  if (existing) {
78
129
  logger.debug("Updating content script", existing);
79
- await browser2.scripting.updateContentScripts([{ ...contentScript, id }]);
130
+ await browser.scripting.updateContentScripts([{ ...contentScript, id }]);
80
131
  } else {
81
132
  logger.debug("Registering new content script...");
82
- await browser2.scripting.registerContentScripts([{ ...contentScript, id }]);
133
+ await browser.scripting.registerContentScripts([{ ...contentScript, id }]);
83
134
  }
84
- const allTabs = await browser2.tabs.query({});
135
+ const allTabs = await browser.tabs.query({});
85
136
  const matchPatterns = contentScript.matches.map(
86
- (match) => new MatchPattern(match)
137
+ (match) => new sandbox_exports.MatchPattern(match)
87
138
  );
88
139
  const matchingTabs = allTabs.filter((tab) => {
89
140
  const url = tab.url;
@@ -91,7 +142,7 @@ async function reloadContentScriptMv3(contentScript) {
91
142
  return false;
92
143
  return !!matchPatterns.find((pattern) => pattern.includes(url));
93
144
  });
94
- await Promise.all(matchingTabs.map((tab) => browser2.tabs.reload(tab.id)));
145
+ await Promise.all(matchingTabs.map((tab) => browser.tabs.reload(tab.id)));
95
146
  }
96
147
  async function reloadContentScriptMv2(contentScript) {
97
148
  throw Error("TODO: reloadContentScriptMv2");
@@ -102,7 +153,7 @@ if (__COMMAND__ === "serve") {
102
153
  try {
103
154
  const ws = setupWebSocket((message) => {
104
155
  if (message.event === "wxt:reload-extension")
105
- browser3.runtime.reload();
156
+ browser.runtime.reload();
106
157
  if (message.event === "wxt:reload-content-script" && message.data != null)
107
158
  reloadContentScript(message.data);
108
159
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.12.1",
4
+ "version": "0.12.2-alpha1",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",