-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathinterface.d.ts
More file actions
128 lines (122 loc) · 4.38 KB
/
Copy pathinterface.d.ts
File metadata and controls
128 lines (122 loc) · 4.38 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import type { MachinesListing } from 'components/MachineManagerProvider'
import 'electron'
import type { Stats } from 'fs'
import type fs from 'node:fs/promises'
import type path from 'path'
import type { AutoUpdateDownloadProgress } from '@src/lib/autoUpdate'
import type { PluginIpcChannel } from '@src/registry/pluginIpc'
import type { dialog, shell } from 'electron'
import type { WebContentSendPayload } from 'menu/channels'
import type { ZooLabel } from 'menu/roles'
// Extend the interface with additional custom properties
declare module 'electron' {
interface Menu {
label?: ZooLabel
}
}
type EnvFn = (value?: string) => string
export type DeviceFlowAuthorization = {
userCode: string
verificationUri: string
}
export interface IElectronAPI {
resizeWindow: (width: number, height: number) => Promise<void>
open: typeof dialog.showOpenDialog
save: typeof dialog.showSaveDialog
openExternal: typeof shell.openExternal
openInNewWindow: (name: string) => void
showInFolder: typeof shell.showItemInFolder
pluginIpc: {
invoke: <T>(channel: PluginIpcChannel, payload?: unknown) => Promise<T>
syncActivePlugins: (pluginIds: readonly string[]) => Promise<void>
}
/** Require to be called first before {@link loginWithDeviceFlow} */
startDeviceFlow: (host: string) => Promise<DeviceFlowAuthorization>
/** Registered by first calling {@link startDeviceFlow}, which sets up the device flow handle */
loginWithDeviceFlow: () => Promise<string>
cancelDeviceFlow: () => Promise<void>
platform: typeof process.env.platform
arch: typeof process.env.arch
version: typeof process.env.version
watchFileOn: (
path: string,
key: string,
callback: (eventType: string, path: string) => void
) => void
readFile: typeof fs.readFile
watchFileOff: (path: string, key: string) => void
writeFile: (path: string, data: string | Uint8Array) => Promise<undefined>
readdir: (path: string) => Promise<string[]>
getPath: (name: 'appData' | 'documents' | 'userData') => Promise<string>
rm: typeof fs.rm
access: typeof fs.access
stat: (path: string) => Promise<Stats>
statIsDirectory: (path: string) => Promise<boolean>
canReadWriteDirectory: (
path: string
) => Promise<{ value: boolean; error: unknown }>
path: path
mkdir: typeof fs.mkdir
path: typeof path
cp: typeof fs.cp
// No such thing as fs.mv, but our function will use fs.cp as a fallback
move: (
source: string | URL,
destination: string | URL
) => Promise<undefined | Error>
rename: (prev: string, next: string) => Promise<undefined>
packageJson: {
name: string
}
os: {
isMac: boolean
isWindows: boolean
isLinux: boolean
}
process: {
env: {
NODE_ENV: string
VITE_ZOO_BASE_DOMAIN: string
VITE_KITTYCAD_WEBSOCKET_URL: string
VITE_MLEPHANT_WEBSOCKET_URL: string
VITE_KITTYCAD_API_TOKEN: string // legacy token name
VITE_ZOO_API_TOKEN: string
}
}
kittycad: (access: string, args: any) => any
listMachines: (machineApiIp: string) => Promise<MachinesListing>
getMachineApiIp: () => Promise<string | null>
getMachineApiRunning: () => Promise<boolean>
setMachineApiState: (signal: 'on' | 'off') => Promise<boolean>
onUpdateChecking: (callback: () => void) => Electron.IpcRenderer
onUpdateNotAvailable: (callback: () => void) => Electron.IpcRenderer
onUpdateDownloadStart: (
callback: (value: AutoUpdateDownloadProgress) => void
) => Electron.IpcRenderer
onUpdateDownloadProgress: (
callback: (value: AutoUpdateDownloadProgress) => void
) => Electron.IpcRenderer
onUpdateDownloaded: (
callback: (value: { version: string; releaseNotes: string }) => void
) => Electron.IpcRenderer
onUpdateError: (callback: (value: { error: Error }) => void) => Electron
appRestart: () => void
appCheckForUpdates: () => Promise<unknown>
getArgvParsed: () => any
getAppTestProperty: (propertyName: string) => any
// Helper functions to create application Menus
createHomePageMenu: () => Promise<any>
createModelingPageMenu: () => Promise<any>
createFallbackMenu: () => Promise<any>
enableMenu(menuId: string): Promise<any>
disableMenu(menuId: string): Promise<any>
menuOn: (callback: (payload: WebContentSendPayload) => void) => any
}
declare global {
interface Window {
electron: IElectronAPI | undefined
openExternalLink:
| ((e: React.MouseEvent<HTMLAnchorElement>) => void)
| undefined
}
}