-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathplugins.d.ts
161 lines (150 loc) · 5.68 KB
/
plugins.d.ts
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
interface Plugins {
APP_TITLE: string
YAML: {
parse(text: string): any
stringify(obj: any): string
}
SubStoreCache?: {
data: Record<string, any>
sync: () => void
get(key: string): any
set(key: string, value: any): void
remove(key: string): void
}
alert(title: string, content: string, options?: { type?: string; markdown?: boolean }): Promise<void>
prompt(title: string, initialValue?: string, options?: { placeholder?: string; type?: string }): Promise<string>
confirm(
title: string,
content: string,
options?: {
type?: string
okText?: string
cancelText?: string
markdown?: boolean
}
): Promise<boolean>
picker: {
multi(title: string, options: Array<{ label: string; value: any }>, initialValue?: any[]): Promise<any[]>
single(
title: string,
options: Array<{
label: string
value: any
description?: string
background?: string
onSelect?: (item: { value: any }) => void
}>,
initialValue?: any[]
): Promise<any>
}
message: {
success(msg: string, duration?: number): void
info(
msg: string,
duration?: number,
onClose?: () => void
): {
id: string | number
update: (msg: string, type?: string) => void
destroy: () => void
success: (msg: string) => void
error: (msg: string) => void
}
update(id: string | number, msg: string, type?: string): void
destroy(id: string | number): void
error(msg: string): void
}
AbsolutePath(relativePath: string): Promise<string>
Copyfile(src: string, dest: string): Promise<void>
Makedir(path: string): Promise<void>
Readdir(path: string): Promise<Array<{ name: string; isDir: boolean; size: number }>>
FileExists(path: string): Promise<boolean>
Removefile(path: string): Promise<void>
Movefile(src: string, dest: string): Promise<void>
Readfile(path: string, options?: { Mode?: 'Binary' | 'Text' }): Promise<string>
Writefile(path: string, content: string, options?: { Mode?: 'Binary' | 'Text' }): Promise<void>
UnzipGZFile(gzPath: string, destPath: string): Promise<void>
UnzipZIPFile(zipPath: string, destPath: string): Promise<void>
ListServer(): Promise<string[]>
StopServer(id: string): Promise<void>
StartServer(
address: string,
serverId: string,
onRequest: (
req: {
url: string
method: string
headers: Record<string, string>
body: string
},
res: {
end: (status: number, headers: Record<string, string>, body: string) => void
}
) => void
): Promise<{ close: () => Promise<void> }>
ProcessInfo(pid: number): Promise<string>
KillProcess(pid: number): Promise<void>
Exec(cmd: string, args?: string[], options?: { convert?: boolean }): Promise<string>
ExecBackground(
cmd: string,
args: string[],
onOut: (out: string) => void,
onExit: () => void,
options?: { env?: Record<string, string>; convert?: boolean }
): Promise<number>
Request: any
HttpGet(url: string, headers?: Record<string, string>, options?: { Insecure?: boolean }): Promise<{ status: number; body: any }>
HttpPost(url: string, headers: Record<string, string>, data: any, options?: { Timeout?: number; Insecure?: boolean }): Promise<{ status: number; body: any }>
HttpDelete(url: string, headers: Record<string, string>, options?: { Insecure?: boolean }): Promise<{ status: number; body: any }>
HttpPatch(url: string, headers: Record<string, string>, data: any): Promise<{ status: number; body: any }>
Requests(options: {
method: string
url: string
headers?: Record<string, string>
body?: string
Insecure?: boolean
}): Promise<{ status: number; body: any }>
Download(url: string, path: string, headers?: Record<string, string>, progressCallback?: (progress: number, total: number) => void): Promise<void>
GetInterfaces(): Promise<string[]>
CheckPermissions(): Promise<boolean>
RestartApp(): Promise<void>
BrowserOpenURL(url: string): void
WindowReloadApp(): Promise<void>
ClipboardSetText(text: string): Promise<void>
ClipboardGetText(): Promise<string>
OpenMMDB(path: string, id: string): Promise<void>
CloseMMDB(path: string, id: string): Promise<void>
QueryMMDB(path: string, ip: string, type?: 'ASN' | 'AnonymousIP' | 'City' | 'ConnectionType' | 'Country' | 'Domain' | 'Enterprise'): Promise<any> // Define return type if known
useKernelApiStore(): any
usePluginsStore(): any
useRulesetsStore(): any
useSubscribesStore(): any
useEnvStore(): any
useAppSettingsStore(): any
useProfilesStore(): any
useScheduledTasksStore(): any
setIntervalImmediately(fn: () => void, delay: number): number
formatRelativeTime(dateString: string): string
base64Decode(encoded: string): string
base64Encode(text: string): string
deepClone<T>(obj: T): T
deepAssign<T, U>(target: T, source: U): T & U
asyncPool: <T>(poolLimit: number, array: T[], iteratorFn: (item: T, array: T[]) => Promise<any>) => Promise<any[]>
sampleID(): string
isValidIPv4(ip: string): boolean
generateConfig(profile: any, stable?: boolean): Promise<any>
formatBytes(bytes: number): string
formatDate(date: string | number, format: string)
handleUseProxy(group: any, proxy: { name: string }): Promise<void>
debounce(fn: (...args: any[]) => void, delay: number): (...args: any[]) => void
getKernelFileName(isAlpha: boolean): Promise<string>
getUserAgent(): Promise<string>
getGitHubApiAuthorization?(): string
sleep(ms: number): Promise<void>
ignoredError<T extends (...args: any[]) => any>(fn: T, ...args: Parameters<T>): Promise<ReturnType<T> | undefined>
exitApp(): Promise<void>
}
declare namespace globalThis {
var Plugins: Plugins
var Plugin: any
}