wxt 0.7.4 → 0.7.5

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
@@ -391,6 +391,7 @@ interface PopupEntrypoint extends BaseEntrypoint {
391
391
  mv2Key?: 'browser_action' | 'page_action';
392
392
  defaultIcon?: Record<string, string>;
393
393
  defaultTitle?: string;
394
+ browserStyle?: boolean;
394
395
  } & BaseEntrypointOptions;
395
396
  }
396
397
  interface OptionsEntrypoint extends BaseEntrypoint {
@@ -453,6 +454,8 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
453
454
  * - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
454
455
  * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
455
456
  * URL
457
+ * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
458
+ * calling `createContentScriptUi`
456
459
  *
457
460
  * @default "manifest"
458
461
  */
@@ -565,7 +568,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
565
568
  */
566
569
  declare function clean(root?: string): Promise<void>;
567
570
 
568
- var version = "0.7.4";
571
+ var version = "0.7.5";
569
572
 
570
573
  declare function defineConfig(config: UserConfig): UserConfig;
571
574
 
package/dist/index.d.ts CHANGED
@@ -391,6 +391,7 @@ interface PopupEntrypoint extends BaseEntrypoint {
391
391
  mv2Key?: 'browser_action' | 'page_action';
392
392
  defaultIcon?: Record<string, string>;
393
393
  defaultTitle?: string;
394
+ browserStyle?: boolean;
394
395
  } & BaseEntrypointOptions;
395
396
  }
396
397
  interface OptionsEntrypoint extends BaseEntrypoint {
@@ -453,6 +454,8 @@ interface ContentScriptDefinition extends ExcludableEntrypoint {
453
454
  * - `"manual"` - Exclude the CSS from the manifest. You are responsible for manually loading it
454
455
  * onto the page. Use `browser.runtime.getURL("content-scripts/<name>.css")` to get the file's
455
456
  * URL
457
+ * - `"ui"` - Exclude the CSS from the manifest. CSS will be automatically added to your UI when
458
+ * calling `createContentScriptUi`
456
459
  *
457
460
  * @default "manifest"
458
461
  */
@@ -565,7 +568,7 @@ type EntrypointGroup = Entrypoint | Entrypoint[];
565
568
  */
566
569
  declare function clean(root?: string): Promise<void>;
567
570
 
568
- var version = "0.7.4";
571
+ var version = "0.7.5";
569
572
 
570
573
  declare function defineConfig(config: UserConfig): UserConfig;
571
574
 
package/dist/index.js CHANGED
@@ -2084,9 +2084,13 @@ async function getPopupEntrypoint(config, path9) {
2084
2084
  );
2085
2085
  }
2086
2086
  }
2087
- const mv2KeyContent = document.querySelector("meta[name='manifest.type']")?.getAttribute("content");
2088
- if (mv2KeyContent) {
2089
- options.mv2Key = mv2KeyContent === "page_action" ? "page_action" : "browser_action";
2087
+ const mv2TypeContent = document.querySelector("meta[name='manifest.type']")?.getAttribute("content");
2088
+ if (mv2TypeContent) {
2089
+ options.mv2Key = mv2TypeContent === "page_action" ? "page_action" : "browser_action";
2090
+ }
2091
+ const browserStyleContent = document.querySelector("meta[name='manifest.browser_style']")?.getAttribute("content");
2092
+ if (browserStyleContent) {
2093
+ options.browserStyle = browserStyleContent === "true";
2090
2094
  }
2091
2095
  return {
2092
2096
  type: "popup",
@@ -2473,18 +2477,23 @@ var ContentSecurityPolicy = class _ContentSecurityPolicy {
2473
2477
  };
2474
2478
 
2475
2479
  // src/core/utils/content-scripts.ts
2476
- function hashContentScriptOptions(options) {
2480
+ function hashContentScriptOptions(options, config) {
2481
+ const simplifiedOptions = mapWxtOptionsToContentScript(options, config);
2482
+ Object.keys(simplifiedOptions).forEach((key) => {
2483
+ if (simplifiedOptions[key] == null)
2484
+ delete simplifiedOptions[key];
2485
+ });
2477
2486
  const withDefaults = {
2478
- excludeGlobs: [],
2479
- excludeMatches: [],
2480
- includeGlobs: [],
2481
- matchAboutBlank: false,
2482
- matchOriginAsFallback: false,
2483
- runAt: "document_idle",
2484
- allFrames: false,
2487
+ exclude_globs: [],
2488
+ exclude_matches: [],
2489
+ include_globs: [],
2490
+ match_about_blank: false,
2491
+ run_at: "document_idle",
2492
+ all_frames: false,
2493
+ // @ts-expect-error - not in type
2494
+ match_origin_as_fallback: false,
2485
2495
  world: "ISOLATED",
2486
- // TODO: strip undefined fields from options object to improve content script grouping.
2487
- ...options
2496
+ ...simplifiedOptions
2488
2497
  };
2489
2498
  return JSON.stringify(
2490
2499
  Object.entries(withDefaults).map(([key, value]) => {
@@ -2557,13 +2566,17 @@ async function writeManifest(manifest, output, config) {
2557
2566
  }
2558
2567
  async function generateMainfest(entrypoints, buildOutput, config) {
2559
2568
  const pkg = await getPackageJson(config);
2569
+ const versionName = config.manifest.version_name ?? pkg?.version;
2570
+ const version3 = config.manifest.version ?? simplifyVersion(pkg?.version);
2560
2571
  const baseManifest = {
2561
2572
  manifest_version: config.manifestVersion,
2562
2573
  name: pkg?.name,
2563
2574
  description: pkg?.description,
2564
- version: pkg?.version && simplifyVersion(pkg.version),
2565
- // Only add the version name to chromium and if the user hasn't specified a custom version.
2566
- version_name: config.browser !== "firefox" && !config.manifest.version ? pkg?.version : void 0,
2575
+ version: version3,
2576
+ version_name: (
2577
+ // Firefox doesn't support version_name
2578
+ config.browser === "firefox" || versionName === version3 ? void 0 : versionName
2579
+ ),
2567
2580
  short_name: pkg?.shortName,
2568
2581
  icons: discoverIcons(buildOutput)
2569
2582
  };
@@ -2757,7 +2770,7 @@ function addEntrypoints(manifest, entrypoints, buildOutput, config) {
2757
2770
  );
2758
2771
  } else {
2759
2772
  const hashToEntrypointsMap = contentScripts.reduce((map, script) => {
2760
- const hash = hashContentScriptOptions(script.options);
2773
+ const hash = hashContentScriptOptions(script.options, config);
2761
2774
  if (map.has(hash))
2762
2775
  map.get(hash)?.push(script);
2763
2776
  else
@@ -4553,7 +4566,7 @@ async function clean(root = process.cwd()) {
4553
4566
  }
4554
4567
 
4555
4568
  // package.json
4556
- var version2 = "0.7.4";
4569
+ var version2 = "0.7.5";
4557
4570
 
4558
4571
  // src/core/utils/defineConfig.ts
4559
4572
  function defineConfig(config) {