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

Commit 8c8153d

Browse files
committed
damn you npm
1 parent 23a8785 commit 8c8153d

File tree

6 files changed

+49
-12
lines changed

6 files changed

+49
-12
lines changed

dist/preload/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
2222
__setModuleDefault(result, mod);
2323
return result;
2424
};
25+
var __importDefault = (this && this.__importDefault) || function (mod) {
26+
return (mod && mod.__esModule) ? mod : { "default": mod };
27+
};
2528
Object.defineProperty(exports, "__esModule", { value: true });
2629
const electron_1 = require("electron");
2730
const remote = __importStar(require("@electron/remote"));
31+
const native_1 = __importDefault(require("./native"));
32+
window.Native = native_1.default;
2833
window.remote = remote;
2934
electron_1.ipcRenderer.on('log', (event, { level, message, context }) => {
3035
if (level === 'error') {

dist/preload/native.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
const electron_1 = require("electron");
4+
exports.default = {
5+
on: (event, callback) => {
6+
electron_1.ipcRenderer.on('native-event', (_, data) => {
7+
event = event.replace(/^(\\)+/, '');
8+
data.event = data.event.replace(/^(\\)+/, '');
9+
if (event === data.event) {
10+
return callback(data.payload, event);
11+
}
12+
});
13+
}
14+
};

dist/server/api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const app_1 = __importDefault(require("./api/app"));
2121
const screen_1 = __importDefault(require("./api/screen"));
2222
const dialog_1 = __importDefault(require("./api/dialog"));
2323
const debug_1 = __importDefault(require("./api/debug"));
24+
const broadcasting_1 = __importDefault(require("./api/broadcasting"));
2425
const system_1 = __importDefault(require("./api/system"));
2526
const globalShortcut_1 = __importDefault(require("./api/globalShortcut"));
2627
const notification_1 = __importDefault(require("./api/notification"));
@@ -60,6 +61,7 @@ function startAPIServer(randomSecret) {
6061
httpServer.use("/api/menu-bar", menuBar_1.default);
6162
httpServer.use("/api/progress-bar", progressBar_1.default);
6263
httpServer.use("/api/power-monitor", powerMonitor_1.default);
64+
httpServer.use("/api/broadcast", broadcasting_1.default);
6365
if (process.env.NODE_ENV === "development") {
6466
httpServer.use("/api/debug", debug_1.default);
6567
}

dist/server/api/broadcasting.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const express_1 = __importDefault(require("express"));
7+
const utils_1 = require("../utils");
8+
const router = express_1.default.Router();
9+
router.post('/', (req, res) => {
10+
const { event, payload } = req.body;
11+
(0, utils_1.broadcastToWindows)("native-event", { event, payload });
12+
res.sendStatus(200);
13+
});
14+
exports.default = router;

dist/server/api/debug.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44
};
55
Object.defineProperty(exports, "__esModule", { value: true });
66
const express_1 = __importDefault(require("express"));
7-
const state_1 = __importDefault(require("../state"));
7+
const utils_1 = require("../utils");
88
const router = express_1.default.Router();
99
router.post('/log', (req, res) => {
10-
var _a;
1110
const { level, message, context } = req.body;
12-
Object.values(state_1.default.windows).forEach(window => {
13-
window.webContents.send('log', { level, message, context });
14-
});
15-
if ((_a = state_1.default.activeMenuBar) === null || _a === void 0 ? void 0 : _a.window) {
16-
state_1.default.activeMenuBar.window.webContents.send('log', { level, message, context });
17-
}
11+
(0, utils_1.broadcastToWindows)('log', { level, message, context });
1812
res.sendStatus(200);
1913
});
2014
exports.default = router;

dist/server/utils.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1212
return (mod && mod.__esModule) ? mod : { "default": mod };
1313
};
1414
Object.defineProperty(exports, "__esModule", { value: true });
15-
exports.trimOptions = exports.notifyLaravel = exports.appendCookie = void 0;
15+
exports.trimOptions = exports.broadcastToWindows = exports.notifyLaravel = exports.appendCookie = void 0;
1616
const electron_1 = require("electron");
1717
const state_1 = __importDefault(require("./state"));
1818
const axios_1 = __importDefault(require("axios"));
@@ -39,13 +39,21 @@ function notifyLaravel(endpoint, payload = {}) {
3939
catch (e) {
4040
}
4141
if (endpoint === 'events') {
42-
Object.values(state_1.default.windows).forEach(window => {
43-
window.webContents.send('native-event', payload);
44-
});
42+
broadcastToWindows('native-event', payload);
4543
}
4644
});
4745
}
4846
exports.notifyLaravel = notifyLaravel;
47+
function broadcastToWindows(event, payload) {
48+
var _a;
49+
Object.values(state_1.default.windows).forEach(window => {
50+
window.webContents.send(event, payload);
51+
});
52+
if ((_a = state_1.default.activeMenuBar) === null || _a === void 0 ? void 0 : _a.window) {
53+
state_1.default.activeMenuBar.window.webContents.send(event, payload);
54+
}
55+
}
56+
exports.broadcastToWindows = broadcastToWindows;
4957
function trimOptions(options) {
5058
Object.keys(options).forEach(key => options[key] == null && delete options[key]);
5159
return options;

0 commit comments

Comments
 (0)