wxt 0.16.8 → 0.16.9

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,156 @@ 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'>;
639
574
  }
640
- interface BackgroundDefinition extends ExcludableEntrypoint {
641
- type?: PerBrowserOption<'module'>;
642
- persistent?: PerBrowserOption<boolean>;
643
- main(): void;
575
+ interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
576
+ /**
577
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
578
+ */
579
+ world: 'MAIN';
644
580
  }
645
- interface UnlistedScriptDefinition extends ExcludableEntrypoint {
581
+ interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
646
582
  /**
647
- * Main function executed when the unlisted script is ran.
583
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
584
+ * @default "ISOLATED"
648
585
  */
649
- main(): void | Promise<void>;
586
+ world?: 'ISOLATED';
650
587
  }
651
- type PerBrowserOption<T> = T | {
652
- [browser: TargetBrowser]: T;
653
- };
654
- interface ExcludableEntrypoint {
588
+ interface PopupEntrypointOptions extends BaseEntrypointOptions {
655
589
  /**
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
590
+ * Defaults to "browser_action" to be equivalent to MV3's "action" key
660
591
  */
661
- include?: TargetBrowser[];
592
+ mv2Key?: PerBrowserOption<'browser_action' | 'page_action'>;
593
+ defaultIcon?: Record<string, string>;
594
+ defaultTitle?: PerBrowserOption<string>;
595
+ browserStyle?: PerBrowserOption<boolean>;
596
+ }
597
+ interface OptionsEntrypointOptions extends BaseEntrypointOptions {
598
+ openInTab?: PerBrowserOption<boolean>;
599
+ browserStyle?: PerBrowserOption<boolean>;
600
+ chromeStyle?: PerBrowserOption<boolean>;
601
+ }
602
+ interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
662
603
  /**
663
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
664
- * must choose one of the two options.
604
+ * Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
605
+ * @default false
606
+ */
607
+ openAtInstall?: PerBrowserOption<boolean>;
608
+ /**
609
+ * @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
610
+ */
611
+ browserStyle?: PerBrowserOption<boolean>;
612
+ defaultIcon?: string | Record<string, string>;
613
+ defaultTitle?: PerBrowserOption<string>;
614
+ }
615
+ interface BaseEntrypoint {
616
+ /**
617
+ * The entrypoint's name. This is the filename or dirname without the type suffix.
665
618
  *
666
- * @default undefined
619
+ * Examples:
620
+ * - `popup.html` &rarr; `popup`
621
+ * - `options/index.html` &rarr; `options`
622
+ * - `named.sandbox.html` &rarr; `named`
623
+ * - `named.sandbox/index.html` &rarr; `named`
624
+ * - `sandbox.html` &rarr; `sandbox`
625
+ * - `sandbox/index.html` &rarr; `sandbox`
626
+ * - `overlay.content.ts` &rarr; `overlay`
627
+ * - `overlay.content/index.ts` &rarr; `overlay`
628
+ *
629
+ * The name is used when generating an output file:
630
+ * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
667
631
  */
668
- exclude?: TargetBrowser[];
632
+ name: string;
633
+ /**
634
+ * Absolute path to the entrypoint's input file.
635
+ */
636
+ inputPath: string;
637
+ /**
638
+ * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
639
+ * subdirectory of it.
640
+ */
641
+ outputDir: string;
642
+ skipped: boolean;
669
643
  }
644
+ interface GenericEntrypoint extends BaseEntrypoint {
645
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
646
+ options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
647
+ }
648
+ interface BackgroundEntrypoint extends BaseEntrypoint {
649
+ type: 'background';
650
+ options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
651
+ }
652
+ interface ContentScriptEntrypoint extends BaseEntrypoint {
653
+ type: 'content-script';
654
+ options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
655
+ }
656
+ interface PopupEntrypoint extends BaseEntrypoint {
657
+ type: 'popup';
658
+ options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
659
+ }
660
+ interface OptionsEntrypoint extends BaseEntrypoint {
661
+ type: 'options';
662
+ options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
663
+ }
664
+ interface SidepanelEntrypoint extends BaseEntrypoint {
665
+ type: 'sidepanel';
666
+ options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
667
+ }
668
+ type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
669
+ type EntrypointGroup = Entrypoint | Entrypoint[];
670
+ type OnContentScriptStopped = (cb: () => void) => void;
671
+ interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
672
+ /**
673
+ * Main function executed when the content script is loaded.
674
+ */
675
+ main(ctx: ContentScriptContext): void | Promise<void>;
676
+ }
677
+ interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
678
+ /**
679
+ * Main function executed when the content script is loaded.
680
+ */
681
+ main(): void | Promise<void>;
682
+ }
683
+ type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
684
+ interface BackgroundDefinition extends BackgroundEntrypointOptions {
685
+ /**
686
+ * Main function executed when the background script is started. Cannot be async.
687
+ */
688
+ main(): void;
689
+ }
690
+ interface UnlistedScriptDefinition extends BaseEntrypointOptions {
691
+ /**
692
+ * Main function executed when the unlisted script is ran.
693
+ */
694
+ main(): void | Promise<void>;
695
+ }
696
+ /**
697
+ * Either a single value or a map of different browsers to the value for that browser.
698
+ */
699
+ type PerBrowserOption<T> = T | PerBrowserMap<T>;
700
+ type PerBrowserMap<T> = {
701
+ [browser: TargetBrowser]: T;
702
+ };
703
+ /**
704
+ * Convert `{ key: PerBrowserOption<T> }` to just `{ key: T }`, stripping away the
705
+ * `PerBrowserOption` type for all fields inside the object.
706
+ *
707
+ * A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
708
+ */
709
+ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
710
+ [key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
711
+ } & {
712
+ [key in TOmitted]: T[key];
713
+ };
670
714
  /**
671
715
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
672
716
  * here, they are configured inline.
673
717
  */
674
- type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'sidepanel' | 'sidebar_action'>>;
718
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
675
719
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
676
720
  interface ConfigEnv {
677
721
  mode: string;
@@ -986,4 +1030,4 @@ type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
986
1030
  eslintrc: ResolvedEslintrc;
987
1031
  };
988
1032
 
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 };
1033
+ 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,156 @@ 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'>;
639
574
  }
640
- interface BackgroundDefinition extends ExcludableEntrypoint {
641
- type?: PerBrowserOption<'module'>;
642
- persistent?: PerBrowserOption<boolean>;
643
- main(): void;
575
+ interface MainWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
576
+ /**
577
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
578
+ */
579
+ world: 'MAIN';
644
580
  }
645
- interface UnlistedScriptDefinition extends ExcludableEntrypoint {
581
+ interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
646
582
  /**
647
- * Main function executed when the unlisted script is ran.
583
+ * See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
584
+ * @default "ISOLATED"
648
585
  */
649
- main(): void | Promise<void>;
586
+ world?: 'ISOLATED';
650
587
  }
651
- type PerBrowserOption<T> = T | {
652
- [browser: TargetBrowser]: T;
653
- };
654
- interface ExcludableEntrypoint {
588
+ interface PopupEntrypointOptions extends BaseEntrypointOptions {
655
589
  /**
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
590
+ * Defaults to "browser_action" to be equivalent to MV3's "action" key
660
591
  */
661
- include?: TargetBrowser[];
592
+ mv2Key?: PerBrowserOption<'browser_action' | 'page_action'>;
593
+ defaultIcon?: Record<string, string>;
594
+ defaultTitle?: PerBrowserOption<string>;
595
+ browserStyle?: PerBrowserOption<boolean>;
596
+ }
597
+ interface OptionsEntrypointOptions extends BaseEntrypointOptions {
598
+ openInTab?: PerBrowserOption<boolean>;
599
+ browserStyle?: PerBrowserOption<boolean>;
600
+ chromeStyle?: PerBrowserOption<boolean>;
601
+ }
602
+ interface SidepanelEntrypointOptions extends BaseEntrypointOptions {
662
603
  /**
663
- * List of target browsers to exclude this entrypoint from. Cannot be used with `include`. You
664
- * must choose one of the two options.
604
+ * Firefox only. See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
605
+ * @default false
606
+ */
607
+ openAtInstall?: PerBrowserOption<boolean>;
608
+ /**
609
+ * @deprecated See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/sidebar_action#syntax
610
+ */
611
+ browserStyle?: PerBrowserOption<boolean>;
612
+ defaultIcon?: string | Record<string, string>;
613
+ defaultTitle?: PerBrowserOption<string>;
614
+ }
615
+ interface BaseEntrypoint {
616
+ /**
617
+ * The entrypoint's name. This is the filename or dirname without the type suffix.
665
618
  *
666
- * @default undefined
619
+ * Examples:
620
+ * - `popup.html` &rarr; `popup`
621
+ * - `options/index.html` &rarr; `options`
622
+ * - `named.sandbox.html` &rarr; `named`
623
+ * - `named.sandbox/index.html` &rarr; `named`
624
+ * - `sandbox.html` &rarr; `sandbox`
625
+ * - `sandbox/index.html` &rarr; `sandbox`
626
+ * - `overlay.content.ts` &rarr; `overlay`
627
+ * - `overlay.content/index.ts` &rarr; `overlay`
628
+ *
629
+ * The name is used when generating an output file:
630
+ * `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
667
631
  */
668
- exclude?: TargetBrowser[];
632
+ name: string;
633
+ /**
634
+ * Absolute path to the entrypoint's input file.
635
+ */
636
+ inputPath: string;
637
+ /**
638
+ * Absolute path to the entrypoint's output directory. Can be the`InternalConfg.outDir` or a
639
+ * subdirectory of it.
640
+ */
641
+ outputDir: string;
642
+ skipped: boolean;
669
643
  }
644
+ interface GenericEntrypoint extends BaseEntrypoint {
645
+ type: 'sandbox' | 'bookmarks' | 'history' | 'newtab' | 'devtools' | 'unlisted-page' | 'unlisted-script' | 'unlisted-style' | 'content-script-style';
646
+ options: ResolvedPerBrowserOptions<BaseEntrypointOptions>;
647
+ }
648
+ interface BackgroundEntrypoint extends BaseEntrypoint {
649
+ type: 'background';
650
+ options: ResolvedPerBrowserOptions<BackgroundEntrypointOptions>;
651
+ }
652
+ interface ContentScriptEntrypoint extends BaseEntrypoint {
653
+ type: 'content-script';
654
+ options: ResolvedPerBrowserOptions<MainWorldContentScriptEntrypointOptions | IsolatedWorldContentScriptEntrypointOptions>;
655
+ }
656
+ interface PopupEntrypoint extends BaseEntrypoint {
657
+ type: 'popup';
658
+ options: ResolvedPerBrowserOptions<PopupEntrypointOptions, 'defaultIcon'>;
659
+ }
660
+ interface OptionsEntrypoint extends BaseEntrypoint {
661
+ type: 'options';
662
+ options: ResolvedPerBrowserOptions<OptionsEntrypointOptions>;
663
+ }
664
+ interface SidepanelEntrypoint extends BaseEntrypoint {
665
+ type: 'sidepanel';
666
+ options: ResolvedPerBrowserOptions<SidepanelEntrypointOptions, 'defaultIcon'>;
667
+ }
668
+ type Entrypoint = GenericEntrypoint | BackgroundEntrypoint | ContentScriptEntrypoint | PopupEntrypoint | OptionsEntrypoint | SidepanelEntrypoint;
669
+ type EntrypointGroup = Entrypoint | Entrypoint[];
670
+ type OnContentScriptStopped = (cb: () => void) => void;
671
+ interface IsolatedWorldContentScriptDefinition extends IsolatedWorldContentScriptEntrypointOptions {
672
+ /**
673
+ * Main function executed when the content script is loaded.
674
+ */
675
+ main(ctx: ContentScriptContext): void | Promise<void>;
676
+ }
677
+ interface MainWorldContentScriptDefinition extends MainWorldContentScriptEntrypointOptions {
678
+ /**
679
+ * Main function executed when the content script is loaded.
680
+ */
681
+ main(): void | Promise<void>;
682
+ }
683
+ type ContentScriptDefinition = IsolatedWorldContentScriptDefinition | MainWorldContentScriptDefinition;
684
+ interface BackgroundDefinition extends BackgroundEntrypointOptions {
685
+ /**
686
+ * Main function executed when the background script is started. Cannot be async.
687
+ */
688
+ main(): void;
689
+ }
690
+ interface UnlistedScriptDefinition extends BaseEntrypointOptions {
691
+ /**
692
+ * Main function executed when the unlisted script is ran.
693
+ */
694
+ main(): void | Promise<void>;
695
+ }
696
+ /**
697
+ * Either a single value or a map of different browsers to the value for that browser.
698
+ */
699
+ type PerBrowserOption<T> = T | PerBrowserMap<T>;
700
+ type PerBrowserMap<T> = {
701
+ [browser: TargetBrowser]: T;
702
+ };
703
+ /**
704
+ * Convert `{ key: PerBrowserOption<T> }` to just `{ key: T }`, stripping away the
705
+ * `PerBrowserOption` type for all fields inside the object.
706
+ *
707
+ * A optional second list of keys can be passed if a field isn't compatible with `PerBrowserOption`, like `defaultIcon`.
708
+ */
709
+ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
710
+ [key in keyof Omit<T, TOmitted>]: T[key] extends PerBrowserOption<infer U> ? U : T[key];
711
+ } & {
712
+ [key in TOmitted]: T[key];
713
+ };
670
714
  /**
671
715
  * Manifest customization available in the `wxt.config.ts` file. You cannot configure entrypoints
672
716
  * here, they are configured inline.
673
717
  */
674
- type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox' | 'sidepanel' | 'sidebar_action'>>;
718
+ type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
675
719
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
676
720
  interface ConfigEnv {
677
721
  mode: string;
@@ -986,4 +1030,4 @@ type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
986
1030
  eslintrc: ResolvedEslintrc;
987
1031
  };
988
1032
 
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 };
1033
+ 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 };