Repository navigation
Expand file tree
/
Copy pathpreload.js
More file actions
48 lines (41 loc) · 2.79 KB
/
Copy pathpreload.js
File metadata and controls
48 lines (41 loc) · 2.79 KB
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
38
39
40
41
42
43
44
45
46
47
48
const { contextBridge, ipcRenderer, webUtils } = require('electron');
contextBridge.exposeInMainWorld('neo', {
readLibrary: () => ipcRenderer.invoke('library:read'),
writeLibrary: (data) => ipcRenderer.invoke('library:write', data),
createBook: (meta) => ipcRenderer.invoke('book:create', meta),
readBookMeta: (bookId) => ipcRenderer.invoke('book:readMeta', bookId),
writeBookMeta: (bookId, meta) => ipcRenderer.invoke('book:writeMeta', bookId, meta),
deleteBook: (bookId, title) => ipcRenderer.invoke('book:delete', bookId, title),
readChapter: (bookId, chId) => ipcRenderer.invoke('chapter:read', bookId, chId),
writeChapter: (bookId, chId, html) => ipcRenderer.invoke('chapter:write', bookId, chId, html),
deleteChapter: (bookId, chId) => ipcRenderer.invoke('chapter:delete', bookId, chId),
readAux: (bookId, name) => ipcRenderer.invoke('aux:read', bookId, name),
writeAux: (bookId, name, html) => ipcRenderer.invoke('aux:write', bookId, name, html),
readJSON: (bookId, name, fallback) => ipcRenderer.invoke('json:read', bookId, name, fallback),
writeJSON: (bookId, name, data) => ipcRenderer.invoke('json:write', bookId, name, data),
exportSave: (payload) => ipcRenderer.invoke('export:save', payload),
emailDraft: (payload) => ipcRenderer.invoke('email:draft', payload),
logError: (msg) => ipcRenderer.invoke('log:error', msg),
importPick: () => ipcRenderer.invoke('import:pick'),
libraryPath: () => ipcRenderer.invoke('library:path'),
pickCover: () => ipcRenderer.invoke('cover:pick'),
setCover: (bookId, srcPath) => ipcRenderer.invoke('cover:set', bookId, srcPath),
removeCover: (bookId) => ipcRenderer.invoke('cover:remove', bookId),
readCover: (bookId, fname) => ipcRenderer.invoke('cover:read', bookId, fname),
paintCover: (bookId, text, options) => ipcRenderer.invoke('cover:paint', bookId, text, options),
setSecret: (name, value) => ipcRenderer.invoke('secret:set', name, value),
hasSecret: (name) => ipcRenderer.invoke('secret:has', name),
importFiles: (paths) => ipcRenderer.invoke('import:files', paths),
pathForFile: (file) => webUtils.getPathForFile(file),
fullscreenEscape: () => ipcRenderer.invoke('fullscreen:escape'),
fullscreenToggle: () => ipcRenderer.invoke('fullscreen:toggle'),
checkForUpdate: () => ipcRenderer.invoke('update:check'),
spellCheckWords: (words) => ipcRenderer.invoke('spell:check', words),
spellSuggest: (word) => ipcRenderer.invoke('spell:suggest', word),
spellLearn: (word) => ipcRenderer.invoke('spell:learn', word),
setSpellLanguage: (code) => ipcRenderer.invoke('spell:setLanguage', code),
appVersion: () => ipcRenderer.invoke('app:version'),
openRelease: () => ipcRenderer.invoke('update:openRelease'),
poetryState: (on) => ipcRenderer.send('poetry:state', on),
onMenu: (cb) => ipcRenderer.on('menu', (_e, msg) => cb(msg))
});