Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
damn you npm
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Sep 16, 2024
1 parent 23a8785 commit 8c8153d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
5 changes: 5 additions & 0 deletions dist/preload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const remote = __importStar(require("@electron/remote"));
const native_1 = __importDefault(require("./native"));
window.Native = native_1.default;
window.remote = remote;
electron_1.ipcRenderer.on('log', (event, { level, message, context }) => {
if (level === 'error') {
Expand Down
14 changes: 14 additions & 0 deletions dist/preload/native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
exports.default = {
on: (event, callback) => {
electron_1.ipcRenderer.on('native-event', (_, data) => {
event = event.replace(/^(\\)+/, '');
data.event = data.event.replace(/^(\\)+/, '');
if (event === data.event) {
return callback(data.payload, event);
}
});
}
};
2 changes: 2 additions & 0 deletions dist/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const app_1 = __importDefault(require("./api/app"));
const screen_1 = __importDefault(require("./api/screen"));
const dialog_1 = __importDefault(require("./api/dialog"));
const debug_1 = __importDefault(require("./api/debug"));
const broadcasting_1 = __importDefault(require("./api/broadcasting"));
const system_1 = __importDefault(require("./api/system"));
const globalShortcut_1 = __importDefault(require("./api/globalShortcut"));
const notification_1 = __importDefault(require("./api/notification"));
Expand Down Expand Up @@ -60,6 +61,7 @@ function startAPIServer(randomSecret) {
httpServer.use("/api/menu-bar", menuBar_1.default);
httpServer.use("/api/progress-bar", progressBar_1.default);
httpServer.use("/api/power-monitor", powerMonitor_1.default);
httpServer.use("/api/broadcast", broadcasting_1.default);
if (process.env.NODE_ENV === "development") {
httpServer.use("/api/debug", debug_1.default);
}
Expand Down
14 changes: 14 additions & 0 deletions dist/server/api/broadcasting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const utils_1 = require("../utils");
const router = express_1.default.Router();
router.post('/', (req, res) => {
const { event, payload } = req.body;
(0, utils_1.broadcastToWindows)("native-event", { event, payload });
res.sendStatus(200);
});
exports.default = router;
10 changes: 2 additions & 8 deletions dist/server/api/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const state_1 = __importDefault(require("../state"));
const utils_1 = require("../utils");
const router = express_1.default.Router();
router.post('/log', (req, res) => {
var _a;
const { level, message, context } = req.body;
Object.values(state_1.default.windows).forEach(window => {
window.webContents.send('log', { level, message, context });
});
if ((_a = state_1.default.activeMenuBar) === null || _a === void 0 ? void 0 : _a.window) {
state_1.default.activeMenuBar.window.webContents.send('log', { level, message, context });
}
(0, utils_1.broadcastToWindows)('log', { level, message, context });
res.sendStatus(200);
});
exports.default = router;
16 changes: 12 additions & 4 deletions dist/server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.trimOptions = exports.notifyLaravel = exports.appendCookie = void 0;
exports.trimOptions = exports.broadcastToWindows = exports.notifyLaravel = exports.appendCookie = void 0;
const electron_1 = require("electron");
const state_1 = __importDefault(require("./state"));
const axios_1 = __importDefault(require("axios"));
Expand All @@ -39,13 +39,21 @@ function notifyLaravel(endpoint, payload = {}) {
catch (e) {
}
if (endpoint === 'events') {
Object.values(state_1.default.windows).forEach(window => {
window.webContents.send('native-event', payload);
});
broadcastToWindows('native-event', payload);
}
});
}
exports.notifyLaravel = notifyLaravel;
function broadcastToWindows(event, payload) {
var _a;
Object.values(state_1.default.windows).forEach(window => {
window.webContents.send(event, payload);
});
if ((_a = state_1.default.activeMenuBar) === null || _a === void 0 ? void 0 : _a.window) {
state_1.default.activeMenuBar.window.webContents.send(event, payload);
}
}
exports.broadcastToWindows = broadcastToWindows;
function trimOptions(options) {
Object.keys(options).forEach(key => options[key] == null && delete options[key]);
return options;
Expand Down

0 comments on commit 8c8153d

Please sign in to comment.