Skip to content

Commit f8ec609

Browse files
fix: use session.extensions when available
Fixes #257
1 parent 05057e8 commit f8ec609

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"chai": "^4.2.0",
4242
"chai-as-promised": "^7.1.1",
4343
"chai-fs": "chaijs/chai-fs",
44-
"electron": "33.3.0",
44+
"electron": "36.0.0",
4545
"electron-mocha": "^13.0.1",
4646
"mocha-testdata": "^1.2.0",
4747
"prettier": "^3.4.2",
@@ -56,5 +56,6 @@
5656
"LICENSE",
5757
"README.md",
5858
"dist"
59-
]
59+
],
60+
"packageManager": "yarn@1.22.22"
6061
}

src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export async function installExtension(
7373
throw new Error(`Invalid extensionReference passed in: "${extensionReference}"`);
7474
}
7575

76-
const installedExtension = targetSession.getAllExtensions().find((e) => e.id === chromeStoreID);
76+
const extensionApi: Electron.Extensions | Electron.Session =
77+
(targetSession.extensions as Electron.Extensions | undefined) || targetSession;
78+
const installedExtension = extensionApi.getAllExtensions().find((e) => e.id === chromeStoreID);
7779

7880
if (!forceDownload && installedExtension) {
7981
return installedExtension;
@@ -86,17 +88,17 @@ export async function installExtension(
8688
const unloadPromise = new Promise<void>((resolve) => {
8789
const handler = (_: unknown, ext: Extension) => {
8890
if (ext.id === installedExtension.id) {
89-
targetSession.removeListener('extension-unloaded', handler);
91+
extensionApi.removeListener('extension-unloaded', handler);
9092
resolve();
9193
}
9294
};
93-
targetSession.on('extension-unloaded', handler);
95+
extensionApi.on('extension-unloaded', handler);
9496
});
95-
targetSession.removeExtension(installedExtension.id);
97+
extensionApi.removeExtension(installedExtension.id);
9698
await unloadPromise;
9799
}
98100

99-
return targetSession.loadExtension(extensionFolder, loadExtensionOptions);
101+
return extensionApi.loadExtension(extensionFolder, loadExtensionOptions);
100102
}
101103

102104
export default installExtension;

yarn.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
dependencies:
9494
undici-types "~5.26.4"
9595

96-
"@types/node@^20.9.0":
97-
version "20.17.10"
98-
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.17.10.tgz#3f7166190aece19a0d1d364d75c8b0b5778c1e18"
99-
integrity sha512-/jrvh5h6NXhEauFFexRin69nA0uHJ5gwk4iDivp/DeoEua3uwCUto6PC86IpRITBOs4+6i2I56K5x5b6WYGXHA==
96+
"@types/node@^22.7.7":
97+
version "22.16.5"
98+
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.16.5.tgz#cc46ac3994cd957000d0c11095a0b1dae2ea2368"
99+
integrity sha512-bJFoMATwIGaxxx8VJPeM8TonI8t579oRvgAuT8zFugJsJZgzqv0Fu8Mhp68iecjzG7cnN3mO2dJQ5uUM2EFrgQ==
100100
dependencies:
101-
undici-types "~6.19.2"
101+
undici-types "~6.21.0"
102102

103103
"@types/responselike@^1.0.0":
104104
version "1.0.3"
@@ -445,13 +445,13 @@ electron-window@^0.8.0:
445445
dependencies:
446446
is-electron-renderer "^2.0.0"
447447

448-
electron@33.3.0:
449-
version "33.3.0"
450-
resolved "https://registry.yarnpkg.com/electron/-/electron-33.3.0.tgz#5ae603818820c2a29736ed924d32bf18d31a9f63"
451-
integrity sha512-316ZlFUHJmzGrhRj87tVStxyYvknDqVR9eYSsGKAHY7auhVWFLIcPPGxcnbD/H1mez8CpDjXvEjcz76zpWxsXw==
448+
electron@36.0.0:
449+
version "36.0.0"
450+
resolved "https://registry.yarnpkg.com/electron/-/electron-36.0.0.tgz#ffbe7ca9edecaee53617f29a088be10bbed9a45f"
451+
integrity sha512-MhBL5tgzqLsiw++YXxzXRvF5s90gelcEZP4Upz/aaRmmoscmCw/EtimxMSH6EPnKt+8KwBY9RVAdlcffFPYkyw==
452452
dependencies:
453453
"@electron/get" "^2.0.0"
454-
"@types/node" "^20.9.0"
454+
"@types/node" "^22.7.7"
455455
extract-zip "^2.0.1"
456456

457457
emoji-regex@^8.0.0:
@@ -1216,10 +1216,10 @@ undici-types@~5.26.4:
12161216
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
12171217
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==
12181218

1219-
undici-types@~6.19.2:
1220-
version "6.19.8"
1221-
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02"
1222-
integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==
1219+
undici-types@~6.21.0:
1220+
version "6.21.0"
1221+
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb"
1222+
integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==
12231223

12241224
universalify@^0.1.0:
12251225
version "0.1.2"

0 commit comments

Comments
 (0)