Update the manifest code.
This commit is contained in:
parent
544d915233
commit
04b6c23093
|
@ -1,11 +1,17 @@
|
||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
|
|
||||||
export default function createManifest(
|
import {type Manifest} from 'webextension-polyfill';
|
||||||
target: string,
|
|
||||||
): Record<string, unknown> {
|
/**
|
||||||
const manifest: Record<string, unknown> = {
|
* Creates the WebExtension manifest based on the browser target.
|
||||||
|
*
|
||||||
|
* @param browser The browser target ("firefox" or "chromium").
|
||||||
|
* @returns The WebExtension manifest.
|
||||||
|
*/
|
||||||
|
export function createManifest(browser: string): Manifest.WebExtensionManifest {
|
||||||
|
const manifest: Manifest.WebExtensionManifest = {
|
||||||
|
manifest_version: Number.NaN,
|
||||||
name: 'Queue',
|
name: 'Queue',
|
||||||
description: 'A WebExtension for queueing links.',
|
|
||||||
version: '0.3.2',
|
version: '0.3.2',
|
||||||
permissions: ['contextMenus', 'storage'],
|
permissions: ['contextMenus', 'storage'],
|
||||||
options_ui: {
|
options_ui: {
|
||||||
|
@ -14,36 +20,41 @@ export default function createManifest(
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const icons = {
|
const icons: Manifest.IconPath = {
|
||||||
128: 'queue.png',
|
128: 'queue.png',
|
||||||
};
|
};
|
||||||
|
|
||||||
manifest.icons = icons;
|
const action: Manifest.ActionManifest = {
|
||||||
|
|
||||||
const browserAction = {
|
|
||||||
default_icon: icons,
|
default_icon: icons,
|
||||||
};
|
};
|
||||||
|
|
||||||
const backgroundScript = 'background-scripts/initialize.ts';
|
const backgroundScript = 'background/setup.js';
|
||||||
|
|
||||||
if (target === 'chromium') {
|
if (browser === 'firefox') {
|
||||||
|
manifest.manifest_version = 2;
|
||||||
|
manifest.background = {
|
||||||
|
scripts: [backgroundScript],
|
||||||
|
};
|
||||||
|
manifest.browser_action = action;
|
||||||
|
manifest.browser_specific_settings = {
|
||||||
|
gecko: {
|
||||||
|
id: '{c3560e6b-00e5-4ab3-b89e-8a54ee5b2c9f}',
|
||||||
|
strict_min_version: '102.0',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else if (browser === 'chromium') {
|
||||||
manifest.manifest_version = 3;
|
manifest.manifest_version = 3;
|
||||||
manifest.action = browserAction;
|
manifest.action = action;
|
||||||
manifest.background = {
|
manifest.background = {
|
||||||
service_worker: backgroundScript,
|
service_worker: backgroundScript,
|
||||||
type: 'module',
|
type: 'module',
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
manifest.manifest_version = 2;
|
throw new Error(`Unknown target browser: ${browser}`);
|
||||||
manifest.browser_action = browserAction;
|
}
|
||||||
manifest.background = {
|
|
||||||
scripts: [backgroundScript],
|
if (Number.isNaN(manifest.manifest_version)) {
|
||||||
};
|
throw new TypeError('Manifest version is NaN');
|
||||||
manifest.applications = {
|
|
||||||
gecko: {
|
|
||||||
id: '{c3560e6b-00e5-4ab3-b89e-8a54ee5b2c9f}',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return manifest;
|
return manifest;
|
||||||
|
|
Loading…
Reference in New Issue