fix: Allow actions without a popup (#181)

This commit is contained in:
Aaron
2023-10-20 10:20:40 -05:00
committed by GitHub
parent 1b1af245bd
commit 5a70d9e57d
3 changed files with 36 additions and 10 deletions
+25
View File
@@ -599,4 +599,29 @@ describe('Manifest Content', () => {
},
);
});
it('should respect the action field in the manifest without a popup', async () => {
const project = new TestProject();
project.setConfigFileConfig({
manifest: {
action: {
default_title: 'Hello world',
},
},
});
await project.build();
expect(await project.getOutputManifest()).toMatchInlineSnapshot(`
{
"action": {
"default_title": "Hello world",
},
"description": "Example description",
"manifest_version": 3,
"name": "E2E Extension",
"version": "0.0.0",
}
`);
});
});
-4
View File
@@ -468,17 +468,13 @@ export interface ExcludableEntrypoint {
export type UserManifest = Partial<
Omit<
Manifest.WebExtensionManifest,
| 'action'
| 'background'
| 'browser_action'
| 'chrome_url_overrides'
| 'devtools_page'
| 'manifest_version'
| 'options_page'
| 'options_ui'
| 'sandbox'
| 'page_action'
| 'popup'
| 'sidepanel'
| 'sidebar_action'
>
+11 -6
View File
@@ -214,18 +214,23 @@ function addEntrypoints(
config.outDir,
'.html',
);
const options: Manifest.ActionManifest = {
default_icon: popup.options.defaultIcon,
default_title: popup.options.defaultTitle,
browser_style: popup.options.browserStyle,
};
const options: Manifest.ActionManifest = {};
if (popup.options.defaultIcon)
options.default_icon = popup.options.defaultIcon;
if (popup.options.defaultTitle)
options.default_title = popup.options.defaultTitle;
if (popup.options.browserStyle)
options.browser_style = popup.options.browserStyle;
if (manifest.manifest_version === 3) {
manifest.action = {
...(manifest.action ?? {}),
...options,
default_popup,
};
} else {
manifest[popup.options.mv2Key ?? 'browser_action'] = {
const key = popup.options.mv2Key ?? 'browser_action';
manifest[key] = {
...(manifest[key] ?? {}),
...options,
default_popup,
};