-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
preload.js
37 lines (31 loc) · 1.06 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { contextBridge, ipcRenderer, clipboard, shell } = require("electron");
const equal = require('fast-deep-equal');
const friendCode = require("csgo-friendcode");
var showdown = require('showdown');
const md_converter = new showdown.Converter();
contextBridge.exposeInMainWorld("ipcRenderer", {
send: (channel, data) => {
ipcRenderer.send(channel, data);
},
on: (channel, func) => {
ipcRenderer.on(channel, (...args) => func(...args));
},
invoke: (chanel, ...args) => {
return ipcRenderer.invoke(chanel, ...args);
}
});
contextBridge.exposeInMainWorld('fastEqual', {
equal: (...args) => equal(...args)
});
contextBridge.exposeInMainWorld('friendCode', {
encode: (steamId) => friendCode.encode(steamId)
});
contextBridge.exposeInMainWorld('clipboard', {
writeText: (text, type) => clipboard.writeText(text, type)
});
contextBridge.exposeInMainWorld('shell', {
openExternal: (url, options) => shell.openExternal(url, options)
});
contextBridge.exposeInMainWorld('md_converter', {
makeHtml: (markdown) => md_converter.makeHtml(markdown)
});