Skip to content

action vs. browserAction #490

Closed

Description

@dword-design

Feature Request

First of all, thanks for this great Nuxt-inspired tool :).

Looks like the lib currently does not abstract away action in v3 and browserAction in v2. So one would need to define both in wxt.config.js and then distinguish between the cases in the scripts. Would be great to just have browser.action from wxt/browser and action in the config. Or am I missing something?

Activity

  1. aklinker1 commented on Feb 28, 2024

    @aklinker1
    Member

    Are you talking about the case where you're using an action without a popup entrypoint?

    If not, see https://wxt.dev/entrypoints/popup.html.

    If so, how do you propose letting the extension opt-in to using a page_action instead of a browser_action?

  2. aklinker1 commented on Feb 28, 2024

    @aklinker1
    Member

    Are you talking about the case where you're using an action without a popup entrypoint?

    If not, see https://wxt.dev/entrypoints/popup.html.

    If so, how do you propose letting the extension opt-in to using a page_action instead of a browser_action?

  3. aklinker1 commented on Feb 28, 2024

    @aklinker1
    Member

    Are you talking about the case where you're using an action without a popup entrypoint?

    If not, see https://wxt.dev/entrypoints/popup.html.

    If so, how do you propose letting the extension opt-in to using a page_action instead of a browser_action?

  4. aklinker1 commented on Feb 28, 2024

    @aklinker1
    Member

    Are you talking about the case where you're using an action without a popup entrypoint?

    If not, see https://wxt.dev/entrypoints/popup.html.

    If so, how do you propose letting the extension opt-in to using a page_action instead of a browser_action?

  5. dword-design commented on Feb 28, 2024

    @dword-design
    ContributorAuthor

    @aklinker1 Yes I mean action without a popup.

    I haven't used page actions yet but if I understood it correctly they were merged together with browser actions into one action in v3. So I guess the issue is to distinguish between page and browser actions in v2?

  6. aklinker1 commented on Feb 28, 2024

    @aklinker1
    Member

    Correct, I for one perfer page actions over browser actions, and think MV3 made a bad decision choosing browser actions over page actions for the new action field. it prevents a cluttered navigation bar with all your extensions trying to take up space when they're not even being used... All that to say I like page actions and would recommend people use them. But I also understand that browser actions are the most equivalent to the new action, so it makes sense to default to the browser action...

    But anyways, my understanding of your suggestion is that when I have a config file that looks like this:

    export default defineConfig({
      manifest: {
        action: {},
      },
    });

    it should automatically output a browser_action instead while targetting MV2, is that correct? So I'm curious what you'd recommend for opting into converting it to a popup_action instead. I have an idea, but if you have one I'd like to hear that first!

  7. dword-design commented on Feb 28, 2024

    @dword-design
    ContributorAuthor

    @aklinker1 Yes that's what I mean. I don't have a clear idea or suggestion and I think you are way deeper into the topic. I guess you mean page_action instead of popup_action in your second to last sentence. Maybe it could be made configurable per project which action should resolve to and have decide for one as default.

    I also partly solved the issue by forcing mv3 for Firefox since it seems to work fine except for dev mode and I'm fine doublechecking Firefox by manually loading it into the browser. But still ofc, if Firefox mv2 could be made compatible for actions this would be an improvement :).

  8. aklinker1 commented on Feb 28, 2024

    @aklinker1
    Member

    Oh yeah, sorry, page_action is what I meant.

    What about letting you provide a manifest like this:

    manifest: {
      action: {},
      browser_action: {},
    }

    And WXT automatically strips out any fields that aren't available for the target manifest version. Then if someone wants to use the page action instead, they can just use:

    manifest: {
      action: {},
      page_action: {},
    }

    And if you exclude both page_action and browser_action, MV2 defaults to a browser_action for compatibility

    manifest: {
      action: {},
    }

    This applies to more than just the action fields. That way you don't have to use a function to remove fields based on the target manifest version, like this:

    manifest: ({ manifestVersion }) => manfiestVersion === 3 ? { action: {} } : { browser_action: {} },

    Which is annoying to write.

  9. dword-design commented on Feb 29, 2024

    @dword-design
    ContributorAuthor

    @aklinker1 Sounds good to me 🤔

  10. aklinker1 commented on Mar 3, 2024

    @aklinker1
    Member

    Released in v0.17.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions