wxt 0.19.18 → 0.19.19

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.
@@ -20,6 +20,7 @@ import {
20
20
  getContentScriptJs,
21
21
  mapWxtOptionsToRegisteredContentScript
22
22
  } from "./utils/content-scripts.mjs";
23
+ import { createKeyboardShortcuts } from "./keyboard-shortcuts.mjs";
23
24
  export async function createServer(inlineConfig) {
24
25
  await registerWxt("serve", inlineConfig);
25
26
  wxt.server = await createServerInternal();
@@ -67,16 +68,19 @@ async function createServerInternal() {
67
68
  await builderServer.listen();
68
69
  wxt.logger.success(`Started dev server @ ${server.origin}`);
69
70
  await wxt.hooks.callHook("server:started", wxt, server);
70
- await buildAndOpenBrowser();
71
71
  server.ws.on("wxt:background-initialized", () => {
72
72
  if (server.currentOutput == null) return;
73
73
  reloadContentScripts(server.currentOutput.steps, server);
74
74
  });
75
+ await buildAndOpenBrowser();
75
76
  const reloadOnChange = createFileReloader(server);
76
77
  server.watcher.on("all", reloadOnChange);
78
+ keyboardShortcuts.start();
79
+ keyboardShortcuts.printHelp();
77
80
  },
78
81
  async stop() {
79
82
  wasStopped = true;
83
+ keyboardShortcuts.stop();
80
84
  await runner.closeBrowser();
81
85
  await builderServer.close();
82
86
  await wxt.hooks.callHook("server:closed", wxt, server);
@@ -101,11 +105,14 @@ async function createServerInternal() {
101
105
  },
102
106
  async restartBrowser() {
103
107
  await runner.closeBrowser();
108
+ keyboardShortcuts.stop();
104
109
  await wxt.reloadConfig();
105
110
  runner = await createExtensionRunner();
106
111
  await runner.openBrowser();
112
+ keyboardShortcuts.start();
107
113
  }
108
114
  };
115
+ const keyboardShortcuts = createKeyboardShortcuts(server);
109
116
  const buildAndOpenBrowser = async () => {
110
117
  server.currentOutput = await internalBuild();
111
118
  try {
@@ -0,0 +1,10 @@
1
+ import { WxtDevServer } from '../types';
2
+ export interface KeyboardShortcutWatcher {
3
+ start(): void;
4
+ stop(): void;
5
+ printHelp(): void;
6
+ }
7
+ /**
8
+ * Function that creates a keyboard shortcut handler for the extension.
9
+ */
10
+ export declare function createKeyboardShortcuts(server: WxtDevServer): KeyboardShortcutWatcher;
@@ -0,0 +1,39 @@
1
+ import readline from "node:readline";
2
+ import { wxt } from "./wxt.mjs";
3
+ import pc from "picocolors";
4
+ export function createKeyboardShortcuts(server) {
5
+ let isWatching = false;
6
+ let rl;
7
+ const handleInput = (line) => {
8
+ if (line.trim() === "o") {
9
+ server.restartBrowser();
10
+ }
11
+ };
12
+ return {
13
+ start() {
14
+ if (isWatching) return;
15
+ rl = readline.createInterface({
16
+ input: process.stdin,
17
+ terminal: false
18
+ // Don't intercept ctrl+C, ctrl+Z, etc
19
+ });
20
+ rl.on("line", handleInput);
21
+ isWatching = true;
22
+ },
23
+ stop() {
24
+ if (!isWatching) return;
25
+ if (rl) {
26
+ rl.close();
27
+ rl = void 0;
28
+ }
29
+ isWatching = false;
30
+ },
31
+ printHelp() {
32
+ if (!wxt.config.runnerConfig.config.disabled) {
33
+ wxt.logger.info(
34
+ `${pc.dim("Press")} ${pc.bold("o + enter")} ${pc.dim("to reopen the browser")}`
35
+ );
36
+ }
37
+ }
38
+ };
39
+ }
package/dist/core/wxt.mjs CHANGED
@@ -19,6 +19,11 @@ export async function registerWxt(command, inlineConfig = {}) {
19
19
  return config.logger;
20
20
  },
21
21
  async reloadConfig() {
22
+ if (wxt.config.dev.server?.port) {
23
+ inlineConfig.dev ??= {};
24
+ inlineConfig.dev.server ??= {};
25
+ inlineConfig.dev.server.port = wxt.config.dev.server.port;
26
+ }
22
27
  wxt.config = await resolveConfig(inlineConfig, command);
23
28
  await wxt.hooks.callHook("config:resolved", wxt);
24
29
  },
package/dist/core/zip.mjs CHANGED
@@ -5,7 +5,7 @@ import { getPackageJson } from "./utils/package.mjs";
5
5
  import { minimatch } from "minimatch";
6
6
  import { formatDuration } from "./utils/time.mjs";
7
7
  import { printFileList } from "./utils/log/printFileList.mjs";
8
- import { internalBuild } from "./utils/building/index.mjs";
8
+ import { findEntrypoints, internalBuild } from "./utils/building/index.mjs";
9
9
  import { registerWxt, wxt } from "./wxt.mjs";
10
10
  import JSZip from "jszip";
11
11
  import glob from "fast-glob";
@@ -34,6 +34,14 @@ export async function zip(config) {
34
34
  zipFiles.push(outZipPath);
35
35
  await wxt.hooks.callHook("zip:extension:done", wxt, outZipPath);
36
36
  if (wxt.config.zip.zipSources) {
37
+ const entrypoints = await findEntrypoints();
38
+ const skippedEntrypoints = entrypoints.filter((entry) => entry.skipped);
39
+ const excludeSources = [
40
+ ...wxt.config.zip.excludeSources,
41
+ ...skippedEntrypoints.map(
42
+ (entry) => path.relative(wxt.config.zip.sourcesRoot, entry.inputPath)
43
+ )
44
+ ].map((paths) => paths.replaceAll("\\", "/"));
37
45
  await wxt.hooks.callHook("zip:sources:start", wxt);
38
46
  const { overrides, files: downloadedPackages } = await downloadPrivatePackages();
39
47
  const sourcesZipFilename = applyTemplate(wxt.config.zip.sourcesTemplate);
@@ -43,7 +51,7 @@ export async function zip(config) {
43
51
  );
44
52
  await zipDir(wxt.config.zip.sourcesRoot, sourcesZipPath, {
45
53
  include: wxt.config.zip.includeSources,
46
- exclude: wxt.config.zip.excludeSources,
54
+ exclude: excludeSources,
47
55
  transform(absolutePath, zipPath, content) {
48
56
  if (zipPath.endsWith("package.json")) {
49
57
  return addOverridesToPackageJson(absolutePath, content, overrides);
package/dist/version.mjs CHANGED
@@ -1 +1 @@
1
- export const version = "0.19.18";
1
+ export const version = "0.19.19";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.19.18",
4
+ "version": "0.19.19",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "repository": {
7
7
  "type": "git",