wxt 0.18.5 → 0.18.7

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.
Files changed (35) hide show
  1. package/dist/{chunk-7AOGIMIM.js → chunk-A3R6ZPUA.js} +120 -175
  2. package/dist/{chunk-5X3S6AWF.js → chunk-BERPNPEZ.js} +2 -4
  3. package/dist/{chunk-ZZCTFNQ5.js → chunk-BM6QYGAW.js} +1 -1
  4. package/dist/{chunk-NAMV4VWQ.js → chunk-KPD5J7PZ.js} +1 -1
  5. package/dist/{chunk-VBXJIVYU.js → chunk-QGM4M3NI.js} +1 -2
  6. package/dist/{chunk-73I7FAJU.js → chunk-SGKCDMVR.js} +1 -2
  7. package/dist/cli.js +141 -213
  8. package/dist/client.js +12 -24
  9. package/dist/{execa-QQUOQNS3.js → execa-ATHZH2Y4.js} +1576 -610
  10. package/dist/{execa-5TSWMF32.js → execa-D7CMCKO2.js} +1576 -610
  11. package/dist/{index-q2ZwJBs6.d.cts → index-D6lH9OkP.d.cts} +7 -3
  12. package/dist/{index-q2ZwJBs6.d.ts → index-D6lH9OkP.d.ts} +7 -3
  13. package/dist/index.cjs +2187 -1176
  14. package/dist/index.d.cts +3 -3
  15. package/dist/index.d.ts +3 -3
  16. package/dist/index.js +23 -38
  17. package/dist/modules.cjs +11 -2
  18. package/dist/modules.d.cts +31 -3
  19. package/dist/modules.d.ts +31 -3
  20. package/dist/modules.js +11 -3
  21. package/dist/{prompt-Y7B5HSD5.js → prompt-25QIVJDC.js} +28 -55
  22. package/dist/{prompt-TFJ7OLL7.js → prompt-7BMKNSWS.js} +28 -55
  23. package/dist/sandbox.js +2 -4
  24. package/dist/storage.cjs +4 -8
  25. package/dist/storage.js +6 -10
  26. package/dist/testing.cjs +47 -72
  27. package/dist/testing.d.cts +1 -1
  28. package/dist/testing.d.ts +1 -1
  29. package/dist/testing.js +4 -4
  30. package/dist/virtual/background-entrypoint.js +3 -6
  31. package/dist/virtual/content-script-isolated-world-entrypoint.js +1 -2
  32. package/dist/virtual/content-script-main-world-entrypoint.js +1 -2
  33. package/dist/virtual/reload-html.js +1 -2
  34. package/dist/virtual/unlisted-script-entrypoint.js +1 -2
  35. package/package.json +34 -33
@@ -2,17 +2,17 @@ import {
2
2
  every,
3
3
  some,
4
4
  toArray
5
- } from "./chunk-5X3S6AWF.js";
5
+ } from "./chunk-BERPNPEZ.js";
6
6
  import {
7
7
  LogLevels,
8
8
  consola
9
- } from "./chunk-ZZCTFNQ5.js";
9
+ } from "./chunk-BM6QYGAW.js";
10
10
  import {
11
11
  __require
12
- } from "./chunk-VBXJIVYU.js";
12
+ } from "./chunk-QGM4M3NI.js";
13
13
 
14
14
  // package.json
15
- var version = "0.18.5";
15
+ var version = "0.18.6";
16
16
 
17
17
  // src/core/utils/paths.ts
18
18
  import systemPath from "node:path";
@@ -60,12 +60,9 @@ function isHtmlEntrypoint(entrypoint) {
60
60
 
61
61
  // src/core/utils/time.ts
62
62
  function formatDuration(duration) {
63
- if (duration < 1e3)
64
- return `${duration} ms`;
65
- if (duration < 1e4)
66
- return `${(duration / 1e3).toFixed(3)} s`;
67
- if (duration < 6e4)
68
- return `${(duration / 1e3).toFixed(1)} s`;
63
+ if (duration < 1e3) return `${duration} ms`;
64
+ if (duration < 1e4) return `${(duration / 1e3).toFixed(3)} s`;
65
+ if (duration < 6e4) return `${(duration / 1e3).toFixed(1)} s`;
69
66
  return `${(duration / 1e3).toFixed(0)} s`;
70
67
  }
71
68
  function withTimeout(promise, duration) {
@@ -108,8 +105,7 @@ async function fetchCached(url, config) {
108
105
  );
109
106
  }
110
107
  }
111
- if (!content)
112
- content = await config.fsCache.get(url) ?? "";
108
+ if (!content) content = await config.fsCache.get(url) ?? "";
113
109
  if (!content)
114
110
  throw Error(
115
111
  `Offline and "${url}" has not been cached. Try again when online.`
@@ -122,12 +118,10 @@ function download(config) {
122
118
  return {
123
119
  name: "wxt:download",
124
120
  resolveId(id) {
125
- if (id.startsWith("url:"))
126
- return "\0" + id;
121
+ if (id.startsWith("url:")) return "\0" + id;
127
122
  },
128
123
  async load(id) {
129
- if (!id.startsWith("\0url:"))
130
- return;
124
+ if (!id.startsWith("\0url:")) return;
131
125
  const url = id.replace("\0url:", "");
132
126
  return await fetchCached(url, config);
133
127
  }
@@ -147,8 +141,7 @@ var ENABLED_EXTENSIONS = /* @__PURE__ */ new Set([
147
141
  ]);
148
142
  function unimport(config) {
149
143
  const options = config.imports;
150
- if (options === false)
151
- return [];
144
+ if (options === false) return [];
152
145
  const unimport2 = createUnimport(options);
153
146
  return {
154
147
  name: "wxt:unimport",
@@ -156,10 +149,8 @@ function unimport(config) {
156
149
  await unimport2.scanImportsFromDir(void 0, { cwd: config.srcDir });
157
150
  },
158
151
  async transform(code, id) {
159
- if (id.includes("node_modules"))
160
- return;
161
- if (!ENABLED_EXTENSIONS.has(extname(id)))
162
- return;
152
+ if (id.includes("node_modules")) return;
153
+ if (!ENABLED_EXTENSIONS.has(extname(id))) return;
163
154
  const injected = await unimport2.injectImports(code, id);
164
155
  return {
165
156
  code: injected.code,
@@ -282,15 +273,16 @@ function webextensionPolyfillMock(config) {
282
273
  // src/core/builders/vite/plugins/devHtmlPrerender.ts
283
274
  import { parseHTML } from "linkedom";
284
275
  import { dirname, relative as relative2, resolve as resolve2 } from "node:path";
285
- var reactRefreshPreamble = "";
276
+ import { murmurHash } from "ohash";
277
+ var inlineScriptContents = {};
286
278
  function devHtmlPrerender(config, server) {
287
279
  const htmlReloadId = "@wxt/reload-html";
288
280
  const resolvedHtmlReloadId = resolve2(
289
281
  config.wxtModuleDir,
290
282
  "dist/virtual/reload-html.js"
291
283
  );
292
- const virtualReactRefreshId = "@wxt/virtual-react-refresh";
293
- const resolvedVirtualReactRefreshId = "\0" + virtualReactRefreshId;
284
+ const virtualInlineScript = "virtual:wxt-inline-script";
285
+ const resolvedVirtualInlineScript = "\0" + virtualInlineScript;
294
286
  return [
295
287
  {
296
288
  apply: "build",
@@ -325,23 +317,22 @@ function devHtmlPrerender(config, server) {
325
317
  },
326
318
  // Pass the HTML through the dev server to add dev-mode specific code
327
319
  async transformIndexHtml(html, ctx) {
328
- if (config.command !== "serve" || server == null)
329
- return;
320
+ if (config.command !== "serve" || server == null) return;
330
321
  const originalUrl = `${server.origin}${ctx.path}`;
331
322
  const name = getEntrypointName(config.entrypointsDir, ctx.filename);
332
323
  const url = `${server.origin}/${name}.html`;
333
324
  const serverHtml = await server.transformHtml(url, html, originalUrl);
334
325
  const { document } = parseHTML(serverHtml);
335
- const reactRefreshScript = Array.from(
336
- document.querySelectorAll("script[type=module]")
337
- ).find((script) => script.innerHTML.includes("@react-refresh"));
338
- if (reactRefreshScript) {
339
- reactRefreshPreamble = reactRefreshScript.innerHTML;
326
+ const inlineScripts = document.querySelectorAll("script:not([src])");
327
+ inlineScripts.forEach((script) => {
328
+ const textContent = script.textContent ?? "";
329
+ const hash = murmurHash(textContent);
330
+ inlineScriptContents[hash] = textContent;
340
331
  const virtualScript = document.createElement("script");
341
332
  virtualScript.type = "module";
342
- virtualScript.src = `${server.origin}/${virtualReactRefreshId}`;
343
- reactRefreshScript.replaceWith(virtualScript);
344
- }
333
+ virtualScript.src = `${server.origin}/@id/${virtualInlineScript}?${hash}`;
334
+ script.replaceWith(virtualScript);
335
+ });
345
336
  const viteClientScript = document.querySelector(
346
337
  "script[src='/@vite/client']"
347
338
  );
@@ -359,16 +350,17 @@ function devHtmlPrerender(config, server) {
359
350
  name: "wxt:virtualize-react-refresh",
360
351
  apply: "serve",
361
352
  resolveId(id) {
362
- if (id === `/${virtualReactRefreshId}`) {
363
- return resolvedVirtualReactRefreshId;
353
+ if (id.startsWith(virtualInlineScript)) {
354
+ return "\0" + id;
364
355
  }
365
356
  if (id.startsWith("/chunks/")) {
366
357
  return "\0noop";
367
358
  }
368
359
  },
369
360
  load(id) {
370
- if (id === resolvedVirtualReactRefreshId) {
371
- return reactRefreshPreamble;
361
+ if (id.startsWith(resolvedVirtualInlineScript)) {
362
+ const hash = Number(id.substring(id.indexOf("?") + 1));
363
+ return inlineScriptContents[hash];
372
364
  }
373
365
  if (id === "\0noop") {
374
366
  return "";
@@ -380,8 +372,7 @@ function devHtmlPrerender(config, server) {
380
372
  function pointToDevServer(config, server, id, document, querySelector, attr) {
381
373
  document.querySelectorAll(querySelector).forEach((element) => {
382
374
  const src = element.getAttribute(attr);
383
- if (!src || isUrl(src))
384
- return;
375
+ if (!src || isUrl(src)) return;
385
376
  let resolvedAbsolutePath;
386
377
  const matchingAlias = Object.entries(config.alias).find(
387
378
  ([key]) => src.startsWith(key)
@@ -401,8 +392,7 @@ function pointToDevServer(config, server, id, document, querySelector, attr) {
401
392
  );
402
393
  if (relativePath.startsWith(".")) {
403
394
  let path8 = normalizePath(resolvedAbsolutePath);
404
- if (!path8.startsWith("/"))
405
- path8 = "/" + path8;
395
+ if (!path8.startsWith("/")) path8 = "/" + path8;
406
396
  element.setAttribute(attr, `${server.origin}/@fs${path8}`);
407
397
  } else {
408
398
  const url = new URL(relativePath, server.origin);
@@ -425,8 +415,7 @@ function devServerGlobals(config, server) {
425
415
  return {
426
416
  name: "wxt:dev-server-globals",
427
417
  config() {
428
- if (server == null || config.command == "build")
429
- return;
418
+ if (server == null || config.command == "build") return;
430
419
  return {
431
420
  define: {
432
421
  __DEV_SERVER_PROTOCOL__: JSON.stringify("ws:"),
@@ -524,14 +513,12 @@ function resolveVirtualModules(config) {
524
513
  name: `wxt:resolve-virtual-${name}`,
525
514
  resolveId(id) {
526
515
  const index = id.indexOf(virtualId);
527
- if (index === -1)
528
- return;
516
+ if (index === -1) return;
529
517
  const inputPath = normalizePath(id.substring(index + virtualId.length));
530
518
  return resolvedVirtualId + inputPath;
531
519
  },
532
520
  async load(id) {
533
- if (!id.startsWith(resolvedVirtualId))
534
- return;
521
+ if (!id.startsWith(resolvedVirtualId)) return;
535
522
  const inputPath = id.replace(resolvedVirtualId, "");
536
523
  const template = await fs2.readFile(
537
524
  resolve4(config.wxtModuleDir, `dist/virtual/${name}.js`),
@@ -553,8 +540,7 @@ function noopBackground() {
553
540
  return {
554
541
  name: "wxt:noop-background",
555
542
  resolveId(id) {
556
- if (id === virtualModuleId)
557
- return resolvedVirtualModuleId;
543
+ if (id === virtualModuleId) return resolvedVirtualModuleId;
558
544
  },
559
545
  load(id) {
560
546
  if (id === resolvedVirtualModuleId) {
@@ -582,8 +568,7 @@ function cssEntrypoints(entrypoint, config) {
582
568
  },
583
569
  generateBundle(_, bundle) {
584
570
  Object.keys(bundle).forEach((file) => {
585
- if (file.endsWith(".js"))
586
- delete bundle[file];
571
+ if (file.endsWith(".js")) delete bundle[file];
587
572
  });
588
573
  }
589
574
  };
@@ -609,8 +594,7 @@ function excludeBrowserPolyfill(config) {
609
594
  return {
610
595
  name: "wxt:exclude-browser-polyfill",
611
596
  config() {
612
- if (config.experimental.includeBrowserPolyfill)
613
- return;
597
+ if (config.experimental.includeBrowserPolyfill) return;
614
598
  return {
615
599
  resolve: {
616
600
  alias: {
@@ -685,8 +669,7 @@ function removeEntrypointMainFunction(config, path8) {
685
669
  return {
686
670
  name: "wxt:remove-entrypoint-main-function",
687
671
  transform(code, id) {
688
- if (id === absPath)
689
- return removeMainFunctionCode(code);
672
+ if (id === absPath) return removeMainFunctionCode(code);
690
673
  }
691
674
  };
692
675
  }
@@ -701,10 +684,8 @@ function wxtPluginLoader(config) {
701
684
  return {
702
685
  name: "wxt:plugin-loader",
703
686
  resolveId(id) {
704
- if (id === virtualModuleId)
705
- return resolvedVirtualModuleId;
706
- if (id === virtualHtmlModuleId)
707
- return resolvedVirtualHtmlModuleId;
687
+ if (id === virtualModuleId) return resolvedVirtualModuleId;
688
+ if (id === virtualHtmlModuleId) return resolvedVirtualHtmlModuleId;
708
689
  },
709
690
  load(id) {
710
691
  if (id === resolvedVirtualModuleId) {
@@ -735,7 +716,7 @@ try {
735
716
  const { document } = parseHTML2(html);
736
717
  const script = document.createElement("script");
737
718
  script.type = "module";
738
- script.src = "virtual:wxt-html-plugins";
719
+ script.src = config.command === "serve" ? `http://${config.dev.server?.hostname}:${config.dev.server?.port}/@id/${virtualHtmlModuleId}` : virtualHtmlModuleId;
739
720
  if (document.head == null) {
740
721
  const newHead = document.createElement("head");
741
722
  document.documentElement.prepend(newHead);
@@ -777,8 +758,7 @@ async function writeFileIfDifferent(file, newContents) {
777
758
  }
778
759
  }
779
760
  async function getPublicFiles() {
780
- if (!await fs3.exists(wxt.config.publicDir))
781
- return [];
761
+ if (!await fs3.exists(wxt.config.publicDir)) return [];
782
762
  const files = await glob("**/*", { cwd: wxt.config.publicDir });
783
763
  return files.map(unnormalizePath);
784
764
  }
@@ -811,8 +791,7 @@ async function copyPublicDirectory() {
811
791
  relativeDest: file
812
792
  }));
813
793
  await wxt.hooks.callHook("build:publicAssets", wxt, files);
814
- if (files.length === 0)
815
- return [];
794
+ if (files.length === 0) return [];
816
795
  const publicAssets = [];
817
796
  for (const { absoluteSrc, relativeDest } of files) {
818
797
  const absoluteDest = resolve6(wxt.config.outDir, relativeDest);
@@ -832,21 +811,18 @@ function detectDevChanges(changedFiles, currentOutput) {
832
811
  changedFiles,
833
812
  (file) => file === wxt.config.userConfigMetadata.configFile
834
813
  );
835
- if (isConfigChange)
836
- return { type: "full-restart" };
814
+ if (isConfigChange) return { type: "full-restart" };
837
815
  const isRunnerChange = some(
838
816
  changedFiles,
839
817
  (file) => file === wxt.config.runnerConfig.configFile
840
818
  );
841
- if (isRunnerChange)
842
- return { type: "browser-restart" };
819
+ if (isRunnerChange) return { type: "browser-restart" };
843
820
  const changedSteps = new Set(
844
821
  changedFiles.flatMap(
845
822
  (changedFile) => findEffectedSteps(changedFile, currentOutput)
846
823
  )
847
824
  );
848
- if (changedSteps.size === 0)
849
- return { type: "no-change" };
825
+ if (changedSteps.size === 0) return { type: "no-change" };
850
826
  const unchangedOutput = {
851
827
  manifest: currentOutput.manifest,
852
828
  steps: [],
@@ -909,14 +885,12 @@ function findEffectedSteps(changedFile, currentOutput) {
909
885
  );
910
886
  for (const step of currentOutput.steps) {
911
887
  const effectedChunk = step.chunks.find((chunk) => isChunkEffected(chunk));
912
- if (effectedChunk)
913
- changes.push(step);
888
+ if (effectedChunk) changes.push(step);
914
889
  }
915
890
  const effectedAsset = currentOutput.publicAssets.find(
916
891
  (chunk) => isChunkEffected(chunk)
917
892
  );
918
- if (effectedAsset)
919
- changes.push(effectedAsset);
893
+ if (effectedAsset) changes.push(effectedAsset);
920
894
  return changes;
921
895
  }
922
896
 
@@ -1576,7 +1550,14 @@ async function writeMainDeclarationFile(references) {
1576
1550
  `/// <reference types="wxt/vite-builder-env" />`,
1577
1551
  ...references.map(
1578
1552
  (ref) => `/// <reference types="./${normalizePath(relative5(dir, ref))}" />`
1579
- )
1553
+ ),
1554
+ // Add references to modules installed from NPM to the TS project so
1555
+ // their type augmentation can update InlineConfig correctly. Local
1556
+ // modules defined in <root>/modules are already apart of the project, so
1557
+ // we don't need to add them.
1558
+ ...wxt.config.modules.filter(
1559
+ (module) => module.type === "node_module" && module.configKey != null
1560
+ ).map((module) => `/// <reference types="${module.id}" />`)
1580
1561
  ].join("\n") + "\n"
1581
1562
  );
1582
1563
  return filePath;
@@ -1689,8 +1670,7 @@ async function resolveConfig(inlineConfig, command) {
1689
1670
  const mergedConfig = await mergeInlineConfig(inlineConfig, userConfig);
1690
1671
  const debug = mergedConfig.debug ?? false;
1691
1672
  const logger = mergedConfig.logger ?? consola;
1692
- if (debug)
1693
- logger.level = LogLevels.debug;
1673
+ if (debug) logger.level = LogLevels.debug;
1694
1674
  const browser = mergedConfig.browser ?? "chrome";
1695
1675
  const manifestVersion = mergedConfig.manifestVersion ?? (browser === "firefox" || browser === "safari" ? 2 : 3);
1696
1676
  const mode = mergedConfig.mode ?? COMMAND_MODES[command];
@@ -1866,8 +1846,7 @@ function resolveAnalysisConfig(root, mergedConfig) {
1866
1846
  };
1867
1847
  }
1868
1848
  async function getUnimportOptions(wxtDir, logger, config) {
1869
- if (config.imports === false)
1870
- return false;
1849
+ if (config.imports === false) return false;
1871
1850
  const enabledConfig = config.imports?.eslintrc?.enabled;
1872
1851
  let enabled;
1873
1852
  switch (enabledConfig) {
@@ -1944,7 +1923,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
1944
1923
  if (mod.default == null) {
1945
1924
  throw Error("Module missing default export: " + moduleId);
1946
1925
  }
1947
- return mod.default;
1926
+ return {
1927
+ ...mod.default,
1928
+ type: "node_module",
1929
+ id: moduleId
1930
+ };
1948
1931
  })
1949
1932
  );
1950
1933
  const localModulePaths = await glob3(["*.[tj]s", "*/index.[tj]s"], {
@@ -1953,8 +1936,9 @@ async function resolveWxtModules(modulesDir, modules = []) {
1953
1936
  }).catch(() => []);
1954
1937
  const localModules = await Promise.all(
1955
1938
  localModulePaths.map(async (file) => {
1939
+ const absolutePath = normalizePath(path5.resolve(modulesDir, file));
1956
1940
  const { config } = await loadConfig({
1957
- configFile: path5.resolve(modulesDir, file),
1941
+ configFile: absolutePath,
1958
1942
  globalRc: false,
1959
1943
  rcFile: false,
1960
1944
  packageJson: false,
@@ -1966,7 +1950,11 @@ async function resolveWxtModules(modulesDir, modules = []) {
1966
1950
  `No config found for ${file}. Did you forget to add a default export?`
1967
1951
  );
1968
1952
  config.name ??= file;
1969
- return config;
1953
+ return {
1954
+ ...config,
1955
+ type: "local",
1956
+ id: absolutePath
1957
+ };
1970
1958
  })
1971
1959
  );
1972
1960
  return [...npmModules, ...localModules];
@@ -2026,8 +2014,7 @@ import { filesize } from "filesize";
2026
2014
 
2027
2015
  // src/core/utils/log/printTable.ts
2028
2016
  function printTable(log, header, rows, gap = 2) {
2029
- if (rows.length === 0)
2030
- return;
2017
+ if (rows.length === 0) return;
2031
2018
  const columnWidths = rows.reduce(
2032
2019
  (widths, row) => {
2033
2020
  for (let i = 0; i < Math.max(widths.length, row.length); i++) {
@@ -2041,11 +2028,9 @@ function printTable(log, header, rows, gap = 2) {
2041
2028
  rows.forEach((row, i) => {
2042
2029
  row.forEach((col, j) => {
2043
2030
  str += col.padEnd(columnWidths[j], " ");
2044
- if (j !== row.length - 1)
2045
- str += "".padEnd(gap, " ");
2031
+ if (j !== row.length - 1) str += "".padEnd(gap, " ");
2046
2032
  });
2047
- if (i !== rows.length - 1)
2048
- str += "\n";
2033
+ if (i !== rows.length - 1) str += "\n";
2049
2034
  });
2050
2035
  log(`${header}
2051
2036
  ${str}`);
@@ -2099,8 +2084,7 @@ async function printBuildSummary(log, header, output) {
2099
2084
  const lWeight = getChunkSortWeight(l.fileName);
2100
2085
  const rWeight = getChunkSortWeight(r.fileName);
2101
2086
  const diff = lWeight - rWeight;
2102
- if (diff !== 0)
2103
- return diff;
2087
+ if (diff !== 0) return diff;
2104
2088
  return l.fileName.localeCompare(r.fileName);
2105
2089
  });
2106
2090
  const files = chunks.map(
@@ -2145,8 +2129,7 @@ var ContentSecurityPolicy = class _ContentSecurityPolicy {
2145
2129
  const sections = csp.split(";").map((section) => section.trim());
2146
2130
  this.data = sections.reduce((data, section) => {
2147
2131
  const [key, ...values] = section.split(" ").map((item) => item.trim());
2148
- if (key)
2149
- data[key] = values;
2132
+ if (key) data[key] = values;
2150
2133
  return data;
2151
2134
  }, {});
2152
2135
  } else {
@@ -2159,8 +2142,7 @@ var ContentSecurityPolicy = class _ContentSecurityPolicy {
2159
2142
  add(directive, ...newValues) {
2160
2143
  const values = this.data[directive] ?? [];
2161
2144
  newValues.forEach((newValue) => {
2162
- if (!values.includes(newValue))
2163
- values.push(newValue);
2145
+ if (!values.includes(newValue)) values.push(newValue);
2164
2146
  });
2165
2147
  this.data[directive] = values;
2166
2148
  return this;
@@ -2183,8 +2165,7 @@ function hashContentScriptOptions(options) {
2183
2165
  void 0
2184
2166
  );
2185
2167
  Object.keys(simplifiedOptions).forEach((key) => {
2186
- if (simplifiedOptions[key] == null)
2187
- delete simplifiedOptions[key];
2168
+ if (simplifiedOptions[key] == null) delete simplifiedOptions[key];
2188
2169
  });
2189
2170
  const withDefaults = {
2190
2171
  exclude_globs: [],
@@ -2200,10 +2181,8 @@ function hashContentScriptOptions(options) {
2200
2181
  };
2201
2182
  return JSON.stringify(
2202
2183
  Object.entries(withDefaults).map(([key, value]) => {
2203
- if (Array.isArray(value))
2204
- return [key, value.sort()];
2205
- else
2206
- return [key, value];
2184
+ if (Array.isArray(value)) return [key, value.sort()];
2185
+ else return [key, value];
2207
2186
  }).sort((l, r) => l[0].localeCompare(r[0]))
2208
2187
  );
2209
2188
  }
@@ -2293,10 +2272,8 @@ async function generateManifest(entrypoints, buildOutput) {
2293
2272
  manifest.version_name = // Firefox doesn't support version_name
2294
2273
  wxt.config.browser === "firefox" || versionName === version2 ? void 0 : versionName;
2295
2274
  addEntrypoints(manifest, entrypoints, buildOutput);
2296
- if (wxt.config.command === "serve")
2297
- addDevModeCsp(manifest);
2298
- if (wxt.config.command === "serve")
2299
- addDevModePermissions(manifest);
2275
+ if (wxt.config.command === "serve") addDevModeCsp(manifest);
2276
+ if (wxt.config.command === "serve") addDevModePermissions(manifest);
2300
2277
  wxt.config.transformManifest?.(manifest);
2301
2278
  await wxt.hooks.callHook("build:manifestGenerated", wxt, manifest);
2302
2279
  if (wxt.config.manifestVersion === 2) {
@@ -2501,10 +2478,8 @@ function addEntrypoints(manifest, entrypoints, buildOutput) {
2501
2478
  } else {
2502
2479
  const hashToEntrypointsMap = contentScripts.filter((cs) => cs.options.registration !== "runtime").reduce((map, script) => {
2503
2480
  const hash = hashContentScriptOptions(script.options);
2504
- if (map.has(hash))
2505
- map.get(hash)?.push(script);
2506
- else
2507
- map.set(hash, [script]);
2481
+ if (map.has(hash)) map.get(hash)?.push(script);
2482
+ else map.set(hash, [script]);
2508
2483
  return map;
2509
2484
  }, /* @__PURE__ */ new Map());
2510
2485
  const manifestContentScripts = Array.from(
@@ -2573,8 +2548,7 @@ function discoverIcons(buildOutput) {
2573
2548
  break;
2574
2549
  }
2575
2550
  }
2576
- if (size == null)
2577
- return;
2551
+ if (size == null) return;
2578
2552
  icons.push([size, normalizePath(asset.fileName)]);
2579
2553
  });
2580
2554
  return icons.length > 0 ? Object.fromEntries(icons) : void 0;
@@ -2613,8 +2587,7 @@ function addDevModeCsp(manifest) {
2613
2587
  }
2614
2588
  function addDevModePermissions(manifest) {
2615
2589
  addPermission(manifest, "tabs");
2616
- if (wxt.config.manifestVersion === 3)
2617
- addPermission(manifest, "scripting");
2590
+ if (wxt.config.manifestVersion === 3) addPermission(manifest, "scripting");
2618
2591
  }
2619
2592
  function getContentScriptCssFiles(contentScripts, contentScriptCssMap) {
2620
2593
  const css = [];
@@ -2622,23 +2595,18 @@ function getContentScriptCssFiles(contentScripts, contentScriptCssMap) {
2622
2595
  if (script.options.cssInjectionMode === "manual" || script.options.cssInjectionMode === "ui")
2623
2596
  return;
2624
2597
  const cssFile = contentScriptCssMap[script.name];
2625
- if (cssFile == null)
2626
- return;
2627
- if (cssFile)
2628
- css.push(cssFile);
2598
+ if (cssFile == null) return;
2599
+ if (cssFile) css.push(cssFile);
2629
2600
  });
2630
- if (css.length > 0)
2631
- return css;
2601
+ if (css.length > 0) return css;
2632
2602
  return void 0;
2633
2603
  }
2634
2604
  function getContentScriptCssWebAccessibleResources(contentScripts, contentScriptCssMap) {
2635
2605
  const resources = [];
2636
2606
  contentScripts.forEach((script) => {
2637
- if (script.options.cssInjectionMode !== "ui")
2638
- return;
2607
+ if (script.options.cssInjectionMode !== "ui") return;
2639
2608
  const cssFile = contentScriptCssMap[script.name];
2640
- if (cssFile == null)
2641
- return;
2609
+ if (cssFile == null) return;
2642
2610
  resources.push({
2643
2611
  resources: [cssFile],
2644
2612
  matches: script.options.matches.map(
@@ -2655,46 +2623,39 @@ function getContentScriptsCssMap(buildOutput, scripts) {
2655
2623
  const relatedCss = allChunks.find(
2656
2624
  (chunk) => chunk.fileName === `content-scripts/${script.name}.css`
2657
2625
  );
2658
- if (relatedCss != null)
2659
- map[script.name] = relatedCss.fileName;
2626
+ if (relatedCss != null) map[script.name] = relatedCss.fileName;
2660
2627
  });
2661
2628
  return map;
2662
2629
  }
2663
2630
  function addPermission(manifest, permission) {
2664
2631
  manifest.permissions ??= [];
2665
- if (manifest.permissions.includes(permission))
2666
- return;
2632
+ if (manifest.permissions.includes(permission)) return;
2667
2633
  manifest.permissions.push(permission);
2668
2634
  }
2669
2635
  function addHostPermission(manifest, hostPermission) {
2670
2636
  manifest.host_permissions ??= [];
2671
- if (manifest.host_permissions.includes(hostPermission))
2672
- return;
2637
+ if (manifest.host_permissions.includes(hostPermission)) return;
2673
2638
  manifest.host_permissions.push(hostPermission);
2674
2639
  }
2675
2640
  function stripPathFromMatchPattern(pattern) {
2676
2641
  const protocolSepIndex = pattern.indexOf("://");
2677
- if (protocolSepIndex === -1)
2678
- return pattern;
2642
+ if (protocolSepIndex === -1) return pattern;
2679
2643
  const startOfPath = pattern.indexOf("/", protocolSepIndex + 3);
2680
2644
  return pattern.substring(0, startOfPath) + "/*";
2681
2645
  }
2682
2646
  function convertWebAccessibleResourcesToMv2(manifest) {
2683
- if (manifest.web_accessible_resources == null)
2684
- return;
2647
+ if (manifest.web_accessible_resources == null) return;
2685
2648
  manifest.web_accessible_resources = Array.from(
2686
2649
  new Set(
2687
2650
  manifest.web_accessible_resources.flatMap((item) => {
2688
- if (typeof item === "string")
2689
- return item;
2651
+ if (typeof item === "string") return item;
2690
2652
  return item.resources;
2691
2653
  })
2692
2654
  )
2693
2655
  );
2694
2656
  }
2695
2657
  function moveHostPermissionsToPermissions(manifest) {
2696
- if (!manifest.host_permissions?.length)
2697
- return;
2658
+ if (!manifest.host_permissions?.length) return;
2698
2659
  manifest.host_permissions.forEach(
2699
2660
  (permission) => addPermission(manifest, permission)
2700
2661
  );
@@ -2706,8 +2667,7 @@ function convertActionToMv2(manifest) {
2706
2667
  manifest.browser_action = manifest.action;
2707
2668
  }
2708
2669
  function validateMv3WebAccessbileResources(manifest) {
2709
- if (manifest.web_accessible_resources == null)
2710
- return;
2670
+ if (manifest.web_accessible_resources == null) return;
2711
2671
  const stringResources = manifest.web_accessible_resources.filter(
2712
2672
  (item) => typeof item === "string"
2713
2673
  );
@@ -2769,8 +2729,7 @@ async function rebuild(allEntrypoints, entrypointGroups, existingOutput = {
2769
2729
  const spinner = ora(`Preparing...`).start();
2770
2730
  await generateTypesDir(allEntrypoints).catch((err) => {
2771
2731
  wxt.logger.warn("Failed to update .wxt directory:", err);
2772
- if (wxt.config.command === "build")
2773
- throw err;
2732
+ if (wxt.config.command === "build") throw err;
2774
2733
  });
2775
2734
  const newOutput = await buildEntrypoints(entrypointGroups, spinner);
2776
2735
  const mergedOutput = {
@@ -2814,10 +2773,8 @@ function validateEntrypoints(entrypoints) {
2814
2773
  let errorCount = 0;
2815
2774
  let warningCount = 0;
2816
2775
  for (const err of errors) {
2817
- if (err.type === "warning")
2818
- warningCount++;
2819
- else
2820
- errorCount++;
2776
+ if (err.type === "warning") warningCount++;
2777
+ else errorCount++;
2821
2778
  }
2822
2779
  return {
2823
2780
  errors,
@@ -2979,7 +2936,7 @@ var npm = {
2979
2936
  overridesKey: "overrides",
2980
2937
  async downloadDependency(id, downloadDir) {
2981
2938
  await ensureDir3(downloadDir);
2982
- const { execa } = await import("./execa-5TSWMF32.js");
2939
+ const { execa } = await import("./execa-D7CMCKO2.js");
2983
2940
  const res = await execa("npm", ["pack", id, "--json"], {
2984
2941
  cwd: downloadDir
2985
2942
  });
@@ -2991,7 +2948,7 @@ var npm = {
2991
2948
  if (options?.all) {
2992
2949
  args.push("--depth", "Infinity");
2993
2950
  }
2994
- const { execa } = await import("./execa-5TSWMF32.js");
2951
+ const { execa } = await import("./execa-D7CMCKO2.js");
2995
2952
  const res = await execa("npm", args, { cwd: options?.cwd });
2996
2953
  const project = JSON.parse(res.stdout);
2997
2954
  return flattenNpmListOutput([project]);
@@ -3001,10 +2958,8 @@ function flattenNpmListOutput(projects) {
3001
2958
  const queue = projects.flatMap(
3002
2959
  (project) => {
3003
2960
  const acc = [];
3004
- if (project.dependencies)
3005
- acc.push(project.dependencies);
3006
- if (project.devDependencies)
3007
- acc.push(project.devDependencies);
2961
+ if (project.dependencies) acc.push(project.dependencies);
2962
+ if (project.devDependencies) acc.push(project.devDependencies);
3008
2963
  return acc;
3009
2964
  }
3010
2965
  );
@@ -3015,10 +2970,8 @@ function flattenNpmListOutput(projects) {
3015
2970
  name,
3016
2971
  version: meta.version
3017
2972
  });
3018
- if (meta.dependencies)
3019
- queue.push(meta.dependencies);
3020
- if (meta.devDependencies)
3021
- queue.push(meta.devDependencies);
2973
+ if (meta.dependencies) queue.push(meta.dependencies);
2974
+ if (meta.devDependencies) queue.push(meta.devDependencies);
3022
2975
  });
3023
2976
  }
3024
2977
  return dedupeDependencies(dependencies);
@@ -3048,7 +3001,7 @@ var bun = {
3048
3001
  if (options?.all) {
3049
3002
  args.push("--all");
3050
3003
  }
3051
- const { execa } = await import("./execa-5TSWMF32.js");
3004
+ const { execa } = await import("./execa-D7CMCKO2.js");
3052
3005
  const res = await execa("bun", args, { cwd: options?.cwd });
3053
3006
  return dedupeDependencies(
3054
3007
  res.stdout.split("\n").slice(1).map((line) => line.trim()).map((line) => /.* (@?\S+)@(\S+)$/.exec(line)).filter((match) => !!match).map(([_, name, version2]) => ({ name, version: version2 }))
@@ -3067,11 +3020,10 @@ var yarn = {
3067
3020
  if (options?.all) {
3068
3021
  args.push("--depth", "Infinity");
3069
3022
  }
3070
- const { execa } = await import("./execa-5TSWMF32.js");
3023
+ const { execa } = await import("./execa-D7CMCKO2.js");
3071
3024
  const res = await execa("yarn", args, { cwd: options?.cwd });
3072
3025
  const tree = res.stdout.split("\n").map((line) => JSON.parse(line)).find((line) => line.type === "tree")?.data;
3073
- if (tree == null)
3074
- throw Error("'yarn list --json' did not output a tree");
3026
+ if (tree == null) throw Error("'yarn list --json' did not output a tree");
3075
3027
  const queue = [...tree.trees];
3076
3028
  const dependencies = [];
3077
3029
  while (queue.length > 0) {
@@ -3104,7 +3056,7 @@ var pnpm = {
3104
3056
  if (typeof process !== "undefined" && process.env.WXT_PNPM_IGNORE_WORKSPACE === "true") {
3105
3057
  args.push("--ignore-workspace");
3106
3058
  }
3107
- const { execa } = await import("./execa-5TSWMF32.js");
3059
+ const { execa } = await import("./execa-D7CMCKO2.js");
3108
3060
  const res = await execa("pnpm", args, { cwd: options?.cwd });
3109
3061
  const projects = JSON.parse(res.stdout);
3110
3062
  return flattenNpmListOutput(projects);
@@ -3117,8 +3069,7 @@ async function createWxtPackageManager(root) {
3117
3069
  includeParentDirs: true
3118
3070
  });
3119
3071
  const requirePm = (cb) => {
3120
- if (pm == null)
3121
- throw Error("Could not detect package manager");
3072
+ if (pm == null) throw Error("Could not detect package manager");
3122
3073
  return cb(pm);
3123
3074
  };
3124
3075
  return {
@@ -3280,8 +3231,7 @@ async function createViteBuilder(wxtConfig, hooks, server) {
3280
3231
  // Include a hash to prevent conflicts
3281
3232
  chunkFileNames: "chunks/[name]-[hash].js",
3282
3233
  entryFileNames: ({ name }) => {
3283
- if (htmlEntrypoints.has(name))
3284
- return "chunks/[name]-[hash].js";
3234
+ if (htmlEntrypoints.has(name)) return "chunks/[name]-[hash].js";
3285
3235
  return "[name].js";
3286
3236
  },
3287
3237
  // We can't control the "name", so we need a hash to prevent conflicts
@@ -3334,12 +3284,10 @@ async function createViteBuilder(wxtConfig, hooks, server) {
3334
3284
  },
3335
3285
  async build(group) {
3336
3286
  let entryConfig;
3337
- if (Array.isArray(group))
3338
- entryConfig = getMultiPageConfig(group);
3287
+ if (Array.isArray(group)) entryConfig = getMultiPageConfig(group);
3339
3288
  else if (group.inputPath.endsWith(".css"))
3340
3289
  entryConfig = getCssConfig(group);
3341
- else
3342
- entryConfig = getLibModeConfig(group);
3290
+ else entryConfig = getLibModeConfig(group);
3343
3291
  const buildConfig = vite.mergeConfig(await getBaseConfig(), entryConfig);
3344
3292
  await hooks.callHook(
3345
3293
  "vite:build:extendConfig",
@@ -3390,10 +3338,8 @@ async function createViteBuilder(wxtConfig, hooks, server) {
3390
3338
  };
3391
3339
  }
3392
3340
  function getBuildOutputChunks(result) {
3393
- if ("on" in result)
3394
- throw Error("wxt does not support vite watch mode.");
3395
- if (Array.isArray(result))
3396
- return result.flatMap(({ output }) => output);
3341
+ if ("on" in result) throw Error("wxt does not support vite watch mode.");
3342
+ if (Array.isArray(result)) return result.flatMap(({ output }) => output);
3397
3343
  return result.output;
3398
3344
  }
3399
3345
  function getRollupEntry(entrypoint) {
@@ -3436,8 +3382,7 @@ async function registerWxt(command, inlineConfig = {}, getServer) {
3436
3382
  server
3437
3383
  };
3438
3384
  for (const module of config.modules) {
3439
- if (module.hooks)
3440
- wxt.hooks.addHooks(module.hooks);
3385
+ if (module.hooks) wxt.hooks.addHooks(module.hooks);
3441
3386
  if (wxt.config.imports !== false && module.imports) {
3442
3387
  wxt.config.imports.imports ??= [];
3443
3388
  wxt.config.imports.imports.push(...module.imports);