Skip to content

Commit e5a5c73

Browse files
committed
feat: deprecate mv2 by default
Maybe someday this can be better supported. For now, default to deprecating so apps using this package don't need to handle deprecation and communicating that to users.
1 parent 0db564d commit e5a5c73

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/electron-chrome-web-store/src/browser/api.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function getExtensionInstallStatus(
5959
}
6060

6161
if (manifest) {
62-
if (manifest.manifest_version < 2) {
62+
if (manifest.manifest_version < state.minimumManifestVersion) {
6363
return ExtensionInstallStatus.DEPRECATED_MANIFEST_VERSION
6464
}
6565
}
@@ -268,7 +268,9 @@ export function registerWebStoreApi(webStoreState: WebStoreState) {
268268
})
269269

270270
handle('chromeWebstore.getMV2DeprecationStatus', async () => {
271-
return MV2DeprecationStatus.INACTIVE
271+
return webStoreState.minimumManifestVersion > 2
272+
? MV2DeprecationStatus.SOFT_DISABLE
273+
: MV2DeprecationStatus.INACTIVE
272274
})
273275

274276
handle('chromeWebstore.getReferrerChain', async () => {

packages/electron-chrome-web-store/src/browser/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ interface ElectronChromeWebStoreOptions {
5656
*/
5757
autoUpdate?: boolean
5858

59+
/**
60+
* Minimum supported version of Chrome extensions.
61+
* Defaults to 3.
62+
*/
63+
minimumManifestVersion?: number
64+
5965
beforeInstall?: BeforeInstall
6066
}
6167

@@ -72,6 +78,8 @@ export async function installChromeWebStore(opts: ElectronChromeWebStoreOptions
7278
const allowUnpackedExtensions =
7379
typeof opts.allowUnpackedExtensions === 'boolean' ? opts.allowUnpackedExtensions : false
7480
const autoUpdate = typeof opts.autoUpdate === 'boolean' ? opts.autoUpdate : true
81+
const minimumManifestVersion =
82+
typeof opts.minimumManifestVersion === 'number' ? opts.minimumManifestVersion : 3
7583
const beforeInstall = typeof opts.beforeInstall === 'function' ? opts.beforeInstall : undefined
7684

7785
const webStoreState: WebStoreState = {
@@ -80,6 +88,7 @@ export async function installChromeWebStore(opts: ElectronChromeWebStoreOptions
8088
installing: new Set(),
8189
allowlist: opts.allowlist ? new Set(opts.allowlist) : undefined,
8290
denylist: opts.denylist ? new Set(opts.denylist) : undefined,
91+
minimumManifestVersion,
8392
beforeInstall,
8493
}
8594

packages/electron-chrome-web-store/src/browser/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ export interface WebStoreState {
1919
installing: Set<ExtensionId>
2020
allowlist?: Set<ExtensionId>
2121
denylist?: Set<ExtensionId>
22+
minimumManifestVersion: number
2223
beforeInstall?: BeforeInstall
2324
}

0 commit comments

Comments
 (0)