wxt 0.19.9 → 0.19.10

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
@@ -1,16 +1,17 @@
1
+ <!-- DO NOT EDIT, THIS FILE WAS GENERATED BY '../../scripts/generate-readmes.sh' -->
1
2
  <h1 align="center">
2
- <img style="vertical-align:middle" width="44" src="https://raw.githubusercontent.com/wxt-dev/wxt/HEAD/docs/public/hero-logo.svg" alt="WXT Logo">
3
+ <img align="top" width="44" src="https://raw.githubusercontent.com/wxt-dev/wxt/HEAD/docs/public/hero-logo.svg" alt="WXT Logo">
3
4
  <span>WXT</span>
4
5
  </h1>
5
6
 
6
7
  <p align="center">
7
- <a href="https://www.npmjs.com/package/wxt" target="_blank"><img alt="npm" src="https://img.shields.io/npm/v/wxt?labelColor=black&color=%234fa048"></a>
8
+ <a href="https://www.npmjs.com/package/wxt" target="_blank"><img alt="npm version" src="https://img.shields.io/npm/v/wxt?labelColor=black&color=%234fa048"></a>
8
9
  <span> </span>
9
- <a href="https://www.npmjs.com/package/wxt" target="_blank"><img alt="npm" src="https://img.shields.io/npm/dm/wxt?labelColor=black&color=%234fa048"></a>
10
+ <a href="https://www.npmjs.com/package/wxt" target="_blank"><img alt="downloads" src="https://img.shields.io/npm/dm/wxt?labelColor=black&color=%234fa048"></a>
10
11
  <span> </span>
11
- <a href="https://github.com/wxt-dev/wxt/blob/main/LICENSE" target="_blank"><img alt="NPM" src="https://img.shields.io/npm/l/wxt?labelColor=black&color=%234fa048"></a>
12
+ <a href="https://github.com/wxt-dev/wxt/blob/main/LICENSE" target="_blank"><img alt="license | MIT" src="https://img.shields.io/npm/l/wxt?labelColor=black&color=%234fa048"></a>
12
13
  <span> </span>
13
- <a href="https://codecov.io/github/wxt-dev/wxt" target="_blank"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/wxt-dev/wxt?labelColor=black&color=%234fa048"></a>
14
+ <a href="https://codecov.io/github/wxt-dev/wxt" target="_blank"><img alt="coverage" src="https://img.shields.io/codecov/c/github/wxt-dev/wxt?labelColor=black&color=%234fa048"></a>
14
15
  </p>
15
16
 
16
17
  <p align="center">
@@ -18,7 +19,7 @@
18
19
  <br/>
19
20
  <span>⚡</span>
20
21
  <br/>
21
- <q><i>It's like Nuxt, but for Chrome Extensions</i></q>
22
+ <q><i>It's like Nuxt, but for Web Extensions</i></q>
22
23
  </p>
23
24
 
24
25
  <p align="center">
@@ -43,10 +44,21 @@ https://github.com/wxt-dev/wxt/assets/10101283/4d678939-1bdb-495c-9c36-3aa281d84
43
44
 
44
45
  Bootstrap a new project:
45
46
 
47
+ <!-- automd:pm-x version="latest" name="wxt" args="init" -->
48
+
46
49
  ```sh
47
- pnpm dlx wxt@latest init <project-name>
50
+ # npm
51
+ npx wxt@latest init
52
+
53
+ # pnpm
54
+ pnpm dlx wxt@latest init
55
+
56
+ # bun
57
+ bunx wxt@latest init
48
58
  ```
49
59
 
60
+ <!-- /automd -->
61
+
50
62
  Or see the [installation guide](https://wxt.dev/guide/installation.html) to get started with WXT.
51
63
 
52
64
  ## Features
@@ -66,6 +78,13 @@ Or see the [installation guide](https://wxt.dev/guide/installation.html) to get
66
78
 
67
79
  ## Contributors
68
80
 
81
+ <!-- automd:contributors author="aklinker1" license="MIT" github="wxt-dev/wxt" -->
82
+
83
+ Published under the [MIT](https://github.com/wxt-dev/wxt/blob/main/LICENSE) license.
84
+ Made by [@aklinker1](https://github.com/aklinker1) and [community](https://github.com/wxt-dev/wxt/graphs/contributors) 💛
85
+ <br><br>
69
86
  <a href="https://github.com/wxt-dev/wxt/graphs/contributors">
70
- <img src="https://contrib.rocks/image?repo=wxt-dev/wxt" />
87
+ <img src="https://contrib.rocks/image?repo=wxt-dev/wxt" />
71
88
  </a>
89
+
90
+ <!-- /automd -->
@@ -1,3 +1,4 @@
1
+ import { debounce } from "perfect-debounce";
1
2
  import { getEntrypointBundlePath, isHtmlEntrypoint } from "./utils/entrypoints.mjs";
2
3
  import {
3
4
  getContentScriptCssFiles,
@@ -98,7 +99,7 @@ export async function createServer(inlineConfig) {
98
99
  function createFileReloader(server) {
99
100
  const fileChangedMutex = new Mutex();
100
101
  const changeQueue = [];
101
- return async (event, path) => {
102
+ const cb = async (event, path) => {
102
103
  changeQueue.push([event, path]);
103
104
  await fileChangedMutex.runExclusive(async () => {
104
105
  if (server.currentOutput == null) return;
@@ -151,6 +152,10 @@ function createFileReloader(server) {
151
152
  }
152
153
  });
153
154
  };
155
+ return debounce(cb, wxt.config.dev.server.watchDebounce, {
156
+ leading: true,
157
+ trailing: false
158
+ });
154
159
  }
155
160
  function reloadContentScripts(steps, server) {
156
161
  if (wxt.config.manifestVersion === 3) {
@@ -8,6 +8,8 @@ import { normalizePath } from "../paths.mjs";
8
8
  import glob from "fast-glob";
9
9
  import { builtinModules } from "../../../builtin-modules/index.mjs";
10
10
  import { getEslintVersion } from "../eslint.mjs";
11
+ import { safeStringToNumber } from "../number.mjs";
12
+ import { loadEnv } from "../env.mjs";
11
13
  export async function resolveConfig(inlineConfig, command) {
12
14
  let userConfig = {};
13
15
  let userConfigMetadata;
@@ -32,6 +34,7 @@ export async function resolveConfig(inlineConfig, command) {
32
34
  const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
33
35
  const mode = mergedConfig.mode ?? COMMAND_MODES[command];
34
36
  const env = { browser, command, manifestVersion, mode };
37
+ loadEnv(mode);
35
38
  const root = path.resolve(
36
39
  inlineConfig.root ?? userConfig.root ?? process.cwd()
37
40
  );
@@ -78,7 +81,8 @@ export async function resolveConfig(inlineConfig, command) {
78
81
  }
79
82
  devServerConfig = {
80
83
  port,
81
- hostname: mergedConfig.dev?.server?.hostname ?? "localhost"
84
+ hostname: mergedConfig.dev?.server?.hostname ?? "localhost",
85
+ watchDebounce: safeStringToNumber(process.env.WXT_WATCH_DEBOUNCE) ?? 800
82
86
  };
83
87
  }
84
88
  const userModules = await resolveWxtUserModules(
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Load environment files based on the current mode.
3
+ */
4
+ export declare function loadEnv(mode: string): import("dotenv").DotenvConfigOutput;
@@ -0,0 +1,6 @@
1
+ import { config } from "dotenv";
2
+ export function loadEnv(mode) {
3
+ return config({
4
+ path: [`.env`, `.env.local`, `.env.${mode}`, `.env.${mode}.local`]
5
+ });
6
+ }
@@ -0,0 +1 @@
1
+ export declare function safeStringToNumber(str: string | undefined): number | null;
@@ -0,0 +1,4 @@
1
+ export function safeStringToNumber(str) {
2
+ const num = Number(str);
3
+ return isNaN(num) ? null : num;
4
+ }