Update to native Electron 11.1.1 - Fix breaking changes and refactoring.

This commit is contained in:
Gregor Biswanger
2021-01-11 01:56:39 +01:00
parent b9feff3436
commit f06b95803f
45 changed files with 2083 additions and 718 deletions

View File

@@ -1,20 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.browserViewMediateService = exports.browserViewApi = void 0;
const electron_1 = require("electron");
let browserViews = [];
const browserViews = [];
let browserView, electronSocket;
module.exports = (socket) => {
const browserViewApi = (socket) => {
electronSocket = socket;
socket.on('createBrowserView', (options) => {
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
options = { ...options, webPreferences: { nodeIntegration: true } };
}
browserView = new electron_1.BrowserView(options);
browserView['id'] = browserViews.length + 1;
browserViews.push(browserView);
electronSocket.emit('BrowserViewCreated', browserView.id);
});
socket.on('browserView-isDestroyed', (id) => {
const isDestroyed = getBrowserViewById(id).isDestroyed();
electronSocket.emit('browserView-isDestroyed-reply', isDestroyed);
electronSocket.emit('BrowserViewCreated', browserView['id']);
});
socket.on('browserView-getBounds', (id) => {
const bounds = getBrowserViewById(id).getBounds();
@@ -23,11 +22,6 @@ module.exports = (socket) => {
socket.on('browserView-setBounds', (id, bounds) => {
getBrowserViewById(id).setBounds(bounds);
});
socket.on('browserView-destroy', (id) => {
const browserViewIndex = browserViews.findIndex(b => b.id === id);
getBrowserViewById(id).destroy();
browserViews.splice(browserViewIndex, 1);
});
socket.on('browserView-setAutoResize', (id, options) => {
getBrowserViewById(id).setAutoResize(options);
});
@@ -43,13 +37,18 @@ module.exports = (socket) => {
}
return true;
}
function getBrowserViewById(id) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem.id === id) {
return browserViewItem;
}
};
exports.browserViewApi = browserViewApi;
const browserViewMediateService = (browserViewId) => {
return getBrowserViewById(browserViewId);
};
exports.browserViewMediateService = browserViewMediateService;
function getBrowserViewById(id) {
for (let index = 0; index < browserViews.length; index++) {
const browserViewItem = browserViews[index];
if (browserViewItem['id'] === id) {
return browserViewItem;
}
}
};
}
//# sourceMappingURL=browserView.js.map