Skip to content

Commit

Permalink
Merge pull request #4 from Lukewh/dev-console
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukewh authored May 20, 2022
2 parents 80c7a30 + 256edb4 commit 7f61ce7
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
21 changes: 21 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { app, BrowserWindow, desktopCapturer, ipcMain } = require("electron");
const path = require("path");

const createWindow = () => {
let devtoolsOpen = false;
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 1024,
Expand Down Expand Up @@ -36,6 +37,26 @@ const createWindow = () => {

// Open the DevTools.
//mainWindow.webContents.openDevTools();

ipcMain.handle("TOGGLE_DEV_TOOLS", async (event, opts) => {
if (!devtoolsOpen) {
mainWindow.webContents.openDevTools();
} else {
mainWindow.webContents.closeDevTools();
}
});

mainWindow.webContents.on("devtools-opened", () => {
devtoolsOpen = true;
// setImmediate(() => {
// // do whatever you want to do after dev tool completely opened here

// });
});

mainWindow.webContents.on("devtools-closed", () => {
devtoolsOpen = false;
});
};

// This method will be called when Electron has finished
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gathertown",
"version": "0.1.1",
"version": "0.2.0",
"description": "A better way to meet.",
"main": "main.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ window.addEventListener("DOMContentLoaded", () => {
contextBridge.exposeInMainWorld("myCustomGetDisplayMedia", async () => {
return await ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES");
});

contextBridge.exposeInMainWorld("toggleDevTools", async () => {
return await ipcRenderer.invoke("TOGGLE_DEV_TOOLS");
});
25 changes: 25 additions & 0 deletions renderer.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,28 @@
width: 100%;
overflow: hidden;
}

#snap-dev-tools {
position: absolute;
top: 10px;
left: 10px;
font-size: 11px;
font-family: monospace;
color: #fff;
background: #000;
border: 1px solid rgba(255,255,255,0.5);
border-radius: 5px;
width: 16px;
height: 16px;
display: flex;
z-index: 99999;
cursor: pointer;
justify-content: center;
align-items: center;
line-height: 0;
opacity: 0.4;
}

#snap-dev-tools:hover {
opacity: 1;
}
14 changes: 14 additions & 0 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,17 @@ const createSourceEl = (source) => {
el: wrapper,
};
};

const addDevToggle = async () => {
const devToolsButton = document.createElement("div");
devToolsButton.setAttribute("id", "snap-dev-tools");
devToolsButton.innerText = ">_";

devToolsButton.addEventListener("click", () => {
window.toggleDevTools();
});

document.body.appendChild(devToolsButton);
};

addDevToggle();
2 changes: 1 addition & 1 deletion snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: gathertown
version: 0.1.1
version: 0.2.0
summary: A better way to meet.
description: |
Electron wrapper for Gather Town
Expand Down

0 comments on commit 7f61ce7

Please sign in to comment.