chore: tsify extensions shim (#24355)
This commit is contained in:
parent
ee61eb9aa4
commit
451086d7f2
4 changed files with 8 additions and 10 deletions
|
@ -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;
|
||||
});
|
|
@ -55,12 +55,12 @@ const deprecate: ElectronInternal.DeprecationUtil = {
|
|||
};
|
||||
},
|
||||
|
||||
moveAPI: (fn: Function, oldUsage: string, newUsage: string) => {
|
||||
moveAPI<T extends Function> (fn: T, oldUsage: string, newUsage: string): T {
|
||||
const warn = warnOnce(oldUsage, newUsage);
|
||||
return function (this: any) {
|
||||
warn();
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
} as any;
|
||||
},
|
||||
|
||||
// change the name of an event
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue