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.
- package/dist/{chunk-N26YUOBL.js → chunk-PIVW7CL3.js} +178 -145
- package/dist/cli.js +180 -163
- package/dist/client.d.ts +1 -1
- package/dist/client.js +2 -2
- package/dist/{index-sl22zA2Z.d.ts → index-h54vKikt.d.cts} +163 -107
- package/dist/{index-sl22zA2Z.d.cts → index-h54vKikt.d.ts} +163 -107
- package/dist/{index-TYmXqKVq.d.ts → index-v_64CCcw.d.ts} +69 -36
- package/dist/index.cjs +180 -163
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -21
- package/dist/sandbox.d.ts +1 -1
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/cli.d.ts +0 -2
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
502
|
+
include?: TargetBrowser[];
|
|
573
503
|
/**
|
|
574
|
-
*
|
|
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
|
-
|
|
509
|
+
exclude?: TargetBrowser[];
|
|
577
510
|
}
|
|
578
|
-
interface
|
|
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
|
-
*
|
|
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
|
-
|
|
521
|
+
type?: PerBrowserOption<'module'>;
|
|
587
522
|
}
|
|
588
|
-
interface
|
|
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 `
|
|
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
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
|
593
|
+
interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
646
594
|
/**
|
|
647
|
-
*
|
|
595
|
+
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
596
|
+
* @default "ISOLATED"
|
|
648
597
|
*/
|
|
649
|
-
|
|
598
|
+
world?: 'ISOLATED';
|
|
650
599
|
}
|
|
651
|
-
|
|
652
|
-
[browser: TargetBrowser]: T;
|
|
653
|
-
};
|
|
654
|
-
interface ExcludableEntrypoint {
|
|
600
|
+
interface PopupEntrypointOptions extends BaseEntrypointOptions {
|
|
655
601
|
/**
|
|
656
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
664
|
-
*
|
|
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
|
-
*
|
|
631
|
+
* Examples:
|
|
632
|
+
* - `popup.html` → `popup`
|
|
633
|
+
* - `options/index.html` → `options`
|
|
634
|
+
* - `named.sandbox.html` → `named`
|
|
635
|
+
* - `named.sandbox/index.html` → `named`
|
|
636
|
+
* - `sandbox.html` → `sandbox`
|
|
637
|
+
* - `sandbox/index.html` → `sandbox`
|
|
638
|
+
* - `overlay.content.ts` → `overlay`
|
|
639
|
+
* - `overlay.content/index.ts` → `overlay`
|
|
640
|
+
*
|
|
641
|
+
* The name is used when generating an output file:
|
|
642
|
+
* `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
|
|
667
643
|
*/
|
|
668
|
-
|
|
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'
|
|
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 {
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
|
|
502
|
+
include?: TargetBrowser[];
|
|
573
503
|
/**
|
|
574
|
-
*
|
|
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
|
-
|
|
509
|
+
exclude?: TargetBrowser[];
|
|
577
510
|
}
|
|
578
|
-
interface
|
|
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
|
-
*
|
|
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
|
-
|
|
521
|
+
type?: PerBrowserOption<'module'>;
|
|
587
522
|
}
|
|
588
|
-
interface
|
|
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 `
|
|
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
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
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
|
|
593
|
+
interface IsolatedWorldContentScriptEntrypointOptions extends BaseContentScriptEntrypointOptions {
|
|
646
594
|
/**
|
|
647
|
-
*
|
|
595
|
+
* See https://developer.chrome.com/docs/extensions/develop/concepts/content-scripts#isolated_world
|
|
596
|
+
* @default "ISOLATED"
|
|
648
597
|
*/
|
|
649
|
-
|
|
598
|
+
world?: 'ISOLATED';
|
|
650
599
|
}
|
|
651
|
-
|
|
652
|
-
[browser: TargetBrowser]: T;
|
|
653
|
-
};
|
|
654
|
-
interface ExcludableEntrypoint {
|
|
600
|
+
interface PopupEntrypointOptions extends BaseEntrypointOptions {
|
|
655
601
|
/**
|
|
656
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
664
|
-
*
|
|
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
|
-
*
|
|
631
|
+
* Examples:
|
|
632
|
+
* - `popup.html` → `popup`
|
|
633
|
+
* - `options/index.html` → `options`
|
|
634
|
+
* - `named.sandbox.html` → `named`
|
|
635
|
+
* - `named.sandbox/index.html` → `named`
|
|
636
|
+
* - `sandbox.html` → `sandbox`
|
|
637
|
+
* - `sandbox/index.html` → `sandbox`
|
|
638
|
+
* - `overlay.content.ts` → `overlay`
|
|
639
|
+
* - `overlay.content/index.ts` → `overlay`
|
|
640
|
+
*
|
|
641
|
+
* The name is used when generating an output file:
|
|
642
|
+
* `<entrypoint.outputDir>/<entrypoint.name>.<ext>`
|
|
667
643
|
*/
|
|
668
|
-
|
|
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'
|
|
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 {
|
|
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 };
|