wxt 0.11.1 → 0.12.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.
package/dist/client.d.ts CHANGED
@@ -1,15 +1,16 @@
1
- import { B as BackgroundDefinition, C as ContentScriptContext, a as ContentScriptDefinition } from './external-PmmO6xnl.js';
1
+ import { a as ContentScriptContext } from './external-TYmXqKVq.js';
2
2
  import * as wxt_browser from 'wxt/browser';
3
3
  import 'webextension-polyfill';
4
4
 
5
- declare function defineBackground(main: () => void): BackgroundDefinition;
6
- declare function defineBackground(definition: BackgroundDefinition): BackgroundDefinition;
7
-
8
5
  type ContentScriptOverlayAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
6
+ /**
7
+ * ![Visualization of different append modes](https://wxt.dev/content-script-ui-append.png)
8
+ */
9
9
  type ContentScriptAppendMode = 'last' | 'first' | 'replace' | 'before' | 'after' | ((anchor: Element, ui: Element) => void);
10
- type ContentScriptPositioningOptions = {
10
+ interface ContentScriptInlinePositioningOptions {
11
11
  type: 'inline';
12
- } | {
12
+ }
13
+ interface ContentScriptOverlayPositioningOptions {
13
14
  type: 'overlay';
14
15
  /**
15
16
  * The `z-index` used on the `shadowHost`. Set to a positive number to show your UI over website
@@ -20,17 +21,26 @@ type ContentScriptPositioningOptions = {
20
21
  * When using `type: "overlay"`, the mounted element is 0px by 0px in size. Alignment specifies
21
22
  * which corner is aligned with that 0x0 pixel space.
22
23
  *
24
+ * ![Visualization of alignment options](https://wxt.dev/content-script-ui-alignment.png)
25
+ *
23
26
  * @default "top-left"
24
27
  */
25
28
  alignment?: ContentScriptOverlayAlignment;
26
- } | {
29
+ }
30
+ interface ContentScriptModalPositioningOptions {
27
31
  type: 'modal';
28
32
  /**
29
33
  * The `z-index` used on the `shadowHost`. Set to a positive number to show your UI over website
30
34
  * content.
31
35
  */
32
36
  zIndex?: number;
33
- };
37
+ }
38
+ /**
39
+ * Choose between `"inline"`, `"overlay"`, or `"modal" `types.
40
+ *
41
+ * ![Visualization of different types](https://wxt.dev/content-script-ui-type.png)
42
+ */
43
+ type ContentScriptPositioningOptions = ContentScriptInlinePositioningOptions | ContentScriptOverlayPositioningOptions | ContentScriptModalPositioningOptions;
34
44
  interface ContentScriptAnchoredOptions {
35
45
  /**
36
46
  * A CSS selector, element, or function that returns one of the two. Along with `append`, the
@@ -54,7 +64,7 @@ interface ContentScriptAnchoredOptions {
54
64
  * Utility for mounting content script UI's with isolated styles. Automatically removed from the DOM
55
65
  * when the content script's context is invalidated.
56
66
  *
57
- * See https://wxt.dev/entrypoints/content-scripts.html#ui for full documentation.
67
+ * See https://wxt.dev/guide/content-script-ui.html for full documentation.
58
68
  *
59
69
  * @example
60
70
  * // entrypoints/example-ui.content/index.ts
@@ -129,7 +139,7 @@ type ContentScriptUiOptions<TApp> = ContentScriptPositioningOptions & ContentScr
129
139
  * set `cssInjectionMode: "ui"`, the imported CSS will be included automatically. You do not need
130
140
  * to pass those styles in here. This is for any additional styles not in the imported CSS.
131
141
  *
132
- * See https://wxt.dev/entrypoints/content-scripts.html#ui for more info.
142
+ * See https://wxt.dev/guide/content-script-ui.html for more info.
133
143
  */
134
144
  css?: string;
135
145
  };
@@ -179,6 +189,4 @@ type ContentScriptIframeOptions = ContentScriptPositioningOptions & ContentScrip
179
189
  page: wxt_browser.PublicPath;
180
190
  };
181
191
 
182
- declare function defineContentScript(definition: ContentScriptDefinition): ContentScriptDefinition;
183
-
184
- export { ContentScriptContext, type ContentScriptIframe, type ContentScriptIframeOptions, type ContentScriptUi, type ContentScriptUiOptions, createContentScriptIframe, createContentScriptUi, defineBackground, defineContentScript };
192
+ export { type ContentScriptAnchoredOptions, type ContentScriptAppendMode, ContentScriptContext, type ContentScriptIframe, type ContentScriptIframeOptions, type ContentScriptInlinePositioningOptions, type ContentScriptModalPositioningOptions, type ContentScriptOverlayAlignment, type ContentScriptOverlayPositioningOptions, type ContentScriptPositioningOptions, type ContentScriptUi, type ContentScriptUiOptions, createContentScriptIframe, createContentScriptUi };
package/dist/client.js CHANGED
@@ -2,13 +2,6 @@ import {
2
2
  browser
3
3
  } from "./chunk-FNTE2L27.js";
4
4
 
5
- // src/client/define-background.ts
6
- function defineBackground(arg) {
7
- if (typeof arg === "function")
8
- return { main: arg };
9
- return arg;
10
- }
11
-
12
5
  // src/client/utils/logger.ts
13
6
  function print(method, ...args) {
14
7
  if (import.meta.env.MODE === "production")
@@ -393,15 +386,8 @@ function createContentScriptIframe(ctx, options) {
393
386
  remove
394
387
  };
395
388
  }
396
-
397
- // src/client/content-scripts/define-content-script.ts
398
- function defineContentScript(definition) {
399
- return definition;
400
- }
401
389
  export {
402
390
  ContentScriptContext,
403
391
  createContentScriptIframe,
404
- createContentScriptUi,
405
- defineBackground,
406
- defineContentScript
392
+ createContentScriptUi
407
393
  };
@@ -97,7 +97,29 @@ interface WxtContentScriptEventMap extends WindowEventMap {
97
97
  }
98
98
 
99
99
  type TargetBrowser = string;
100
- interface ContentScriptDefinition extends ExcludableEntrypoint {
100
+ type ContentScriptDefinition = ContentScriptIsolatedWorldDefinition | ContentScriptMainWorldDefinition;
101
+ interface ContentScriptIsolatedWorldDefinition extends ContentScriptBaseDefinition {
102
+ /**
103
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
104
+ * @default "ISOLATED"
105
+ */
106
+ world?: 'ISOLATED';
107
+ /**
108
+ * Main function executed when the content script is loaded.
109
+ */
110
+ main(ctx: ContentScriptContext): void | Promise<void>;
111
+ }
112
+ interface ContentScriptMainWorldDefinition extends ContentScriptBaseDefinition {
113
+ /**
114
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
115
+ */
116
+ world: 'MAIN';
117
+ /**
118
+ * Main function executed when the content script is loaded.
119
+ */
120
+ main(): void | Promise<void>;
121
+ }
122
+ interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
101
123
  matches: PerBrowserOption<Manifest.ContentScript['matches']>;
102
124
  /**
103
125
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -134,11 +156,6 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
134
156
  * @default false
135
157
  */
136
158
  matchOriginAsFallback?: PerBrowserOption<boolean>;
137
- /**
138
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
139
- * @default "ISOLATED"
140
- */
141
- world?: PerBrowserOption<'ISOLATED' | 'MAIN'>;
142
159
  /**
143
160
  * Customize how imported/generated styles are injected with the content script. Regardless of the
144
161
  * mode selected, CSS will always be built and included in the output directory.
@@ -153,10 +170,6 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
153
170
  * @default "manifest"
154
171
  */
155
172
  cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
156
- /**
157
- * Main function executed when the content script is loaded.
158
- */
159
- main(ctx: ContentScriptContext): void | Promise<void>;
160
173
  }
161
174
  interface BackgroundDefinition extends ExcludableEntrypoint {
162
175
  type?: PerBrowserOption<'module'>;
@@ -189,4 +202,4 @@ interface ExcludableEntrypoint {
189
202
  exclude?: TargetBrowser[];
190
203
  }
191
204
 
192
- export { type BackgroundDefinition as B, ContentScriptContext as C, type UnlistedScriptDefinition as U, type ContentScriptDefinition as a };
205
+ export { type BackgroundDefinition as B, type ContentScriptDefinition as C, type UnlistedScriptDefinition as U, ContentScriptContext as a };
@@ -483,7 +483,29 @@ interface OptionsEntrypoint extends BaseEntrypoint {
483
483
  type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
484
484
  type EntrypointGroup = Entrypoint | Entrypoint[];
485
485
  type OnContentScriptStopped = (cb: () => void) => void;
486
- interface ContentScriptDefinition extends ExcludableEntrypoint {
486
+ type ContentScriptDefinition = ContentScriptIsolatedWorldDefinition | ContentScriptMainWorldDefinition;
487
+ interface ContentScriptIsolatedWorldDefinition extends ContentScriptBaseDefinition {
488
+ /**
489
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
490
+ * @default "ISOLATED"
491
+ */
492
+ world?: 'ISOLATED';
493
+ /**
494
+ * Main function executed when the content script is loaded.
495
+ */
496
+ main(ctx: ContentScriptContext): void | Promise<void>;
497
+ }
498
+ interface ContentScriptMainWorldDefinition extends ContentScriptBaseDefinition {
499
+ /**
500
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
501
+ */
502
+ world: 'MAIN';
503
+ /**
504
+ * Main function executed when the content script is loaded.
505
+ */
506
+ main(): void | Promise<void>;
507
+ }
508
+ interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
487
509
  matches: PerBrowserOption<Manifest.ContentScript['matches']>;
488
510
  /**
489
511
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -520,11 +542,6 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
520
542
  * @default false
521
543
  */
522
544
  matchOriginAsFallback?: PerBrowserOption<boolean>;
523
- /**
524
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
525
- * @default "ISOLATED"
526
- */
527
- world?: PerBrowserOption<'ISOLATED' | 'MAIN'>;
528
545
  /**
529
546
  * Customize how imported/generated styles are injected with the content script. Regardless of the
530
547
  * mode selected, CSS will always be built and included in the output directory.
@@ -539,10 +556,6 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
539
556
  * @default "manifest"
540
557
  */
541
558
  cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
542
- /**
543
- * Main function executed when the content script is loaded.
544
- */
545
- main(ctx: ContentScriptContext): void | Promise<void>;
546
559
  }
547
560
  interface BackgroundDefinition extends ExcludableEntrypoint {
548
561
  type?: PerBrowserOption<'module'>;
@@ -707,4 +720,4 @@ interface ServerInfo {
707
720
  origin: string;
708
721
  }
709
722
 
710
- export type { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ServerInfo as S, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, BackgroundDefinition as n, UnlistedScriptDefinition as o, PerBrowserOption as p, ExcludableEntrypoint as q, UserManifest as r, UserManifestFn as s, ConfigEnv as t, WxtBuilder as u, WxtBuilderServer as v };
723
+ export type { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ServerInfo as S, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, ContentScriptIsolatedWorldDefinition as n, ContentScriptMainWorldDefinition as o, ContentScriptBaseDefinition as p, BackgroundDefinition as q, UnlistedScriptDefinition as r, PerBrowserOption as s, ExcludableEntrypoint as t, UserManifest as u, UserManifestFn as v, ConfigEnv as w, WxtBuilder as x, WxtBuilderServer as y };
@@ -483,7 +483,29 @@ interface OptionsEntrypoint extends BaseEntrypoint {
483
483
  type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
484
484
  type EntrypointGroup = Entrypoint | Entrypoint[];
485
485
  type OnContentScriptStopped = (cb: () => void) => void;
486
- interface ContentScriptDefinition extends ExcludableEntrypoint {
486
+ type ContentScriptDefinition = ContentScriptIsolatedWorldDefinition | ContentScriptMainWorldDefinition;
487
+ interface ContentScriptIsolatedWorldDefinition extends ContentScriptBaseDefinition {
488
+ /**
489
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
490
+ * @default "ISOLATED"
491
+ */
492
+ world?: 'ISOLATED';
493
+ /**
494
+ * Main function executed when the content script is loaded.
495
+ */
496
+ main(ctx: ContentScriptContext): void | Promise<void>;
497
+ }
498
+ interface ContentScriptMainWorldDefinition extends ContentScriptBaseDefinition {
499
+ /**
500
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
501
+ */
502
+ world: 'MAIN';
503
+ /**
504
+ * Main function executed when the content script is loaded.
505
+ */
506
+ main(): void | Promise<void>;
507
+ }
508
+ interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
487
509
  matches: PerBrowserOption<Manifest.ContentScript['matches']>;
488
510
  /**
489
511
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -520,11 +542,6 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
520
542
  * @default false
521
543
  */
522
544
  matchOriginAsFallback?: PerBrowserOption<boolean>;
523
- /**
524
- * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
525
- * @default "ISOLATED"
526
- */
527
- world?: PerBrowserOption<'ISOLATED' | 'MAIN'>;
528
545
  /**
529
546
  * Customize how imported/generated styles are injected with the content script. Regardless of the
530
547
  * mode selected, CSS will always be built and included in the output directory.
@@ -539,10 +556,6 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
539
556
  * @default "manifest"
540
557
  */
541
558
  cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
542
- /**
543
- * Main function executed when the content script is loaded.
544
- */
545
- main(ctx: ContentScriptContext): void | Promise<void>;
546
559
  }
547
560
  interface BackgroundDefinition extends ExcludableEntrypoint {
548
561
  type?: PerBrowserOption<'module'>;
@@ -707,4 +720,4 @@ interface ServerInfo {
707
720
  origin: string;
708
721
  }
709
722
 
710
- export type { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ServerInfo as S, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, BackgroundDefinition as n, UnlistedScriptDefinition as o, PerBrowserOption as p, ExcludableEntrypoint as q, UserManifest as r, UserManifestFn as s, ConfigEnv as t, WxtBuilder as u, WxtBuilderServer as v };
723
+ export type { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ServerInfo as S, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtViteConfig as a, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BaseEntrypoint as g, BackgroundEntrypoint as h, OptionsEntrypoint as i, Entrypoint as j, EntrypointGroup as k, OnContentScriptStopped as l, ContentScriptDefinition as m, ContentScriptIsolatedWorldDefinition as n, ContentScriptMainWorldDefinition as o, ContentScriptBaseDefinition as p, BackgroundDefinition as q, UnlistedScriptDefinition as r, PerBrowserOption as s, ExcludableEntrypoint as t, UserManifest as u, UserManifestFn as v, ConfigEnv as w, WxtBuilder as x, WxtBuilderServer as y };