wxt 0.10.4 → 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).
@@ -168,17 +169,6 @@ interface InlineConfig {
168
169
  * consola
169
170
  */
170
171
  logger?: Logger;
171
- /**
172
- * Return custom Vite options from a function. See
173
- * <https://vitejs.dev/config/shared-options.html>.
174
- *
175
- * [`root`](#root), [`configFile`](#configfile), and [`mode`](#mode) should be set in WXT's config
176
- * instead of Vite's.
177
- *
178
- * This is a function because any vite plugins added need to be recreated for each individual
179
- * build step, incase they have internal state causing them to fail when reused.
180
- */
181
- vite?: (env: ConfigEnv) => WxtViteConfig | Promise<WxtViteConfig>;
182
172
  /**
183
173
  * Customize the `manifest.json` output. Can be an object, promise, or function that returns an
184
174
  * object or promise.
@@ -278,10 +268,6 @@ interface InlineConfig {
278
268
  * Add additional paths to the `.wxt/tsconfig.json`. Use this instead of overwriting the `paths`
279
269
  * in the root `tsconfig.json` if you want to add new paths.
280
270
  *
281
- * Passed into Vite's
282
- * [`resolve.alias`](https://vitejs.dev/config/shared-options.html#resolve-alias) option and used
283
- * to generate the `.wxt/tsconfig.json`.
284
- *
285
271
  * The key is the import alias and the value is either a relative path to the root directory or an absolute path.
286
272
  *
287
273
  * @example
@@ -316,39 +302,65 @@ interface InlineConfig {
316
302
  includeBrowserPolyfill?: boolean;
317
303
  };
318
304
  }
319
- interface WxtInlineViteConfig extends Omit<vite.InlineConfig, 'root' | 'configFile' | 'mode' | 'build'> {
320
- 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>;
321
317
  }
318
+ type WxtViteConfig = Omit<vite.UserConfig, 'root' | 'configFile' | 'mode'>;
322
319
  interface BuildOutput {
323
320
  manifest: Manifest.WebExtensionManifest;
324
- publicAssets: vite.Rollup.OutputAsset[];
321
+ publicAssets: OutputAsset[];
325
322
  steps: BuildStepOutput[];
326
323
  }
327
- interface BuildStepOutput {
328
- entrypoints: EntrypointGroup;
329
- chunks: (vite.Rollup.OutputChunk | vite.Rollup.OutputAsset)[];
330
- }
331
- interface WxtDevServer extends vite.ViteDevServer {
324
+ type OutputFile = OutputChunk | OutputAsset;
325
+ interface OutputChunk {
326
+ type: 'chunk';
332
327
  /**
333
- * Ex: `3000`
328
+ * Relative, normalized path relative to the output directory.
329
+ *
330
+ * Ex: "content-scripts/overlay.js"
334
331
  */
335
- port: number;
332
+ fileName: string;
336
333
  /**
337
- * Ex: `"localhost"`
334
+ * Absolute, normalized paths to all dependencies this chunk relies on.
338
335
  */
339
- hostname: string;
336
+ moduleIds: string[];
337
+ }
338
+ interface OutputAsset {
339
+ type: 'asset';
340
340
  /**
341
- * Ex: `"http://localhost:3000"`
341
+ * Relative, normalized path relative to the output directory.
342
+ *
343
+ * Ex: "icons/16.png"
342
344
  */
343
- origin: string;
345
+ fileName: string;
346
+ }
347
+ interface BuildStepOutput {
348
+ entrypoints: EntrypointGroup;
349
+ chunks: OutputFile[];
350
+ }
351
+ interface WxtDevServer extends Omit<WxtBuilderServer, 'listen'>, ServerInfo {
344
352
  /**
345
353
  * Stores the current build output of the server.
346
354
  */
347
355
  currentOutput: BuildOutput;
348
356
  /**
349
- * Start the server on the first open port.
357
+ * Start the server.
350
358
  */
351
359
  start(): Promise<void>;
360
+ /**
361
+ * Transform the HTML for dev mode.
362
+ */
363
+ transformHtml(url: string, html: string, originalUrl?: string | undefined): Promise<string>;
352
364
  /**
353
365
  * Tell the extension to reload by running `browser.runtime.reload`.
354
366
  */
@@ -614,6 +626,69 @@ interface ExtensionRunnerConfig {
614
626
  */
615
627
  startUrls?: string[];
616
628
  }
617
- 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
+ }
618
693
 
619
- 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 };