Skip to content

feat: Automatically update .wxt/types/paths.d.ts and web_accessible_resources manifest for favicon #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

nishu-murmu
Copy link
Contributor

Overview

As suggested I've used WxtModules to implement this functionality.

Manual Testing

  1. Add favicon permissions wxt.config.ts.
  2. Add this below code for favicon functionality testing.
function getFaviconUrl(url: string, size = 16) {
  //@ts-expect-error not supported by wxt now
  const u = new URL(browser.runtime.getURL("/_favicon/"));
  u.searchParams.set("pageUrl", url);
  u.searchParams.set("size", size.toString());
  return u.toString();
}

console.log(getFaviconUrl("https://developer.chrome.com/docs/extensions/how-to/ui/favicons"))

Related Issue

This PR closes #1559

Copy link

netlify bot commented Apr 11, 2025

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit a983d27
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/680f7298dcb1e40008f147de
😎 Deploy Preview https://deploy-preview-1570--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nishu-murmu
Copy link
Contributor Author

nishu-murmu commented Apr 11, 2025

@aklinker1
Additionally name of the inbuilt module doesn't seems right, please suggest so I can update accordingly??

@nishu-murmu
Copy link
Contributor Author

@aklinker1
I've updated the name of the builtin module for more generic use case.

Copy link
Collaborator

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test! After seeing the expected outupt, I think this PR is still missing a few things:

  1. The favicon's URL needs to be typed as "/_favicon?${string}", right? Or else query parameters won't be allowed.
  2. The web_accessible_resources.matches is an empty array, meaning I would have to write a module or hook to modify that array so I can load favicons from content scripts. A simpler solution would be to not add this entry if one containing the /_favicon URL already exists. That way devs can just add their own entry and not worry about duplicating them.
  3. I think we need to add docs around this similar to the https://wxt.dev/guide/essentials/scripting.html page, just documenting what happens when you add the favicon permission, how to fetch a favicon, and how to add a custom matches to the web_accessible_resources entry.

@nishu-murmu
Copy link
Contributor Author

Thanks for adding the test! After seeing the expected outupt, I think this PR is still missing a few things:

  1. The favicon's URL needs to be typed as "/_favicon?${string}", right? Or else query parameters won't be allowed.
  2. The web_accessible_resources.matches is an empty array, meaning I would have to write a module or hook to modify that array so I can load favicons from content scripts. A simpler solution would be to not add this entry if one containing the /_favicon URL already exists. That way devs can just add their own entry and not worry about duplicating them.
  3. I think we need to add docs around this similar to the https://wxt.dev/guide/essentials/scripting.html page, just documenting what happens when you add the favicon permission, how to fetch a favicon, and how to add a custom matches to the web_accessible_resources entry.

In second point, so basically only types will be updated automatically and web_accessible_resources will be added by devs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically update .wxt/types/paths.d.ts and web_accessible_resources manifest for favicon
2 participants