wxt 0.11.2 → 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,10 +1,7 @@
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';
9
6
  /**
10
7
  * ![Visualization of different append modes](https://wxt.dev/content-script-ui-append.png)
@@ -41,7 +38,7 @@ interface ContentScriptModalPositioningOptions {
41
38
  /**
42
39
  * Choose between `"inline"`, `"overlay"`, or `"modal" `types.
43
40
  *
44
- * ![Visualization of different types](https://wxt.dev/content-script-ui-types.png)
41
+ * ![Visualization of different types](https://wxt.dev/content-script-ui-type.png)
45
42
  */
46
43
  type ContentScriptPositioningOptions = ContentScriptInlinePositioningOptions | ContentScriptOverlayPositioningOptions | ContentScriptModalPositioningOptions;
47
44
  interface ContentScriptAnchoredOptions {
@@ -192,6 +189,4 @@ type ContentScriptIframeOptions = ContentScriptPositioningOptions & ContentScrip
192
189
  page: wxt_browser.PublicPath;
193
190
  };
194
191
 
195
- declare function defineContentScript(definition: ContentScriptDefinition): ContentScriptDefinition;
196
-
197
- 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, 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 };