wxt 0.17.4 → 0.17.6

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.
@@ -6,6 +6,7 @@ import { PluginVisualizerOptions } from '@aklinker1/rollup-plugin-visualizer';
6
6
  import { FSWatcher } from 'chokidar';
7
7
  import { ResolvedConfig as ResolvedConfig$1 } from 'c12';
8
8
  import { NestedHooks, Hookable } from 'hookable';
9
+ import * as Nypm from 'nypm';
9
10
 
10
11
  declare class WxtLocationChangeEvent extends Event {
11
12
  readonly newUrl: URL;
@@ -138,6 +139,9 @@ interface InlineConfig {
138
139
  * Directory containing all source code. Set to `"src"` to move all source code to a `src/`
139
140
  * directory.
140
141
  *
142
+ * After changing, don't forget to move the `public/` and `entrypoints/` directories into the new
143
+ * source dir.
144
+ *
141
145
  * @default config.root
142
146
  */
143
147
  srcDir?: string;
@@ -289,6 +293,31 @@ interface InlineConfig {
289
293
  * ]
290
294
  */
291
295
  excludeSources?: string[];
296
+ /**
297
+ * The Firefox review process requires the extension be buildable from source to make reviewing
298
+ * easier. This field allows you to use private packages without exposing your auth tokens.
299
+ *
300
+ * Just list the name of all the packages you want to download and include in the sources zip.
301
+ * Usually, these will be private packages behind auth tokens, but they don't have to be.
302
+ *
303
+ * All packages listed here will be downloaded to in `.wxt/local_modules/` and an `overrides` or
304
+ * `resolutions` field (depending on your package manager) will be added to the `package.json`,
305
+ * pointing to the downloaded packages.
306
+ *
307
+ * > ***DO NOT include versions or version filters.*** Just the package name. If multiple
308
+ * > versions of a package are present in the project, all versions will be downloaded and
309
+ * > referenced in the package.json correctly.
310
+ *
311
+ * @default []
312
+ *
313
+ * @example
314
+ * // Correct:
315
+ * ["@scope/package-name", "package-name"]
316
+ *
317
+ * // Incorrect, don't include versions!!!
318
+ * ["@scope/package-name@1.1.3", "package-name@^2"]
319
+ */
320
+ downloadPackages?: string[];
292
321
  };
293
322
  /**
294
323
  * @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
@@ -757,14 +786,23 @@ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
757
786
  type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
758
787
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
759
788
  interface ConfigEnv {
789
+ /**
790
+ * The build mode passed into the CLI. By default, `wxt` uses `"development"` and `wxt build|zip`
791
+ * uses `"production"`.
792
+ */
760
793
  mode: string;
794
+ /**
795
+ * The command used to run WXT. `"serve"` during development and `"build"` for any other command.
796
+ */
761
797
  command: 'build' | 'serve';
762
798
  /**
763
- * Browser passed in from the CLI
799
+ * Browser passed in from the CLI via the `-b` or `--browser` flag. Defaults to `"chrome"` when not passed.
764
800
  */
765
801
  browser: TargetBrowser;
766
802
  /**
767
- * Manifest version passed in from the CLI
803
+ * Manifest version passed in from the CLI via the `--mv2` or `--mv3` flags. When not passed, it depends on the target browser. See
804
+ * [the guide](https://wxt.dev/guide/multiple-browsers.html#target-manifest-version) for more
805
+ * details.
768
806
  */
769
807
  manifestVersion: 2 | 3;
770
808
  }
@@ -964,6 +1002,10 @@ interface Wxt {
964
1002
  * Reload config file and update the `config` field with the result.
965
1003
  */
966
1004
  reloadConfig: () => Promise<void>;
1005
+ /**
1006
+ * Package manager utilities.
1007
+ */
1008
+ pm: WxtPackageManager;
967
1009
  }
968
1010
  interface ResolvedConfig {
969
1011
  root: string;
@@ -998,6 +1040,8 @@ interface ResolvedConfig {
998
1040
  includeSources: string[];
999
1041
  excludeSources: string[];
1000
1042
  sourcesRoot: string;
1043
+ downloadedPackagesDir: string;
1044
+ downloadPackages: string[];
1001
1045
  };
1002
1046
  transformManifest: (manifest: Manifest.WebExtensionManifest) => void;
1003
1047
  analysis: {
@@ -1072,5 +1116,41 @@ type WxtUnimportOptions = Partial<UnimportOptions> & {
1072
1116
  type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
1073
1117
  eslintrc: ResolvedEslintrc;
1074
1118
  };
1119
+ /**
1120
+ * Package management utils built on top of [`nypm`](https://www.npmjs.com/package/nypm)
1121
+ */
1122
+ interface WxtPackageManager extends Nypm.PackageManager {
1123
+ addDependency: typeof Nypm.addDependency;
1124
+ addDevDependency: typeof Nypm.addDevDependency;
1125
+ ensureDependencyInstalled: typeof Nypm.ensureDependencyInstalled;
1126
+ installDependencies: typeof Nypm.installDependencies;
1127
+ removeDependency: typeof Nypm.removeDependency;
1128
+ /**
1129
+ * Download a package's TGZ file and move it into the `downloadDir`. Use's `npm pack <name>`, so
1130
+ * you must have setup authorization in `.npmrc` file, regardless of the package manager used.
1131
+ *
1132
+ * @param id Name of the package to download, can include a version (like `wxt@0.17.1`)
1133
+ * @param downloadDir Where to store the package.
1134
+ * @returns Absolute path to downloaded file.
1135
+ */
1136
+ downloadDependency: (id: string, downloadDir: string) => Promise<string>;
1137
+ /**
1138
+ * Run `npm ls`, `pnpm ls`, or `bun pm ls`, or `yarn list` and return the results.
1139
+ *
1140
+ * WARNING: Yarn always returns all dependencies
1141
+ */
1142
+ listDependencies: (options?: {
1143
+ cwd?: string;
1144
+ all?: boolean;
1145
+ }) => Promise<Dependency[]>;
1146
+ /**
1147
+ * Key used to override package versions. Sometimes called "resolutions".
1148
+ */
1149
+ overridesKey: string;
1150
+ }
1151
+ interface Dependency {
1152
+ name: string;
1153
+ version: string;
1154
+ }
1075
1155
 
1076
- export type { EslintGlobalsPropValue as $, UserManifest as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifestFn as D, ExtensionRunnerConfig as E, ConfigEnv as F, GenericEntrypoint as G, WxtBuilder as H, InlineConfig as I, WxtBuilderServer as J, ServerInfo as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, HookResult as N, OutputFile as O, PopupEntrypointOptions as P, WxtHooks as Q, ReloadContentScriptPayload as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, Wxt as V, WxtDevServer as W, ResolvedConfig as X, FsCache as Y, ExtensionRunner as Z, VirtualEntrypointType as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, 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, ResolvedPerBrowserOptions as z };
1156
+ export type { EslintGlobalsPropValue as $, UserManifest as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifestFn as D, ExtensionRunnerConfig as E, ConfigEnv as F, GenericEntrypoint as G, WxtBuilder as H, InlineConfig as I, WxtBuilderServer as J, ServerInfo as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, HookResult as N, OutputFile as O, PopupEntrypointOptions as P, WxtHooks as Q, ReloadContentScriptPayload as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, Wxt as V, WxtDevServer as W, ResolvedConfig as X, FsCache as Y, ExtensionRunner as Z, VirtualEntrypointType as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, 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, ResolvedPerBrowserOptions as z };
@@ -6,6 +6,7 @@ import { PluginVisualizerOptions } from '@aklinker1/rollup-plugin-visualizer';
6
6
  import { FSWatcher } from 'chokidar';
7
7
  import { ResolvedConfig as ResolvedConfig$1 } from 'c12';
8
8
  import { NestedHooks, Hookable } from 'hookable';
9
+ import * as Nypm from 'nypm';
9
10
 
10
11
  declare class WxtLocationChangeEvent extends Event {
11
12
  readonly newUrl: URL;
@@ -138,6 +139,9 @@ interface InlineConfig {
138
139
  * Directory containing all source code. Set to `"src"` to move all source code to a `src/`
139
140
  * directory.
140
141
  *
142
+ * After changing, don't forget to move the `public/` and `entrypoints/` directories into the new
143
+ * source dir.
144
+ *
141
145
  * @default config.root
142
146
  */
143
147
  srcDir?: string;
@@ -289,6 +293,31 @@ interface InlineConfig {
289
293
  * ]
290
294
  */
291
295
  excludeSources?: string[];
296
+ /**
297
+ * The Firefox review process requires the extension be buildable from source to make reviewing
298
+ * easier. This field allows you to use private packages without exposing your auth tokens.
299
+ *
300
+ * Just list the name of all the packages you want to download and include in the sources zip.
301
+ * Usually, these will be private packages behind auth tokens, but they don't have to be.
302
+ *
303
+ * All packages listed here will be downloaded to in `.wxt/local_modules/` and an `overrides` or
304
+ * `resolutions` field (depending on your package manager) will be added to the `package.json`,
305
+ * pointing to the downloaded packages.
306
+ *
307
+ * > ***DO NOT include versions or version filters.*** Just the package name. If multiple
308
+ * > versions of a package are present in the project, all versions will be downloaded and
309
+ * > referenced in the package.json correctly.
310
+ *
311
+ * @default []
312
+ *
313
+ * @example
314
+ * // Correct:
315
+ * ["@scope/package-name", "package-name"]
316
+ *
317
+ * // Incorrect, don't include versions!!!
318
+ * ["@scope/package-name@1.1.3", "package-name@^2"]
319
+ */
320
+ downloadPackages?: string[];
292
321
  };
293
322
  /**
294
323
  * @deprecated Use `hooks.build.manifestGenerated` to modify your manifest instead. This option
@@ -757,14 +786,23 @@ type ResolvedPerBrowserOptions<T, TOmitted extends keyof T = never> = {
757
786
  type UserManifest = Partial<Omit<Manifest.WebExtensionManifest, 'background' | 'chrome_url_overrides' | 'devtools_page' | 'manifest_version' | 'options_page' | 'options_ui' | 'sandbox'>>;
758
787
  type UserManifestFn = (env: ConfigEnv) => UserManifest | Promise<UserManifest>;
759
788
  interface ConfigEnv {
789
+ /**
790
+ * The build mode passed into the CLI. By default, `wxt` uses `"development"` and `wxt build|zip`
791
+ * uses `"production"`.
792
+ */
760
793
  mode: string;
794
+ /**
795
+ * The command used to run WXT. `"serve"` during development and `"build"` for any other command.
796
+ */
761
797
  command: 'build' | 'serve';
762
798
  /**
763
- * Browser passed in from the CLI
799
+ * Browser passed in from the CLI via the `-b` or `--browser` flag. Defaults to `"chrome"` when not passed.
764
800
  */
765
801
  browser: TargetBrowser;
766
802
  /**
767
- * Manifest version passed in from the CLI
803
+ * Manifest version passed in from the CLI via the `--mv2` or `--mv3` flags. When not passed, it depends on the target browser. See
804
+ * [the guide](https://wxt.dev/guide/multiple-browsers.html#target-manifest-version) for more
805
+ * details.
768
806
  */
769
807
  manifestVersion: 2 | 3;
770
808
  }
@@ -964,6 +1002,10 @@ interface Wxt {
964
1002
  * Reload config file and update the `config` field with the result.
965
1003
  */
966
1004
  reloadConfig: () => Promise<void>;
1005
+ /**
1006
+ * Package manager utilities.
1007
+ */
1008
+ pm: WxtPackageManager;
967
1009
  }
968
1010
  interface ResolvedConfig {
969
1011
  root: string;
@@ -998,6 +1040,8 @@ interface ResolvedConfig {
998
1040
  includeSources: string[];
999
1041
  excludeSources: string[];
1000
1042
  sourcesRoot: string;
1043
+ downloadedPackagesDir: string;
1044
+ downloadPackages: string[];
1001
1045
  };
1002
1046
  transformManifest: (manifest: Manifest.WebExtensionManifest) => void;
1003
1047
  analysis: {
@@ -1072,5 +1116,41 @@ type WxtUnimportOptions = Partial<UnimportOptions> & {
1072
1116
  type WxtResolvedUnimportOptions = Partial<UnimportOptions> & {
1073
1117
  eslintrc: ResolvedEslintrc;
1074
1118
  };
1119
+ /**
1120
+ * Package management utils built on top of [`nypm`](https://www.npmjs.com/package/nypm)
1121
+ */
1122
+ interface WxtPackageManager extends Nypm.PackageManager {
1123
+ addDependency: typeof Nypm.addDependency;
1124
+ addDevDependency: typeof Nypm.addDevDependency;
1125
+ ensureDependencyInstalled: typeof Nypm.ensureDependencyInstalled;
1126
+ installDependencies: typeof Nypm.installDependencies;
1127
+ removeDependency: typeof Nypm.removeDependency;
1128
+ /**
1129
+ * Download a package's TGZ file and move it into the `downloadDir`. Use's `npm pack <name>`, so
1130
+ * you must have setup authorization in `.npmrc` file, regardless of the package manager used.
1131
+ *
1132
+ * @param id Name of the package to download, can include a version (like `wxt@0.17.1`)
1133
+ * @param downloadDir Where to store the package.
1134
+ * @returns Absolute path to downloaded file.
1135
+ */
1136
+ downloadDependency: (id: string, downloadDir: string) => Promise<string>;
1137
+ /**
1138
+ * Run `npm ls`, `pnpm ls`, or `bun pm ls`, or `yarn list` and return the results.
1139
+ *
1140
+ * WARNING: Yarn always returns all dependencies
1141
+ */
1142
+ listDependencies: (options?: {
1143
+ cwd?: string;
1144
+ all?: boolean;
1145
+ }) => Promise<Dependency[]>;
1146
+ /**
1147
+ * Key used to override package versions. Sometimes called "resolutions".
1148
+ */
1149
+ overridesKey: string;
1150
+ }
1151
+ interface Dependency {
1152
+ name: string;
1153
+ version: string;
1154
+ }
1075
1155
 
1076
- export type { EslintGlobalsPropValue as $, UserManifest as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifestFn as D, ExtensionRunnerConfig as E, ConfigEnv as F, GenericEntrypoint as G, WxtBuilder as H, InlineConfig as I, WxtBuilderServer as J, ServerInfo as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, HookResult as N, OutputFile as O, PopupEntrypointOptions as P, WxtHooks as Q, ReloadContentScriptPayload as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, Wxt as V, WxtDevServer as W, ResolvedConfig as X, FsCache as Y, ExtensionRunner as Z, VirtualEntrypointType as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, 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, ResolvedPerBrowserOptions as z };
1156
+ export type { EslintGlobalsPropValue as $, UserManifest as A, BuildOutput as B, ContentScriptEntrypoint as C, UserManifestFn as D, ExtensionRunnerConfig as E, ConfigEnv as F, GenericEntrypoint as G, WxtBuilder as H, InlineConfig as I, WxtBuilderServer as J, ServerInfo as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, HookResult as N, OutputFile as O, PopupEntrypointOptions as P, WxtHooks as Q, ReloadContentScriptPayload as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, Wxt as V, WxtDevServer as W, ResolvedConfig as X, FsCache as Y, ExtensionRunner as Z, VirtualEntrypointType as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, 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, ResolvedPerBrowserOptions as z };