wxt 0.18.9 → 0.18.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.
@@ -1041,6 +1041,23 @@ interface WxtHooks {
1041
1041
  * @returns Promise
1042
1042
  */
1043
1043
  ready: (wxt: Wxt) => HookResult;
1044
+ /**
1045
+ * Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
1046
+ * addition of custom references and declarations in wxt.d.ts, or directly
1047
+ * modifying the options in `tsconfig.json`.
1048
+ *
1049
+ * @example
1050
+ * wxt.hooks.hook("prepare:types", (wxt, entries) => {
1051
+ * // Add a file, ".wxt/types/example.d.ts", that defines a global
1052
+ * // variable called "example" in the TS project.
1053
+ * entries.push({
1054
+ * path: "types/example.d.ts",
1055
+ * textContent: "declare const a: string;",
1056
+ * tsReference: true,
1057
+ * });
1058
+ * })
1059
+ */
1060
+ 'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
1044
1061
  /**
1045
1062
  * Called before the build is started in both dev mode and build mode.
1046
1063
  *
@@ -1193,7 +1210,8 @@ interface ResolvedConfig {
1193
1210
  reloadCommand: string | false;
1194
1211
  };
1195
1212
  hooks: NestedHooks<WxtHooks>;
1196
- modules: WxtModuleWithMetadata<any>[];
1213
+ builtinModules: WxtModule<any>[];
1214
+ userModules: WxtModuleWithMetadata<any>[];
1197
1215
  /**
1198
1216
  * An array of string to import plugins from. These paths should be
1199
1217
  * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
@@ -1316,20 +1334,53 @@ interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtMo
1316
1334
  type: 'local' | 'node_module';
1317
1335
  id: string;
1318
1336
  }
1319
- interface ResolvedPublicFile {
1337
+ type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
1338
+ interface ResolvedBasePublicFile {
1339
+ /**
1340
+ * The relative path in the output directory to copy the file to.
1341
+ * @example
1342
+ * "content-scripts/base-styles.css"
1343
+ */
1344
+ relativeDest: string;
1345
+ }
1346
+ interface CopiedPublicFile extends ResolvedBasePublicFile {
1320
1347
  /**
1321
1348
  * The absolute path to the file that will be copied to the output directory.
1322
1349
  * @example
1323
1350
  * "/path/to/any/file.css"
1324
1351
  */
1325
1352
  absoluteSrc: string;
1353
+ }
1354
+ interface GeneratedPublicFile extends ResolvedBasePublicFile {
1326
1355
  /**
1327
- * The relative path in the output directory to copy the file to.
1328
- * @example
1329
- * "content-scripts/base-styles.css"
1356
+ * Text to write to the file.
1330
1357
  */
1331
- relativeDest: string;
1358
+ contents: string;
1332
1359
  }
1333
1360
  type WxtPlugin = () => void;
1361
+ type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
1362
+ /**
1363
+ * Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
1364
+ */
1365
+ interface WxtDirTypeReferenceEntry {
1366
+ module: string;
1367
+ }
1368
+ /**
1369
+ * Represents a file to be written to the project's `.wxt/` directory.
1370
+ */
1371
+ interface WxtDirFileEntry {
1372
+ /**
1373
+ * Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
1374
+ */
1375
+ path: string;
1376
+ /**
1377
+ * The text that will be written to the file.
1378
+ */
1379
+ text: string;
1380
+ /**
1381
+ * Set to `true` to add a reference to this file in `.wxt/wxt.d.ts`.
1382
+ */
1383
+ tsReference?: boolean;
1384
+ }
1334
1385
 
1335
- export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, WxtPlugin as ab, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
1386
+ export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, ResolvedBasePublicFile as ab, CopiedPublicFile as ac, GeneratedPublicFile as ad, WxtPlugin as ae, WxtDirEntry as af, WxtDirTypeReferenceEntry as ag, WxtDirFileEntry as ah, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
@@ -1041,6 +1041,23 @@ interface WxtHooks {
1041
1041
  * @returns Promise
1042
1042
  */
1043
1043
  ready: (wxt: Wxt) => HookResult;
1044
+ /**
1045
+ * Called before WXT writes .wxt/tsconfig.json and .wxt/wxt.d.ts, allowing
1046
+ * addition of custom references and declarations in wxt.d.ts, or directly
1047
+ * modifying the options in `tsconfig.json`.
1048
+ *
1049
+ * @example
1050
+ * wxt.hooks.hook("prepare:types", (wxt, entries) => {
1051
+ * // Add a file, ".wxt/types/example.d.ts", that defines a global
1052
+ * // variable called "example" in the TS project.
1053
+ * entries.push({
1054
+ * path: "types/example.d.ts",
1055
+ * textContent: "declare const a: string;",
1056
+ * tsReference: true,
1057
+ * });
1058
+ * })
1059
+ */
1060
+ 'prepare:types': (wxt: Wxt, entries: WxtDirEntry[]) => HookResult;
1044
1061
  /**
1045
1062
  * Called before the build is started in both dev mode and build mode.
1046
1063
  *
@@ -1193,7 +1210,8 @@ interface ResolvedConfig {
1193
1210
  reloadCommand: string | false;
1194
1211
  };
1195
1212
  hooks: NestedHooks<WxtHooks>;
1196
- modules: WxtModuleWithMetadata<any>[];
1213
+ builtinModules: WxtModule<any>[];
1214
+ userModules: WxtModuleWithMetadata<any>[];
1197
1215
  /**
1198
1216
  * An array of string to import plugins from. These paths should be
1199
1217
  * resolvable by vite, and they should `export default defineWxtPlugin(...)`.
@@ -1316,20 +1334,53 @@ interface WxtModuleWithMetadata<TOptions extends WxtModuleOptions> extends WxtMo
1316
1334
  type: 'local' | 'node_module';
1317
1335
  id: string;
1318
1336
  }
1319
- interface ResolvedPublicFile {
1337
+ type ResolvedPublicFile = CopiedPublicFile | GeneratedPublicFile;
1338
+ interface ResolvedBasePublicFile {
1339
+ /**
1340
+ * The relative path in the output directory to copy the file to.
1341
+ * @example
1342
+ * "content-scripts/base-styles.css"
1343
+ */
1344
+ relativeDest: string;
1345
+ }
1346
+ interface CopiedPublicFile extends ResolvedBasePublicFile {
1320
1347
  /**
1321
1348
  * The absolute path to the file that will be copied to the output directory.
1322
1349
  * @example
1323
1350
  * "/path/to/any/file.css"
1324
1351
  */
1325
1352
  absoluteSrc: string;
1353
+ }
1354
+ interface GeneratedPublicFile extends ResolvedBasePublicFile {
1326
1355
  /**
1327
- * The relative path in the output directory to copy the file to.
1328
- * @example
1329
- * "content-scripts/base-styles.css"
1356
+ * Text to write to the file.
1330
1357
  */
1331
- relativeDest: string;
1358
+ contents: string;
1332
1359
  }
1333
1360
  type WxtPlugin = () => void;
1361
+ type WxtDirEntry = WxtDirTypeReferenceEntry | WxtDirFileEntry;
1362
+ /**
1363
+ * Represents type reference to a node module to be added to `.wxt/wxt.d.ts` file
1364
+ */
1365
+ interface WxtDirTypeReferenceEntry {
1366
+ module: string;
1367
+ }
1368
+ /**
1369
+ * Represents a file to be written to the project's `.wxt/` directory.
1370
+ */
1371
+ interface WxtDirFileEntry {
1372
+ /**
1373
+ * Path relative to the `.wxt/` directory. So "tsconfig.json" would resolve to ".wxt/tsconfig.json".
1374
+ */
1375
+ path: string;
1376
+ /**
1377
+ * The text that will be written to the file.
1378
+ */
1379
+ text: string;
1380
+ /**
1381
+ * Set to `true` to add a reference to this file in `.wxt/wxt.d.ts`.
1382
+ */
1383
+ tsReference?: boolean;
1384
+ }
1334
1385
 
1335
- export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, WxtPlugin as ab, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };
1386
+ export type { EslintGlobalsPropValue as $, PerBrowserMap as A, BuildOutput as B, ContentScriptEntrypoint as C, ResolvedPerBrowserOptions as D, ExtensionRunnerConfig as E, UserManifest as F, GenericEntrypoint as G, UserManifestFn as H, InlineConfig as I, ConfigEnv as J, WxtCommand as K, Logger as L, MainWorldContentScriptEntrypointOptions as M, WxtBuilder as N, OutputFile as O, PopupEntrypointOptions as P, WxtBuilderServer as Q, ResolvedConfig as R, SidepanelEntrypointOptions as S, TargetBrowser as T, UserConfig as U, ServerInfo as V, WxtDevServer as W, HookResult as X, Wxt as Y, FsCache as Z, ExtensionRunner as _, WxtViteConfig as a, Eslintrc as a0, ResolvedEslintrc as a1, WxtUnimportOptions as a2, WxtResolvedUnimportOptions as a3, WxtPackageManager as a4, Dependency as a5, WxtModuleOptions as a6, WxtModuleSetup as a7, WxtModule as a8, WxtModuleWithMetadata as a9, ResolvedPublicFile as aa, ResolvedBasePublicFile as ab, CopiedPublicFile as ac, GeneratedPublicFile as ad, WxtPlugin as ae, WxtDirEntry as af, WxtDirTypeReferenceEntry as ag, WxtDirFileEntry as ah, WxtHooks as b, OutputChunk as c, OutputAsset as d, BuildStepOutput as e, ReloadContentScriptPayload as f, TargetManifestVersion as g, BaseEntrypointOptions as h, BackgroundEntrypointOptions as i, BaseContentScriptEntrypointOptions as j, IsolatedWorldContentScriptEntrypointOptions as k, OptionsEntrypointOptions as l, BaseEntrypoint as m, BackgroundEntrypoint as n, PopupEntrypoint as o, OptionsEntrypoint as p, SidepanelEntrypoint as q, Entrypoint as r, EntrypointGroup as s, OnContentScriptStopped as t, IsolatedWorldContentScriptDefinition as u, MainWorldContentScriptDefinition as v, ContentScriptDefinition as w, BackgroundDefinition as x, UnlistedScriptDefinition as y, PerBrowserOption as z };