wxt 0.10.3 → 0.11.0

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as BackgroundDefinition, C as ContentScriptContext, a as ContentScriptDefinition } from './external-9107db91.js';
1
+ import { B as BackgroundDefinition, C as ContentScriptContext, a as ContentScriptDefinition } from './external-6YqvLCcd.js';
2
2
  import * as wxt_browser from 'wxt/browser';
3
3
  import 'webextension-polyfill';
4
4
 
@@ -181,4 +181,4 @@ type ContentScriptIframeOptions = ContentScriptPositioningOptions & ContentScrip
181
181
 
182
182
  declare function defineContentScript(definition: ContentScriptDefinition): ContentScriptDefinition;
183
183
 
184
- export { ContentScriptContext, ContentScriptIframe, ContentScriptIframeOptions, ContentScriptUi, ContentScriptUiOptions, createContentScriptIframe, createContentScriptUi, defineBackground, defineContentScript };
184
+ export { ContentScriptContext, type ContentScriptIframe, type ContentScriptIframeOptions, type ContentScriptUi, type ContentScriptUiOptions, createContentScriptIframe, createContentScriptUi, defineBackground, defineContentScript };
@@ -2,7 +2,7 @@ import {
2
2
  __commonJS,
3
3
  __require,
4
4
  __toESM
5
- } from "./chunk-YUG22S6W.js";
5
+ } from "./chunk-VBXJIVYU.js";
6
6
 
7
7
  // node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
8
8
  var require_windows = __commonJS({
@@ -1816,8 +1816,8 @@ var getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBu
1816
1816
  };
1817
1817
 
1818
1818
  // node_modules/.pnpm/execa@8.0.1/node_modules/execa/lib/promise.js
1819
- var nativePromisePrototype = (/* @__PURE__ */ (async () => {
1820
- })()).constructor.prototype;
1819
+ var nativePromisePrototype = (async () => {
1820
+ })().constructor.prototype;
1821
1821
  var descriptors = ["then", "catch", "finally"].map((property) => [
1822
1822
  property,
1823
1823
  Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property)
@@ -173,4 +173,4 @@ interface ExcludableEntrypoint {
173
173
  exclude?: TargetBrowser[];
174
174
  }
175
175
 
176
- export { BackgroundDefinition as B, ContentScriptContext as C, UnlistedScriptDefinition as U, ContentScriptDefinition as a };
176
+ export { type BackgroundDefinition as B, ContentScriptContext as C, type UnlistedScriptDefinition as U, type ContentScriptDefinition as a };
@@ -3,6 +3,7 @@ import { Manifest, Scripting } from 'webextension-polyfill';
3
3
  import { UnimportOptions } from 'unimport';
4
4
  import { LogLevel } from 'consola';
5
5
  import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
6
+ import { FSWatcher } from 'chokidar';
6
7
 
7
8
  /**
8
9
  * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
@@ -109,6 +110,12 @@ interface InlineConfig {
109
110
  * @default "${config.srcDir}/entrypoints"
110
111
  */
111
112
  entrypointsDir?: string;
113
+ /**
114
+ * Output directory that stored build folders and ZIPs.
115
+ *
116
+ * @default ".output"
117
+ */
118
+ outDir?: string;
112
119
  /**
113
120
  * > Only available when using the JS API. Not available in `wxt.config.ts` files
114
121
  *
@@ -162,17 +169,6 @@ interface InlineConfig {
162
169
  * consola
163
170
  */
164
171
  logger?: Logger;
165
- /**
166
- * Return custom Vite options from a function. See
167
- * <https://vitejs.dev/config/shared-options.html>.
168
- *
169
- * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
170
- * instead of Vite's.
171
- *
172
- * This is a function because any vite plugins added need to be recreated for each individual
173
- * build step, incase they have internal state causing them to fail when reused.
174
- */
175
- vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
176
172
  /**
177
173
  * Customize the `manifest.json` output. Can be an object, promise, or function that returns an
178
174
  * object or promise.
@@ -272,10 +268,6 @@ interface InlineConfig {
272
268
  * Add additional paths to the `.wxt/tsconfig.json`. Use this instead of overwriting the `paths`
273
269
  * in the root `tsconfig.json` if you want to add new paths.
274
270
  *
275
- * Passed into Vite's
276
- * [`resolve.alias`](https://vitejs.dev/config/shared-options.html#resolve-alias) option and used
277
- * to generate the `.wxt/tsconfig.json`.
278
- *
279
271
  * The key is the import alias and the value is either a relative path to the root directory or an absolute path.
280
272
  *
281
273
  * @example
@@ -310,39 +302,65 @@ interface InlineConfig {
310
302
  includeBrowserPolyfill?: boolean;
311
303
  };
312
304
  }
313
- interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
314
- build?: Omit<vite.BuildOptions, 'outDir'>;
305
+ interface InlineConfig {
306
+ /**
307
+ * Return custom Vite options from a function. See
308
+ * <https://vitejs.dev/config/shared-options.html>.
309
+ *
310
+ * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
311
+ * instead of Vite's.
312
+ *
313
+ * This is a function because any vite plugins added need to be recreated for each individual
314
+ * build step, incase they have internal state causing them to fail when reused.
315
+ */
316
+ vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
315
317
  }
318
+ type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
316
319
  interface BuildOutput {
317
320
  manifest: Manifest.WebExtensionManifest;
318
- publicAssets: vite.Rollup.OutputAsset[];
321
+ publicAssets: OutputAsset[];
319
322
  steps: BuildStepOutput[];
320
323
  }
321
- interface BuildStepOutput {
322
- entrypoints: EntrypointGroup;
323
- chunks: (vite.Rollup.OutputChunk | vite.Rollup.OutputAsset)[];
324
- }
325
- interface WxtDevServer extends vite.ViteDevServer {
324
+ type OutputFile = OutputChunk | OutputAsset;
325
+ interface OutputChunk {
326
+ type: 'chunk';
326
327
  /**
327
- * Ex: `3000`
328
+ * Relative, normalized path relative to the output directory.
329
+ *
330
+ * Ex: "content-scripts/overlay.js"
328
331
  */
329
- port: number;
332
+ fileName: string;
330
333
  /**
331
- * Ex: `"localhost"`
334
+ * Absolute, normalized paths to all dependencies this chunk relies on.
332
335
  */
333
- hostname: string;
336
+ moduleIds: string[];
337
+ }
338
+ interface OutputAsset {
339
+ type: 'asset';
334
340
  /**
335
- * Ex: `"http://localhost:3000"`
341
+ * Relative, normalized path relative to the output directory.
342
+ *
343
+ * Ex: "icons/16.png"
336
344
  */
337
- origin: string;
345
+ fileName: string;
346
+ }
347
+ interface BuildStepOutput {
348
+ entrypoints: EntrypointGroup;
349
+ chunks: OutputFile[];
350
+ }
351
+ interface WxtDevServer extends Omit<WxtBuilderServer, 'listen'>, ServerInfo {
338
352
  /**
339
353
  * Stores the current build output of the server.
340
354
  */
341
355
  currentOutput: BuildOutput;
342
356
  /**
343
- * Start the server on the first open port.
357
+ * Start the server.
344
358
  */
345
359
  start(): Promise<void>;
360
+ /**
361
+ * Transform the HTML for dev mode.
362
+ */
363
+ transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
346
364
  /**
347
365
  * Tell the extension to reload by running `browser.runtime.reload`.
348
366
  */
@@ -608,6 +626,69 @@ interface ExtensionRunnerConfig {
608
626
  */
609
627
  startUrls?: string[];
610
628
  }
611
- type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
629
+ interface WxtBuilder {
630
+ /**
631
+ * Name of tool used to build. Ex: "Vite" or "Webpack".
632
+ */
633
+ name: string;
634
+ /**
635
+ * Version of tool used to build. Ex: "5.0.2"
636
+ */
637
+ version: string;
638
+ /**
639
+ * Build a single entrypoint group. This is effectively one of the multiple "steps" during the
640
+ * build process.
641
+ */
642
+ build(group: EntrypointGroup): Promise<BuildStepOutput>;
643
+ /**
644
+ * Start a dev server at the provided port.
645
+ */
646
+ createServer(info: ServerInfo): Promise<WxtBuilderServer>;
647
+ }
648
+ interface WxtBuilderServer {
649
+ /**
650
+ * Start the server.
651
+ */
652
+ listen(): Promise<void>;
653
+ /**
654
+ * Transform the HTML for dev mode.
655
+ */
656
+ transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
657
+ /**
658
+ * The web socket server used to communicate with the extension.
659
+ */
660
+ ws: {
661
+ /**
662
+ * Send a message via the server's websocket, with an optional payload.
663
+ *
664
+ * @example
665
+ * ws.send("wxt:reload-extension");
666
+ * ws.send("wxt:reload-content-script", { ... });
667
+ */
668
+ send(message: string, payload?: any): void;
669
+ /**
670
+ * Listen for messages over the server's websocket.
671
+ */
672
+ on(message: string, cb: (payload: any) => void): void;
673
+ };
674
+ /**
675
+ * Chokidar file watcher instance.
676
+ */
677
+ watcher: FSWatcher;
678
+ }
679
+ interface ServerInfo {
680
+ /**
681
+ * Ex: `3000`
682
+ */
683
+ port: number;
684
+ /**
685
+ * Ex: `"localhost"`
686
+ */
687
+ hostname: string;
688
+ /**
689
+ * Ex: `"http://localhost:3000"`
690
+ */
691
+ origin: string;
692
+ }
612
693
 
613
- export { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OptionsEntrypoint as O, PopupEntrypoint as P, TargetBrowser as T, UserConfig as U, WxtDevServer as W, WxtInlineViteConfig as a, BuildStepOutput as b, TargetManifestVersion as c, BaseEntrypointOptions as d, BaseEntrypoint as e, BackgroundEntrypoint as f, Entrypoint as g, EntrypointGroup as h, OnContentScriptStopped as i, ContentScriptDefinition as j, BackgroundDefinition as k, UnlistedScriptDefinition as l, PerBrowserOption as m, ExcludableEntrypoint as n, UserManifest as o, UserManifestFn as p, ConfigEnv as q, WxtViteConfig as r };
694
+ export type { BuildOutput as B, ContentScriptEntrypoint as C, ExtensionRunnerConfig as E, GenericEntrypoint as G, InlineConfig as I, Logger as L, OutputFile as O, PopupEntrypoint as P, ServerInfo as S, TargetBrowser as T, UserConfig as U, 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, BackgroundDefinition as n, UnlistedScriptDefinition as o, PerBrowserOption as p, ExcludableEntrypoint as q, UserManifest as r, UserManifestFn as s, ConfigEnv as t, WxtBuilder as u, WxtBuilderServer as v };