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
@@ -1,17 +0,0 @@
1
- import { Dependency } from '../../types';
2
- import { WxtPackageManagerImpl } from './types';
3
- export declare const npm: WxtPackageManagerImpl;
4
- export declare function flattenNpmListOutput(projects: NpmListProject[]): Dependency[];
5
- export declare function dedupeDependencies(dependencies: Dependency[]): Dependency[];
6
- export interface NpmListProject {
7
- name: string;
8
- dependencies?: Record<string, NpmListDependency>;
9
- devDependencies?: Record<string, NpmListDependency>;
10
- }
11
- export interface NpmListDependency {
12
- version: string;
13
- resolved?: string;
14
- overridden?: boolean;
15
- dependencies?: Record<string, NpmListDependency>;
16
- devDependencies?: Record<string, NpmListDependency>;
17
- }
@@ -1,2 +0,0 @@
1
- import { WxtPackageManagerImpl } from './types';
2
- export declare const pnpm: WxtPackageManagerImpl;
@@ -1,2 +0,0 @@
1
- import { WxtPackageManager } from '../../types';
2
- export type WxtPackageManagerImpl = Pick<WxtPackageManager, 'downloadDependency' | 'listDependencies' | 'overridesKey'>;
File without changes
@@ -1,2 +0,0 @@
1
- import { WxtPackageManagerImpl } from './types';
2
- export declare const yarn: WxtPackageManagerImpl;
@@ -1,2 +0,0 @@
1
- import { InlineConfig } from '../types';
2
- export declare function prepare(config: InlineConfig): Promise<void>;
@@ -1,11 +0,0 @@
1
- import { InlineConfig, ResolvedConfig, UserConfig, Logger, WxtCommand, WxtModuleWithMetadata } from '../types';
2
- /**
3
- * Given an inline config, discover the config file if necessary, merge the results, resolve any
4
- * relative paths, and apply any defaults.
5
- *
6
- * Inline config always has priority over user config. Cli flags are passed as inline config if set.
7
- * If unset, undefined is passed in, letting this function decide default values.
8
- */
9
- export declare function resolveConfig(inlineConfig: InlineConfig, command: WxtCommand): Promise<ResolvedConfig>;
10
- export declare function mergeBuilderConfig(logger: Logger, inlineConfig: InlineConfig, userConfig: UserConfig): Promise<Pick<InlineConfig, 'vite'>>;
11
- export declare function resolveWxtUserModules(root: string, modulesDir: string, modules?: string[]): Promise<WxtModuleWithMetadata<any>[]>;
@@ -1,2 +0,0 @@
1
- import { ExtensionRunner } from '../../types';
2
- export declare function createExtensionRunner(): Promise<ExtensionRunner>;
@@ -1,5 +0,0 @@
1
- import { ExtensionRunner } from '../../types';
2
- /**
3
- * The manual runner tells the user to load the unpacked extension manually.
4
- */
5
- export declare function createManualRunner(): ExtensionRunner;
@@ -1,5 +0,0 @@
1
- import { ExtensionRunner } from '../../types';
2
- /**
3
- * The Safari runner just logs a warning message because `web-ext` doesn't work with Safari.
4
- */
5
- export declare function createSafariRunner(): ExtensionRunner;
@@ -1,5 +0,0 @@
1
- import { ExtensionRunner } from '../../types';
2
- /**
3
- * Create an `ExtensionRunner` backed by `web-ext`.
4
- */
5
- export declare function createWebExtRunner(): ExtensionRunner;
@@ -1,5 +0,0 @@
1
- import { ExtensionRunner } from '../../types';
2
- /**
3
- * The WSL runner just logs a warning message because `web-ext` doesn't work in WSL.
4
- */
5
- export declare function createWslRunner(): ExtensionRunner;
@@ -1,13 +0,0 @@
1
- /**
2
- * Checks if `predicate` returns truthy for all elements of the array.
3
- */
4
- export declare function every<T>(array: T[], predicate: (item: T, index: number) => boolean): boolean;
5
- /**
6
- * Returns true when any of the predicates return true;
7
- */
8
- export declare function some<T>(array: T[], predicate: (item: T, index: number) => boolean): boolean;
9
- /**
10
- * Convert an item or array to an array.
11
- */
12
- export declare function toArray<T>(a: T | T[]): T[];
13
- export declare function filterTruthy<T>(array: Array<T | undefined>): T[];
@@ -1,3 +0,0 @@
1
- import { BuildOutput, EntrypointGroup } from '../../../types';
2
- import type { Ora } from 'ora';
3
- export declare function buildEntrypoints(groups: EntrypointGroup[], spinner: Ora): Promise<Omit<BuildOutput, 'manifest'>>;
@@ -1,61 +0,0 @@
1
- import { BuildOutput, BuildStepOutput, EntrypointGroup } from '../../../types';
2
- /**
3
- * Compare the changed files vs the build output and determine what kind of reload needs to happen:
4
- *
5
- * - Do nothing
6
- * - CSS or JS file associated with an HTML page is changed - this is handled automatically by the
7
- * dev server
8
- * - Change isn't used by any of the entrypoints
9
- * - Reload Content script
10
- * - CSS or JS file associated with a content script
11
- * - Background script will be told to reload the content script
12
- * - Reload HTML file
13
- * - HTML file itself is saved - HMR doesn't handle this because the HTML pages are pre-rendered
14
- * - Chrome is OK reloading the page when the HTML file is changed without reloading the whole
15
- * extension. Not sure about firefox, this might need to change to an extension reload
16
- * - Reload extension
17
- * - Background script is changed
18
- * - Manifest is different
19
- * - Restart browser
20
- * - web-ext.config.ts (runner config changes)
21
- * - Full dev server restart
22
- * - wxt.config.ts (main config file)
23
- * - modules/* (any file related to WXT modules)
24
- * - .env (environment variable changed could effect build)
25
- */
26
- export declare function detectDevChanges(changedFiles: string[], currentOutput: BuildOutput): DevModeChange;
27
- /**
28
- * Contains information about what files changed, what needs rebuilt, and the type of reload that is
29
- * required.
30
- */
31
- export type DevModeChange = NoChange | HtmlReload | ExtensionReload | ContentScriptReload | FullRestart | BrowserRestart;
32
- interface NoChange {
33
- type: 'no-change';
34
- }
35
- interface RebuildChange {
36
- /**
37
- * The list of entrypoints that need rebuilt.
38
- */
39
- rebuildGroups: EntrypointGroup[];
40
- /**
41
- * The previous output stripped of any files are going to change.
42
- */
43
- cachedOutput: BuildOutput;
44
- }
45
- interface FullRestart {
46
- type: 'full-restart';
47
- }
48
- interface BrowserRestart {
49
- type: 'browser-restart';
50
- }
51
- interface HtmlReload extends RebuildChange {
52
- type: 'html-reload';
53
- }
54
- interface ExtensionReload extends RebuildChange {
55
- type: 'extension-reload';
56
- }
57
- interface ContentScriptReload extends RebuildChange {
58
- type: 'content-script-reload';
59
- changedSteps: BuildStepOutput[];
60
- }
61
- export {};
@@ -1,5 +0,0 @@
1
- import { Entrypoint } from '../../../types';
2
- /**
3
- * Return entrypoints and their configuration by looking through the project's files.
4
- */
5
- export declare function findEntrypoints(): Promise<Entrypoint[]>;
@@ -1,8 +0,0 @@
1
- import { Entrypoint, EntrypointGroup } from '../../../types';
2
- /**
3
- * Entrypoints are built in groups. HTML pages can all be built together in a single step,
4
- * content scripts must be build individually, etc.
5
- *
6
- * This function returns the entrypoints put into these types of groups.
7
- */
8
- export declare function groupEntrypoints(entrypoints: Entrypoint[]): EntrypointGroup[];
@@ -1,6 +0,0 @@
1
- export * from './build-entrypoints';
2
- export * from './detect-dev-changes';
3
- export * from './find-entrypoints';
4
- export * from './group-entrypoints';
5
- export * from './internal-build';
6
- export * from './rebuild';
@@ -1,12 +0,0 @@
1
- import { BuildOutput } from '../../../types';
2
- /**
3
- * Builds the extension based on an internal config. No more config discovery is performed, the
4
- * build is based on exactly what is passed in.
5
- *
6
- * This function:
7
- * 1. Cleans the output directory
8
- * 2. Executes the rebuild function with a blank previous output so everything is built (see
9
- * `rebuild` for more details)
10
- * 3. Prints the summary
11
- */
12
- export declare function internalBuild(): Promise<BuildOutput>;
@@ -1,23 +0,0 @@
1
- import { BuildOutput, Entrypoint, EntrypointGroup } from '../../../types';
2
- import type { Browser } from '@wxt-dev/browser';
3
- /**
4
- * Given a configuration, list of entrypoints, and an existing, partial output, build the
5
- * entrypoints and merge the new output with the existing output.
6
- *
7
- * This function will:
8
- * 1. Generate the .wxt directory's types
9
- * 2. Build the `entrypointGroups` (and copies public files)
10
- * 3. Generate the latest manifest for all entrypoints
11
- * 4. Write the new manifest to the file system
12
- *
13
- * @param config Internal config containing all the project information.
14
- * @param allEntrypoints List of entrypoints used to generate the types inside .wxt directory.
15
- * @param entrypointGroups The list of entrypoint groups to build.
16
- * @param existingOutput The previous output to combine the rebuild results into. An emptry array if
17
- * this is the first build.
18
- */
19
- export declare function rebuild(allEntrypoints: Entrypoint[], entrypointGroups: EntrypointGroup[], existingOutput?: Omit<BuildOutput, 'manifest'>): Promise<{
20
- output: BuildOutput;
21
- manifest: Browser.runtime.Manifest;
22
- warnings: any[][];
23
- }>;
@@ -1,8 +0,0 @@
1
- import { FsCache } from '../../types';
2
- /**
3
- * A basic file system cache stored at `<srcDir>/.wxt/cache/<key>`. Just caches a string in a
4
- * file for the given key.
5
- *
6
- * @param srcDir Absolute path to source directory. See `InternalConfig.srcDir`
7
- */
8
- export declare function createFsCache(wxtDir: string): FsCache;
@@ -1,3 +0,0 @@
1
- export declare function defineCommand<TArgs extends any[]>(cb: (...args: TArgs) => void | boolean | Promise<void | boolean>, options?: {
2
- disableFinishedLog?: boolean;
3
- }): (...args: TArgs) => Promise<void>;
@@ -1,26 +0,0 @@
1
- import { LogLevels, consola } from "consola";
2
- import { printHeader } from "./log/index.mjs";
3
- import { formatDuration } from "./time.mjs";
4
- export function defineCommand(cb, options) {
5
- return async (...args) => {
6
- const isDebug = !!args.find((arg) => arg?.debug);
7
- if (isDebug) {
8
- consola.level = LogLevels.debug;
9
- }
10
- const startTime = Date.now();
11
- try {
12
- printHeader();
13
- const ongoing = await cb(...args);
14
- if (!ongoing && !options?.disableFinishedLog)
15
- consola.success(
16
- `Finished in ${formatDuration(Date.now() - startTime)}`
17
- );
18
- } catch (err) {
19
- consola.fail(
20
- `Command failed after ${formatDuration(Date.now() - startTime)}`
21
- );
22
- consola.error(err);
23
- process.exit(1);
24
- }
25
- };
26
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Module ID used to build the background in dev mode if the extension doesn't include a background
3
- * script/service worker.
4
- */
5
- export declare const VIRTUAL_NOOP_BACKGROUND_MODULE_ID = "virtual:user-background";
@@ -1,12 +0,0 @@
1
- import type { Browser } from '@wxt-dev/browser';
2
- import { ContentScriptEntrypoint, ResolvedConfig } from '../../types';
3
- import { ManifestContentScript } from './types';
4
- /**
5
- * Returns a unique and consistent string hash based on a content scripts options.
6
- *
7
- * It is able to recognize default values,
8
- */
9
- export declare function hashContentScriptOptions(options: ContentScriptEntrypoint['options']): string;
10
- export declare function mapWxtOptionsToContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): ManifestContentScript;
11
- export declare function mapWxtOptionsToRegisteredContentScript(options: ContentScriptEntrypoint['options'], js: string[] | undefined, css: string[] | undefined): Omit<Browser.scripting.RegisteredContentScript, 'id'>;
12
- export declare function getContentScriptJs(config: ResolvedConfig, entrypoint: ContentScriptEntrypoint): string[];
@@ -1,14 +0,0 @@
1
- /**
2
- * Directive names that make up CSPs. There are more, this is all I need for the plugin.
3
- */
4
- export type CspDirective = 'default-src' | 'script-src' | 'object-src';
5
- export declare class ContentSecurityPolicy {
6
- private static DIRECTIVE_ORDER;
7
- data: Record<string, string[]>;
8
- constructor(csp?: string);
9
- /**
10
- * Ensure a set of values are listed under a directive.
11
- */
12
- add(directive: CspDirective, ...newValues: string[]): ContentSecurityPolicy;
13
- toString(): string;
14
- }
@@ -1,31 +0,0 @@
1
- import { Entrypoint, PerBrowserOption, ResolvedPerBrowserOptions, TargetBrowser } from '../../types';
2
- export declare function getEntrypointName(entrypointsDir: string, inputPath: string): string;
3
- export declare function getEntrypointOutputFile(entrypoint: Entrypoint, ext: string): string;
4
- /**
5
- * Return's the entrypoint's output path relative to the output directory. Used for paths in the
6
- * manifest and rollup's bundle.
7
- */
8
- export declare function getEntrypointBundlePath(entrypoint: Entrypoint, outDir: string, ext: string): string;
9
- /**
10
- * Given an entrypoint option, resolve it's value based on a target browser.
11
- */
12
- export declare function resolvePerBrowserOption<T>(option: PerBrowserOption<T>, browser: TargetBrowser): T;
13
- /**
14
- * Given an entrypoint option, resolve it's value based on a target browser.
15
- *
16
- * defaultIcon is special, it's the only key that's a record, which can confuse this function. So
17
- * it's been manually excluded from resolution.
18
- */
19
- export declare function resolvePerBrowserOptions<T extends Record<string, any>, TKeys extends keyof T>(options: T, browser: TargetBrowser): ResolvedPerBrowserOptions<T, TKeys>;
20
- /**
21
- * Returns true when the entrypoint is an HTML entrypoint.
22
- *
23
- * Naively just checking the file extension of the input path.
24
- */
25
- export declare function isHtmlEntrypoint(entrypoint: Pick<Entrypoint, 'inputPath'>): boolean;
26
- /**
27
- * Returns true when the entrypoint is a JS entrypoint.
28
- *
29
- * Naively just checking the file extension of the input path.
30
- */
31
- export declare function isJsEntrypoint(entrypoint: Pick<Entrypoint, 'inputPath'>): boolean;
@@ -1,5 +0,0 @@
1
- import type { TargetBrowser } from '../../types';
2
- /**
3
- * Load environment files based on the current mode and browser.
4
- */
5
- export declare function loadEnv(mode: string, browser: TargetBrowser): import("dotenv-expand").DotenvExpandOutput;
@@ -1,3 +0,0 @@
1
- import { Environment, EnvGlobals } from './environment';
2
- export declare function createBrowserEnvironment(): Environment;
3
- export declare function getBrowserEnvironmentGlobals(): EnvGlobals;
@@ -1,8 +0,0 @@
1
- export interface Environment {
2
- setup: () => () => void;
3
- run: <T>(fn: () => Promise<T>) => Promise<T>;
4
- }
5
- export declare function createEnvironment(getGlobals: () => EnvGlobals): Environment;
6
- export type EnvGlobals = Record<string, any>;
7
- export declare function getOgGlobals(envGlobals: EnvGlobals): EnvGlobals;
8
- export declare function applyGlobals(globals: EnvGlobals): void;
@@ -1,6 +0,0 @@
1
- import { Environment } from './environment';
2
- export declare function createExtensionEnvironment(): Environment;
3
- export declare function getExtensionEnvironmentGlobals(): {
4
- chrome: import("@webext-core/fake-browser").FakeBrowser;
5
- browser: import("@webext-core/fake-browser").FakeBrowser;
6
- };
@@ -1,2 +0,0 @@
1
- export * from './browser-environment';
2
- export * from './extension-environment';
@@ -1 +0,0 @@
1
- export declare function getEslintVersion(): Promise<string[]>;
@@ -1,13 +0,0 @@
1
- /**
2
- * Only write the contents to a file if it results in a change. This prevents unnecessary file
3
- * watchers from being triggered, like WXT's dev server or the TS language server in editors.
4
- *
5
- * @param file The file to write to.
6
- * @param newContents The new text content to write.
7
- */
8
- export declare function writeFileIfDifferent(file: string, newContents: string): Promise<void>;
9
- /**
10
- * Get all the files in the project's public directory. Returned paths are relative to the
11
- * `config.publicDir`.
12
- */
13
- export declare function getPublicFiles(): Promise<string[]>;
@@ -1,11 +0,0 @@
1
- import { ResolvedConfig } from '../../types';
2
- export declare function getGlobals(config: ResolvedConfig): Array<{
3
- name: string;
4
- value: any;
5
- type: string;
6
- }>;
7
- export declare function getEntrypointGlobals(entrypointName: string): {
8
- name: string;
9
- value: string;
10
- type: string;
11
- }[];
@@ -1,11 +0,0 @@
1
- export interface Message {
2
- name: string;
3
- message: string;
4
- description?: string;
5
- }
6
- /**
7
- * Get a list of all messages and their metadata from JSON file contents.
8
- *
9
- * @param messagesJson The contents of a `_locales/en/messages.json` file.
10
- */
11
- export declare function parseI18nMessages(messagesJson: object): Message[];
@@ -1,4 +0,0 @@
1
- export * from './printBuildSummary';
2
- export * from './printFileList';
3
- export * from './printHeader';
4
- export * from './printTable';
@@ -1,2 +0,0 @@
1
- import { BuildOutput } from '../../../types';
2
- export declare function printBuildSummary(log: (...args: any[]) => void, header: string, output: BuildOutput): Promise<void>;
@@ -1 +0,0 @@
1
- export declare function printFileList(log: (message: string) => void, header: string, baseDir: string, files: string[]): Promise<void>;
@@ -1 +0,0 @@
1
- export declare function printHeader(): void;
@@ -1 +0,0 @@
1
- export declare function printTable(log: (message: string) => void, header: string, rows: string[][], gap?: number): void;
@@ -1,40 +0,0 @@
1
- import { Entrypoint, BuildOutput, ContentScriptEntrypoint } from '../../types';
2
- import type { Browser } from '@wxt-dev/browser';
3
- /**
4
- * Writes the manifest to the output directory and the build output.
5
- */
6
- export declare function writeManifest(manifest: Browser.runtime.Manifest, output: BuildOutput): Promise<void>;
7
- /**
8
- * Generates the manifest based on the config and entrypoints.
9
- */
10
- export declare function generateManifest(allEntrypoints: Entrypoint[], buildOutput: Omit<BuildOutput, 'manifest'>): Promise<{
11
- manifest: Browser.runtime.Manifest;
12
- warnings: any[][];
13
- }>;
14
- /**
15
- * Returns the bundle paths to CSS files associated with a list of content scripts, or undefined if
16
- * there is no associated CSS.
17
- */
18
- export declare function getContentScriptCssFiles(contentScripts: ContentScriptEntrypoint[], contentScriptCssMap: Record<string, string | undefined>): string[] | undefined;
19
- /**
20
- * Content scripts configured with `cssInjectionMode: "ui"` need to add their CSS files to web
21
- * accessible resources so they can be fetched as text and added to shadow roots that the UI is
22
- * added to.
23
- */
24
- export declare function getContentScriptCssWebAccessibleResources(contentScripts: ContentScriptEntrypoint[], contentScriptCssMap: Record<string, string | undefined>): any[];
25
- /**
26
- * Based on the build output, return a Record of each content script's name to it CSS file if the
27
- * script includes one.
28
- */
29
- export declare function getContentScriptsCssMap(buildOutput: Omit<BuildOutput, 'manifest'>, scripts: ContentScriptEntrypoint[]): Record<string, string | undefined>;
30
- /**
31
- * - "<all_urls>" &rarr; "<all_urls>"
32
- * - "*://play.google.com/books/*" &rarr; "*://play.google.com/*"
33
- */
34
- export declare function stripPathFromMatchPattern(pattern: string): string;
35
- /**
36
- * Converts all MV3 web accessible resources to their MV2 forms. MV3 web accessible resources are
37
- * generated in this file, and may be defined by the user in their manifest. In both cases, when
38
- * targeting MV2, automatically convert their definitions down to the basic MV2 array.
39
- */
40
- export declare function convertWebAccessibleResourcesToMv2(manifest: Browser.runtime.Manifest): void;
@@ -1,15 +0,0 @@
1
- import { MinimatchOptions } from 'minimatch';
2
- /**
3
- * Run [`minimatch`](https://npmjs.com/package/minimatch) against multiple
4
- * patterns.
5
- *
6
- * Supports negated patterns, the order does not matter. If your `search` string
7
- * matches any of the negative patterns, it will return `false`.
8
- *
9
- * @example
10
- * ```ts
11
- * minimatchMultiple('a.json', ['*.json', '!b.json']); // => true
12
- * minimatchMultiple('b.json', ['*.json', '!b.json']); // => false
13
- * ```
14
- */
15
- export declare function minimatchMultiple(search: string, patterns: string[] | undefined, options?: MinimatchOptions): boolean;
@@ -1,7 +0,0 @@
1
- import { ResolvedConfig } from '../../types';
2
- export declare function isOnline(): Promise<boolean>;
3
- /**
4
- * Fetches a URL with a simple GET request. Grabs it from cache if it doesn't exist, or throws an
5
- * error if it can't be resolved via the network or cache.
6
- */
7
- export declare function fetchCached(url: string, config: ResolvedConfig): Promise<string>;
@@ -1 +0,0 @@
1
- export declare function safeStringToNumber(str: string | undefined): number | null;
@@ -1,6 +0,0 @@
1
- /**
2
- * Read the project's package.json.
3
- *
4
- * TODO: look in root and up directories until it's found
5
- */
6
- export declare function getPackageJson(): Promise<Partial<Record<string, any>> | undefined>;
@@ -1,11 +0,0 @@
1
- /**
2
- * Converts system paths to normalized bundler path. On windows and unix, this returns paths with /
3
- * instead of \.
4
- */
5
- export declare function normalizePath(path: string): string;
6
- /**
7
- * Given a normalized path, convert it to the system path style. On Windows, switch to \, otherwise use /.
8
- */
9
- export declare function unnormalizePath(path: string): string;
10
- export declare const CSS_EXTENSIONS: string[];
11
- export declare const CSS_EXTENSIONS_PATTERN: string;
@@ -1,14 +0,0 @@
1
- export declare function kebabCaseAlphanumeric(str: string): string;
2
- /**
3
- * Return a safe variable name for a given string.
4
- */
5
- export declare function safeVarName(str: string): string;
6
- /**
7
- * Converts a string to a valid filename (NOT path), stripping out invalid characters.
8
- */
9
- export declare function safeFilename(str: string): string;
10
- /**
11
- * Removes import statements from the top of a file. Keeps import.meta and inline, async `import()`
12
- * calls.
13
- */
14
- export declare function removeImportStatements(text: string): string;
@@ -1,11 +0,0 @@
1
- export interface BabelSyntaxError extends SyntaxError {
2
- code: 'BABEL_PARSER_SYNTAX_ERROR';
3
- frame?: string;
4
- id: string;
5
- loc: {
6
- line: number;
7
- column: number;
8
- };
9
- }
10
- export declare function isBabelSyntaxError(error: unknown): error is BabelSyntaxError;
11
- export declare function logBabelSyntaxError(error: BabelSyntaxError): void;