wxt 0.14.4 → 0.14.6

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/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-QOQPHF1G.cjs';
2
- export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-QOQPHF1G.cjs';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-mJ1bW7iy.cjs';
2
+ export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-mJ1bW7iy.cjs';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.14.4";
65
+ var version = "0.14.6";
66
66
 
67
67
  export { BuildOutput, ExtensionRunnerConfig, InlineConfig, UserConfig, WxtDevServer, build, clean, createServer, defineConfig, defineRunnerConfig, initialize, prepare, version, zip };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-QOQPHF1G.js';
2
- export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-QOQPHF1G.js';
1
+ import { I as InlineConfig, B as BuildOutput, U as UserConfig, E as ExtensionRunnerConfig, W as WxtDevServer } from './external-mJ1bW7iy.js';
2
+ export { q as BackgroundDefinition, h as BackgroundEntrypoint, g as BaseEntrypoint, f as BaseEntrypointOptions, d as BuildStepOutput, w as ConfigEnv, p as ContentScriptBaseDefinition, m as ContentScriptDefinition, C as ContentScriptEntrypoint, n as ContentScriptIsolatedWorldDefinition, o as ContentScriptMainWorldDefinition, j as Entrypoint, k as EntrypointGroup, t as ExcludableEntrypoint, G as GenericEntrypoint, L as Logger, l as OnContentScriptStopped, i as OptionsEntrypoint, c as OutputAsset, b as OutputChunk, O as OutputFile, s as PerBrowserOption, P as PopupEntrypoint, S as ServerInfo, T as TargetBrowser, e as TargetManifestVersion, r as UnlistedScriptDefinition, u as UserManifest, v as UserManifestFn, x as WxtBuilder, y as WxtBuilderServer, a as WxtViteConfig } from './external-mJ1bW7iy.js';
3
3
  import 'vite';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
@@ -62,6 +62,6 @@ declare function prepare(config: InlineConfig): Promise<void>;
62
62
  */
63
63
  declare function zip(config?: InlineConfig): Promise<string[]>;
64
64
 
65
- var version = "0.14.4";
65
+ var version = "0.14.6";
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-LETSPJCU.js";
18
+ } from "./chunk-XDRW7AKZ.js";
19
19
  import "./chunk-VBXJIVYU.js";
20
20
 
21
21
  // src/core/build.ts
@@ -91,7 +91,7 @@ function createWebExtRunner() {
91
91
  let runner;
92
92
  return {
93
93
  async openBrowser(config) {
94
- config.logger.info("Opening browser...");
94
+ const startTime = Date.now();
95
95
  if (config.browser === "firefox" && config.manifestVersion === 3) {
96
96
  throw Error(
97
97
  "Dev mode does not support Firefox MV3. For alternatives, see https://github.com/wxt-dev/wxt/issues/230#issuecomment-1806881653"
@@ -136,7 +136,8 @@ function createWebExtRunner() {
136
136
  config.logger.debug("web-ext options:", options);
137
137
  const webExt = await import("web-ext-run");
138
138
  runner = await webExt.default.cmd.run(finalConfig, options);
139
- config.logger.success("Opened!");
139
+ const duration = Date.now() - startTime;
140
+ config.logger.success(`Opened browser in ${formatDuration(duration)}`);
140
141
  },
141
142
  async closeBrowser() {
142
143
  return await runner?.exit();
@@ -211,19 +212,36 @@ async function createServer(inlineConfig) {
211
212
  hostname,
212
213
  origin
213
214
  };
215
+ const buildAndOpenBrowser = async () => {
216
+ server.currentOutput = await internalBuild(config);
217
+ await runner.openBrowser(config);
218
+ };
219
+ const closeAndRecreateRunner = async () => {
220
+ await runner.closeBrowser();
221
+ config = await getLatestConfig();
222
+ runner = await createExtensionRunner(config);
223
+ };
214
224
  const server = {
215
225
  ...serverInfo,
216
- watcher: void 0,
217
- // Filled out later down below
218
- ws: void 0,
219
- // Filled out later down below
226
+ get watcher() {
227
+ return builderServer.watcher;
228
+ },
229
+ get ws() {
230
+ return builderServer.ws;
231
+ },
220
232
  currentOutput: void 0,
221
- // Filled out later down below
222
233
  async start() {
223
234
  await builderServer.listen();
224
235
  config.logger.success(`Started dev server @ ${serverInfo.origin}`);
225
- server.currentOutput = await internalBuild(config);
226
- await runner.openBrowser(config);
236
+ await buildAndOpenBrowser();
237
+ },
238
+ async stop() {
239
+ await runner.closeBrowser();
240
+ await builderServer.close();
241
+ },
242
+ async restart() {
243
+ await closeAndRecreateRunner();
244
+ await buildAndOpenBrowser();
227
245
  },
228
246
  transformHtml(url, html, originalUrl) {
229
247
  return builderServer.transformHtml(url, html, originalUrl);
@@ -236,17 +254,21 @@ async function createServer(inlineConfig) {
236
254
  },
237
255
  reloadExtension() {
238
256
  server.ws.send("wxt:reload-extension");
257
+ },
258
+ async restartBrowser() {
259
+ await closeAndRecreateRunner();
260
+ await runner.openBrowser(config);
239
261
  }
240
262
  };
241
263
  const getLatestConfig = () => getInternalConfig(inlineConfig ?? {}, "serve", server);
242
264
  let config = await getLatestConfig();
243
- const [runner, builderServer] = await Promise.all([
265
+ let [runner, builderServer] = await Promise.all([
244
266
  createExtensionRunner(config),
245
267
  config.builder.createServer(server)
246
268
  ]);
247
- server.watcher = builderServer.watcher;
248
- server.ws = builderServer.ws;
249
269
  server.ws.on("wxt:background-initialized", () => {
270
+ if (server.currentOutput == null)
271
+ return;
250
272
  reloadContentScripts(server.currentOutput.steps, config, server);
251
273
  });
252
274
  const reloadOnChange = createFileReloader({
@@ -274,14 +296,30 @@ function createFileReloader(options) {
274
296
  return;
275
297
  changeQueue.push([event, path3]);
276
298
  await fileChangedMutex.runExclusive(async () => {
277
- const fileChanges = changeQueue.splice(0, changeQueue.length);
299
+ if (server.currentOutput == null)
300
+ return;
301
+ const fileChanges = changeQueue.splice(0, changeQueue.length).map(([_, file]) => file);
278
302
  if (fileChanges.length === 0)
279
303
  return;
280
- const changes = detectDevChanges(fileChanges, server.currentOutput);
304
+ const changes = detectDevChanges(
305
+ config,
306
+ fileChanges,
307
+ server.currentOutput
308
+ );
281
309
  if (changes.type === "no-change")
282
310
  return;
311
+ if (changes.type === "full-restart") {
312
+ config.logger.info("Config changed, restarting server...");
313
+ server.restart();
314
+ return;
315
+ }
316
+ if (changes.type === "browser-restart") {
317
+ config.logger.info("Runner config changed, restarting browser...");
318
+ server.restartBrowser();
319
+ return;
320
+ }
283
321
  config.logger.info(
284
- `Changed: ${Array.from(new Set(fileChanges.map((change) => change[1]))).map((file) => pc2.dim(relative4(config.root, file))).join(", ")}`
322
+ `Changed: ${Array.from(new Set(fileChanges)).map((file) => pc2.dim(relative4(config.root, file))).join(", ")}`
285
323
  );
286
324
  const rebuiltNames = changes.rebuildGroups.flat().map((entry) => {
287
325
  return pc2.cyan(
@@ -315,6 +353,8 @@ function createFileReloader(options) {
315
353
  function reloadContentScripts(steps, config, server) {
316
354
  if (config.manifestVersion === 3) {
317
355
  steps.forEach((step) => {
356
+ if (server.currentOutput == null)
357
+ return;
318
358
  const entry = step.entrypoints;
319
359
  if (Array.isArray(entry) || entry.type !== "content-script")
320
360
  return;
package/dist/testing.cjs CHANGED
@@ -896,6 +896,9 @@ async function createViteBuilder(inlineConfig, userConfig, wxtConfig) {
896
896
  async listen() {
897
897
  await viteServer.listen(info.port);
898
898
  },
899
+ async close() {
900
+ await viteServer.close();
901
+ },
899
902
  transformHtml(...args) {
900
903
  return viteServer.transformIndexHtml(...args);
901
904
  },
@@ -961,6 +964,7 @@ async function getInternalConfig(inlineConfig, command, server) {
961
964
  const typesDir = import_node_path7.default.resolve(wxtDir, "types");
962
965
  const outBaseDir = import_node_path7.default.resolve(root, mergedConfig.outDir ?? ".output");
963
966
  const outDir = import_node_path7.default.resolve(outBaseDir, `${browser}-mv${manifestVersion}`);
967
+ const reloadCommand = mergedConfig.dev?.reloadCommand ?? "Alt+R";
964
968
  const runnerConfig = await (0, import_c12.loadConfig)({
965
969
  name: "web-ext",
966
970
  cwd: root,
@@ -1013,7 +1017,10 @@ async function getInternalConfig(inlineConfig, command, server) {
1013
1017
  experimental: {
1014
1018
  includeBrowserPolyfill: mergedConfig.experimental?.includeBrowserPolyfill ?? true
1015
1019
  },
1016
- server
1020
+ server,
1021
+ dev: {
1022
+ reloadCommand
1023
+ }
1017
1024
  };
1018
1025
  const builder = await createViteBuilder(
1019
1026
  inlineConfig,
@@ -1080,7 +1087,11 @@ function mergeInlineConfig(inlineConfig, userConfig) {
1080
1087
  ...inlineConfig.experimental
1081
1088
  },
1082
1089
  vite: void 0,
1083
- transformManifest: void 0
1090
+ transformManifest: void 0,
1091
+ dev: {
1092
+ ...userConfig.dev,
1093
+ ...inlineConfig.dev
1094
+ }
1084
1095
  };
1085
1096
  }
1086
1097
  function resolveInternalZipConfig(root, mergedConfig) {
@@ -1153,6 +1164,11 @@ var import_fs_extra10 = __toESM(require("fs-extra"), 1);
1153
1164
  var import_immer = require("immer");
1154
1165
  var import_defu3 = __toESM(require("defu"), 1);
1155
1166
 
1167
+ // src/core/utils/building/internal-build.ts
1168
+ var import_manage_path = __toESM(require("manage-path"), 1);
1169
+ var import_node_path11 = require("path");
1170
+ var import_consola3 = __toESM(require("consola"), 1);
1171
+
1156
1172
  // src/testing/wxt-vitest-plugin.ts
1157
1173
  function WxtVitest(inlineConfig) {
1158
1174
  return getInternalConfig(inlineConfig ?? {}, "serve").then((config) => [
@@ -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-QOQPHF1G.cjs';
3
+ import { I as InlineConfig } from './external-mJ1bW7iy.cjs';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FakeBrowser, fakeBrowser } from '@webext-core/fake-browser';
2
2
  import * as vite from 'vite';
3
- import { I as InlineConfig } from './external-QOQPHF1G.js';
3
+ import { I as InlineConfig } from './external-mJ1bW7iy.js';
4
4
  import 'webextension-polyfill';
5
5
  import 'unimport';
6
6
  import 'consola';
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  tsconfigPaths,
6
6
  unimport,
7
7
  webextensionPolyfillMock
8
- } from "./chunk-LETSPJCU.js";
8
+ } from "./chunk-XDRW7AKZ.js";
9
9
  import "./chunk-VBXJIVYU.js";
10
10
 
11
11
  // 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.14.4",
4
+ "version": "0.14.6",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "engines": {
7
7
  "node": ">=18",
@@ -104,7 +104,9 @@
104
104
  "jiti": "^1.21.0",
105
105
  "json5": "^2.2.3",
106
106
  "linkedom": "^0.16.1",
107
+ "manage-path": "^2.0.0",
107
108
  "minimatch": "^9.0.3",
109
+ "natural-compare": "^1.4.0",
108
110
  "normalize-path": "^3.0.0",
109
111
  "ora": "^7.0.1",
110
112
  "picocolors": "^1.0.0",
@@ -120,6 +122,7 @@
120
122
  "@faker-js/faker": "^8.3.1",
121
123
  "@types/fs-extra": "^11.0.4",
122
124
  "@types/lodash.merge": "^4.6.9",
125
+ "@types/natural-compare": "^1.4.3",
123
126
  "@types/node": "^20.10.3",
124
127
  "@types/normalize-path": "^3.0.2",
125
128
  "@types/prompts": "^2.4.9",