electron-extension-installer
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -1,2 +0,2 @@ | ||
import type { LoadExtensionOptions } from "electron"; | ||
import type { LoadExtensionOptions, Session } from "electron"; | ||
export interface ExtensionReference { | ||
@@ -21,2 +21,6 @@ /** | ||
loadExtensionOptions?: LoadExtensionOptions; | ||
/** | ||
* The target session on which the extension shall be installed | ||
*/ | ||
session?: string | Session; | ||
} | ||
@@ -23,0 +27,0 @@ /** |
@@ -109,2 +109,3 @@ "use strict"; | ||
const installExtension = async (extensionReference, options = {}) => { | ||
const targetSession = typeof options.session === 'string' ? electron_1.session.fromPartition(options.session) : options.session || electron_1.session.defaultSession; | ||
const { forceDownload, loadExtensionOptions } = options; | ||
@@ -131,3 +132,3 @@ if (process.type !== "browser") { | ||
// todo - should we check id here? | ||
const installedExtension = electron_1.session.defaultSession.getAllExtensions().find((e) => e.name === extensionName); | ||
const installedExtension = targetSession.getAllExtensions().find((e) => e.name === extensionName); | ||
if (!forceDownload && installedExtension) { | ||
@@ -139,3 +140,3 @@ return IDMap[chromeStoreID]; | ||
if (installedExtension) { | ||
electron_1.session.defaultSession.removeExtension(installedExtension.id); | ||
targetSession.removeExtension(installedExtension.id); | ||
} | ||
@@ -150,3 +151,3 @@ if (await isManifestVersion3(extensionFolder)) { | ||
} | ||
const ext = await electron_1.session.defaultSession.loadExtension(extensionFolder, loadExtensionOptions); | ||
const ext = await targetSession.loadExtension(extensionFolder, loadExtensionOptions); | ||
return ext.name; | ||
@@ -153,0 +154,0 @@ }; |
{ | ||
"name": "electron-extension-installer", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"license": "MIT", | ||
@@ -32,3 +32,3 @@ "author": "Jonluca DeCaro <electronextension@jonlu.ca>", | ||
"lint": "eslint src", | ||
"build": "rm -fr dist/* && tsc -p tsconfig.json", | ||
"build": "rimraf dist/* && tsc -p tsconfig.json", | ||
"typecheck": "tsc --noEmit", | ||
@@ -35,0 +35,0 @@ "prettier": "prettier --write \"**/*.+(js|jsx|ts|tsx|har||json|css|md)\"" |
@@ -1,2 +0,2 @@ | ||
import type { LoadExtensionOptions } from "electron"; | ||
import type { LoadExtensionOptions, Session } from "electron"; | ||
import { session } from "electron"; | ||
@@ -85,2 +85,6 @@ import * as path from "path"; | ||
loadExtensionOptions?: LoadExtensionOptions; | ||
/** | ||
* The target session on which the extension shall be installed | ||
*/ | ||
session?: string | Session; | ||
} | ||
@@ -106,2 +110,3 @@ | ||
): Promise<string | string[]> => { | ||
const targetSession = typeof options.session === 'string' ? session.fromPartition(options.session) : options.session || session.defaultSession; | ||
const { forceDownload, loadExtensionOptions } = options; | ||
@@ -129,3 +134,3 @@ | ||
// todo - should we check id here? | ||
const installedExtension = session.defaultSession.getAllExtensions().find((e) => e.name === extensionName); | ||
const installedExtension = targetSession.getAllExtensions().find((e) => e.name === extensionName); | ||
@@ -139,3 +144,3 @@ if (!forceDownload && installedExtension) { | ||
if (installedExtension) { | ||
session.defaultSession.removeExtension(installedExtension.id); | ||
targetSession.removeExtension(installedExtension.id); | ||
} | ||
@@ -151,3 +156,3 @@ | ||
} | ||
const ext = await session.defaultSession.loadExtension(extensionFolder, loadExtensionOptions); | ||
const ext = await targetSession.loadExtension(extensionFolder, loadExtensionOptions); | ||
return ext.name; | ||
@@ -154,0 +159,0 @@ }; |
30439
703