wxt 0.20.13 → 0.20.15

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.
Files changed (280) hide show
  1. package/dist/browser.d.mts +20 -0
  2. package/dist/browser.mjs +18 -3
  3. package/dist/builtin-modules/index.mjs +7 -2
  4. package/dist/builtin-modules/unimport.mjs +69 -75
  5. package/dist/cli/cli-utils.mjs +54 -50
  6. package/dist/cli/commands.mjs +78 -103
  7. package/dist/cli/index.d.mts +1 -0
  8. package/dist/cli/index.mjs +9 -4
  9. package/dist/core/{build.d.ts → build.d.mts} +6 -2
  10. package/dist/core/build.mjs +23 -4
  11. package/dist/core/builders/vite/index.mjs +293 -343
  12. package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +11 -12
  13. package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +27 -20
  14. package/dist/core/builders/vite/plugins/defineImportMeta.mjs +17 -12
  15. package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +105 -136
  16. package/dist/core/builders/vite/plugins/devServerGlobals.mjs +15 -14
  17. package/dist/core/builders/vite/plugins/download.mjs +23 -12
  18. package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +18 -14
  19. package/dist/core/builders/vite/plugins/extensionApiMock.mjs +31 -33
  20. package/dist/core/builders/vite/plugins/globals.mjs +14 -13
  21. package/dist/core/builders/vite/plugins/iifeFooter.mjs +17 -11
  22. package/dist/core/builders/vite/plugins/index.mjs +18 -16
  23. package/dist/core/builders/vite/plugins/noopBackground.mjs +21 -15
  24. package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +26 -23
  25. package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +26 -24
  26. package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +28 -26
  27. package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +11 -11
  28. package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +42 -47
  29. package/dist/core/{clean.d.ts → clean.d.mts} +7 -3
  30. package/dist/core/clean.mjs +38 -35
  31. package/dist/core/{create-server.d.ts → create-server.d.mts} +6 -2
  32. package/dist/core/create-server.mjs +236 -247
  33. package/dist/core/define-config.d.mts +6 -0
  34. package/dist/core/define-config.mjs +6 -2
  35. package/dist/core/define-web-ext-config.d.mts +13 -0
  36. package/dist/core/define-web-ext-config.mjs +16 -7
  37. package/dist/core/generate-wxt-dir.mjs +110 -148
  38. package/dist/core/index.d.mts +9 -0
  39. package/dist/core/index.mjs +12 -8
  40. package/dist/core/initialize.d.mts +8 -0
  41. package/dist/core/initialize.mjs +110 -124
  42. package/dist/core/keyboard-shortcuts.mjs +30 -28
  43. package/dist/core/package-managers/bun.mjs +18 -16
  44. package/dist/core/package-managers/deno.mjs +12 -8
  45. package/dist/core/package-managers/index.mjs +52 -60
  46. package/dist/core/package-managers/npm.mjs +51 -52
  47. package/dist/core/package-managers/pnpm.mjs +21 -18
  48. package/dist/core/package-managers/yarn.mjs +31 -28
  49. package/dist/core/prepare.d.mts +6 -0
  50. package/dist/core/prepare.mjs +12 -7
  51. package/dist/core/resolve-config.mjs +393 -462
  52. package/dist/core/runners/index.mjs +15 -10
  53. package/dist/core/runners/manual.mjs +13 -14
  54. package/dist/core/runners/safari.mjs +13 -14
  55. package/dist/core/runners/web-ext.mjs +62 -83
  56. package/dist/core/runners/wsl.mjs +13 -14
  57. package/dist/core/utils/arrays.mjs +23 -12
  58. package/dist/core/utils/building/build-entrypoints.mjs +44 -40
  59. package/dist/core/utils/building/detect-dev-changes.mjs +84 -105
  60. package/dist/core/utils/building/find-entrypoints.mjs +278 -359
  61. package/dist/core/utils/building/group-entrypoints.mjs +42 -35
  62. package/dist/core/utils/building/index.mjs +8 -6
  63. package/dist/core/utils/building/internal-build.mjs +86 -102
  64. package/dist/core/utils/building/rebuild.mjs +50 -30
  65. package/dist/core/utils/cache.mjs +29 -18
  66. package/dist/core/utils/constants.mjs +9 -1
  67. package/dist/core/utils/content-scripts.mjs +56 -54
  68. package/dist/core/utils/content-security-policy.mjs +36 -39
  69. package/dist/core/utils/entrypoints.mjs +51 -28
  70. package/dist/core/utils/env.mjs +22 -17
  71. package/dist/core/utils/environments/browser-environment.mjs +13 -12
  72. package/dist/core/utils/environments/environment.mjs +36 -33
  73. package/dist/core/utils/environments/extension-environment.mjs +15 -10
  74. package/dist/core/utils/environments/index.mjs +4 -2
  75. package/dist/core/utils/eslint.mjs +11 -10
  76. package/dist/core/utils/fs.mjs +23 -11
  77. package/dist/core/utils/globals.mjs +53 -51
  78. package/dist/core/utils/i18n.mjs +41 -32
  79. package/dist/core/utils/index.mjs +3 -0
  80. package/dist/core/utils/log/index.mjs +6 -4
  81. package/dist/core/utils/log/printBuildSummary.mjs +20 -25
  82. package/dist/core/utils/log/printFileList.mjs +30 -33
  83. package/dist/core/utils/log/printHeader.mjs +9 -5
  84. package/dist/core/utils/log/printTable.mjs +19 -21
  85. package/dist/core/utils/manifest.mjs +366 -479
  86. package/dist/core/utils/minimatch-multiple.mjs +26 -15
  87. package/dist/core/utils/network.mjs +27 -33
  88. package/dist/core/utils/number.mjs +7 -3
  89. package/dist/core/utils/package.mjs +20 -13
  90. package/dist/core/utils/paths.d.mts +8 -0
  91. package/dist/core/utils/paths.mjs +26 -7
  92. package/dist/core/utils/strings.mjs +19 -14
  93. package/dist/core/utils/syntax-errors.mjs +14 -16
  94. package/dist/core/utils/time.mjs +19 -15
  95. package/dist/core/utils/transform.mjs +129 -160
  96. package/dist/core/utils/types.d.mts +6 -0
  97. package/dist/core/utils/validation.mjs +43 -50
  98. package/dist/core/utils/virtual-modules.mjs +20 -12
  99. package/dist/core/utils/wsl.mjs +11 -3
  100. package/dist/core/wxt.mjs +65 -60
  101. package/dist/core/{zip.d.ts → zip.d.mts} +6 -2
  102. package/dist/core/zip.mjs +118 -140
  103. package/dist/index.d.mts +13 -0
  104. package/dist/index.mjs +13 -3
  105. package/dist/{modules.d.ts → modules.d.mts} +14 -16
  106. package/dist/modules.mjs +179 -51
  107. package/dist/testing/fake-browser.d.mts +2 -0
  108. package/dist/testing/fake-browser.mjs +3 -1
  109. package/dist/testing/index.d.mts +3 -0
  110. package/dist/testing/index.mjs +4 -2
  111. package/dist/testing/{wxt-vitest-plugin.d.ts → wxt-vitest-plugin.d.mts} +7 -9
  112. package/dist/testing/wxt-vitest-plugin.mjs +38 -19
  113. package/dist/types.d.mts +1475 -0
  114. package/dist/utils/app-config.d.mts +6 -0
  115. package/dist/utils/app-config.mjs +8 -2
  116. package/dist/utils/content-script-context.d.mts +134 -0
  117. package/dist/utils/content-script-context.mjs +187 -175
  118. package/dist/utils/content-script-ui/iframe.d.mts +42 -0
  119. package/dist/utils/content-script-ui/iframe.mjs +42 -27
  120. package/dist/utils/content-script-ui/integrated.d.mts +37 -0
  121. package/dist/utils/content-script-ui/integrated.mjs +36 -29
  122. package/dist/utils/content-script-ui/shadow-root.d.mts +80 -0
  123. package/dist/utils/content-script-ui/shadow-root.mjs +75 -82
  124. package/dist/utils/content-script-ui/shared.mjs +115 -150
  125. package/dist/utils/content-script-ui/types.d.mts +107 -0
  126. package/dist/utils/content-script-ui/types.mjs +1 -0
  127. package/dist/utils/{define-app-config.d.ts → define-app-config.d.mts} +5 -3
  128. package/dist/utils/define-app-config.mjs +22 -2
  129. package/dist/utils/define-background.d.mts +7 -0
  130. package/dist/utils/define-background.mjs +7 -3
  131. package/dist/utils/define-content-script.d.mts +6 -0
  132. package/dist/utils/define-content-script.mjs +6 -2
  133. package/dist/utils/define-unlisted-script.d.mts +7 -0
  134. package/dist/utils/define-unlisted-script.mjs +7 -3
  135. package/dist/utils/define-wxt-plugin.d.mts +6 -0
  136. package/dist/utils/define-wxt-plugin.mjs +6 -2
  137. package/dist/utils/inject-script.d.mts +41 -0
  138. package/dist/utils/inject-script.mjs +44 -34
  139. package/dist/utils/internal/custom-events.d.mts +9 -0
  140. package/dist/utils/internal/custom-events.mjs +18 -10
  141. package/dist/utils/internal/location-watcher.mjs +23 -20
  142. package/dist/utils/internal/logger.mjs +15 -12
  143. package/dist/utils/match-patterns.d.mts +1 -0
  144. package/dist/utils/match-patterns.mjs +3 -1
  145. package/dist/utils/{split-shadow-root-css.d.ts → split-shadow-root-css.d.mts} +6 -3
  146. package/dist/utils/split-shadow-root-css.mjs +16 -7
  147. package/dist/utils/storage.d.mts +1 -0
  148. package/dist/utils/storage.mjs +3 -1
  149. package/dist/version.d.mts +4 -0
  150. package/dist/version.mjs +5 -1
  151. package/dist/virtual/background-entrypoint.d.mts +4 -0
  152. package/dist/virtual/background-entrypoint.mjs +143 -161
  153. package/dist/virtual/content-script-isolated-world-entrypoint.d.mts +4 -0
  154. package/dist/virtual/content-script-isolated-world-entrypoint.mjs +26 -27
  155. package/dist/virtual/content-script-main-world-entrypoint.d.mts +4 -0
  156. package/dist/virtual/content-script-main-world-entrypoint.mjs +24 -24
  157. package/dist/virtual/mock-browser.d.mts +6 -0
  158. package/dist/virtual/mock-browser.mjs +5 -3
  159. package/dist/virtual/reload-html.d.mts +1 -0
  160. package/dist/virtual/reload-html.mjs +57 -53
  161. package/dist/virtual/unlisted-script-entrypoint.d.mts +4 -0
  162. package/dist/virtual/unlisted-script-entrypoint.mjs +35 -43
  163. package/package.json +56 -50
  164. package/dist/browser.d.ts +0 -30
  165. package/dist/builtin-modules/index.d.ts +0 -2
  166. package/dist/builtin-modules/unimport.d.ts +0 -5
  167. package/dist/cli/cli-utils.d.ts +0 -25
  168. package/dist/cli/commands.d.ts +0 -2
  169. package/dist/cli/index.d.ts +0 -1
  170. package/dist/core/builders/vite/index.d.ts +0 -7
  171. package/dist/core/builders/vite/plugins/bundleAnalysis.d.ts +0 -7
  172. package/dist/core/builders/vite/plugins/cssEntrypoints.d.ts +0 -13
  173. package/dist/core/builders/vite/plugins/defineImportMeta.d.ts +0 -14
  174. package/dist/core/builders/vite/plugins/devHtmlPrerender.d.ts +0 -7
  175. package/dist/core/builders/vite/plugins/devServerGlobals.d.ts +0 -6
  176. package/dist/core/builders/vite/plugins/download.d.ts +0 -10
  177. package/dist/core/builders/vite/plugins/entrypointGroupGlobals.d.ts +0 -6
  178. package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +0 -6
  179. package/dist/core/builders/vite/plugins/globals.d.ts +0 -3
  180. package/dist/core/builders/vite/plugins/iifeFooter.d.ts +0 -8
  181. package/dist/core/builders/vite/plugins/index.d.ts +0 -16
  182. package/dist/core/builders/vite/plugins/noopBackground.d.ts +0 -6
  183. package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.d.ts +0 -6
  184. package/dist/core/builders/vite/plugins/resolveAppConfig.d.ts +0 -6
  185. package/dist/core/builders/vite/plugins/resolveVirtualModules.d.ts +0 -6
  186. package/dist/core/builders/vite/plugins/tsconfigPaths.d.ts +0 -3
  187. package/dist/core/builders/vite/plugins/wxtPluginLoader.d.ts +0 -6
  188. package/dist/core/define-config.d.ts +0 -2
  189. package/dist/core/define-web-ext-config.d.ts +0 -9
  190. package/dist/core/generate-wxt-dir.d.ts +0 -5
  191. package/dist/core/index.d.ts +0 -8
  192. package/dist/core/initialize.d.ts +0 -5
  193. package/dist/core/keyboard-shortcuts.d.ts +0 -12
  194. package/dist/core/package-managers/bun.d.ts +0 -2
  195. package/dist/core/package-managers/deno.d.ts +0 -2
  196. package/dist/core/package-managers/index.d.ts +0 -2
  197. package/dist/core/package-managers/npm.d.ts +0 -17
  198. package/dist/core/package-managers/pnpm.d.ts +0 -2
  199. package/dist/core/package-managers/types.d.ts +0 -2
  200. package/dist/core/package-managers/types.mjs +0 -0
  201. package/dist/core/package-managers/yarn.d.ts +0 -2
  202. package/dist/core/prepare.d.ts +0 -2
  203. package/dist/core/resolve-config.d.ts +0 -11
  204. package/dist/core/runners/index.d.ts +0 -2
  205. package/dist/core/runners/manual.d.ts +0 -5
  206. package/dist/core/runners/safari.d.ts +0 -5
  207. package/dist/core/runners/web-ext.d.ts +0 -5
  208. package/dist/core/runners/wsl.d.ts +0 -5
  209. package/dist/core/utils/arrays.d.ts +0 -13
  210. package/dist/core/utils/building/build-entrypoints.d.ts +0 -3
  211. package/dist/core/utils/building/detect-dev-changes.d.ts +0 -61
  212. package/dist/core/utils/building/find-entrypoints.d.ts +0 -5
  213. package/dist/core/utils/building/group-entrypoints.d.ts +0 -8
  214. package/dist/core/utils/building/index.d.ts +0 -6
  215. package/dist/core/utils/building/internal-build.d.ts +0 -12
  216. package/dist/core/utils/building/rebuild.d.ts +0 -23
  217. package/dist/core/utils/cache.d.ts +0 -8
  218. package/dist/core/utils/cli.d.ts +0 -3
  219. package/dist/core/utils/cli.mjs +0 -26
  220. package/dist/core/utils/constants.d.ts +0 -5
  221. package/dist/core/utils/content-scripts.d.ts +0 -12
  222. package/dist/core/utils/content-security-policy.d.ts +0 -14
  223. package/dist/core/utils/entrypoints.d.ts +0 -31
  224. package/dist/core/utils/env.d.ts +0 -5
  225. package/dist/core/utils/environments/browser-environment.d.ts +0 -3
  226. package/dist/core/utils/environments/environment.d.ts +0 -8
  227. package/dist/core/utils/environments/extension-environment.d.ts +0 -6
  228. package/dist/core/utils/environments/index.d.ts +0 -2
  229. package/dist/core/utils/eslint.d.ts +0 -1
  230. package/dist/core/utils/fs.d.ts +0 -13
  231. package/dist/core/utils/globals.d.ts +0 -11
  232. package/dist/core/utils/i18n.d.ts +0 -11
  233. package/dist/core/utils/log/index.d.ts +0 -4
  234. package/dist/core/utils/log/printBuildSummary.d.ts +0 -2
  235. package/dist/core/utils/log/printFileList.d.ts +0 -1
  236. package/dist/core/utils/log/printHeader.d.ts +0 -1
  237. package/dist/core/utils/log/printTable.d.ts +0 -1
  238. package/dist/core/utils/manifest.d.ts +0 -40
  239. package/dist/core/utils/minimatch-multiple.d.ts +0 -15
  240. package/dist/core/utils/network.d.ts +0 -7
  241. package/dist/core/utils/number.d.ts +0 -1
  242. package/dist/core/utils/package.d.ts +0 -6
  243. package/dist/core/utils/paths.d.ts +0 -11
  244. package/dist/core/utils/strings.d.ts +0 -14
  245. package/dist/core/utils/syntax-errors.d.ts +0 -11
  246. package/dist/core/utils/testing/fake-objects.d.ts +0 -11665
  247. package/dist/core/utils/testing/fake-objects.mjs +0 -326
  248. package/dist/core/utils/time.d.ts +0 -9
  249. package/dist/core/utils/transform.d.ts +0 -11
  250. package/dist/core/utils/types.d.ts +0 -13
  251. package/dist/core/utils/types.mjs +0 -0
  252. package/dist/core/utils/validation.d.ts +0 -15
  253. package/dist/core/utils/virtual-modules.d.ts +0 -22
  254. package/dist/core/utils/wsl.d.ts +0 -4
  255. package/dist/core/wxt.d.ts +0 -24
  256. package/dist/index.d.ts +0 -11
  257. package/dist/testing/fake-browser.d.ts +0 -10
  258. package/dist/testing/index.d.ts +0 -10
  259. package/dist/types.d.ts +0 -1459
  260. package/dist/types.mjs +0 -0
  261. package/dist/utils/app-config.d.ts +0 -2
  262. package/dist/utils/content-script-context.d.ts +0 -134
  263. package/dist/utils/content-script-ui/iframe.d.ts +0 -32
  264. package/dist/utils/content-script-ui/integrated.d.ts +0 -34
  265. package/dist/utils/content-script-ui/shadow-root.d.ts +0 -76
  266. package/dist/utils/content-script-ui/shared.d.ts +0 -5
  267. package/dist/utils/content-script-ui/types.d.ts +0 -104
  268. package/dist/utils/define-background.d.ts +0 -4
  269. package/dist/utils/define-content-script.d.ts +0 -3
  270. package/dist/utils/define-unlisted-script.d.ts +0 -4
  271. package/dist/utils/define-wxt-plugin.d.ts +0 -3
  272. package/dist/utils/inject-script.d.ts +0 -36
  273. package/dist/utils/internal/custom-events.d.ts +0 -10
  274. package/dist/utils/internal/dev-server-websocket.d.ts +0 -21
  275. package/dist/utils/internal/dev-server-websocket.mjs +0 -37
  276. package/dist/utils/internal/location-watcher.d.ts +0 -12
  277. package/dist/utils/internal/logger.d.ts +0 -9
  278. package/dist/utils/match-patterns.d.ts +0 -5
  279. package/dist/utils/storage.d.ts +0 -5
  280. package/dist/version.d.ts +0 -1
package/dist/types.d.ts DELETED
@@ -1,1459 +0,0 @@
1
- import type * as vite from 'vite';
2
- import { UnimportOptions, Import } from 'unimport';
3
- import { LogLevel } from 'consola';
4
- import type { ContentScriptContext } from './utils/content-script-context';
5
- import type { PluginVisualizerOptions } from '@aklinker1/rollup-plugin-visualizer';
6
- import { ResolvedConfig as C12ResolvedConfig } from 'c12';
7
- import { Hookable, NestedHooks } from 'hookable';
8
- import type * as Nypm from 'nypm';
9
- import { ManifestContentScript } from './core/utils/types';
10
- import type { Browser } from '@wxt-dev/browser';
11
- export interface InlineConfig {
12
- /**
13
- * Your project's root directory containing the `package.json` used to fill out the
14
- * `manifest.json`.
15
- *
16
- * @default process.cwd()
17
- */
18
- root?: string;
19
- /**
20
- * Directory containing all source code. Set to `"src"` to move all source code to a `src/`
21
- * directory.
22
- *
23
- * After changing, don't forget to move the `public/` and `entrypoints/` directories into the new
24
- * source dir.
25
- *
26
- * @default config.root
27
- */
28
- srcDir?: string;
29
- /**
30
- * Directory containing files that will be copied to the output directory as-is.
31
- *
32
- * @default "${config.root}/public"
33
- */
34
- publicDir?: string;
35
- /**
36
- * @default "${config.srcDir}/entrypoints"
37
- */
38
- entrypointsDir?: string;
39
- /**
40
- * @default "${config.root}/modules"
41
- */
42
- modulesDir?: string;
43
- /**
44
- * A list of entrypoint names (`"popup"`, `"options"`, etc.) to build. Will speed up the build if
45
- * your extension has lots of entrypoints, and you don't need to build all of them to develop a
46
- * feature.
47
- * If specified, this completely overrides the `include`/`exclude` option provided per-entrypoint.
48
- */
49
- filterEntrypoints?: string[];
50
- /**
51
- * Output directory that stored build folders and ZIPs.
52
- *
53
- * @default ".output"
54
- */
55
- outDir?: string;
56
- /**
57
- * Template string for customizing the output directory structure.
58
- * Available variables:
59
- * - <span v-pre>`{{browser}}`</span>: The target browser (e.g., 'chrome', 'firefox')
60
- * - <span v-pre>`{{manifestVersion}}`</span>: The manifest version (e.g., 2 or 3)
61
- * - <span v-pre>`{{mode}}`</span>: The build mode (e.g., 'development', 'production')
62
- * - <span v-pre>`{{modeSuffix}}`</span>: A suffix based on the mode ('-dev' for development, '' for production)
63
- * - <span v-pre>`{{command}}`</span>: The WXT command being run (e.g., 'build', 'serve')
64
- *
65
- * @example "{{browser}}-mv{{manifestVersion}}"
66
- * @default <span v-pre>`"{{browser}}-mv{{manifestVersion}}{{modeSuffix}}"`</span>
67
- */
68
- outDirTemplate?: string;
69
- /**
70
- * > Only available when using the JS API. Not available in `wxt.config.ts` files
71
- *
72
- * Path to `wxt.config.ts` file or `false` to disable config file discovery.
73
- *
74
- * @default "wxt.config.ts"
75
- */
76
- configFile?: string | false;
77
- /**
78
- * Set to `true` to show debug logs. Overridden by the command line `--debug` option.
79
- *
80
- * @default false
81
- */
82
- debug?: boolean;
83
- /**
84
- * Explicitly set a mode to run in. This will override the default mode for each command, and can
85
- * be overridden by the command line `--mode` option.
86
- */
87
- mode?: string;
88
- /**
89
- * Customize auto-import options. Set to `false` to disable auto-imports.
90
- *
91
- * For example, to add a directory to auto-import from, you can use:
92
- *
93
- * ```ts
94
- * export default defineConfig({
95
- * imports: {
96
- * dirs: ["some-directory"]
97
- * }
98
- * })
99
- * ```
100
- */
101
- imports?: WxtUnimportOptions | false;
102
- /**
103
- * Explicitly set a browser to build for. This will override the default browser for each command,
104
- * and can be overridden by the command line `--browser` option.
105
- *
106
- * @default
107
- * "chrome"
108
- */
109
- browser?: TargetBrowser;
110
- /**
111
- * Target browsers to support. When set, `import.meta.env.BROWSER` will be narrowed to a string literal type containing only the specified browser names.
112
- *
113
- * @default []
114
- */
115
- targetBrowsers?: TargetBrowser[];
116
- /**
117
- * Explicitly set a manifest version to target. This will override the default manifest version
118
- * for each command, and can be overridden by the command line `--mv2` or `--mv3` option.
119
- */
120
- manifestVersion?: TargetManifestVersion;
121
- /**
122
- * Override the logger used.
123
- *
124
- * @default
125
- * consola
126
- */
127
- logger?: Logger;
128
- /**
129
- * Customize the `manifest.json` output. Can be an object, promise, or function that returns an
130
- * object or promise.
131
- */
132
- manifest?: UserManifest | Promise<UserManifest> | UserManifestFn;
133
- /**
134
- * Configure browser startup. Options set here can be overridden in a `web-ext.config.ts` file.
135
- */
136
- webExt?: WebExtConfig;
137
- /**
138
- * @deprecated Use `webExt` instead. Same option, just renamed.
139
- */
140
- runner?: WebExtConfig;
141
- zip?: {
142
- /**
143
- * Configure the filename output when zipping files.
144
- *
145
- * Available template variables:
146
- *
147
- * - <span v-pre>`{{name}}`</span> - The project's name converted to kebab-case
148
- * - <span v-pre>`{{version}}`</span> - The version_name or version from the manifest
149
- * - <span v-pre>`{{packageVersion}}`</span> - The version from the package.json
150
- * - <span v-pre>`{{browser}}`</span> - The target browser from the `--browser` CLI flag
151
- * - <span v-pre>`{{mode}}`</span> - The current mode
152
- * - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
153
- *
154
- * @default "{{name}}-{{version}}-{{browser}}.zip"
155
- */
156
- artifactTemplate?: string;
157
- /**
158
- * When zipping the extension, also zip sources.
159
- *
160
- * - `undefined`: zip sources if the target browser is "firefox" or "opera"
161
- * - `true`: always zip sources
162
- * - `false`: never zip sources
163
- *
164
- * @default undefined
165
- */
166
- zipSources?: boolean;
167
- /**
168
- * Configure the filename output when zipping files.
169
- *
170
- * Available template variables:
171
- *
172
- * - <span v-pre>`{{name}}`</span> - The project's name converted to kebab-case
173
- * - <span v-pre>`{{version}}`</span> - The version_name or version from the manifest
174
- * - <span v-pre>`{{packageVersion}}`</span> - The version from the package.json
175
- * - <span v-pre>`{{browser}}`</span> - The target browser from the `--browser` CLI flag
176
- * - <span v-pre>`{{mode}}`</span> - The current mode
177
- * - <span v-pre>`{{manifestVersion}}`</span> - Either "2" or "3"
178
- *
179
- * @default "{{name}}-{{version}}-sources.zip"
180
- */
181
- sourcesTemplate?: string;
182
- /**
183
- * Override the artifactTemplate's `{name}` template variable. Defaults to the `package.json`'s
184
- * name, or if that doesn't exist, the current working directories name.
185
- */
186
- name?: string;
187
- /**
188
- * Root directory to ZIP when generating the sources ZIP.
189
- *
190
- * @default config.root
191
- */
192
- sourcesRoot?: string;
193
- /**
194
- * [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to include when
195
- * creating a ZIP of all your source code for Firefox. Patterns are relative to your
196
- * `config.zip.sourcesRoot`.
197
- *
198
- * This setting overrides `excludeSources`. So if a file matches both lists, it is included in the ZIP.
199
- *
200
- * @example
201
- * [
202
- * "coverage", // Include the coverage directory in the `sourcesRoot`
203
- * ]
204
- */
205
- includeSources?: string[];
206
- /**
207
- * [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
208
- * creating a ZIP of all your source code for Firefox. Patterns are relative to your
209
- * `config.zip.sourcesRoot`.
210
- *
211
- * Hidden files, node_modules, and tests are ignored by default.
212
- *
213
- * @example
214
- * [
215
- * "coverage", // Ignore the coverage directory in the `sourcesRoot`
216
- * ]
217
- */
218
- excludeSources?: string[];
219
- /**
220
- * [Minimatch](https://www.npmjs.com/package/minimatch) patterns of files to exclude when
221
- * zipping the extension.
222
- *
223
- * @example
224
- * [
225
- * "**\/*.map", // Exclude all sourcemaps
226
- * ]
227
- */
228
- exclude?: string[];
229
- /**
230
- * The Firefox review process requires the extension be buildable from source to make reviewing
231
- * easier. This field allows you to use private packages without exposing your auth tokens.
232
- *
233
- * Just list the name of all the packages you want to download and include in the sources zip.
234
- * Usually, these will be private packages behind auth tokens, but they don't have to be.
235
- *
236
- * All packages listed here will be downloaded to in `.wxt/local_modules/` and an `overrides` or
237
- * `resolutions` field (depending on your package manager) will be added to the `package.json`,
238
- * pointing to the downloaded packages.
239
- *
240
- * > ***DO NOT include versions or version filters.*** Just the package name. If multiple
241
- * > versions of a package are present in the project, all versions will be downloaded and
242
- * > referenced in the package.json correctly.
243
- *
244
- * @default []
245
- *
246
- * @example
247
- * // Correct:
248
- * ["@scope/package-name", "package-name"]
249
- *
250
- * // Incorrect, don't include versions!!!
251
- * ["@scope/package-name@1.1.3", "package-name@^2"]
252
- */
253
- downloadPackages?: string[];
254
- /**
255
- * Compression level to use when zipping files.
256
- *
257
- * Levels: 0 (no compression) to 9 (maximum compression).
258
- *
259
- * @default 9
260
- */
261
- compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
262
- };
263
- analysis?: {
264
- /**
265
- * Explicitly include bundle analysis when running `wxt build`. This can be overridden by the
266
- * command line `--analyze` option.
267
- *
268
- * @default false
269
- */
270
- enabled?: boolean;
271
- /**
272
- * Set to true to automatically open the `stats.html` file when the build is finished. When building in CI, the browser will never open.
273
- *
274
- * @default false
275
- */
276
- open?: boolean;
277
- /**
278
- * When running `wxt build --analyze` or setting `analysis.enabled` to true, customize how the
279
- * bundle will be visualized. See
280
- * [`rollup-plugin-visualizer`](https://github.com/btd/rollup-plugin-visualizer#how-to-use-generated-files)
281
- * for more details.
282
- *
283
- * @default "treemap"
284
- */
285
- template?: PluginVisualizerOptions['template'];
286
- /**
287
- * Name of the output HTML file. Relative to the project's root directory.
288
- *
289
- * Changing the filename of the outputFile also effects the names of the artifacts generated
290
- * when setting `keepArtifacts` to true:
291
- * - "stats.html" => "stats-*.json"
292
- * - "stats/bundle.html" => "bundle-*.json"
293
- * - ".analysis/index.html" => "index-*.json"
294
- *
295
- * @default "stats.html"
296
- */
297
- outputFile?: string;
298
- /**
299
- * By default, the `stats-*.json` artifacts generated during bundle analysis are deleted. Set to
300
- * `true` to keep them.
301
- *
302
- * One stats file is output per build step.
303
- *
304
- * @default false
305
- */
306
- keepArtifacts?: boolean;
307
- };
308
- /**
309
- * Add additional paths to the `.wxt/tsconfig.json`. Use this instead of overwriting the `paths`
310
- * in the root `tsconfig.json` if you want to add new paths.
311
- *
312
- * The key is the import alias and the value is either a relative path to the root directory or an absolute path.
313
- *
314
- * @example
315
- * {
316
- * "testing": "src/utils/testing.ts"
317
- * }
318
- */
319
- alias?: Record<string, string>;
320
- /**
321
- * Experimental settings - use with caution.
322
- */
323
- experimental?: {};
324
- /**
325
- * Config effecting dev mode only.
326
- */
327
- dev?: {
328
- server?: {
329
- /**
330
- * Host to bind the dev server to.
331
- *
332
- * @default "localhost"
333
- */
334
- host?: string;
335
- /**
336
- * Port to run the dev server on. Defaults to the first open port from 3000 to 3010.
337
- */
338
- port?: number;
339
- /**
340
- * Origin to use to connect from the extension ui runtime to the dev server.
341
- *
342
- * @default "http://localhost:3000"
343
- */
344
- origin?: string;
345
- /**
346
- * Hostname to run the dev server on.
347
- *
348
- * @deprecated use `host` to specify the interface to bind to, or use `origin` to specify the dev server hostname.
349
- */
350
- hostname?: string;
351
- };
352
- /**
353
- * Controls whether a custom keyboard shortcut command, `Alt+R`, is added during dev mode to
354
- * quickly reload the extension.
355
- *
356
- * If false, the shortcut is not added during development.
357
- *
358
- * If set to a custom string, you can override the key combo used. See
359
- * [Chrome's command docs](https://developer.chrome.com/docs/extensions/reference/api/commands)
360
- * for available options.
361
- *
362
- * @default "Alt+R"
363
- */
364
- reloadCommand?: string | false;
365
- };
366
- /**
367
- * Project hooks for running logic during the build process.
368
- */
369
- hooks?: NestedHooks<WxtHooks>;
370
- /**
371
- * List of WXT module names to include. Can be the full package name
372
- * ("wxt-module-analytics"), or just the suffix ("analytics" would resolve to
373
- * "wxt-module-analytics").
374
- */
375
- modules?: string[];
376
- }
377
- export interface InlineConfig {
378
- /**
379
- * Return custom Vite options from a function. See
380
- * <https://vitejs.dev/config/shared-options.html>.
381
- *
382
- * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
383
- * instead of Vite's.
384
- *
385
- * This is a function because any vite plugins added need to be recreated for each individual
386
- * build step, incase they have internal state causing them to fail when reused.
387
- */
388
- vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
389
- }
390
- export interface ResolvedConfig {
391
- vite: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
392
- }
393
- export type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
394
- export interface WxtHooks {
395
- /**
396
- * Called when WXT has created Vite's config for a build step. Useful if you
397
- * want to add plugins or update the vite config per entrypoint group.
398
- *
399
- * @param entrypoints The list of entrypoints being built with the provided config.
400
- * @param viteConfig The config that will be used for the dev server.
401
- */
402
- 'vite:build:extendConfig': (entrypoints: readonly Entrypoint[], viteConfig: vite.InlineConfig) => HookResult;
403
- /**
404
- * Called when WXT has created Vite's config for the dev server. Useful if
405
- * you want to add plugins or update the vite config per entrypoint group.
406
- *
407
- * @param viteConfig The config that will be used to build the entrypoints. Can be updated by reference.
408
- */
409
- 'vite:devServer:extendConfig': (config: vite.InlineConfig) => HookResult;
410
- }
411
- export interface BuildOutput {
412
- manifest: Browser.runtime.Manifest;
413
- publicAssets: OutputAsset[];
414
- steps: BuildStepOutput[];
415
- }
416
- export type OutputFile = OutputChunk | OutputAsset;
417
- export interface OutputChunk {
418
- type: 'chunk';
419
- /**
420
- * Relative, normalized path relative to the output directory.
421
- *
422
- * Ex: "content-scripts/overlay.js"
423
- */
424
- fileName: string;
425
- /**
426
- * Absolute, normalized paths to all dependencies this chunk relies on.
427
- */
428
- moduleIds: string[];
429
- }
430
- export interface OutputAsset {
431
- type: 'asset';
432
- /**
433
- * Relative, normalized path relative to the output directory.
434
- *
435
- * Ex: "icons/16.png"
436
- */
437
- fileName: string;
438
- }
439
- export interface BuildStepOutput {
440
- entrypoints: EntrypointGroup;
441
- chunks: OutputFile[];
442
- }
443
- export interface WxtDevServer extends Omit<WxtBuilderServer, 'listen' | 'close'>, ServerInfo {
444
- /**
445
- * Stores the current build output of the server.
446
- */
447
- currentOutput: BuildOutput | undefined;
448
- /**
449
- * Start the server.
450
- */
451
- start(): Promise<void>;
452
- /**
453
- * Stop the server.
454
- */
455
- stop(): Promise<void>;
456
- /**
457
- * Close the browser, stop the server, rebuild the entire extension, and start the server again.
458
- */
459
- restart(): Promise<void>;
460
- /**
461
- * Transform the HTML for dev mode.
462
- */
463
- transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
464
- /**
465
- * Tell the extension to reload by running `browser.runtime.reload`.
466
- */
467
- reloadExtension: () => void;
468
- /**
469
- * Tell an extension page to reload.
470
- *
471
- * The path is the bundle path, not the input paths, so if the input paths is
472
- * "src/options/index.html", you would pass "options.html" because that's where it is written to
473
- * in the dist directory, and where it's available at in the actual extension.
474
- *
475
- * @example
476
- * server.reloadPage("popup.html")
477
- * server.reloadPage("sandbox.html")
478
- */
479
- reloadPage: (path: string) => void;
480
- /**
481
- * Tell the extension to restart a content script.
482
- *
483
- * @param payload Information about the content script to reload.
484
- */
485
- reloadContentScript: (payload: ReloadContentScriptPayload) => void;
486
- /**
487
- * Grab the latest runner config and restart the browser.
488
- */
489
- restartBrowser: () => void;
490
- }
491
- export interface ReloadContentScriptPayload {
492
- registration?: BaseContentScriptEntrypointOptions['registration'];
493
- contentScript: Omit<Browser.scripting.RegisteredContentScript, 'id'>;
494
- }
495
- export type TargetBrowser = string;
496
- export type TargetManifestVersion = 2 | 3;
497
- export type UserConfig = Omit<InlineConfig, 'configFile'>;
498
- export interface Logger {
499
- debug(...args: any[]): void;
500
- log(...args: any[]): void;
501
- info(...args: any[]): void;
502
- warn(...args: any[]): void;
503
- error(...args: any[]): void;
504
- fatal(...args: any[]): void;
505
- success(...args: any[]): void;
506
- level: LogLevel;
507
- }
508
- export interface BaseEntrypointOptions {
509
- /**
510
- * List of target browsers to include this entrypoint in. Defaults to being included in all
511
- * builds. Cannot be used with `exclude`. You must choose one of the two options.
512
- *
513
- * @default undefined
514
- */
515
- include?: TargetBrowser[];
516
- /**
517
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
518
- * must choose one of the two options.
519
- *
520
- * @default undefined
521
- */
522
- exclude?: TargetBrowser[];
523
- }
524
- export interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
525
- persistent?: PerBrowserOption<boolean>;
526
- /**
527
- * Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
528
- * reduce the overall size of the bundled extension.
529
- *
530
- * When `undefined`, the background is bundled individually into an IIFE format.
531
- *
532
- * @default undefined
533
- */
534
- type?: PerBrowserOption<'module'>;
535
- }
536
- export interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
537
- matches?: PerBrowserOption<NonNullable<ManifestContentScript['matches']>>;
538
- /**
539
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
540
- * @default "documentIdle"
541
- */
542
- runAt?: PerBrowserOption<Browser.scripting.RegisteredContentScript['runAt']>;
543
- /**
544
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
545
- * @default false
546
- */
547
- matchAboutBlank?: PerBrowserOption<ManifestContentScript['match_about_blank']>;
548
- /**
549
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
550
- * @default []
551
- */
552
- excludeMatches?: PerBrowserOption<ManifestContentScript['exclude_matches']>;
553
- /**
554
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
555
- * @default []
556
- */
557
- includeGlobs?: PerBrowserOption<ManifestContentScript['include_globs']>;
558
- /**
559
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
560
- * @default []
561
- */
562
- excludeGlobs?: PerBrowserOption<ManifestContentScript['exclude_globs']>;
563
- /**
564
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
565
- * @default false
566
- */
567
- allFrames?: PerBrowserOption<ManifestContentScript['all_frames']>;
568
- /**
569
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
570
- * @default false
571
- */
572
- matchOriginAsFallback?: PerBrowserOption<boolean>;
573
- /**
574
- * Customize how imported/generated styles are injected with the content script. Regardless of the
575
- * mode selected, CSS will always be built and included in the output directory.
576
- *
577
- * - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
578
- * - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
579
- * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
580
- * URL
581
- * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
582
- * calling `createShadowRootUi`
583
- *
584
- * @default "manifest"
585
- */
586
- cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
587
- /**
588
- * Specify how the content script is registered.
589
- *
590
- * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
591
- * manifest. This is the normal and most well known way of registering a content script.
592
- * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
593
- * responsible for using the scripting API to register/execute the content script
594
- * dynamically at runtime.
595
- *
596
- * @default "manifest"
597
- */
598
- registration?: PerBrowserOption<'manifest' | 'runtime'>;
599
- }
600
- export interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
601
- /**
602
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
603
- */
604
- world: 'MAIN';
605
- }
606
- export interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
607
- /**
608
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
609
- * @default "ISOLATED"
610
- */
611
- world?: 'ISOLATED';
612
- }
613
- export interface PopupEntrypointOptions extends BaseEntrypointOptions {
614
- /**
615
- * Defaults to "browser_action" to be equivalent to MV3's "action" key
616
- */
617
- mv2Key?: PerBrowserOption<'browser_action' | 'page_action'>;
618
- defaultIcon?: Record<string, string>;
619
- defaultTitle?: PerBrowserOption<string>;
620
- browserStyle?: PerBrowserOption<boolean>;
621
- }
622
- export interface OptionsEntrypointOptions extends BaseEntrypointOptions {
623
- openInTab?: PerBrowserOption<boolean>;
624
- browserStyle?: PerBrowserOption<boolean>;
625
- chromeStyle?: PerBrowserOption<boolean>;
626
- }
627
- export interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
628
- /**
629
- * Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
630
- * @default false
631
- */
632
- openAtInstall?: PerBrowserOption<boolean>;
633
- /**
634
- * @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
635
- */
636
- browserStyle?: PerBrowserOption<boolean>;
637
- defaultIcon?: string | Record<string, string>;
638
- defaultTitle?: PerBrowserOption<string>;
639
- }
640
- export interface BaseEntrypoint {
641
- /**
642
- * The entrypoint's name. This is the filename or dirname without the type suffix.
643
- *
644
- * Examples:
645
- * - `popup.html` &rarr; `popup`
646
- * - `options/index.html` &rarr; `options`
647
- * - `named.sandbox.html` &rarr; `named`
648
- * - `named.sandbox/index.html` &rarr; `named`
649
- * - `sandbox.html` &rarr; `sandbox`
650
- * - `sandbox/index.html` &rarr; `sandbox`
651
- * - `overlay.content.ts` &rarr; `overlay`
652
- * - `overlay.content/index.ts` &rarr; `overlay`
653
- *
654
- * The name is used when generating an output file:
655
- * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
656
- */
657
- name: string;
658
- /**
659
- * Absolute path to the entrypoint's input file.
660
- */
661
- inputPath: string;
662
- /**
663
- * Absolute path to the entrypoint's output directory. Can be `wxt.config.outDir` or a
664
- * subdirectory of it.
665
- */
666
- outputDir: string;
667
- /**
668
- * When true, the entrypoint will not be built by WXT. Normally this is set
669
- * based on the `filterEntrypoints` config or the entrypoint's
670
- * `include`/`exclude` options defined inside the file.
671
- *
672
- * See https://wxt.dev/guide/essentials/target-different-browsers.html#filtering-entrypoints
673
- */
674
- skipped?: boolean;
675
- }
676
- export interface GenericEntrypoint extends BaseEntrypoint {
677
- type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
678
- options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
679
- }
680
- export interface BackgroundEntrypoint extends BaseEntrypoint {
681
- type: 'background';
682
- options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
683
- }
684
- export interface ContentScriptEntrypoint extends BaseEntrypoint {
685
- type: 'content-script';
686
- options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
687
- }
688
- export interface PopupEntrypoint extends BaseEntrypoint {
689
- type: 'popup';
690
- options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
691
- }
692
- export interface OptionsEntrypoint extends BaseEntrypoint {
693
- type: 'options';
694
- options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
695
- }
696
- export interface SidepanelEntrypoint extends BaseEntrypoint {
697
- type: 'sidepanel';
698
- options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
699
- }
700
- export type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
701
- export interface EntrypointInfo {
702
- name: string;
703
- /** Absolute path to the entrypoint file. */
704
- inputPath: string;
705
- type: Entrypoint['type'];
706
- }
707
- export type EntrypointGroup = Entrypoint | Entrypoint[];
708
- export type OnContentScriptStopped = (cb: () => void) => void;
709
- export interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
710
- /**
711
- * Main function executed when the content script is loaded.
712
- *
713
- * When running a content script with `browser.scripting.executeScript`,
714
- * values returned from this function will be returned in the `executeScript`
715
- * result as well. Otherwise returning a value does nothing.
716
- */
717
- main(ctx: ContentScriptContext): any | Promise<any>;
718
- }
719
- export interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
720
- /**
721
- * Main function executed when the content script is loaded.
722
- *
723
- * When running a content script with `browser.scripting.executeScript`,
724
- * values returned from this function will be returned in the `executeScript`
725
- * result as well. Otherwise returning a value does nothing.
726
- */
727
- main(): any | Promise<any>;
728
- }
729
- export type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
730
- export interface BackgroundDefinition extends BackgroundEntrypointOptions {
731
- /**
732
- * Main function executed when the background script is started. Cannot be async.
733
- */
734
- main(): void;
735
- }
736
- export interface UnlistedScriptDefinition extends BaseEntrypointOptions {
737
- /**
738
- * Main function executed when the unlisted script is ran.
739
- *
740
- * When running a content script with `browser.scripting.executeScript`,
741
- * values returned from this function will be returned in the `executeScript`
742
- * result as well. Otherwise returning a value does nothing.
743
- */
744
- main(): any | Promise<any>;
745
- }
746
- /**
747
- * Either a single value or a map of different browsers to the value for that browser.
748
- */
749
- export type PerBrowserOption<T> = T | PerBrowserMap<T>;
750
- export type PerBrowserMap<T> = {
751
- [browser: TargetBrowser]: T;
752
- };
753
- /**
754
- * Convert `{ key: PerBrowserOption<T> }` to just `{ key: T }`, stripping away the
755
- * `PerBrowserOption` type for all fields inside the object.
756
- *
757
- * A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
758
- */
759
- export type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
760
- [key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
761
- } & {
762
- [key in TOmitted]: T[key];
763
- };
764
- /**
765
- * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
766
- * here, they are configured inline.
767
- */
768
- export type UserManifest = {
769
- [key in keyof Browser.runtime.ManifestV3 as key extends 'action' | 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'permissions' | 'sandbox' | 'web_accessible_resources' ? never : key]?: Browser.runtime.ManifestV3[key];
770
- } & {
771
- action?: Browser.runtime.ManifestV3['action'] & {
772
- browser_style?: boolean;
773
- };
774
- browser_action?: Browser.runtime.ManifestV2['browser_action'] & {
775
- browser_style?: boolean;
776
- };
777
- page_action?: Browser.runtime.ManifestV2['page_action'] & {
778
- browser_style?: boolean;
779
- };
780
- browser_specific_settings?: {
781
- gecko?: {
782
- id?: string;
783
- strict_min_version?: string;
784
- strict_max_version?: string;
785
- update_url?: string;
786
- };
787
- gecko_android?: {
788
- strict_min_version?: string;
789
- strict_max_version?: string;
790
- };
791
- safari?: {
792
- strict_min_version?: string;
793
- strict_max_version?: string;
794
- };
795
- };
796
- permissions?: (Browser.runtime.ManifestPermissions | (string & Record<never, never>))[];
797
- web_accessible_resources?: string[] | Browser.runtime.ManifestV3['web_accessible_resources'];
798
- };
799
- export type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
800
- export interface ConfigEnv {
801
- /**
802
- * The build mode passed into the CLI. By default, `wxt` uses `"development"` and `wxt build|zip`
803
- * uses `"production"`.
804
- */
805
- mode: string;
806
- /**
807
- * The command used to run WXT. `"serve"` during development and `"build"` for any other command.
808
- */
809
- command: WxtCommand;
810
- /**
811
- * Browser passed in from the CLI via the `-b` or `--browser` flag. Defaults to `"chrome"` when not passed.
812
- */
813
- browser: TargetBrowser;
814
- /**
815
- * Manifest version passed in from the CLI via the `--mv2` or `--mv3` flags. When not passed, it depends on the target browser. See
816
- * [the guide](https://wxt.dev/guide/key-concepts/multiple-browsers.html#target-manifest-version) for more
817
- * details.
818
- */
819
- manifestVersion: 2 | 3;
820
- }
821
- export type WxtCommand = 'build' | 'serve';
822
- /**
823
- * @deprecated Use `WebExtConfig` instead.
824
- */
825
- export type ExtensionRunnerConfig = WebExtConfig;
826
- /**
827
- * Options for how [`web-ext`](https://github.com/mozilla/web-ext) starts the browser.
828
- */
829
- export interface WebExtConfig {
830
- /**
831
- * Whether or not to open the browser with the extension installed in dev mode.
832
- *
833
- * @default false
834
- */
835
- disabled?: boolean;
836
- /**
837
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#browser-console
838
- */
839
- openConsole?: boolean;
840
- /**
841
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#devtools
842
- */
843
- openDevtools?: boolean;
844
- /**
845
- * List of browser names and the binary that should be used to open the browser.
846
- *
847
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-binary
848
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox
849
- */
850
- binaries?: Record<string, string>;
851
- /**
852
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#firefox-profile
853
- */
854
- firefoxProfile?: string;
855
- /**
856
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#chromium-profile
857
- */
858
- chromiumProfile?: string;
859
- /**
860
- * An map of chrome preferences from https://chromium.googlesource.com/chromium/src/+/main/chrome/common/pref_names.h
861
- *
862
- * @example
863
- * // change your downloads directory
864
- * {
865
- * download: {
866
- * default_directory: "/my/custom/dir",
867
- * },
868
- * }
869
- *
870
- * @default
871
- * // Enable dev mode and allow content script sourcemaps
872
- * {
873
- * devtools: {
874
- * synced_preferences_sync_disabled: {
875
- * skipContentScripts: false,
876
- * },
877
- * }
878
- * extensions: {
879
- * ui: {
880
- * developer_mode: true,
881
- * },
882
- * }
883
- * }
884
- */
885
- chromiumPref?: Record<string, any>;
886
- /**
887
- * By default, chrome opens a random port for debugging. Set this value to use a specific port.
888
- */
889
- chromiumPort?: number;
890
- /**
891
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#pref
892
- */
893
- firefoxPrefs?: Record<string, string>;
894
- /**
895
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
896
- */
897
- firefoxArgs?: string[];
898
- /**
899
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#args
900
- */
901
- chromiumArgs?: string[];
902
- /**
903
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#start-url
904
- */
905
- startUrls?: string[];
906
- /**
907
- * @see https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#keep-profile-changes
908
- */
909
- keepProfileChanges?: boolean;
910
- }
911
- export interface WxtBuilder {
912
- /**
913
- * Name of tool used to build. Ex: "Vite" or "Webpack".
914
- */
915
- name: string;
916
- /**
917
- * Version of tool used to build. Ex: "5.0.2"
918
- */
919
- version: string;
920
- /**
921
- * Import a JS entrypoint file, returning the default export containing the options.
922
- */
923
- importEntrypoint<T>(path: string): Promise<T>;
924
- /**
925
- * Import a list of JS entrypoint files, returning their options.
926
- */
927
- importEntrypoints(paths: string[]): Promise<Record<string, unknown>[]>;
928
- /**
929
- * Build a single entrypoint group. This is effectively one of the multiple "steps" during the
930
- * build process.
931
- */
932
- build(group: EntrypointGroup): Promise<BuildStepOutput>;
933
- /**
934
- * Start a dev server at the provided port.
935
- */
936
- createServer(info: ServerInfo): Promise<WxtBuilderServer>;
937
- }
938
- export interface WxtBuilderServer {
939
- /**
940
- * Start the server.
941
- */
942
- listen(): Promise<void>;
943
- /**
944
- * Stop the server.
945
- */
946
- close(): Promise<void>;
947
- /**
948
- * Transform the HTML for dev mode.
949
- */
950
- transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
951
- /**
952
- * The web socket server used to communicate with the extension.
953
- */
954
- ws: {
955
- /**
956
- * Send a message via the server's websocket, with an optional payload.
957
- *
958
- * @example
959
- * ws.send("wxt:reload-extension");
960
- * ws.send("wxt:reload-content-script", { ... });
961
- */
962
- send(message: string, payload?: any): void;
963
- /**
964
- * Listen for messages over the server's websocket.
965
- */
966
- on(message: string, cb: (payload: any) => void): void;
967
- };
968
- /**
969
- * Chokidar file watcher instance.
970
- */
971
- watcher: vite.ViteDevServer['watcher'];
972
- on?(event: string, callback: () => void): void;
973
- }
974
- export interface ServerInfo {
975
- /**
976
- * Ex: `"localhost"`
977
- */
978
- host: string;
979
- /**
980
- * Ex: `3000`
981
- */
982
- port: number;
983
- /**
984
- * Ex: `"http://localhost:3000"`
985
- */
986
- origin: string;
987
- }
988
- export type HookResult = Promise<void> | void;
989
- export interface WxtHooks {
990
- /**
991
- * Called after WXT modules are initialized, when the WXT instance is ready to
992
- * be used. `wxt.server` isn't available yet, use `server:created` to get it.
993
- * @param wxt The configured WXT object
994
- */
995
- ready: (wxt: Wxt) => HookResult;
996
- /**
997
- * Called whenever config is loaded or reloaded. Use this hook to modify config by modifying `wxt.config`.
998
- * @param wxt The configured WXT object
999
- */
1000
- 'config:resolved': (wxt: Wxt) => HookResult;
1001
- /**
1002
- * Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
1003
- * addition of custom references and declarations in wxt.d.ts, or directly
1004
- * modifying the options in `tsconfig.json`.
1005
- *
1006
- * @example
1007
- * wxt.hooks.hook("prepare:types", (wxt, entries) => {
1008
- * // Add a file, ".wxt/types/example.d.ts", that defines a global
1009
- * // variable called "example" in the TS project.
1010
- * entries.push({
1011
- * path: "types/example.d.ts",
1012
- * text: "declare const a: string;",
1013
- * tsReference: true,
1014
- * });
1015
- * // use module to add Triple-Slash Directive in .wxt/wxt.d.ts
1016
- * // eg: /// <reference types="@types/example" />
1017
- * entries.push({
1018
- * module: '@types/example'
1019
- * });
1020
- * })
1021
- */
1022
- 'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
1023
- /**
1024
- * Called before generating the list of public paths inside
1025
- * `.wxt/types/paths.d.ts`. Use this hook to add additional paths (relative
1026
- * to output directory) WXT doesn't add automatically.
1027
- *
1028
- * @param wxt The configured WXT object
1029
- * @param paths This list of paths TypeScript allows `browser.runtime.getURL` to be called with.
1030
- *
1031
- * @example
1032
- * wxt.hooks.hook('prepare:publicPaths', (wxt, paths) => {
1033
- * paths.push('/icons/128.png');
1034
- * })
1035
- */
1036
- 'prepare:publicPaths': (wxt: Wxt, paths: string[]) => HookResult;
1037
- /**
1038
- * Called before the build is started in both dev mode and build mode.
1039
- *
1040
- * @param wxt The configured WXT object
1041
- */
1042
- 'build:before': (wxt: Wxt) => HookResult;
1043
- /**
1044
- * Called once the build process has finished. You can add files to the build
1045
- * summary here by pushing to `output.publicAssets`.
1046
- *
1047
- * @param wxt The configured WXT object
1048
- * @param output The results of the build
1049
- */
1050
- 'build:done': (wxt: Wxt, output: Readonly<BuildOutput>) => HookResult;
1051
- /**
1052
- * Called once the manifest has been generated. Used to transform the manifest by reference before
1053
- * it is written to the output directory.
1054
- * @param wxt The configured WXT object
1055
- * @param manifest The manifest that was generated
1056
- */
1057
- 'build:manifestGenerated': (wxt: Wxt, manifest: Browser.runtime.Manifest) => HookResult;
1058
- /**
1059
- * Called once the names and paths of all entrypoints have been resolved.
1060
- * @param wxt The configured WXT object
1061
- * @param infos List of entrypoints found in the project's `entrypoints` directory
1062
- */
1063
- 'entrypoints:found': (wxt: Wxt, infos: EntrypointInfo[]) => HookResult;
1064
- /**
1065
- * Called once all entrypoints have been loaded from the `entrypointsDir`.
1066
- * Use `wxt.builder.importEntrypoint` to load entrypoint options from the
1067
- * file, or manually define them.
1068
- *
1069
- * @param wxt The configured WXT object
1070
- * @param entrypoints The list of entrypoints to be built
1071
- */
1072
- 'entrypoints:resolved': (wxt: Wxt, entrypoints: Entrypoint[]) => HookResult;
1073
- /**
1074
- * Called once all entrypoints have been grouped into their build groups.
1075
- * @param wxt The configured WXT object
1076
- * @param entrypoints The list of groups to build in each build step
1077
- */
1078
- 'entrypoints:grouped': (wxt: Wxt, groups: EntrypointGroup[]) => HookResult;
1079
- /**
1080
- * Called when public assets are found. You can modify the `files` list by
1081
- * reference to add or remove public files.
1082
- * @param wxt The configured WXT object
1083
- * @param entrypoints The list of files that will be copied into the output directory
1084
- */
1085
- 'build:publicAssets': (wxt: Wxt, files: ResolvedPublicFile[]) => HookResult;
1086
- /**
1087
- * Called before the zip process starts.
1088
- * @param wxt The configured WXT object
1089
- */
1090
- 'zip:start': (wxt: Wxt) => HookResult;
1091
- /**
1092
- * Called before zipping the extension files.
1093
- * @param wxt The configured WXT object
1094
- */
1095
- 'zip:extension:start': (wxt: Wxt) => HookResult;
1096
- /**
1097
- * Called after zipping the extension files.
1098
- * @param wxt The configured WXT object
1099
- * @param zipPath The path to the created extension zip file
1100
- */
1101
- 'zip:extension:done': (wxt: Wxt, zipPath: string) => HookResult;
1102
- /**
1103
- * Called before zipping the source files (for Firefox).
1104
- * @param wxt The configured WXT object
1105
- */
1106
- 'zip:sources:start': (wxt: Wxt) => HookResult;
1107
- /**
1108
- * Called after zipping the source files (for Firefox).
1109
- * @param wxt The configured WXT object
1110
- * @param zipPath The path to the created sources zip file
1111
- */
1112
- 'zip:sources:done': (wxt: Wxt, zipPath: string) => HookResult;
1113
- /**
1114
- * Called after the entire zip process is complete.
1115
- * @param wxt The configured WXT object
1116
- * @param zipFiles An array of paths to all created zip files
1117
- */
1118
- 'zip:done': (wxt: Wxt, zipFiles: string[]) => HookResult;
1119
- /**
1120
- * Called when the dev server is created (and `wxt.server` is assigned). Server has not been started yet.
1121
- * @param wxt The configured WXT object
1122
- * @param server Same as `wxt.server`, the object WXT uses to control the dev server.
1123
- */
1124
- 'server:created': (wxt: Wxt, server: WxtDevServer) => HookResult;
1125
- /**
1126
- * Called when the dev server is started.
1127
- * @param wxt The configured WXT object
1128
- * @param server Same as `wxt.server`, the object WXT uses to control the dev server.
1129
- */
1130
- 'server:started': (wxt: Wxt, server: WxtDevServer) => HookResult;
1131
- /**
1132
- * Called when the dev server is stopped.
1133
- * @param wxt The configured WXT object
1134
- * @param server Same as `wxt.server`, the object WXT uses to control the dev server.
1135
- */
1136
- 'server:closed': (wxt: Wxt, server: WxtDevServer) => HookResult;
1137
- }
1138
- export interface Wxt {
1139
- config: ResolvedConfig;
1140
- hooks: Hookable<WxtHooks>;
1141
- /**
1142
- * Alias for `wxt.hooks.hook(...)`.
1143
- */
1144
- hook: Hookable<WxtHooks>['hook'];
1145
- /**
1146
- * Alias for config.logger
1147
- */
1148
- logger: Logger;
1149
- /**
1150
- * Reload config file and update `wxt.config` with the result.
1151
- */
1152
- reloadConfig: () => Promise<void>;
1153
- /**
1154
- * Package manager utilities.
1155
- */
1156
- pm: WxtPackageManager;
1157
- /**
1158
- * If the dev server was started, it will be available.
1159
- */
1160
- server?: WxtDevServer;
1161
- /**
1162
- * The module in charge of executing all the build steps.
1163
- */
1164
- builder: WxtBuilder;
1165
- }
1166
- export interface ResolvedConfig {
1167
- root: string;
1168
- srcDir: string;
1169
- publicDir: string;
1170
- /**
1171
- * Absolute path pointing to `.wxt` directory in project root.
1172
- * @example
1173
- * "/path/to/project/.wxt"
1174
- */
1175
- wxtDir: string;
1176
- typesDir: string;
1177
- entrypointsDir: string;
1178
- modulesDir: string;
1179
- filterEntrypoints?: Set<string>;
1180
- /**
1181
- * Absolute path to the `.output` directory
1182
- * @example
1183
- * "/path/to/project/.output"
1184
- */
1185
- outBaseDir: string;
1186
- /**
1187
- * Absolute path to the target output directory.
1188
- * @example
1189
- * "/path/to/project/.output/chrome-mv3"
1190
- */
1191
- outDir: string;
1192
- debug: boolean;
1193
- /**
1194
- * Absolute path pointing to the `node_modules/wxt` directory, wherever WXT is installed.
1195
- */
1196
- wxtModuleDir: string;
1197
- mode: string;
1198
- command: WxtCommand;
1199
- browser: TargetBrowser;
1200
- targetBrowsers: TargetBrowser[];
1201
- manifestVersion: TargetManifestVersion;
1202
- env: ConfigEnv;
1203
- logger: Logger;
1204
- imports: WxtResolvedUnimportOptions;
1205
- manifest: UserManifest;
1206
- fsCache: FsCache;
1207
- runnerConfig: C12ResolvedConfig<WebExtConfig>;
1208
- zip: {
1209
- name?: string;
1210
- artifactTemplate: string;
1211
- sourcesTemplate: string;
1212
- includeSources: string[];
1213
- excludeSources: string[];
1214
- sourcesRoot: string;
1215
- downloadedPackagesDir: string;
1216
- downloadPackages: string[];
1217
- compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
1218
- exclude: string[];
1219
- /**
1220
- * If true, when zipping the extension, also zip the sources.
1221
- */
1222
- zipSources: boolean;
1223
- };
1224
- analysis: {
1225
- enabled: boolean;
1226
- open: boolean;
1227
- template: NonNullable<PluginVisualizerOptions['template']>;
1228
- /** Absolute file path to the `stats.html` file */
1229
- outputFile: string;
1230
- /** The directory where the final `stats.html` file is located */
1231
- outputDir: string;
1232
- /** Name of the `stats.html` file, minus ".html" */
1233
- outputName: string;
1234
- keepArtifacts: boolean;
1235
- };
1236
- userConfigMetadata: Omit<C12ResolvedConfig<UserConfig>, 'config'>;
1237
- /**
1238
- * Import aliases to absolute paths.
1239
- */
1240
- alias: Record<string, string>;
1241
- experimental: {};
1242
- dev: {
1243
- /** Only defined during dev command */
1244
- server?: {
1245
- host: string;
1246
- port: number;
1247
- origin: string;
1248
- /**
1249
- * The milliseconds to debounce when a file is saved before reloading.
1250
- * The only way to set this option is to set the `WXT_WATCH_DEBOUNCE`
1251
- * environment variable, either globally (like in `.bashrc` file) or
1252
- * per-project (in `.env` file).
1253
- *
1254
- * For example:
1255
- * ```
1256
- * # ~/.zshrc
1257
- * export WXT_WATCH_DEBOUNCE=1000
1258
- * ```
1259
- * or
1260
- * ```
1261
- * # .env
1262
- * WXT_WATCH_DEBOUNCE=1000
1263
- * ```
1264
- * @default 800
1265
- */
1266
- watchDebounce: number;
1267
- };
1268
- reloadCommand: string | false;
1269
- };
1270
- hooks: NestedHooks<WxtHooks>;
1271
- builtinModules: WxtModule<any>[];
1272
- userModules: WxtModuleWithMetadata<any>[];
1273
- /**
1274
- * An array of string to import plugins from. These paths should be
1275
- * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
1276
- *
1277
- * @example
1278
- * ["@wxt-dev/module-vue/plugin", "wxt-module-google-analytics/plugin"]
1279
- */
1280
- plugins: string[];
1281
- }
1282
- export interface FsCache {
1283
- set(key: string, value: string): Promise<void>;
1284
- get(key: string): Promise<string | undefined>;
1285
- }
1286
- export interface ExtensionRunner {
1287
- openBrowser(): Promise<void>;
1288
- closeBrowser(): Promise<void>;
1289
- /** Whether or not this runner actually opens the browser. */
1290
- canOpen?(): boolean;
1291
- }
1292
- export type EslintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable';
1293
- export interface Eslintrc {
1294
- /**
1295
- * When true, generates a file that can be used by ESLint to know which variables are valid globals.
1296
- *
1297
- * - `false`: Don't generate the file.
1298
- * - `'auto'`: Check if eslint is installed, and if it is, generate a compatible config file.
1299
- * - `true`: Same as `8`.
1300
- * - `8`: Generate a config file compatible with ESLint 8.
1301
- * - `9`: Generate a config file compatible with ESLint 9.
1302
- *
1303
- * @default 'auto'
1304
- */
1305
- enabled?: false | true | 'auto' | 8 | 9;
1306
- /**
1307
- * File path to save the generated eslint config.
1308
- *
1309
- * Default depends on version of ESLint used:
1310
- * - 9 and above: './.wxt/eslint-auto-imports.mjs'
1311
- * - 8 and below: './.wxt/eslintrc-auto-import.json'
1312
- */
1313
- filePath?: string;
1314
- /**
1315
- * @default true
1316
- */
1317
- globalsPropValue?: EslintGlobalsPropValue;
1318
- }
1319
- export interface ResolvedEslintrc {
1320
- /** False if disabled, otherwise the major version of ESLint installed */
1321
- enabled: false | 8 | 9;
1322
- /** Absolute path */
1323
- filePath: string;
1324
- globalsPropValue: EslintGlobalsPropValue;
1325
- }
1326
- export type WxtUnimportOptions = Partial<UnimportOptions> & {
1327
- /**
1328
- * When using ESLint, auto-imported variables are linted as "undeclared
1329
- * globals". This option lets you configure a base eslintrc that, when
1330
- * extended, fixes these lint errors.
1331
- *
1332
- * See <https://wxt.dev/guide/key-concepts/auto-imports.html#eslint>
1333
- */
1334
- eslintrc?: Eslintrc;
1335
- };
1336
- export type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
1337
- /**
1338
- * Set to `true` when the user disabled auto-imports. We still use unimport for the #imports module, but other features should be disabled.
1339
- *
1340
- * You don't need to check this value before modifying the auto-import options. Even if `disabled` is `true`, there's no harm in adding imports to the config - they'll just be ignored.
1341
- */
1342
- disabled: boolean;
1343
- eslintrc: ResolvedEslintrc;
1344
- };
1345
- /**
1346
- * Package management utils built on top of [`nypm`](https://www.npmjs.com/package/nypm)
1347
- */
1348
- export interface WxtPackageManager extends Nypm.PackageManager {
1349
- addDependency: typeof Nypm.addDependency;
1350
- addDevDependency: typeof Nypm.addDevDependency;
1351
- ensureDependencyInstalled: typeof Nypm.ensureDependencyInstalled;
1352
- installDependencies: typeof Nypm.installDependencies;
1353
- removeDependency: typeof Nypm.removeDependency;
1354
- /**
1355
- * Download a package's TGZ file and move it into the `downloadDir`. Use's `npm pack <name>`, so
1356
- * you must have setup authorization in `.npmrc` file, regardless of the package manager used.
1357
- *
1358
- * @param id Name of the package to download, can include a version (like `wxt@0.17.1`)
1359
- * @param downloadDir Where to store the package.
1360
- * @returns Absolute path to downloaded file.
1361
- */
1362
- downloadDependency: (id: string, downloadDir: string) => Promise<string>;
1363
- /**
1364
- * Run `npm ls`, `pnpm ls`, or `bun pm ls`, or `yarn list` and return the results.
1365
- *
1366
- * WARNING: Yarn always returns all dependencies
1367
- */
1368
- listDependencies: (options?: {
1369
- cwd?: string;
1370
- all?: boolean;
1371
- }) => Promise<Dependency[]>;
1372
- /**
1373
- * Key used to override package versions. Sometimes called "resolutions".
1374
- */
1375
- overridesKey: string;
1376
- }
1377
- export interface Dependency {
1378
- name: string;
1379
- version: string;
1380
- }
1381
- export type WxtModuleOptions = Record<string, any>;
1382
- export type WxtModuleSetup<TOptions extends WxtModuleOptions> = (wxt: Wxt, moduleOptions?: TOptions) => void | Promise<void>;
1383
- export interface WxtModule<TOptions extends WxtModuleOptions> {
1384
- name?: string;
1385
- /**
1386
- * Key for users to pass options into your module from their `wxt.config.ts` file.
1387
- */
1388
- configKey?: string;
1389
- /**
1390
- * Provide a list of imports to add to auto-imports.
1391
- */
1392
- imports?: Import[];
1393
- /**
1394
- * Alternative to adding hooks in setup function with `wxt.hooks`. Hooks are
1395
- * added before the `setup` function is called.
1396
- */
1397
- hooks?: NestedHooks<WxtHooks>;
1398
- /**
1399
- * A custom function that can be used to setup hooks and call module-specific
1400
- * APIs.
1401
- */
1402
- setup?: WxtModuleSetup<TOptions>;
1403
- }
1404
- export interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtModule<TOptions> {
1405
- type: 'local' | 'node_module';
1406
- id: string;
1407
- }
1408
- export type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
1409
- export interface ResolvedBasePublicFile {
1410
- /**
1411
- * The relative path in the output directory to copy the file to.
1412
- * @example
1413
- * "content-scripts/base-styles.css"
1414
- */
1415
- relativeDest: string;
1416
- }
1417
- export interface CopiedPublicFile extends ResolvedBasePublicFile {
1418
- /**
1419
- * The absolute path to the file that will be copied to the output directory.
1420
- * @example
1421
- * "/path/to/any/file.css"
1422
- */
1423
- absoluteSrc: string;
1424
- }
1425
- export interface GeneratedPublicFile extends ResolvedBasePublicFile {
1426
- /**
1427
- * Text to write to the file.
1428
- */
1429
- contents: string;
1430
- }
1431
- export type WxtPlugin = () => void;
1432
- export type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
1433
- /**
1434
- * Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
1435
- */
1436
- export interface WxtDirTypeReferenceEntry {
1437
- /**
1438
- * Specifies the module name that will be used in the `/// <reference types="..." />` directive.
1439
- * This value will be added to the `.wxt/wxt.d.ts` file to include type definitions from the specified module.
1440
- */
1441
- module: string;
1442
- }
1443
- /**
1444
- * Represents a file to be written to the project's `.wxt/` directory.
1445
- */
1446
- export interface WxtDirFileEntry {
1447
- /**
1448
- * Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
1449
- */
1450
- path: string;
1451
- /**
1452
- * The text that will be written to the file.
1453
- */
1454
- text: string;
1455
- /**
1456
- * Set to `true` to add a reference to this file in `.wxt/wxt.d.ts`.
1457
- */
1458
- tsReference?: boolean;
1459
- }