chore: tsify extensions shim (#24355)

This commit is contained in:
Jeremy Rose 2020-06-30 12:49:08 -07:00 committed by GitHub
parent ee61eb9aa4
commit 451086d7f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 10 deletions

View file

@ -1,23 +1,21 @@
'use strict';
// This is a temporary shim to aid in transition from the old
// BrowserWindow-based extensions stuff to the new native-backed extensions
// API.
const { app, session, BrowserWindow, deprecate } = require('electron');
import { app, session, BrowserWindow, deprecate } from 'electron';
app.whenReady().then(function () {
const addExtension = function (srcDirectory) {
const addExtension = function (srcDirectory: string) {
return session.defaultSession.loadExtension(srcDirectory);
};
const removeExtension = function (name) {
const removeExtension = function (name: string) {
const extension = session.defaultSession.getAllExtensions().find(e => e.name === name);
if (extension) { session.defaultSession.removeExtension(extension.id); }
};
const getExtensions = function () {
const extensions = {};
const extensions: Record<string, any> = {};
session.defaultSession.getAllExtensions().forEach(e => {
extensions[e.name] = e;
});