1
+ import type { ManifestContentScript } from "./core/utils/types" ;
2
+ import type { Browser } from '@wxt-dev/browser' ;
3
+
4
+ export type TargetBrowser = string ;
5
+
6
+ /**
7
+ * Either a single value or a map of different browsers to the value for that browser.
8
+ */
9
+ export type PerBrowserOption < T > = T | PerBrowserMap < T > ;
10
+ export type PerBrowserMap < T > = { [ browser : TargetBrowser ] : T } ;
11
+
12
+ export interface BaseEntrypointOptions {
13
+ /**
14
+ * List of target browsers to include this entrypoint in. Defaults to being included in all
15
+ * builds. Cannot be used with `exclude`. You must choose one of the two options.
16
+ *
17
+ * @default undefined
18
+ */
19
+ include ?: TargetBrowser [ ] ;
20
+ /**
21
+ * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
22
+ * must choose one of the two options.
23
+ *
24
+ * @default undefined
25
+ */
26
+ exclude ?: TargetBrowser [ ] ;
27
+ }
28
+
29
+ export interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
30
+ persistent ?: PerBrowserOption < boolean > ;
31
+ /**
32
+ * Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
33
+ * reduce the overall size of the bundled extension.
34
+ *
35
+ * When `undefined`, the background is bundled individually into an IIFE format.
36
+ *
37
+ * @default undefined
38
+ */
39
+ type ?: PerBrowserOption < 'module' > ;
40
+ }
41
+
42
+ export interface BaseContentScriptEntrypointOptions
43
+ extends BaseEntrypointOptions {
44
+ matches ?: PerBrowserOption < NonNullable < ManifestContentScript [ 'matches' ] > > ;
45
+ /**
46
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
47
+ * @default "documentIdle"
48
+ */
49
+ runAt ?: PerBrowserOption < Browser . scripting . RegisteredContentScript [ 'runAt' ] > ;
50
+ /**
51
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
52
+ * @default false
53
+ */
54
+ matchAboutBlank ?: PerBrowserOption <
55
+ ManifestContentScript [ 'match_about_blank' ]
56
+ > ;
57
+ /**
58
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
59
+ * @default []
60
+ */
61
+ excludeMatches ?: PerBrowserOption < ManifestContentScript [ 'exclude_matches' ] > ;
62
+ /**
63
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
64
+ * @default []
65
+ */
66
+ includeGlobs ?: PerBrowserOption < ManifestContentScript [ 'include_globs' ] > ;
67
+ /**
68
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
69
+ * @default []
70
+ */
71
+ excludeGlobs ?: PerBrowserOption < ManifestContentScript [ 'exclude_globs' ] > ;
72
+ /**
73
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
74
+ * @default false
75
+ */
76
+ allFrames ?: PerBrowserOption < ManifestContentScript [ 'all_frames' ] > ;
77
+ /**
78
+ * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
79
+ * @default false
80
+ */
81
+ matchOriginAsFallback ?: PerBrowserOption < boolean > ;
82
+ /**
83
+ * Customize how imported/generated styles are injected with the content script. Regardless of the
84
+ * mode selected, CSS will always be built and included in the output directory.
85
+ *
86
+ * - `"manifest"` - Include the CSS in the manifest, under the content script's `css` array.
87
+ * - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
88
+ * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
89
+ * URL
90
+ * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
91
+ * calling `createShadowRootUi`
92
+ *
93
+ * @default "manifest"
94
+ */
95
+ cssInjectionMode ?: PerBrowserOption < 'manifest' | 'manual' | 'ui' > ;
96
+ /**
97
+ * Specify how the content script is registered.
98
+ *
99
+ * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
100
+ * manifest. This is the normal and most well known way of registering a content script.
101
+ * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
102
+ * responsible for using the scripting API to register/execute the content script
103
+ * dynamically at runtime.
104
+ *
105
+ * @default "manifest"
106
+ */
107
+ registration ?: PerBrowserOption < 'manifest' | 'runtime' > ;
108
+ }
109
+
110
+ export interface MainWorldContentScriptEntrypointOptions
111
+ extends BaseContentScriptEntrypointOptions {
112
+ /**
113
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
114
+ */
115
+ world : 'MAIN' ;
116
+ }
117
+
118
+ export interface IsolatedWorldContentScriptEntrypointOptions
119
+ extends BaseContentScriptEntrypointOptions {
120
+ /**
121
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
122
+ * @default "ISOLATED"
123
+ */
124
+ world ?: 'ISOLATED' ;
125
+ }
126
+
127
+ export interface PopupEntrypointOptions extends BaseEntrypointOptions {
128
+ /**
129
+ * Defaults to "browser_action" to be equivalent to MV3's "action" key
130
+ */
131
+ mv2Key ?: PerBrowserOption < 'browser_action' | 'page_action' > ;
132
+ defaultIcon ?: Record < string , string > ;
133
+ defaultTitle ?: PerBrowserOption < string > ;
134
+ browserStyle ?: PerBrowserOption < boolean > ;
135
+ }
136
+
137
+ export interface OptionsEntrypointOptions extends BaseEntrypointOptions {
138
+ openInTab ?: PerBrowserOption < boolean > ;
139
+ browserStyle ?: PerBrowserOption < boolean > ;
140
+ chromeStyle ?: PerBrowserOption < boolean > ;
141
+ }
142
+
143
+ export interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
144
+ /**
145
+ * Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
146
+ * @default false
147
+ */
148
+ openAtInstall ?: PerBrowserOption < boolean > ;
149
+ /**
150
+ * @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
151
+ */
152
+ browserStyle ?: PerBrowserOption < boolean > ;
153
+ defaultIcon ?: string | Record < string , string > ;
154
+ defaultTitle ?: PerBrowserOption < string > ;
155
+ }
0 commit comments