wxt 0.16.8 → 0.16.10

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.
@@ -493,99 +493,34 @@ interface Logger {
493
493
  level: LogLevel;
494
494
  }
495
495
  interface BaseEntrypointOptions {
496
- include?: TargetBrowser[];
497
- exclude?: TargetBrowser[];
498
- }
499
- interface BaseEntrypoint {
500
496
  /**
501
- * The entrypoint's name. This is the filename or dirname without the type suffix.
502
- *
503
- * Examples:
504
- * - `popup.html` → `popup`
505
- * - `options/index.html` → `options`
506
- * - `named.sandbox.html` → `named`
507
- * - `named.sandbox/index.html` → `named`
508
- * - `sandbox.html` → `sandbox`
509
- * - `sandbox/index.html` → `sandbox`
510
- * - `overlay.content.ts` → `overlay`
511
- * - `overlay.content/index.ts` → `overlay`
497
+ * List of target browsers to include this entrypoint in. Defaults to being included in all
498
+ * builds. Cannot be used with `exclude`. You must choose one of the two options.
512
499
  *
513
- * The name is used when generating an output file:
514
- * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
515
- */
516
- name: string;
517
- /**
518
- * Absolute path to the entrypoint's input file.
519
- */
520
- inputPath: string;
521
- /**
522
- * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
523
- * subdirectory of it.
524
- */
525
- outputDir: string;
526
- options: BaseEntrypointOptions;
527
- skipped: boolean;
528
- }
529
- interface GenericEntrypoint extends BaseEntrypoint {
530
- type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
531
- }
532
- interface BackgroundEntrypoint extends BaseEntrypoint {
533
- type: 'background';
534
- options: {
535
- persistent?: boolean;
536
- type?: 'module';
537
- } & BaseEntrypointOptions;
538
- }
539
- interface ContentScriptEntrypoint extends BaseEntrypoint {
540
- type: 'content-script';
541
- options: Omit<ContentScriptDefinition, 'main'> & BaseEntrypointOptions;
542
- }
543
- interface PopupEntrypoint extends BaseEntrypoint {
544
- type: 'popup';
545
- options: {
546
- /**
547
- * Defaults to "browser_action" to be equivalent to MV3's "action" key
548
- */
549
- mv2Key?: 'browser_action' | 'page_action';
550
- defaultIcon?: Record<string, string>;
551
- defaultTitle?: string;
552
- browserStyle?: boolean;
553
- } & BaseEntrypointOptions;
554
- }
555
- interface OptionsEntrypoint extends BaseEntrypoint {
556
- type: 'options';
557
- options: {
558
- openInTab?: boolean;
559
- browserStyle?: boolean;
560
- chromeStyle?: boolean;
561
- } & BaseEntrypointOptions;
562
- }
563
- type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
564
- type EntrypointGroup = Entrypoint | Entrypoint[];
565
- type OnContentScriptStopped = (cb: () => void) => void;
566
- type ContentScriptDefinition = ContentScriptIsolatedWorldDefinition | ContentScriptMainWorldDefinition;
567
- interface ContentScriptIsolatedWorldDefinition extends ContentScriptBaseDefinition {
568
- /**
569
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
570
- * @default "ISOLATED"
500
+ * @default undefined
571
501
  */
572
- world?: 'ISOLATED';
502
+ include?: TargetBrowser[];
573
503
  /**
574
- * Main function executed when the content script is loaded.
504
+ * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
505
+ * must choose one of the two options.
506
+ *
507
+ * @default undefined
575
508
  */
576
- main(ctx: ContentScriptContext): void | Promise<void>;
509
+ exclude?: TargetBrowser[];
577
510
  }
578
- interface ContentScriptMainWorldDefinition extends ContentScriptBaseDefinition {
579
- /**
580
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
581
- */
582
- world: 'MAIN';
511
+ interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
512
+ persistent?: PerBrowserOption<boolean>;
583
513
  /**
584
- * Main function executed when the content script is loaded.
514
+ * Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
515
+ * reduce the overall size of the bundled extension.
516
+ *
517
+ * When `undefined`, the background is bundled individually into an IIFE format.
518
+ *
519
+ * @default undefined
585
520
  */
586
- main(): void | Promise<void>;
521
+ type?: PerBrowserOption<'module'>;
587
522
  }
588
- interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
523
+ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
589
524
  matches: PerBrowserOption<Manifest.ContentScript['matches']>;
590
525
  /**
591
526
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -631,47 +566,168 @@ interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
631
566
  * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
632
567
  * URL
633
568
  * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
634
- * calling `createContentScriptUi`
569
+ * calling `createShadowRootUi`
635
570
  *
636
571
  * @default "manifest"
637
572
  */
638
573
  cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
574
+ /**
575
+ * Specify how the content script is registered.
576
+ *
577
+ * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
578
+ * manifest. This is the normal and most well known way of registering a content script.
579
+ * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
580
+ * responsible for using the scripting API to register the content script dynamically at
581
+ * runtime.
582
+ *
583
+ * @default "manifest"
584
+ */
585
+ registration?: PerBrowserOption<'manifest' | 'runtime'>;
639
586
  }
640
- interface BackgroundDefinition extends ExcludableEntrypoint {
641
- type?: PerBrowserOption<'module'>;
642
- persistent?: PerBrowserOption<boolean>;
643
- main(): void;
587
+ interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
588
+ /**
589
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
590
+ */
591
+ world: 'MAIN';
644
592
  }
645
- interface UnlistedScriptDefinition extends ExcludableEntrypoint {
593
+ interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
646
594
  /**
647
- * Main function executed when the unlisted script is ran.
595
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
596
+ * @default "ISOLATED"
648
597
  */
649
- main(): void | Promise<void>;
598
+ world?: 'ISOLATED';
650
599
  }
651
- type PerBrowserOption<T> = T | {
652
- [browser: TargetBrowser]: T;
653
- };
654
- interface ExcludableEntrypoint {
600
+ interface PopupEntrypointOptions extends BaseEntrypointOptions {
655
601
  /**
656
- * List of target browsers to include this entrypoint in. Defaults to being included in all
657
- * builds. Cannot be used with `exclude`. You must choose one of the two options.
658
- *
659
- * @default undefined
602
+ * Defaults to "browser_action" to be equivalent to MV3's "action" key
660
603
  */
661
- include?: TargetBrowser[];
604
+ mv2Key?: PerBrowserOption<'browser_action' | 'page_action'>;
605
+ defaultIcon?: Record<string, string>;
606
+ defaultTitle?: PerBrowserOption<string>;
607
+ browserStyle?: PerBrowserOption<boolean>;
608
+ }
609
+ interface OptionsEntrypointOptions extends BaseEntrypointOptions {
610
+ openInTab?: PerBrowserOption<boolean>;
611
+ browserStyle?: PerBrowserOption<boolean>;
612
+ chromeStyle?: PerBrowserOption<boolean>;
613
+ }
614
+ interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
662
615
  /**
663
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
664
- * must choose one of the two options.
616
+ * Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
617
+ * @default false
618
+ */
619
+ openAtInstall?: PerBrowserOption<boolean>;
620
+ /**
621
+ * @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
622
+ */
623
+ browserStyle?: PerBrowserOption<boolean>;
624
+ defaultIcon?: string | Record<string, string>;
625
+ defaultTitle?: PerBrowserOption<string>;
626
+ }
627
+ interface BaseEntrypoint {
628
+ /**
629
+ * The entrypoint's name. This is the filename or dirname without the type suffix.
665
630
  *
666
- * @default undefined
631
+ * Examples:
632
+ * - `popup.html` &rarr; `popup`
633
+ * - `options/index.html` &rarr; `options`
634
+ * - `named.sandbox.html` &rarr; `named`
635
+ * - `named.sandbox/index.html` &rarr; `named`
636
+ * - `sandbox.html` &rarr; `sandbox`
637
+ * - `sandbox/index.html` &rarr; `sandbox`
638
+ * - `overlay.content.ts` &rarr; `overlay`
639
+ * - `overlay.content/index.ts` &rarr; `overlay`
640
+ *
641
+ * The name is used when generating an output file:
642
+ * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
667
643
  */
668
- exclude?: TargetBrowser[];
644
+ name: string;
645
+ /**
646
+ * Absolute path to the entrypoint's input file.
647
+ */
648
+ inputPath: string;
649
+ /**
650
+ * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
651
+ * subdirectory of it.
652
+ */
653
+ outputDir: string;
654
+ skipped: boolean;
669
655
  }
656
+ interface GenericEntrypoint extends BaseEntrypoint {
657
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
658
+ options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
659
+ }
660
+ interface BackgroundEntrypoint extends BaseEntrypoint {
661
+ type: 'background';
662
+ options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
663
+ }
664
+ interface ContentScriptEntrypoint extends BaseEntrypoint {
665
+ type: 'content-script';
666
+ options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
667
+ }
668
+ interface PopupEntrypoint extends BaseEntrypoint {
669
+ type: 'popup';
670
+ options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
671
+ }
672
+ interface OptionsEntrypoint extends BaseEntrypoint {
673
+ type: 'options';
674
+ options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
675
+ }
676
+ interface SidepanelEntrypoint extends BaseEntrypoint {
677
+ type: 'sidepanel';
678
+ options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
679
+ }
680
+ type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
681
+ type EntrypointGroup = Entrypoint | Entrypoint[];
682
+ type OnContentScriptStopped = (cb: () => void) => void;
683
+ interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
684
+ /**
685
+ * Main function executed when the content script is loaded.
686
+ */
687
+ main(ctx: ContentScriptContext): void | Promise<void>;
688
+ }
689
+ interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
690
+ /**
691
+ * Main function executed when the content script is loaded.
692
+ */
693
+ main(): void | Promise<void>;
694
+ }
695
+ type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
696
+ interface BackgroundDefinition extends BackgroundEntrypointOptions {
697
+ /**
698
+ * Main function executed when the background script is started. Cannot be async.
699
+ */
700
+ main(): void;
701
+ }
702
+ interface UnlistedScriptDefinition extends BaseEntrypointOptions {
703
+ /**
704
+ * Main function executed when the unlisted script is ran.
705
+ */
706
+ main(): void | Promise<void>;
707
+ }
708
+ /**
709
+ * Either a single value or a map of different browsers to the value for that browser.
710
+ */
711
+ type PerBrowserOption<T> = T | PerBrowserMap<T>;
712
+ type PerBrowserMap<T> = {
713
+ [browser: TargetBrowser]: T;
714
+ };
715
+ /**
716
+ * Convert `{ key: PerBrowserOption<T> }` to just `{ key: T }`, stripping away the
717
+ * `PerBrowserOption` type for all fields inside the object.
718
+ *
719
+ * A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
720
+ */
721
+ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
722
+ [key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
723
+ } & {
724
+ [key in TOmitted]: T[key];
725
+ };
670
726
  /**
671
727
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
672
728
  * here, they are configured inline.
673
729
  */
674
- type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'sidepanel' | 'sidebar_action'>>;
730
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
675
731
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
676
732
  interface ConfigEnv {
677
733
  mode: string;
@@ -986,4 +1042,4 @@ type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
986
1042
  eslintrc: ResolvedEslintrc;
987
1043
  };
988
1044
 
989
- export type { Wxt as A, BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunner as D, ExtensionRunnerConfig as E, FsCache as F, GenericEntrypoint as G, HookResult as H, InlineConfig as I, EslintGlobalsPropValue as J, Eslintrc as K, Logger as L, ResolvedEslintrc as M, WxtUnimportOptions as N, OutputFile as O, PopupEntrypoint as P, WxtResolvedUnimportOptions as Q, ResolvedConfig as R, ServerInfo as S, TargetBrowser as T, UserConfig as U, VirtualEntrypointType as V, 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, WxtHooks as z };
1045
+ export type { Eslintrc as $, UserManifestFn as A, BuildOutput as B, ContentScriptEntrypoint as C, ConfigEnv as D, ExtensionRunnerConfig as E, WxtBuilder as F, GenericEntrypoint as G, WxtBuilderServer as H, InlineConfig as I, ServerInfo as J, HookResult as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtHooks as N, OutputFile as O, PopupEntrypointOptions as P, Wxt as Q, ResolvedPerBrowserOptions as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ResolvedConfig as V, WxtDevServer as W, FsCache as X, ExtensionRunner as Y, VirtualEntrypointType as Z, EslintGlobalsPropValue as _, WxtViteConfig as a, ResolvedEslintrc as a0, WxtUnimportOptions as a1, WxtResolvedUnimportOptions as a2, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BackgroundEntrypointOptions as g, BaseContentScriptEntrypointOptions as h, IsolatedWorldContentScriptEntrypointOptions as i, OptionsEntrypointOptions as j, BaseEntrypoint as k, BackgroundEntrypoint as l, PopupEntrypoint as m, OptionsEntrypoint as n, SidepanelEntrypoint as o, Entrypoint as p, EntrypointGroup as q, OnContentScriptStopped as r, IsolatedWorldContentScriptDefinition as s, MainWorldContentScriptDefinition as t, ContentScriptDefinition as u, BackgroundDefinition as v, UnlistedScriptDefinition as w, PerBrowserOption as x, PerBrowserMap as y, UserManifest as z };
@@ -493,99 +493,34 @@ interface Logger {
493
493
  level: LogLevel;
494
494
  }
495
495
  interface BaseEntrypointOptions {
496
- include?: TargetBrowser[];
497
- exclude?: TargetBrowser[];
498
- }
499
- interface BaseEntrypoint {
500
496
  /**
501
- * The entrypoint's name. This is the filename or dirname without the type suffix.
502
- *
503
- * Examples:
504
- * - `popup.html` &rarr; `popup`
505
- * - `options/index.html` &rarr; `options`
506
- * - `named.sandbox.html` &rarr; `named`
507
- * - `named.sandbox/index.html` &rarr; `named`
508
- * - `sandbox.html` &rarr; `sandbox`
509
- * - `sandbox/index.html` &rarr; `sandbox`
510
- * - `overlay.content.ts` &rarr; `overlay`
511
- * - `overlay.content/index.ts` &rarr; `overlay`
497
+ * List of target browsers to include this entrypoint in. Defaults to being included in all
498
+ * builds. Cannot be used with `exclude`. You must choose one of the two options.
512
499
  *
513
- * The name is used when generating an output file:
514
- * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
515
- */
516
- name: string;
517
- /**
518
- * Absolute path to the entrypoint's input file.
519
- */
520
- inputPath: string;
521
- /**
522
- * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
523
- * subdirectory of it.
524
- */
525
- outputDir: string;
526
- options: BaseEntrypointOptions;
527
- skipped: boolean;
528
- }
529
- interface GenericEntrypoint extends BaseEntrypoint {
530
- type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'sidepanel' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
531
- }
532
- interface BackgroundEntrypoint extends BaseEntrypoint {
533
- type: 'background';
534
- options: {
535
- persistent?: boolean;
536
- type?: 'module';
537
- } & BaseEntrypointOptions;
538
- }
539
- interface ContentScriptEntrypoint extends BaseEntrypoint {
540
- type: 'content-script';
541
- options: Omit<ContentScriptDefinition, 'main'> & BaseEntrypointOptions;
542
- }
543
- interface PopupEntrypoint extends BaseEntrypoint {
544
- type: 'popup';
545
- options: {
546
- /**
547
- * Defaults to "browser_action" to be equivalent to MV3's "action" key
548
- */
549
- mv2Key?: 'browser_action' | 'page_action';
550
- defaultIcon?: Record<string, string>;
551
- defaultTitle?: string;
552
- browserStyle?: boolean;
553
- } & BaseEntrypointOptions;
554
- }
555
- interface OptionsEntrypoint extends BaseEntrypoint {
556
- type: 'options';
557
- options: {
558
- openInTab?: boolean;
559
- browserStyle?: boolean;
560
- chromeStyle?: boolean;
561
- } & BaseEntrypointOptions;
562
- }
563
- type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint;
564
- type EntrypointGroup = Entrypoint | Entrypoint[];
565
- type OnContentScriptStopped = (cb: () => void) => void;
566
- type ContentScriptDefinition = ContentScriptIsolatedWorldDefinition | ContentScriptMainWorldDefinition;
567
- interface ContentScriptIsolatedWorldDefinition extends ContentScriptBaseDefinition {
568
- /**
569
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
570
- * @default "ISOLATED"
500
+ * @default undefined
571
501
  */
572
- world?: 'ISOLATED';
502
+ include?: TargetBrowser[];
573
503
  /**
574
- * Main function executed when the content script is loaded.
504
+ * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
505
+ * must choose one of the two options.
506
+ *
507
+ * @default undefined
575
508
  */
576
- main(ctx: ContentScriptContext): void | Promise<void>;
509
+ exclude?: TargetBrowser[];
577
510
  }
578
- interface ContentScriptMainWorldDefinition extends ContentScriptBaseDefinition {
579
- /**
580
- * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
581
- */
582
- world: 'MAIN';
511
+ interface BackgroundEntrypointOptions extends BaseEntrypointOptions {
512
+ persistent?: PerBrowserOption<boolean>;
583
513
  /**
584
- * Main function executed when the content script is loaded.
514
+ * Set to `"module"` to output the background entrypoint as ESM. ESM outputs can share chunks and
515
+ * reduce the overall size of the bundled extension.
516
+ *
517
+ * When `undefined`, the background is bundled individually into an IIFE format.
518
+ *
519
+ * @default undefined
585
520
  */
586
- main(): void | Promise<void>;
521
+ type?: PerBrowserOption<'module'>;
587
522
  }
588
- interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
523
+ interface BaseContentScriptEntrypointOptions extends BaseEntrypointOptions {
589
524
  matches: PerBrowserOption<Manifest.ContentScript['matches']>;
590
525
  /**
591
526
  * See https://developer.chrome.com/docs/extensions/mv3/content_scripts/
@@ -631,47 +566,168 @@ interface ContentScriptBaseDefinition extends ExcludableEntrypoint {
631
566
  * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
632
567
  * URL
633
568
  * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
634
- * calling `createContentScriptUi`
569
+ * calling `createShadowRootUi`
635
570
  *
636
571
  * @default "manifest"
637
572
  */
638
573
  cssInjectionMode?: PerBrowserOption<'manifest' | 'manual' | 'ui'>;
574
+ /**
575
+ * Specify how the content script is registered.
576
+ *
577
+ * - `"manifest"`: The content script will be added to the `content_scripts` entry in the
578
+ * manifest. This is the normal and most well known way of registering a content script.
579
+ * - `"runtime"`: The content script's `matches` is added to `host_permissions` and you are
580
+ * responsible for using the scripting API to register the content script dynamically at
581
+ * runtime.
582
+ *
583
+ * @default "manifest"
584
+ */
585
+ registration?: PerBrowserOption<'manifest' | 'runtime'>;
639
586
  }
640
- interface BackgroundDefinition extends ExcludableEntrypoint {
641
- type?: PerBrowserOption<'module'>;
642
- persistent?: PerBrowserOption<boolean>;
643
- main(): void;
587
+ interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
588
+ /**
589
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
590
+ */
591
+ world: 'MAIN';
644
592
  }
645
- interface UnlistedScriptDefinition extends ExcludableEntrypoint {
593
+ interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
646
594
  /**
647
- * Main function executed when the unlisted script is ran.
595
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
596
+ * @default "ISOLATED"
648
597
  */
649
- main(): void | Promise<void>;
598
+ world?: 'ISOLATED';
650
599
  }
651
- type PerBrowserOption<T> = T | {
652
- [browser: TargetBrowser]: T;
653
- };
654
- interface ExcludableEntrypoint {
600
+ interface PopupEntrypointOptions extends BaseEntrypointOptions {
655
601
  /**
656
- * List of target browsers to include this entrypoint in. Defaults to being included in all
657
- * builds. Cannot be used with `exclude`. You must choose one of the two options.
658
- *
659
- * @default undefined
602
+ * Defaults to "browser_action" to be equivalent to MV3's "action" key
660
603
  */
661
- include?: TargetBrowser[];
604
+ mv2Key?: PerBrowserOption<'browser_action' | 'page_action'>;
605
+ defaultIcon?: Record<string, string>;
606
+ defaultTitle?: PerBrowserOption<string>;
607
+ browserStyle?: PerBrowserOption<boolean>;
608
+ }
609
+ interface OptionsEntrypointOptions extends BaseEntrypointOptions {
610
+ openInTab?: PerBrowserOption<boolean>;
611
+ browserStyle?: PerBrowserOption<boolean>;
612
+ chromeStyle?: PerBrowserOption<boolean>;
613
+ }
614
+ interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
662
615
  /**
663
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
664
- * must choose one of the two options.
616
+ * Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
617
+ * @default false
618
+ */
619
+ openAtInstall?: PerBrowserOption<boolean>;
620
+ /**
621
+ * @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
622
+ */
623
+ browserStyle?: PerBrowserOption<boolean>;
624
+ defaultIcon?: string | Record<string, string>;
625
+ defaultTitle?: PerBrowserOption<string>;
626
+ }
627
+ interface BaseEntrypoint {
628
+ /**
629
+ * The entrypoint's name. This is the filename or dirname without the type suffix.
665
630
  *
666
- * @default undefined
631
+ * Examples:
632
+ * - `popup.html` &rarr; `popup`
633
+ * - `options/index.html` &rarr; `options`
634
+ * - `named.sandbox.html` &rarr; `named`
635
+ * - `named.sandbox/index.html` &rarr; `named`
636
+ * - `sandbox.html` &rarr; `sandbox`
637
+ * - `sandbox/index.html` &rarr; `sandbox`
638
+ * - `overlay.content.ts` &rarr; `overlay`
639
+ * - `overlay.content/index.ts` &rarr; `overlay`
640
+ *
641
+ * The name is used when generating an output file:
642
+ * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
667
643
  */
668
- exclude?: TargetBrowser[];
644
+ name: string;
645
+ /**
646
+ * Absolute path to the entrypoint's input file.
647
+ */
648
+ inputPath: string;
649
+ /**
650
+ * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
651
+ * subdirectory of it.
652
+ */
653
+ outputDir: string;
654
+ skipped: boolean;
669
655
  }
656
+ interface GenericEntrypoint extends BaseEntrypoint {
657
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
658
+ options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
659
+ }
660
+ interface BackgroundEntrypoint extends BaseEntrypoint {
661
+ type: 'background';
662
+ options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
663
+ }
664
+ interface ContentScriptEntrypoint extends BaseEntrypoint {
665
+ type: 'content-script';
666
+ options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
667
+ }
668
+ interface PopupEntrypoint extends BaseEntrypoint {
669
+ type: 'popup';
670
+ options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
671
+ }
672
+ interface OptionsEntrypoint extends BaseEntrypoint {
673
+ type: 'options';
674
+ options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
675
+ }
676
+ interface SidepanelEntrypoint extends BaseEntrypoint {
677
+ type: 'sidepanel';
678
+ options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
679
+ }
680
+ type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
681
+ type EntrypointGroup = Entrypoint | Entrypoint[];
682
+ type OnContentScriptStopped = (cb: () => void) => void;
683
+ interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
684
+ /**
685
+ * Main function executed when the content script is loaded.
686
+ */
687
+ main(ctx: ContentScriptContext): void | Promise<void>;
688
+ }
689
+ interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
690
+ /**
691
+ * Main function executed when the content script is loaded.
692
+ */
693
+ main(): void | Promise<void>;
694
+ }
695
+ type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
696
+ interface BackgroundDefinition extends BackgroundEntrypointOptions {
697
+ /**
698
+ * Main function executed when the background script is started. Cannot be async.
699
+ */
700
+ main(): void;
701
+ }
702
+ interface UnlistedScriptDefinition extends BaseEntrypointOptions {
703
+ /**
704
+ * Main function executed when the unlisted script is ran.
705
+ */
706
+ main(): void | Promise<void>;
707
+ }
708
+ /**
709
+ * Either a single value or a map of different browsers to the value for that browser.
710
+ */
711
+ type PerBrowserOption<T> = T | PerBrowserMap<T>;
712
+ type PerBrowserMap<T> = {
713
+ [browser: TargetBrowser]: T;
714
+ };
715
+ /**
716
+ * Convert `{ key: PerBrowserOption<T> }` to just `{ key: T }`, stripping away the
717
+ * `PerBrowserOption` type for all fields inside the object.
718
+ *
719
+ * A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
720
+ */
721
+ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
722
+ [key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
723
+ } & {
724
+ [key in TOmitted]: T[key];
725
+ };
670
726
  /**
671
727
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
672
728
  * here, they are configured inline.
673
729
  */
674
- type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'sidepanel' | 'sidebar_action'>>;
730
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
675
731
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
676
732
  interface ConfigEnv {
677
733
  mode: string;
@@ -986,4 +1042,4 @@ type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
986
1042
  eslintrc: ResolvedEslintrc;
987
1043
  };
988
1044
 
989
- export type { Wxt as A, BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunner as D, ExtensionRunnerConfig as E, FsCache as F, GenericEntrypoint as G, HookResult as H, InlineConfig as I, EslintGlobalsPropValue as J, Eslintrc as K, Logger as L, ResolvedEslintrc as M, WxtUnimportOptions as N, OutputFile as O, PopupEntrypoint as P, WxtResolvedUnimportOptions as Q, ResolvedConfig as R, ServerInfo as S, TargetBrowser as T, UserConfig as U, VirtualEntrypointType as V, 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, WxtHooks as z };
1045
+ export type { Eslintrc as $, UserManifestFn as A, BuildOutput as B, ContentScriptEntrypoint as C, ConfigEnv as D, ExtensionRunnerConfig as E, WxtBuilder as F, GenericEntrypoint as G, WxtBuilderServer as H, InlineConfig as I, ServerInfo as J, HookResult as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtHooks as N, OutputFile as O, PopupEntrypointOptions as P, Wxt as Q, ResolvedPerBrowserOptions as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ResolvedConfig as V, WxtDevServer as W, FsCache as X, ExtensionRunner as Y, VirtualEntrypointType as Z, EslintGlobalsPropValue as _, WxtViteConfig as a, ResolvedEslintrc as a0, WxtUnimportOptions as a1, WxtResolvedUnimportOptions as a2, OutputChunk as b, OutputAsset as c, BuildStepOutput as d, TargetManifestVersion as e, BaseEntrypointOptions as f, BackgroundEntrypointOptions as g, BaseContentScriptEntrypointOptions as h, IsolatedWorldContentScriptEntrypointOptions as i, OptionsEntrypointOptions as j, BaseEntrypoint as k, BackgroundEntrypoint as l, PopupEntrypoint as m, OptionsEntrypoint as n, SidepanelEntrypoint as o, Entrypoint as p, EntrypointGroup as q, OnContentScriptStopped as r, IsolatedWorldContentScriptDefinition as s, MainWorldContentScriptDefinition as t, ContentScriptDefinition as u, BackgroundDefinition as v, UnlistedScriptDefinition as w, PerBrowserOption as x, PerBrowserMap as y, UserManifest as z };