wxt 0.8.1 → 0.8.2

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/index.d.cts CHANGED
@@ -5,18 +5,20 @@ import { LogLevel } from 'consola';
5
5
  import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
6
6
 
7
7
  /**
8
- * Extends [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
8
+ * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
9
9
  * Used to detect and stop content script code when the script is invalidated.
10
10
  *
11
11
  * It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
12
12
  * content scripts instead of `window.setTimeout` or `window.setInterval`.
13
13
  */
14
- declare class ContentScriptContext extends AbortController {
14
+ declare class ContentScriptContext implements AbortController {
15
15
  #private;
16
16
  private readonly contentScriptName;
17
17
  readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
18
18
  private static SCRIPT_STARTED_MESSAGE_TYPE;
19
19
  constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
20
+ get signal(): AbortSignal;
21
+ abort(reason?: any): void;
20
22
  get isInvalid(): boolean;
21
23
  get isValid(): boolean;
22
24
  /**
@@ -578,7 +580,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
578
580
  */
579
581
  declare function clean(root?: string): Promise<void>;
580
582
 
581
- var version = "0.8.1";
583
+ var version = "0.8.2";
582
584
 
583
585
  declare function defineConfig(config: UserConfig): UserConfig;
584
586
 
package/dist/index.d.ts CHANGED
@@ -5,18 +5,20 @@ import { LogLevel } from 'consola';
5
5
  import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
6
6
 
7
7
  /**
8
- * Extends [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
8
+ * Implements [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
9
9
  * Used to detect and stop content script code when the script is invalidated.
10
10
  *
11
11
  * It also provides several utilities like `ctx.setTimeout` and `ctx.setInterval` that should be used in
12
12
  * content scripts instead of `window.setTimeout` or `window.setInterval`.
13
13
  */
14
- declare class ContentScriptContext extends AbortController {
14
+ declare class ContentScriptContext implements AbortController {
15
15
  #private;
16
16
  private readonly contentScriptName;
17
17
  readonly options?: Omit<ContentScriptDefinition, "main"> | undefined;
18
18
  private static SCRIPT_STARTED_MESSAGE_TYPE;
19
19
  constructor(contentScriptName: string, options?: Omit<ContentScriptDefinition, "main"> | undefined);
20
+ get signal(): AbortSignal;
21
+ abort(reason?: any): void;
20
22
  get isInvalid(): boolean;
21
23
  get isValid(): boolean;
22
24
  /**
@@ -578,7 +580,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
578
580
  */
579
581
  declare function clean(root?: string): Promise<void>;
580
582
 
581
- var version = "0.8.1";
583
+ var version = "0.8.2";
582
584
 
583
585
  declare function defineConfig(config: UserConfig): UserConfig;
584
586
 
package/dist/index.js CHANGED
@@ -1960,17 +1960,15 @@ async function findEntrypoints(config) {
1960
1960
  });
1961
1961
  relativePaths.sort();
1962
1962
  const pathGlobs = Object.keys(PATH_GLOB_TO_TYPE_MAP);
1963
- const existingNames = {};
1964
- const entrypoints = [];
1965
1963
  let hasBackground = false;
1966
- await Promise.all(
1964
+ const possibleEntrypoints = await Promise.all(
1967
1965
  relativePaths.map(async (relativePath) => {
1968
1966
  const path9 = resolve8(config.entrypointsDir, relativePath);
1969
1967
  const matchingGlob = pathGlobs.find(
1970
1968
  (glob5) => minimatch(relativePath, glob5)
1971
1969
  );
1972
1970
  if (matchingGlob == null) {
1973
- return config.logger.warn(
1971
+ config.logger.warn(
1974
1972
  `${relativePath} does not match any known entrypoint. Known entrypoints:
1975
1973
  ${JSON.stringify(
1976
1974
  PATH_GLOB_TO_TYPE_MAP,
@@ -1978,33 +1976,27 @@ ${JSON.stringify(
1978
1976
  2
1979
1977
  )}`
1980
1978
  );
1979
+ return;
1981
1980
  }
1982
1981
  const type = PATH_GLOB_TO_TYPE_MAP[matchingGlob];
1983
1982
  if (type === "ignored")
1984
1983
  return;
1985
- let entrypoint;
1986
1984
  switch (type) {
1987
1985
  case "popup":
1988
- entrypoint = await getPopupEntrypoint(config, path9);
1989
- break;
1986
+ return await getPopupEntrypoint(config, path9);
1990
1987
  case "options":
1991
- entrypoint = await getOptionsEntrypoint(config, path9);
1992
- break;
1988
+ return await getOptionsEntrypoint(config, path9);
1993
1989
  case "background":
1994
- entrypoint = await getBackgroundEntrypoint(config, path9);
1995
1990
  hasBackground = true;
1996
- break;
1991
+ return await getBackgroundEntrypoint(config, path9);
1997
1992
  case "content-script":
1998
- entrypoint = await getContentScriptEntrypoint(config, path9);
1999
- break;
1993
+ return await getContentScriptEntrypoint(config, path9);
2000
1994
  case "unlisted-page":
2001
- entrypoint = await getUnlistedPageEntrypoint(config, path9);
2002
- break;
1995
+ return await getUnlistedPageEntrypoint(config, path9);
2003
1996
  case "unlisted-script":
2004
- entrypoint = await getUnlistedScriptEntrypoint(config, path9);
2005
- break;
1997
+ return await getUnlistedScriptEntrypoint(config, path9);
2006
1998
  case "content-script-style":
2007
- entrypoint = {
1999
+ return {
2008
2000
  type,
2009
2001
  name: getEntrypointName(config.entrypointsDir, path9),
2010
2002
  inputPath: path9,
@@ -2014,9 +2006,8 @@ ${JSON.stringify(
2014
2006
  exclude: void 0
2015
2007
  }
2016
2008
  };
2017
- break;
2018
2009
  default:
2019
- entrypoint = {
2010
+ return {
2020
2011
  type,
2021
2012
  name: getEntrypointName(config.entrypointsDir, path9),
2022
2013
  inputPath: path9,
@@ -2027,19 +2018,24 @@ ${JSON.stringify(
2027
2018
  }
2028
2019
  };
2029
2020
  }
2030
- const withSameName = existingNames[entrypoint.name];
2031
- if (withSameName) {
2032
- throw Error(
2033
- `Multiple entrypoints with the name "${entrypoint.name}" detected, but only one is allowed: ${[
2034
- relative3(config.root, withSameName.inputPath),
2035
- relative3(config.root, entrypoint.inputPath)
2036
- ].join(", ")}`
2037
- );
2038
- }
2039
- entrypoints.push(entrypoint);
2040
- existingNames[entrypoint.name] = entrypoint;
2041
2021
  })
2042
2022
  );
2023
+ const entrypoints = possibleEntrypoints.filter(
2024
+ (entry) => !!entry
2025
+ );
2026
+ const existingNames = {};
2027
+ entrypoints.forEach((entrypoint) => {
2028
+ const withSameName = existingNames[entrypoint.name];
2029
+ if (withSameName) {
2030
+ throw Error(
2031
+ `Multiple entrypoints with the name "${entrypoint.name}" detected, but only one is allowed: ${[
2032
+ relative3(config.root, withSameName.inputPath),
2033
+ relative3(config.root, entrypoint.inputPath)
2034
+ ].join(", ")}`
2035
+ );
2036
+ }
2037
+ existingNames[entrypoint.name] = entrypoint;
2038
+ });
2043
2039
  if (config.command === "serve" && !hasBackground) {
2044
2040
  entrypoints.push(
2045
2041
  await getBackgroundEntrypoint(config, VIRTUAL_NOOP_BACKGROUND_MODULE_ID)
@@ -2822,12 +2818,10 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
2822
2818
  const newContentScripts = Array.from(hashToEntrypointsMap.entries()).map(
2823
2819
  ([, scripts]) => ({
2824
2820
  ...mapWxtOptionsToContentScript(scripts[0].options, config),
2825
- // TOOD: Sorting css and js arrays here so we get consistent test results... but we
2826
- // shouldn't have to. Where is the inconsistency coming from?
2827
- css: getContentScriptCssFiles(scripts, cssMap)?.sort(),
2821
+ css: getContentScriptCssFiles(scripts, cssMap),
2828
2822
  js: scripts.map(
2829
2823
  (entry) => getEntrypointBundlePath(entry, config.outDir, ".js")
2830
- ).sort()
2824
+ )
2831
2825
  })
2832
2826
  );
2833
2827
  if (newContentScripts.length >= 0) {
@@ -4608,7 +4602,7 @@ async function clean(root = process.cwd()) {
4608
4602
  }
4609
4603
 
4610
4604
  // package.json
4611
- var version2 = "0.8.1";
4605
+ var version2 = "0.8.2";
4612
4606
 
4613
4607
  // src/core/utils/defineConfig.ts
4614
4608
  function defineConfig(config) {