mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-26 08:52:26 +00:00
Added more missing APIs
This commit is contained in:
@@ -118,6 +118,13 @@ module.exports = (socket) => {
|
||||
electronSocket.emit("webContents-zoomChanged" + id, zoomDirection);
|
||||
});
|
||||
});
|
||||
socket.on("register-webContents-foundInPage", (id) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents.removeAllListeners("found-in-page");
|
||||
browserWindow.webContents.on("found-in-page", (_, result) => {
|
||||
electronSocket.emit("webContents-foundInPage" + id, result);
|
||||
});
|
||||
});
|
||||
socket.on("webContents-openDevTools", (id, options) => {
|
||||
if (options) {
|
||||
getWindowById(id).webContents.openDevTools(options);
|
||||
@@ -315,6 +322,36 @@ module.exports = (socket) => {
|
||||
electronSocket.emit("webContents-loadURL-error" + id, error);
|
||||
});
|
||||
});
|
||||
socket.on("webContents-loadFile", (id, filePath, options) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents
|
||||
.loadFile(filePath, options ?? undefined)
|
||||
.then(() => {
|
||||
electronSocket.emit("webContents-loadFile-complete" + id);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
electronSocket.emit("webContents-loadFile-error" + id, error);
|
||||
});
|
||||
});
|
||||
socket.on("webContents-isLoading", (id) => {
|
||||
electronSocket.emit("webContents-isLoading-completed", getWindowById(id).webContents.isLoading());
|
||||
});
|
||||
socket.on("webContents-isLoadingMainFrame", (id) => {
|
||||
electronSocket.emit("webContents-isLoadingMainFrame-completed", getWindowById(id).webContents.isLoadingMainFrame());
|
||||
});
|
||||
socket.on("webContents-isWaitingForResponse", (id) => {
|
||||
electronSocket.emit("webContents-isWaitingForResponse-completed", getWindowById(id).webContents.isWaitingForResponse());
|
||||
});
|
||||
socket.on("webContents-reload", (id) => {
|
||||
getWindowById(id).webContents.reload();
|
||||
});
|
||||
socket.on("webContents-reloadIgnoringCache", (id) => {
|
||||
getWindowById(id).webContents.reloadIgnoringCache();
|
||||
});
|
||||
socket.on("webContents-stop", (id) => {
|
||||
getWindowById(id).webContents.stop();
|
||||
});
|
||||
socket.on("webContents-insertCSS", (id, isBrowserWindow, path) => {
|
||||
if (isBrowserWindow) {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -337,6 +374,14 @@ module.exports = (socket) => {
|
||||
}
|
||||
}
|
||||
});
|
||||
socket.on("webContents-insertCSSText", async (id, css, cssOrigin) => {
|
||||
const key = await getWindowById(id).webContents.insertCSS(css, cssOrigin ? { cssOrigin } : undefined);
|
||||
electronSocket.emit("webContents-insertCSSText-completed" + id, key);
|
||||
});
|
||||
socket.on("webContents-removeInsertedCSS", async (id, key) => {
|
||||
await getWindowById(id).webContents.removeInsertedCSS(key);
|
||||
electronSocket.emit("webContents-removeInsertedCSS-completed" + id);
|
||||
});
|
||||
socket.on("webContents-session-getAllExtensions", (id) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
const extensionsList = browserWindow.webContents.session.getAllExtensions();
|
||||
@@ -410,6 +455,59 @@ module.exports = (socket) => {
|
||||
socket.on("webContents-setUserAgent", (id, userAgent) => {
|
||||
getWindowById(id).webContents.setUserAgent(userAgent);
|
||||
});
|
||||
socket.on("webContents-undo", (id) => {
|
||||
getWindowById(id).webContents.undo();
|
||||
});
|
||||
socket.on("webContents-redo", (id) => {
|
||||
getWindowById(id).webContents.redo();
|
||||
});
|
||||
socket.on("webContents-cut", (id) => {
|
||||
getWindowById(id).webContents.cut();
|
||||
});
|
||||
socket.on("webContents-copy", (id) => {
|
||||
getWindowById(id).webContents.copy();
|
||||
});
|
||||
socket.on("webContents-copyImageAt", (id, x, y) => {
|
||||
getWindowById(id).webContents.copyImageAt(x, y);
|
||||
});
|
||||
socket.on("webContents-paste", (id) => {
|
||||
getWindowById(id).webContents.paste();
|
||||
});
|
||||
socket.on("webContents-pasteAndMatchStyle", (id) => {
|
||||
getWindowById(id).webContents.pasteAndMatchStyle();
|
||||
});
|
||||
socket.on("webContents-delete", (id) => {
|
||||
getWindowById(id).webContents.delete();
|
||||
});
|
||||
socket.on("webContents-selectAll", (id) => {
|
||||
getWindowById(id).webContents.selectAll();
|
||||
});
|
||||
socket.on("webContents-unselect", (id) => {
|
||||
getWindowById(id).webContents.unselect();
|
||||
});
|
||||
socket.on("webContents-adjustSelection", (id, options) => {
|
||||
getWindowById(id).webContents.adjustSelection(options ?? {});
|
||||
});
|
||||
socket.on("webContents-centerSelection", (id) => {
|
||||
getWindowById(id).webContents.centerSelection();
|
||||
});
|
||||
socket.on("webContents-insertText", async (id, text) => {
|
||||
await getWindowById(id).webContents.insertText(text);
|
||||
electronSocket.emit("webContents-insertText-completed" + id);
|
||||
});
|
||||
socket.on("webContents-replace", (id, text) => {
|
||||
getWindowById(id).webContents.replace(text);
|
||||
});
|
||||
socket.on("webContents-replaceMisspelling", (id, text) => {
|
||||
getWindowById(id).webContents.replaceMisspelling(text);
|
||||
});
|
||||
socket.on("webContents-findInPage", (id, text, options) => {
|
||||
const requestId = getWindowById(id).webContents.findInPage(text, options ?? undefined);
|
||||
electronSocket.emit("webContents-findInPage-completed" + id, requestId);
|
||||
});
|
||||
socket.on("webContents-stopFindInPage", (id, action) => {
|
||||
getWindowById(id).webContents.stopFindInPage(action);
|
||||
});
|
||||
function getWindowById(id) {
|
||||
if (id >= 1000) {
|
||||
return (0, browserView_1.browserViewMediateService)(id - 1000);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -112,6 +112,15 @@ export = (socket: Socket) => {
|
||||
});
|
||||
});
|
||||
|
||||
socket.on("register-webContents-foundInPage", (id) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
|
||||
browserWindow.webContents.removeAllListeners("found-in-page");
|
||||
browserWindow.webContents.on("found-in-page", (_, result) => {
|
||||
electronSocket.emit("webContents-foundInPage" + id, result);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on("webContents-openDevTools", (id, options) => {
|
||||
if (options) {
|
||||
getWindowById(id).webContents.openDevTools(options);
|
||||
@@ -418,6 +427,52 @@ export = (socket: Socket) => {
|
||||
});
|
||||
});
|
||||
|
||||
socket.on("webContents-loadFile", (id, filePath, options) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
browserWindow.webContents
|
||||
.loadFile(filePath, options ?? undefined)
|
||||
.then(() => {
|
||||
electronSocket.emit("webContents-loadFile-complete" + id);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
electronSocket.emit("webContents-loadFile-error" + id, error);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on("webContents-isLoading", (id) => {
|
||||
electronSocket.emit(
|
||||
"webContents-isLoading-completed",
|
||||
getWindowById(id).webContents.isLoading(),
|
||||
);
|
||||
});
|
||||
|
||||
socket.on("webContents-isLoadingMainFrame", (id) => {
|
||||
electronSocket.emit(
|
||||
"webContents-isLoadingMainFrame-completed",
|
||||
getWindowById(id).webContents.isLoadingMainFrame(),
|
||||
);
|
||||
});
|
||||
|
||||
socket.on("webContents-isWaitingForResponse", (id) => {
|
||||
electronSocket.emit(
|
||||
"webContents-isWaitingForResponse-completed",
|
||||
getWindowById(id).webContents.isWaitingForResponse(),
|
||||
);
|
||||
});
|
||||
|
||||
socket.on("webContents-reload", (id) => {
|
||||
getWindowById(id).webContents.reload();
|
||||
});
|
||||
|
||||
socket.on("webContents-reloadIgnoringCache", (id) => {
|
||||
getWindowById(id).webContents.reloadIgnoringCache();
|
||||
});
|
||||
|
||||
socket.on("webContents-stop", (id) => {
|
||||
getWindowById(id).webContents.stop();
|
||||
});
|
||||
|
||||
socket.on("webContents-insertCSS", (id, isBrowserWindow, path) => {
|
||||
if (isBrowserWindow) {
|
||||
const browserWindow = getWindowById(id);
|
||||
@@ -440,6 +495,19 @@ export = (socket: Socket) => {
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("webContents-insertCSSText", async (id, css, cssOrigin) => {
|
||||
const key = await getWindowById(id).webContents.insertCSS(
|
||||
css,
|
||||
cssOrigin ? { cssOrigin } : undefined,
|
||||
);
|
||||
electronSocket.emit("webContents-insertCSSText-completed" + id, key);
|
||||
});
|
||||
|
||||
socket.on("webContents-removeInsertedCSS", async (id, key) => {
|
||||
await getWindowById(id).webContents.removeInsertedCSS(key);
|
||||
electronSocket.emit("webContents-removeInsertedCSS-completed" + id);
|
||||
});
|
||||
|
||||
socket.on("webContents-session-getAllExtensions", (id) => {
|
||||
const browserWindow = getWindowById(id);
|
||||
const extensionsList = browserWindow.webContents.session.getAllExtensions();
|
||||
@@ -566,6 +634,79 @@ export = (socket: Socket) => {
|
||||
getWindowById(id).webContents.setUserAgent(userAgent);
|
||||
});
|
||||
|
||||
socket.on("webContents-undo", (id) => {
|
||||
getWindowById(id).webContents.undo();
|
||||
});
|
||||
|
||||
socket.on("webContents-redo", (id) => {
|
||||
getWindowById(id).webContents.redo();
|
||||
});
|
||||
|
||||
socket.on("webContents-cut", (id) => {
|
||||
getWindowById(id).webContents.cut();
|
||||
});
|
||||
|
||||
socket.on("webContents-copy", (id) => {
|
||||
getWindowById(id).webContents.copy();
|
||||
});
|
||||
|
||||
socket.on("webContents-copyImageAt", (id, x, y) => {
|
||||
getWindowById(id).webContents.copyImageAt(x, y);
|
||||
});
|
||||
|
||||
socket.on("webContents-paste", (id) => {
|
||||
getWindowById(id).webContents.paste();
|
||||
});
|
||||
|
||||
socket.on("webContents-pasteAndMatchStyle", (id) => {
|
||||
getWindowById(id).webContents.pasteAndMatchStyle();
|
||||
});
|
||||
|
||||
socket.on("webContents-delete", (id) => {
|
||||
getWindowById(id).webContents.delete();
|
||||
});
|
||||
|
||||
socket.on("webContents-selectAll", (id) => {
|
||||
getWindowById(id).webContents.selectAll();
|
||||
});
|
||||
|
||||
socket.on("webContents-unselect", (id) => {
|
||||
getWindowById(id).webContents.unselect();
|
||||
});
|
||||
|
||||
socket.on("webContents-adjustSelection", (id, options) => {
|
||||
getWindowById(id).webContents.adjustSelection(options ?? {});
|
||||
});
|
||||
|
||||
socket.on("webContents-centerSelection", (id) => {
|
||||
getWindowById(id).webContents.centerSelection();
|
||||
});
|
||||
|
||||
socket.on("webContents-insertText", async (id, text) => {
|
||||
await getWindowById(id).webContents.insertText(text);
|
||||
electronSocket.emit("webContents-insertText-completed" + id);
|
||||
});
|
||||
|
||||
socket.on("webContents-replace", (id, text) => {
|
||||
getWindowById(id).webContents.replace(text);
|
||||
});
|
||||
|
||||
socket.on("webContents-replaceMisspelling", (id, text) => {
|
||||
getWindowById(id).webContents.replaceMisspelling(text);
|
||||
});
|
||||
|
||||
socket.on("webContents-findInPage", (id, text, options) => {
|
||||
const requestId = getWindowById(id).webContents.findInPage(
|
||||
text,
|
||||
options ?? undefined,
|
||||
);
|
||||
electronSocket.emit("webContents-findInPage-completed" + id, requestId);
|
||||
});
|
||||
|
||||
socket.on("webContents-stopFindInPage", (id, action) => {
|
||||
getWindowById(id).webContents.stopFindInPage(action);
|
||||
});
|
||||
|
||||
function getWindowById(
|
||||
id: number,
|
||||
): Electron.BrowserWindow | Electron.BrowserView {
|
||||
|
||||
Reference in New Issue
Block a user