mirror of https://github.com/keeweb/keeweb
moved native modules to the main process
parent
3c85694fc2
commit
cc750df077
|
@ -40,17 +40,11 @@ const UsbListener = {
|
|||
try {
|
||||
const ts = logger.ts();
|
||||
|
||||
const usb = Launcher.req(`@keeweb/keeweb-native-modules/usb.${process.platform}.node`);
|
||||
|
||||
Object.keys(EventEmitter.prototype).forEach(key => {
|
||||
usb[key] = EventEmitter.prototype[key];
|
||||
});
|
||||
|
||||
this.usb = usb;
|
||||
this.usb = Launcher.reqNative('usb');
|
||||
|
||||
this.listen();
|
||||
|
||||
this.attachedYubiKeys = usb
|
||||
this.attachedYubiKeys = this.usb
|
||||
.getDeviceList()
|
||||
.filter(this.isYubiKey)
|
||||
.map(device => ({ device }));
|
||||
|
|
|
@ -14,9 +14,6 @@ const Launcher = {
|
|||
thirdPartyStoragesSupported: true,
|
||||
clipboardSupported: true,
|
||||
req: window.require,
|
||||
reqNative(module) {
|
||||
return this.req(`@keeweb/keeweb-native-modules/${module}.${process.platform}.node`);
|
||||
},
|
||||
platform() {
|
||||
return process.platform;
|
||||
},
|
||||
|
@ -29,6 +26,9 @@ const Launcher = {
|
|||
remReq(mod) {
|
||||
return this.electron().remote.require(mod);
|
||||
},
|
||||
reqNative(mod) {
|
||||
return this.electron().remote.app.reqNative(mod);
|
||||
},
|
||||
openLink(href) {
|
||||
if (/^(http|https|ftp|sftp|mailto):/i.test(href)) {
|
||||
this.electron().shell.openExternal(href);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const electron = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { EventEmitter } = require('events');
|
||||
|
||||
let perfTimestamps = global.perfTimestamps;
|
||||
perfTimestamps.push({ name: 'loading app requires', ts: process.hrtime() });
|
||||
|
@ -146,6 +147,15 @@ app.getMainWindow = function() {
|
|||
return mainWindow;
|
||||
};
|
||||
app.setGlobalShortcuts = setGlobalShortcuts;
|
||||
app.reqNative = function(mod) {
|
||||
const binding = require(`@keeweb/keeweb-native-modules/${mod}.${process.platform}.node`);
|
||||
if (mod === 'usb') {
|
||||
Object.keys(EventEmitter.prototype).forEach(key => {
|
||||
binding[key] = EventEmitter.prototype[key];
|
||||
});
|
||||
}
|
||||
return binding;
|
||||
};
|
||||
|
||||
function readAppSettings() {
|
||||
try {
|
||||
|
@ -480,6 +490,8 @@ function setEnv() {
|
|||
app.commandLine.appendSwitch('disable-http-cache');
|
||||
app.commandLine.appendSwitch('disable-gpu-shader-disk-cache');
|
||||
|
||||
app.allowRendererProcessReuse = true;
|
||||
|
||||
perfTimestamps?.push({ name: 'setting env', ts: process.hrtime() });
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue