wxt 0.19.8 → 0.19.10-alpha1

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.
@@ -4,13 +4,13 @@ export * from './types';
4
4
  /**
5
5
  * Create a content script UI without any isolation.
6
6
  *
7
- * @see https://wxt.dev/guide/key-concepts/content-script-ui.html#integrated
7
+ * @see https://wxt.dev/guide/key-concepts/content-script-ui#integrated
8
8
  */
9
9
  export declare function createIntegratedUi<TMounted>(ctx: ContentScriptContext, options: IntegratedContentScriptUiOptions<TMounted>): IntegratedContentScriptUi<TMounted>;
10
10
  /**
11
11
  * Create a content script UI using an iframe.
12
12
  *
13
- * @see https://wxt.dev/guide/key-concepts/content-script-ui.html#iframe
13
+ * @see https://wxt.dev/guide/key-concepts/content-script-ui#iframe
14
14
  */
15
15
  export declare function createIframeUi<TMounted>(ctx: ContentScriptContext, options: IframeContentScriptUiOptions<TMounted>): IframeContentScriptUi<TMounted>;
16
16
  /**
@@ -18,6 +18,6 @@ export declare function createIframeUi<TMounted>(ctx: ContentScriptContext, opti
18
18
  *
19
19
  * > This function is async because it has to load the CSS via a network call.
20
20
  *
21
- * @see https://wxt.dev/guide/key-concepts/content-script-ui.html#shadowroot
21
+ * @see https://wxt.dev/guide/key-concepts/content-script-ui#shadowroot
22
22
  */
23
23
  export declare function createShadowRootUi<TMounted>(ctx: ContentScriptContext, options: ShadowRootContentScriptUiOptions<TMounted>): Promise<ShadowRootContentScriptUi<TMounted>>;
@@ -147,7 +147,7 @@ function createFileReloader(server) {
147
147
  wxt.logger.success(`Reloaded: ${getFilenameList(rebuiltNames)}`);
148
148
  break;
149
149
  }
150
- } catch (err) {
150
+ } catch {
151
151
  }
152
152
  });
153
153
  };
@@ -146,7 +146,6 @@ async function getGlobalsDeclarationEntry() {
146
146
  path: "types/globals.d.ts",
147
147
  text: [
148
148
  "// Generated by wxt",
149
- "export {}",
150
149
  "interface ImportMetaEnv {",
151
150
  ...globals.map((global) => ` readonly ${global.name}: ${global.type};`),
152
151
  "}",
@@ -15,24 +15,18 @@ export async function rebuild(allEntrypoints, entrypointGroups, existingOutput =
15
15
  const newOutput = await buildEntrypoints(entrypointGroups, spinner);
16
16
  const mergedOutput = {
17
17
  steps: [...existingOutput.steps, ...newOutput.steps],
18
- publicAssets: [...existingOutput.publicAssets, ...newOutput.publicAssets]
18
+ // Do not merge existing because all publicAssets copied everytime
19
+ publicAssets: newOutput.publicAssets
19
20
  };
20
21
  const { manifest: newManifest, warnings: manifestWarnings } = await generateManifest(allEntrypoints, mergedOutput);
21
22
  const finalOutput = {
22
23
  manifest: newManifest,
23
- ...newOutput
24
+ ...mergedOutput
24
25
  };
25
26
  await writeManifest(newManifest, finalOutput);
26
27
  spinner.clear().stop();
27
28
  return {
28
- output: {
29
- manifest: newManifest,
30
- steps: [...existingOutput.steps, ...finalOutput.steps],
31
- publicAssets: [
32
- ...existingOutput.publicAssets,
33
- ...finalOutput.publicAssets
34
- ]
35
- },
29
+ output: finalOutput,
36
30
  manifest: newManifest,
37
31
  warnings: manifestWarnings
38
32
  };
@@ -46,7 +46,7 @@ export async function resolveConfig(inlineConfig, command) {
46
46
  if (await isDirMissing(entrypointsDir)) {
47
47
  logMissingDir(logger, "Entrypoints", entrypointsDir);
48
48
  }
49
- const filterEntrypoints = !!mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
49
+ const filterEntrypoints = mergedConfig.filterEntrypoints?.length ? new Set(mergedConfig.filterEntrypoints) : void 0;
50
50
  const publicDir = path.resolve(srcDir, mergedConfig.publicDir ?? "public");
51
51
  const typesDir = path.resolve(wxtDir, "types");
52
52
  const outBaseDir = path.resolve(root, mergedConfig.outDir ?? ".output");
@@ -2,7 +2,7 @@ import path, { relative, resolve } from "node:path";
2
2
  import { normalizePath } from "./paths.mjs";
3
3
  export function getEntrypointName(entrypointsDir, inputPath) {
4
4
  const relativePath = path.relative(entrypointsDir, inputPath);
5
- const name = relativePath.split(/[\.\/\\]/, 2)[0];
5
+ const name = relativePath.split(/[./\\]/, 2)[0];
6
6
  return name;
7
7
  }
8
8
  export function getEntrypointOutputFile(entrypoint, ext) {
@@ -30,7 +30,7 @@ export function applyGlobals(globals) {
30
30
  Object.entries(globals).forEach(([key, envValue]) => {
31
31
  try {
32
32
  globalThis[key] = envValue;
33
- } catch (err) {
33
+ } catch {
34
34
  }
35
35
  });
36
36
  }
@@ -5,7 +5,7 @@ export async function getEslintVersion() {
5
5
  );
6
6
  const { ESLint } = require("eslint");
7
7
  return ESLint.version?.split(".") ?? [];
8
- } catch (error) {
8
+ } catch {
9
9
  return [];
10
10
  }
11
11
  }
@@ -27,7 +27,7 @@ export async function generateManifest(entrypoints, buildOutput) {
27
27
  if (versionName == null) {
28
28
  versionName = "0.0.0";
29
29
  wxt.logger.warn(
30
- 'Extension version not found, defaulting to "0.0.0". Add a version to your `package.json` or `wxt.config.ts` file. For more details, see: https://wxt.dev/guide/key-concepts/manifest.html#version-and-version-name'
30
+ 'Extension version not found, defaulting to "0.0.0". Add a version to your `package.json` or `wxt.config.ts` file. For more details, see: https://wxt.dev/guide/key-concepts/manifest#version-and-version-name'
31
31
  );
32
32
  }
33
33
  const version = wxt.config.manifest.version ?? simplifyVersion(versionName);
@@ -190,14 +190,14 @@ function addEntrypoints(manifest, entrypoints, buildOutput) {
190
190
  options2.browser_style = popup.options.browserStyle;
191
191
  if (manifest.manifest_version === 3) {
192
192
  manifest.action = {
193
- ...manifest.action ?? {},
193
+ ...manifest.action,
194
194
  ...options2,
195
195
  default_popup
196
196
  };
197
197
  } else {
198
198
  const key = popup.options.mv2Key ?? "browser_action";
199
199
  manifest[key] = {
200
- ...manifest[key] ?? {},
200
+ ...manifest[key],
201
201
  ...options2,
202
202
  default_popup
203
203
  };
@@ -325,9 +325,9 @@ function discoverIcons(buildOutput) {
325
325
  // icon@16h.png
326
326
  /^icon@([0-9]+)\.png$/,
327
327
  // icon@16.png
328
- /^icons?[\/\\]([0-9]+)\.png$/,
328
+ /^icons?[/\\]([0-9]+)\.png$/,
329
329
  // icon/16.png | icons/16.png
330
- /^icons?[\/\\]([0-9]+)x[0-9]+\.png$/
330
+ /^icons?[/\\]([0-9]+)x[0-9]+\.png$/
331
331
  // icon/16x16.png | icons/16x16.png
332
332
  ];
333
333
  buildOutput.publicAssets.forEach((asset) => {
@@ -7,7 +7,8 @@ export async function getPackageJson() {
7
7
  return await fs.readJson(file);
8
8
  } catch (err) {
9
9
  wxt.logger.debug(
10
- `Failed to read package.json at: ${file}. Returning undefined.`
10
+ `Failed to read package.json at: ${file}. Returning undefined.`,
11
+ err
11
12
  );
12
13
  return {};
13
14
  }
@@ -3,6 +3,10 @@ export declare function kebabCaseAlphanumeric(str: string): string;
3
3
  * Return a safe variable name for a given string.
4
4
  */
5
5
  export declare function safeVarName(str: string): string;
6
+ /**
7
+ * Converts a string to a valid filename (NOT path), stripping out invalid characters.
8
+ */
9
+ export declare function safeFilename(str: string): string;
6
10
  /**
7
11
  * Removes import statements from the top of a file. Keeps import.meta and inline, async `import()`
8
12
  * calls.
@@ -1,8 +1,14 @@
1
+ import { camelCase } from "scule";
1
2
  export function kebabCaseAlphanumeric(str) {
2
3
  return str.toLowerCase().replace(/[^a-z0-9-\s]/g, "").replace(/\s+/g, "-");
3
4
  }
4
5
  export function safeVarName(str) {
5
- return "_" + kebabCaseAlphanumeric(str.trim()).replace("-", "_");
6
+ const name = camelCase(kebabCaseAlphanumeric(str));
7
+ if (name.match(/^[a-z]/)) return name;
8
+ return "_" + name;
9
+ }
10
+ export function safeFilename(str) {
11
+ return kebabCaseAlphanumeric(str);
6
12
  }
7
13
  export function removeImportStatements(text) {
8
14
  return text.replace(