-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.ts
More file actions
61 lines (56 loc) · 2.06 KB
/
preload.ts
File metadata and controls
61 lines (56 loc) · 2.06 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
49
50
51
52
53
54
55
56
57
58
59
60
61
// This file must stay as CommonJS with require to make Electron happy
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('electron', {
// Values
node: () => process.versions.node,
chrome: () => process.versions.chrome,
electron: () => process.versions.electron,
// Actions
getData: (
directory: string,
direction: string,
field: string,
showDuplicates: boolean,
tag: string,
search: string,
type: string
) =>
ipcRenderer.invoke(
'get-data',
directory,
direction,
field,
showDuplicates,
tag,
search,
type
),
getSelectedTags: (fileId: number) =>
ipcRenderer.invoke('get-selected-tags', fileId),
makeTag: (name: string) => ipcRenderer.invoke('make-tag', name),
updateTag: (payload: unknown) => ipcRenderer.invoke('update-tag', payload),
deleteTag: (tag_id: number, directory: string) =>
ipcRenderer.invoke('delete-tag', tag_id, directory),
deleteFileTag: (file_tag_id: number) =>
ipcRenderer.invoke('delete-file-tag', file_tag_id),
openFile: (path: string) => ipcRenderer.invoke('open-file', path),
openFileInFinder: (path: string) =>
ipcRenderer.invoke('open-file-in-finder', path),
getFile: (path: string) => ipcRenderer.invoke('get-file', path),
deleteFiles: (
directory: string,
manifest: Map<number, { path: string; sha512: string }>,
mode: 'trash' | 'permanent'
) => ipcRenderer.invoke('delete-files', directory, manifest, mode),
rotatePhoto: (directory: string, path: string, sha512: string) =>
ipcRenderer.invoke('rotate-photo', directory, path, sha512),
tagItems: (directory: string, file_ids: number[], tag_id: number) =>
ipcRenderer.invoke('tag-items', directory, file_ids, tag_id),
sync: (directory: string) => ipcRenderer.invoke('sync', directory),
publish: (directory: string) => ipcRenderer.invoke('publish', directory),
// Reporter
onReport: (callback: (payload: unknown) => void) =>
ipcRenderer.on('on-report', (_event: unknown, payload: unknown) =>
callback(payload)
),
})