types.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. type Platform =
  2. | "aix"
  3. | "android"
  4. | "darwin"
  5. | "freebsd"
  6. | "haiku"
  7. | "linux"
  8. | "openbsd"
  9. | "sunos"
  10. | "win32"
  11. | "cygwin"
  12. | "netbsd";
  13. /**
  14. * defines in `vite.config.ts`
  15. */
  16. declare const WIN_PORTABLE: boolean;
  17. declare const OS_PLATFORM: Platform;
  18. /**
  19. * Some interface for clash api
  20. */
  21. interface IConfigData {
  22. port: number;
  23. mode: string;
  24. ipv6: boolean;
  25. "socket-port": number;
  26. "allow-lan": boolean;
  27. "log-level": string;
  28. "mixed-port": number;
  29. "redir-port": number;
  30. "socks-port": number;
  31. "tproxy-port": number;
  32. "external-controller": string;
  33. secret: string;
  34. }
  35. interface IRuleItem {
  36. type: string;
  37. payload: string;
  38. proxy: string;
  39. }
  40. interface IProxyItem {
  41. name: string;
  42. type: string;
  43. udp: boolean;
  44. history: {
  45. time: string;
  46. delay: number;
  47. }[];
  48. all?: string[];
  49. now?: string;
  50. provider?: string; // 记录是否来自provider
  51. }
  52. type IProxyGroupItem = Omit<IProxyItem, "all"> & {
  53. all: IProxyItem[];
  54. };
  55. interface IProviderItem {
  56. name: string;
  57. type: string;
  58. proxies: IProxyItem[];
  59. updatedAt: string;
  60. vehicleType: string;
  61. }
  62. interface ITrafficItem {
  63. up: number;
  64. down: number;
  65. }
  66. interface ILogItem {
  67. type: string;
  68. time?: string;
  69. payload: string;
  70. }
  71. interface IConnectionsItem {
  72. id: string;
  73. metadata: {
  74. network: string;
  75. type: string;
  76. host: string;
  77. sourceIP: string;
  78. sourcePort: string;
  79. destinationPort: string;
  80. destinationIP?: string;
  81. process?: string;
  82. processPath?: string;
  83. };
  84. upload: number;
  85. download: number;
  86. start: string;
  87. chains: string[];
  88. rule: string;
  89. rulePayload: string;
  90. curUpload?: number; // upload speed, calculate at runtime
  91. curDownload?: number; // download speed, calculate at runtime
  92. }
  93. interface IConnections {
  94. downloadTotal: number;
  95. uploadTotal: number;
  96. connections: IConnectionsItem[];
  97. }
  98. /**
  99. * Some interface for command
  100. */
  101. interface IClashInfo {
  102. // status: string;
  103. port?: number; // clash mixed port
  104. server?: string; // external-controller
  105. secret?: string;
  106. }
  107. interface IProfileItem {
  108. uid: string;
  109. type?: "local" | "remote" | "merge" | "script";
  110. name?: string;
  111. desc?: string;
  112. file?: string;
  113. url?: string;
  114. updated?: number;
  115. selected?: {
  116. name?: string;
  117. now?: string;
  118. }[];
  119. extra?: {
  120. upload: number;
  121. download: number;
  122. total: number;
  123. expire: number;
  124. };
  125. option?: IProfileOption;
  126. }
  127. interface IProfileOption {
  128. user_agent?: string;
  129. with_proxy?: boolean;
  130. self_proxy?: boolean;
  131. update_interval?: number;
  132. }
  133. interface IProfilesConfig {
  134. current?: string;
  135. chain?: string[];
  136. valid?: string[];
  137. items?: IProfileItem[];
  138. }
  139. interface IVergeConfig {
  140. app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
  141. language?: string;
  142. tray_event?: "main_window" | "system_proxy" | "tun_mode" | string;
  143. clash_core?: string;
  144. theme_mode?: "light" | "dark" | "system";
  145. theme_blur?: boolean;
  146. traffic_graph?: boolean;
  147. enable_memory_usage?: boolean;
  148. enable_tun_mode?: boolean;
  149. enable_auto_launch?: boolean;
  150. enable_service_mode?: boolean;
  151. enable_silent_start?: boolean;
  152. enable_system_proxy?: boolean;
  153. enable_proxy_guard?: boolean;
  154. proxy_guard_duration?: number;
  155. system_proxy_bypass?: string;
  156. web_ui_list?: string[];
  157. hotkeys?: string[];
  158. theme_setting?: {
  159. primary_color?: string;
  160. secondary_color?: string;
  161. primary_text?: string;
  162. secondary_text?: string;
  163. info_color?: string;
  164. error_color?: string;
  165. warning_color?: string;
  166. success_color?: string;
  167. font_family?: string;
  168. css_injection?: string;
  169. };
  170. auto_close_connection?: boolean;
  171. default_latency_test?: string;
  172. enable_clash_fields?: boolean;
  173. enable_builtin_enhanced?: boolean;
  174. auto_log_clean?: 0 | 1 | 2 | 3;
  175. proxy_layout_column?: number;
  176. }
  177. type IClashConfigValue = any;
  178. interface IProfileMerge {
  179. // clash config fields (default supports)
  180. rules?: IClashConfigValue;
  181. proxies?: IClashConfigValue;
  182. "proxy-groups"?: IClashConfigValue;
  183. "proxy-providers"?: IClashConfigValue;
  184. "rule-providers"?: IClashConfigValue;
  185. // clash config fields (use flag)
  186. tun?: IClashConfigValue;
  187. dns?: IClashConfigValue;
  188. hosts?: IClashConfigValue;
  189. script?: IClashConfigValue;
  190. profile?: IClashConfigValue;
  191. payload?: IClashConfigValue;
  192. "interface-name"?: IClashConfigValue;
  193. "routing-mark"?: IClashConfigValue;
  194. // functional fields
  195. use?: string[];
  196. "prepend-rules"?: any[];
  197. "append-rules"?: any[];
  198. "prepend-proxies"?: any[];
  199. "append-proxies"?: any[];
  200. "prepend-proxy-groups"?: any[];
  201. "append-proxy-groups"?: any[];
  202. // fix
  203. ebpf?: any;
  204. experimental?: any;
  205. iptables?: any;
  206. sniffer?: any;
  207. authentication?: any;
  208. "bind-address"?: any;
  209. "external-ui"?: any;
  210. "auto-redir"?: any;
  211. "socks-port"?: any;
  212. "redir-port"?: any;
  213. "tproxy-port"?: any;
  214. "geodata-mode"?: any;
  215. "tcp-concurrent"?: any;
  216. }
  217. // partial of the clash config
  218. type IProfileData = Partial<{
  219. rules: any[];
  220. proxies: any[];
  221. "proxy-groups": any[];
  222. "proxy-providers": any[];
  223. "rule-providers": any[];
  224. [k: string]: any;
  225. }>;
  226. interface IChainItem {
  227. item: IProfileItem;
  228. merge?: IProfileMerge;
  229. script?: string;
  230. }
  231. interface IEnhancedPayload {
  232. chain: IChainItem[];
  233. valid: string[];
  234. current: IProfileData;
  235. callback: string;
  236. }
  237. interface IEnhancedResult {
  238. data: IProfileData;
  239. status: string;
  240. error?: string;
  241. }