From abe1263d279685eff4fff2c6985b58d88a93f61a Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 3 Sep 2024 14:11:24 -0500 Subject: [PATCH] feat: Use `@types/chrome` for config manifest type (#969) --- packages/wxt/e2e/tests/user-config.test.ts | 2 +- packages/wxt/package.json | 5 +--- packages/wxt/src/types.ts | 32 ++++++++++++++++++++-- pnpm-lock.yaml | 6 ++-- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/packages/wxt/e2e/tests/user-config.test.ts b/packages/wxt/e2e/tests/user-config.test.ts index 221200351..01ac7f4d1 100644 --- a/packages/wxt/e2e/tests/user-config.test.ts +++ b/packages/wxt/e2e/tests/user-config.test.ts @@ -74,7 +74,7 @@ describe('User Config', () => { ); await project.build({ - // @ts-expect-error: Specifically setting an invalid field for the test - it should show up in the snapshot + // Specifically setting an invalid field for the test - it should show up in the snapshot manifest: ({ manifestVersion, command }) => ({ example_customization: [String(manifestVersion), command], }), diff --git a/packages/wxt/package.json b/packages/wxt/package.json index 36896e21d..517be7100 100644 --- a/packages/wxt/package.json +++ b/packages/wxt/package.json @@ -81,6 +81,7 @@ "prepack": "pnpm build" }, "dependencies": { + "@types/chrome": "^0.0.269", "@aklinker1/rollup-plugin-visualizer": "5.12.0", "@types/webextension-polyfill": "^0.10.7", "@webext-core/fake-browser": "^1.3.1", @@ -128,7 +129,6 @@ "devDependencies": { "@aklinker1/check": "^1.4.5", "@faker-js/faker": "^8.4.1", - "@types/chrome": "^0.0.269", "@types/fs-extra": "^11.0.4", "@types/lodash.merge": "^4.6.9", "@types/natural-compare": "^1.4.3", @@ -147,9 +147,6 @@ "vitest": "^2.0.4", "vitest-plugin-random-seed": "^1.1.0" }, - "peerDependencies": { - "@types/chrome": "*" - }, "peerDependenciesMeta": { "@types/chrome": { "optional": true diff --git a/packages/wxt/src/types.ts b/packages/wxt/src/types.ts index e58de1403..5935a13f0 100644 --- a/packages/wxt/src/types.ts +++ b/packages/wxt/src/types.ts @@ -832,7 +832,8 @@ export type ResolvedPerBrowserOptions = { */ export type UserManifest = Partial< Omit< - Manifest.WebExtensionManifest, + chrome.runtime.ManifestV3, + | 'action' | 'background' | 'chrome_url_overrides' | 'devtools_page' @@ -841,7 +842,34 @@ export type UserManifest = Partial< | 'options_ui' | 'sandbox' > ->; +> & { + // Add any Browser-specific or MV2 properties that WXT supports here + action?: chrome.runtime.ManifestV3['action'] & { + browser_style?: boolean; + }; + browser_action?: chrome.runtime.ManifestV2['browser_action'] & { + browser_style?: boolean; + }; + page_action?: chrome.runtime.ManifestV2['page_action'] & { + browser_style?: boolean; + }; + browser_specific_settings?: { + gecko?: { + id?: string; + strict_min_version?: string; + strict_max_version?: string; + update_url?: string; + }; + gecko_android?: { + strict_min_version?: string; + strict_max_version?: string; + }; + safari?: { + strict_min_version?: string; + strict_max_version?: string; + }; + }; +}; export type UserManifestFn = ( env: ConfigEnv, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8b4e04fe..602ac57c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -266,6 +266,9 @@ importers: '@aklinker1/rollup-plugin-visualizer': specifier: 5.12.0 version: 5.12.0(rollup@4.19.0) + '@types/chrome': + specifier: ^0.0.269 + version: 0.0.269 '@types/webextension-polyfill': specifier: ^0.10.7 version: 0.10.7 @@ -399,9 +402,6 @@ importers: '@faker-js/faker': specifier: ^8.4.1 version: 8.4.1 - '@types/chrome': - specifier: ^0.0.269 - version: 0.0.269 '@types/fs-extra': specifier: ^11.0.4 version: 11.0.4