wxt 0.18.15 → 0.19.0

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 (257) hide show
  1. package/bin/wxt.mjs +1 -1
  2. package/dist/browser/chrome.d.ts +17 -0
  3. package/dist/browser/chrome.mjs +7 -0
  4. package/dist/browser/index.d.ts +18 -0
  5. package/dist/browser/index.mjs +2 -0
  6. package/dist/builtin-modules/index.d.ts +2 -0
  7. package/dist/builtin-modules/index.mjs +2 -0
  8. package/dist/builtin-modules/unimport.d.ts +8 -0
  9. package/dist/builtin-modules/unimport.mjs +99 -0
  10. package/dist/cli/cli-utils.d.ts +25 -0
  11. package/dist/cli/cli-utils.mjs +58 -0
  12. package/dist/cli/commands.d.ts +2 -0
  13. package/dist/cli/commands.mjs +104 -0
  14. package/dist/cli/index.d.ts +1 -0
  15. package/dist/cli/index.mjs +11 -0
  16. package/dist/client/app-config.d.ts +2 -0
  17. package/dist/client/app-config.mjs +4 -0
  18. package/dist/client/content-scripts/content-script-context.d.ts +114 -0
  19. package/dist/client/content-scripts/content-script-context.mjs +169 -0
  20. package/dist/client/content-scripts/custom-events.d.ts +10 -0
  21. package/dist/client/content-scripts/custom-events.mjs +13 -0
  22. package/dist/client/content-scripts/index.d.ts +2 -0
  23. package/dist/client/content-scripts/index.mjs +2 -0
  24. package/dist/client/content-scripts/location-watcher.d.ts +12 -0
  25. package/dist/client/content-scripts/location-watcher.mjs +22 -0
  26. package/dist/client/content-scripts/ui/index.d.ts +23 -0
  27. package/dist/client/content-scripts/ui/index.mjs +188 -0
  28. package/dist/{client.d.ts → client/content-scripts/ui/types.d.ts} +17 -45
  29. package/dist/client/content-scripts/ui/types.mjs +0 -0
  30. package/dist/client/index.d.ts +7 -0
  31. package/dist/client/index.mjs +2 -0
  32. package/dist/core/build.d.ts +15 -0
  33. package/dist/core/build.mjs +6 -0
  34. package/dist/core/builders/vite/index.d.ts +3 -0
  35. package/dist/core/builders/vite/index.mjs +285 -0
  36. package/dist/core/builders/vite/plugins/bundleAnalysis.d.ts +7 -0
  37. package/dist/core/builders/vite/plugins/bundleAnalysis.mjs +15 -0
  38. package/dist/core/builders/vite/plugins/cssEntrypoints.d.ts +13 -0
  39. package/dist/core/builders/vite/plugins/cssEntrypoints.mjs +22 -0
  40. package/dist/core/builders/vite/plugins/defineImportMeta.d.ts +14 -0
  41. package/dist/core/builders/vite/plugins/defineImportMeta.mjs +13 -0
  42. package/dist/core/builders/vite/plugins/devHtmlPrerender.d.ts +7 -0
  43. package/dist/core/builders/vite/plugins/devHtmlPrerender.mjs +140 -0
  44. package/dist/core/builders/vite/plugins/devServerGlobals.d.ts +6 -0
  45. package/dist/core/builders/vite/plugins/devServerGlobals.mjs +15 -0
  46. package/dist/core/builders/vite/plugins/download.d.ts +10 -0
  47. package/dist/core/builders/vite/plugins/download.mjs +14 -0
  48. package/dist/core/builders/vite/plugins/entrypointGroupGlobals.d.ts +6 -0
  49. package/dist/core/builders/vite/plugins/entrypointGroupGlobals.mjs +16 -0
  50. package/dist/core/builders/vite/plugins/extensionApiMock.d.ts +11 -0
  51. package/dist/core/builders/vite/plugins/extensionApiMock.mjs +26 -0
  52. package/dist/core/builders/vite/plugins/globals.d.ts +3 -0
  53. package/dist/core/builders/vite/plugins/globals.mjs +15 -0
  54. package/dist/core/builders/vite/plugins/index.d.ts +17 -0
  55. package/dist/core/builders/vite/plugins/index.mjs +17 -0
  56. package/dist/core/builders/vite/plugins/multipageMove.d.ts +20 -0
  57. package/dist/core/builders/vite/plugins/multipageMove.mjs +59 -0
  58. package/dist/core/builders/vite/plugins/noopBackground.d.ts +6 -0
  59. package/dist/core/builders/vite/plugins/noopBackground.mjs +17 -0
  60. package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.d.ts +6 -0
  61. package/dist/core/builders/vite/plugins/removeEntrypointMainFunction.mjs +12 -0
  62. package/dist/core/builders/vite/plugins/resolveAppConfig.d.ts +6 -0
  63. package/dist/core/builders/vite/plugins/resolveAppConfig.mjs +26 -0
  64. package/dist/core/builders/vite/plugins/resolveExtensionApi.d.ts +10 -0
  65. package/dist/core/builders/vite/plugins/resolveExtensionApi.mjs +15 -0
  66. package/dist/core/builders/vite/plugins/resolveVirtualModules.d.ts +6 -0
  67. package/dist/core/builders/vite/plugins/resolveVirtualModules.mjs +30 -0
  68. package/dist/core/builders/vite/plugins/tsconfigPaths.d.ts +3 -0
  69. package/dist/core/builders/vite/plugins/tsconfigPaths.mjs +12 -0
  70. package/dist/core/builders/vite/plugins/wxtPluginLoader.d.ts +6 -0
  71. package/dist/core/builders/vite/plugins/wxtPluginLoader.mjs +56 -0
  72. package/dist/core/clean.d.ts +21 -0
  73. package/dist/core/clean.mjs +38 -0
  74. package/dist/core/create-server.d.ts +11 -0
  75. package/dist/core/create-server.mjs +206 -0
  76. package/dist/core/define-config.d.ts +2 -0
  77. package/dist/core/define-config.mjs +3 -0
  78. package/dist/core/define-runner-config.d.ts +2 -0
  79. package/dist/core/define-runner-config.mjs +3 -0
  80. package/dist/core/index.d.ts +8 -0
  81. package/dist/core/index.mjs +8 -0
  82. package/dist/core/initialize.d.ts +5 -0
  83. package/dist/core/initialize.mjs +128 -0
  84. package/dist/core/package-managers/bun.d.ts +2 -0
  85. package/dist/core/package-managers/bun.mjs +19 -0
  86. package/dist/core/package-managers/index.d.ts +2 -0
  87. package/dist/core/package-managers/index.mjs +65 -0
  88. package/dist/core/package-managers/npm.d.ts +17 -0
  89. package/dist/core/package-managers/npm.mjs +58 -0
  90. package/dist/core/package-managers/pnpm.d.ts +2 -0
  91. package/dist/core/package-managers/pnpm.mjs +21 -0
  92. package/dist/core/package-managers/types.d.ts +2 -0
  93. package/dist/core/package-managers/types.mjs +0 -0
  94. package/dist/core/package-managers/yarn.d.ts +2 -0
  95. package/dist/core/package-managers/yarn.mjs +31 -0
  96. package/dist/core/prepare.d.ts +2 -0
  97. package/dist/core/prepare.mjs +8 -0
  98. package/dist/core/runners/index.d.ts +2 -0
  99. package/dist/core/runners/index.mjs +12 -0
  100. package/dist/core/runners/manual.d.ts +5 -0
  101. package/dist/core/runners/manual.mjs +16 -0
  102. package/dist/core/runners/safari.d.ts +5 -0
  103. package/dist/core/runners/safari.mjs +16 -0
  104. package/dist/core/runners/web-ext.d.ts +5 -0
  105. package/dist/core/runners/web-ext.mjs +78 -0
  106. package/dist/core/runners/wsl.d.ts +5 -0
  107. package/dist/core/runners/wsl.mjs +16 -0
  108. package/dist/core/utils/arrays.d.ts +13 -0
  109. package/dist/{chunk-BERPNPEZ.js → core/utils/arrays.mjs} +6 -10
  110. package/dist/core/utils/building/build-entrypoints.d.ts +3 -0
  111. package/dist/core/utils/building/build-entrypoints.mjs +47 -0
  112. package/dist/core/utils/building/detect-dev-changes.d.ts +57 -0
  113. package/dist/core/utils/building/detect-dev-changes.mjs +93 -0
  114. package/dist/core/utils/building/find-entrypoints.d.ts +5 -0
  115. package/dist/core/utils/building/find-entrypoints.mjs +385 -0
  116. package/dist/core/utils/building/generate-wxt-dir.d.ts +5 -0
  117. package/dist/core/utils/building/generate-wxt-dir.mjs +192 -0
  118. package/dist/core/utils/building/group-entrypoints.d.ts +8 -0
  119. package/dist/core/utils/building/group-entrypoints.mjs +37 -0
  120. package/dist/core/utils/building/import-entrypoint.d.ts +16 -0
  121. package/dist/core/utils/building/import-entrypoint.mjs +97 -0
  122. package/dist/core/utils/building/index.d.ts +9 -0
  123. package/dist/core/utils/building/index.mjs +9 -0
  124. package/dist/core/utils/building/internal-build.d.ts +12 -0
  125. package/dist/core/utils/building/internal-build.mjs +112 -0
  126. package/dist/core/utils/building/rebuild.d.ts +23 -0
  127. package/dist/core/utils/building/rebuild.mjs +39 -0
  128. package/dist/core/utils/building/resolve-config.d.ts +11 -0
  129. package/dist/core/utils/building/resolve-config.mjs +364 -0
  130. package/dist/core/utils/cache.d.ts +8 -0
  131. package/dist/core/utils/cache.mjs +21 -0
  132. package/dist/core/utils/cli.d.ts +3 -0
  133. package/dist/core/utils/cli.mjs +26 -0
  134. package/dist/core/utils/constants.d.ts +5 -0
  135. package/dist/core/utils/constants.mjs +1 -0
  136. package/dist/core/utils/content-scripts.d.ts +11 -0
  137. package/dist/core/utils/content-scripts.mjs +60 -0
  138. package/dist/core/utils/content-security-policy.d.ts +14 -0
  139. package/dist/core/utils/content-security-policy.mjs +39 -0
  140. package/dist/core/utils/entrypoints.d.ts +25 -0
  141. package/dist/core/utils/entrypoints.mjs +31 -0
  142. package/dist/core/utils/eslint.d.ts +1 -0
  143. package/dist/core/utils/eslint.mjs +11 -0
  144. package/dist/core/utils/fs.d.ts +13 -0
  145. package/dist/core/utils/fs.mjs +15 -0
  146. package/dist/core/utils/globals.d.ts +11 -0
  147. package/dist/core/utils/globals.mjs +53 -0
  148. package/dist/core/utils/i18n.d.ts +11 -0
  149. package/dist/core/utils/i18n.mjs +35 -0
  150. package/dist/core/utils/log/index.d.ts +4 -0
  151. package/dist/core/utils/log/index.mjs +4 -0
  152. package/dist/core/utils/log/printBuildSummary.d.ts +2 -0
  153. package/dist/core/utils/log/printBuildSummary.mjs +32 -0
  154. package/dist/core/utils/log/printFileList.d.ts +1 -0
  155. package/dist/core/utils/log/printFileList.mjs +42 -0
  156. package/dist/core/utils/log/printHeader.d.ts +1 -0
  157. package/dist/core/utils/log/printHeader.mjs +7 -0
  158. package/dist/core/utils/log/printTable.d.ts +1 -0
  159. package/dist/core/utils/log/printTable.mjs +22 -0
  160. package/dist/core/utils/manifest.d.ts +44 -0
  161. package/dist/core/utils/manifest.mjs +512 -0
  162. package/dist/core/utils/network.d.ts +7 -0
  163. package/dist/core/utils/network.mjs +38 -0
  164. package/dist/core/utils/package.d.ts +6 -0
  165. package/dist/core/utils/package.mjs +14 -0
  166. package/dist/core/utils/paths.d.ts +11 -0
  167. package/dist/core/utils/paths.mjs +10 -0
  168. package/dist/core/utils/strings.d.ts +14 -0
  169. package/dist/core/utils/strings.mjs +18 -0
  170. package/dist/core/utils/testing/fake-objects.d.ts +4556 -0
  171. package/dist/core/utils/testing/fake-objects.mjs +322 -0
  172. package/dist/core/utils/time.d.ts +9 -0
  173. package/dist/core/utils/time.mjs +17 -0
  174. package/dist/core/utils/transform.d.ts +9 -0
  175. package/dist/core/utils/transform.mjs +17 -0
  176. package/dist/core/utils/types.d.ts +10 -0
  177. package/dist/core/utils/types.mjs +0 -0
  178. package/dist/core/utils/validation.d.ts +15 -0
  179. package/dist/core/utils/validation.mjs +55 -0
  180. package/dist/core/utils/virtual-modules.d.ts +22 -0
  181. package/dist/core/utils/virtual-modules.mjs +14 -0
  182. package/dist/core/utils/wsl.d.ts +4 -0
  183. package/dist/core/utils/wsl.mjs +4 -0
  184. package/dist/core/wxt.d.ts +19 -0
  185. package/dist/core/wxt.mjs +41 -0
  186. package/dist/core/zip.d.ts +7 -0
  187. package/dist/core/zip.mjs +137 -0
  188. package/dist/index.d.ts +4 -79
  189. package/dist/index.mjs +3 -0
  190. package/dist/modules.d.ts +10 -20
  191. package/dist/{chunk-6XSIWUWF.js → modules.mjs} +7 -16
  192. package/dist/sandbox/define-app-config.d.ts +19 -0
  193. package/dist/sandbox/define-app-config.mjs +3 -0
  194. package/dist/sandbox/define-background.d.ts +3 -0
  195. package/dist/sandbox/define-background.mjs +4 -0
  196. package/dist/sandbox/define-content-script.d.ts +2 -0
  197. package/dist/sandbox/define-content-script.mjs +3 -0
  198. package/dist/sandbox/define-unlisted-script.d.ts +3 -0
  199. package/dist/sandbox/define-unlisted-script.mjs +4 -0
  200. package/dist/sandbox/define-wxt-plugin.d.ts +2 -0
  201. package/dist/sandbox/define-wxt-plugin.mjs +3 -0
  202. package/dist/sandbox/dev-server-websocket.d.ts +21 -0
  203. package/dist/sandbox/dev-server-websocket.mjs +37 -0
  204. package/dist/sandbox/index.d.ts +11 -0
  205. package/dist/sandbox/index.mjs +6 -0
  206. package/dist/sandbox/utils/logger.d.ts +9 -0
  207. package/dist/sandbox/utils/logger.mjs +15 -0
  208. package/dist/storage.d.ts +39 -16
  209. package/dist/{storage.js → storage.mjs} +30 -41
  210. package/dist/testing/fake-browser.d.ts +1 -0
  211. package/dist/testing/fake-browser.mjs +1 -0
  212. package/dist/testing/index.d.ts +5 -0
  213. package/dist/testing/index.mjs +2 -0
  214. package/dist/{testing.d.ts → testing/wxt-vitest-plugin.d.ts} +3 -15
  215. package/dist/testing/wxt-vitest-plugin.mjs +26 -0
  216. package/dist/{index-nWRfwAJi.d.cts → types.d.ts} +150 -264
  217. package/dist/types.mjs +0 -0
  218. package/dist/version.d.ts +1 -0
  219. package/dist/version.mjs +1 -0
  220. package/dist/virtual/{background-entrypoint.js → background-entrypoint.mjs} +31 -40
  221. package/dist/virtual/{content-script-isolated-world-entrypoint.js → content-script-isolated-world-entrypoint.mjs} +9 -13
  222. package/dist/virtual/{content-script-main-world-entrypoint.js → content-script-main-world-entrypoint.mjs} +9 -14
  223. package/dist/virtual/mock-browser.mjs +6 -0
  224. package/dist/virtual/{reload-html.js → reload-html.mjs} +8 -9
  225. package/dist/virtual/{unlisted-script-entrypoint.js → unlisted-script-entrypoint.mjs} +8 -12
  226. package/package.json +47 -57
  227. package/dist/browser.d.ts +0 -18
  228. package/dist/browser.js +0 -6
  229. package/dist/chunk-BM6QYGAW.js +0 -1063
  230. package/dist/chunk-FNTE2L27.js +0 -7
  231. package/dist/chunk-FP7RYLVL.js +0 -3617
  232. package/dist/chunk-KPD5J7PZ.js +0 -1065
  233. package/dist/chunk-QGM4M3NI.js +0 -37
  234. package/dist/chunk-SGKCDMVR.js +0 -38
  235. package/dist/cli.d.ts +0 -2
  236. package/dist/cli.js +0 -4438
  237. package/dist/client.js +0 -424
  238. package/dist/define-app-config-bg54F_lV.d.ts +0 -294
  239. package/dist/execa-4UBDUBJZ.js +0 -7244
  240. package/dist/execa-QLUM2B3W.js +0 -7245
  241. package/dist/index-nWRfwAJi.d.ts +0 -1401
  242. package/dist/index.cjs +0 -14473
  243. package/dist/index.d.cts +0 -81
  244. package/dist/index.js +0 -696
  245. package/dist/modules.cjs +0 -96
  246. package/dist/modules.d.cts +0 -119
  247. package/dist/modules.js +0 -17
  248. package/dist/prompt-25QIVJDC.js +0 -755
  249. package/dist/prompt-7BMKNSWS.js +0 -754
  250. package/dist/sandbox.d.ts +0 -16
  251. package/dist/sandbox.js +0 -36
  252. package/dist/storage.cjs +0 -439
  253. package/dist/storage.d.cts +0 -200
  254. package/dist/testing.cjs +0 -2815
  255. package/dist/testing.d.cts +0 -30
  256. package/dist/testing.js +0 -40
  257. package/dist/virtual/mock-browser.js +0 -6
@@ -1,294 +0,0 @@
1
- import { Manifest } from 'webextension-polyfill';
2
-
3
- declare class WxtLocationChangeEvent extends Event {
4
- readonly newUrl: URL;
5
- readonly oldUrl: URL;
6
- static EVENT_NAME: string;
7
- constructor(newUrl: URL, oldUrl: URL);
8
- }
9
-
10
- /**
11
- * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
12
- * Used to detect and stop content script code when the script is invalidated.
13
- *
14
- * It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
15
- * content scripts instead of `window.setTimeout` or `window.setInterval`.
16
- *
17
- * To create context for testing, you can use the class's constructor:
18
- *
19
- * ```ts
20
- * import { ContentScriptContext } from 'wxt/client';
21
- *
22
- * test("storage listener should be removed when context is invalidated", () => {
23
- * const ctx = new ContentScriptContext('test');
24
- * const item = storage.defineItem("local:count", { defaultValue: 0 });
25
- * const watcher = vi.fn();
26
- *
27
- * const unwatch = item.watch(watcher);
28
- * ctx.onInvalidated(unwatch); // Listen for invalidate here
29
- *
30
- * await item.setValue(1);
31
- * expect(watcher).toBeCalledTimes(1);
32
- * expect(watcher).toBeCalledWith(1, 0);
33
- *
34
- * ctx.notifyInvalidated(); // Use this function to invalidate the context
35
- * await item.setValue(2);
36
- * expect(watcher).toBeCalledTimes(1);
37
- * });
38
- * ```
39
- */
40
- declare class ContentScriptContext implements AbortController {
41
- #private;
42
- private readonly contentScriptName;
43
- readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
44
- private static SCRIPT_STARTED_MESSAGE_TYPE;
45
- constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
46
- get signal(): AbortSignal;
47
- abort(reason?: any): void;
48
- get isInvalid(): boolean;
49
- get isValid(): boolean;
50
- /**
51
- * Add a listener that is called when the content script's context is invalidated.
52
- *
53
- * @returns A function to remove the listener.
54
- *
55
- * @example
56
- * browser.runtime.onMessage.addListener(cb);
57
- * const removeInvalidatedListener = ctx.onInvalidated(() => {
58
- * browser.runtime.onMessage.removeListener(cb);
59
- * })
60
- * // ...
61
- * removeInvalidatedListener();
62
- */
63
- onInvalidated(cb: () => void): () => void;
64
- /**
65
- * Return a promise that never resolves. Useful if you have an async function that shouldn't run
66
- * after the context is expired.
67
- *
68
- * @example
69
- * const getValueFromStorage = async () => {
70
- * if (ctx.isInvalid) return ctx.block();
71
- *
72
- * // ...
73
- * }
74
- */
75
- block<T>(): Promise<T>;
76
- /**
77
- * Wrapper around `window.setInterval` that automatically clears the interval when invalidated.
78
- */
79
- setInterval(handler: () => void, timeout?: number): number;
80
- /**
81
- * Wrapper around `window.setTimeout` that automatically clears the interval when invalidated.
82
- */
83
- setTimeout(handler: () => void, timeout?: number): number;
84
- /**
85
- * Wrapper around `window.requestAnimationFrame` that automatically cancels the request when
86
- * invalidated.
87
- */
88
- requestAnimationFrame(callback: FrameRequestCallback): number;
89
- /**
90
- * Wrapper around `window.requestIdleCallback` that automatically cancels the request when
91
- * invalidated.
92
- */
93
- requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number;
94
- /**
95
- * Call `target.addEventListener` and remove the event listener when the context is invalidated.
96
- *
97
- * Includes additional events useful for content scripts:
98
- *
99
- * - `"wxt:locationchange"` - Triggered when HTML5 history mode is used to change URL. Content
100
- * scripts are not reloaded when navigating this way, so this can be used to reset the content
101
- * script state on URL change, or run custom code.
102
- *
103
- * @example
104
- * ctx.addEventListener(document, "visibilitychange", () => {
105
- * // ...
106
- * });
107
- * ctx.addEventListener(document, "wxt:locationchange", () => {
108
- * // ...
109
- * });
110
- */
111
- addEventListener<TTarget extends EventTarget, TType extends keyof WxtContentScriptEventMap>(target: TTarget, type: TType, handler: (event: WxtContentScriptEventMap[TType]) => void, options?: AddEventListenerOptions): void;
112
- /**
113
- * @internal
114
- * Abort the abort controller and execute all `onInvalidated` listeners.
115
- */
116
- notifyInvalidated(): void;
117
- }
118
- interface WxtContentScriptEventMap extends WindowEventMap {
119
- 'wxt:locationchange': WxtLocationChangeEvent;
120
- }
121
-
122
- type TargetBrowser = string;
123
- interface BaseEntrypointOptions {
124
- /**
125
- * List of target browsers to include this entrypoint in. Defaults to being included in all
126
- * builds. Cannot be used with `exclude`. You must choose one of the two options.
127
- *
128
- * @default undefined
129
- */
130
- include?: TargetBrowser[];
131
- /**
132
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
133
- * must choose one of the two options.
134
- *
135
- * @default undefined
136
- */
137
- exclude?: TargetBrowser[];
138
- }
139
- interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
140
- persistent?: PerBrowserOption<boolean>;
141
- /**
142
- * Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
143
- * reduce the overall size of the bundled extension.
144
- *
145
- * When `undefined`, the background is bundled individually into an IIFE format.
146
- *
147
- * @default undefined
148
- */
149
- type?: PerBrowserOption<'module'>;
150
- }
151
- interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
152
- matches: PerBrowserOption<Manifest.ContentScript['matches']>;
153
- /**
154
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
155
- * @default "documentIdle"
156
- */
157
- runAt?: PerBrowserOption<Manifest.ContentScript['run_at']>;
158
- /**
159
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
160
- * @default false
161
- */
162
- matchAboutBlank?: PerBrowserOption<Manifest.ContentScript['match_about_blank']>;
163
- /**
164
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
165
- * @default []
166
- */
167
- excludeMatches?: PerBrowserOption<Manifest.ContentScript['exclude_matches']>;
168
- /**
169
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
170
- * @default []
171
- */
172
- includeGlobs?: PerBrowserOption<Manifest.ContentScript['include_globs']>;
173
- /**
174
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
175
- * @default []
176
- */
177
- excludeGlobs?: PerBrowserOption<Manifest.ContentScript['exclude_globs']>;
178
- /**
179
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
180
- * @default false
181
- */
182
- allFrames?: PerBrowserOption<Manifest.ContentScript['all_frames']>;
183
- /**
184
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
185
- * @default false
186
- */
187
- matchOriginAsFallback?: PerBrowserOption<boolean>;
188
- /**
189
- * Customize how imported/generated styles are injected with the content script. Regardless of the
190
- * mode selected, CSS will always be built and included in the output directory.
191
- *
192
- * - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
193
- * - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
194
- * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
195
- * URL
196
- * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
197
- * calling `createShadowRootUi`
198
- *
199
- * @default "manifest"
200
- */
201
- cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
202
- /**
203
- * Specify how the content script is registered.
204
- *
205
- * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
206
- * manifest. This is the normal and most well known way of registering a content script.
207
- * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
208
- * responsible for using the scripting API to register/execute the content script
209
- * dynamically at runtime.
210
- *
211
- * @default "manifest"
212
- */
213
- registration?: PerBrowserOption<'manifest' | 'runtime'>;
214
- }
215
- interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
216
- /**
217
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
218
- */
219
- world: 'MAIN';
220
- }
221
- interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
222
- /**
223
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
224
- * @default "ISOLATED"
225
- */
226
- world?: 'ISOLATED';
227
- }
228
- interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
229
- /**
230
- * Main function executed when the content script is loaded.
231
- *
232
- * When running a content script with `browser.scripting.executeScript`,
233
- * values returned from this function will be returned in the `executeScript`
234
- * result as well. Otherwise returning a value does nothing.
235
- */
236
- main(ctx: ContentScriptContext): any | Promise<any>;
237
- }
238
- interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
239
- /**
240
- * Main function executed when the content script is loaded.
241
- *
242
- * When running a content script with `browser.scripting.executeScript`,
243
- * values returned from this function will be returned in the `executeScript`
244
- * result as well. Otherwise returning a value does nothing.
245
- */
246
- main(): any | Promise<any>;
247
- }
248
- type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
249
- interface BackgroundDefinition extends BackgroundEntrypointOptions {
250
- /**
251
- * Main function executed when the background script is started. Cannot be async.
252
- */
253
- main(): void;
254
- }
255
- interface UnlistedScriptDefinition extends BaseEntrypointOptions {
256
- /**
257
- * Main function executed when the unlisted script is ran.
258
- *
259
- * When running a content script with `browser.scripting.executeScript`,
260
- * values returned from this function will be returned in the `executeScript`
261
- * result as well. Otherwise returning a value does nothing.
262
- */
263
- main(): any | Promise<any>;
264
- }
265
- /**
266
- * Either a single value or a map of different browsers to the value for that browser.
267
- */
268
- type PerBrowserOption<T> = T | PerBrowserMap<T>;
269
- type PerBrowserMap<T> = {
270
- [browser: TargetBrowser]: T;
271
- };
272
- type WxtPlugin = () => void;
273
-
274
- interface WxtAppConfig {
275
- }
276
- /**
277
- * Runtime app config defined in `<srcDir>/app.config.ts`.
278
- *
279
- * You can add fields to this interface via ["Module Augmentation"](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation):
280
- *
281
- * ```ts
282
- * // app.config.ts
283
- * import 'wxt/sandbox';
284
- *
285
- * declare module "wxt/sandbox" {
286
- * export interface WxtAppConfig {
287
- * analytics: AnalyticsConfig
288
- * }
289
- * }
290
- * ```
291
- */
292
- declare function defineAppConfig(config: WxtAppConfig): WxtAppConfig;
293
-
294
- export { type BackgroundDefinition as B, type ContentScriptDefinition as C, type UnlistedScriptDefinition as U, type WxtPlugin as W, type WxtAppConfig as a, ContentScriptContext as b, defineAppConfig as d };