runtime.d.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. _ __ _ __
  3. | | / /___ _(_) /____
  4. | | /| / / __ `/ / / ___/
  5. | |/ |/ / /_/ / / (__ )
  6. |__/|__/\__,_/_/_/____/
  7. The electron alternative for Go
  8. (c) Lea Anthony 2019-present
  9. */
  10. export interface Position {
  11. x: number;
  12. y: number;
  13. }
  14. export interface Size {
  15. w: number;
  16. h: number;
  17. }
  18. export interface Screen {
  19. isCurrent: boolean;
  20. isPrimary: boolean;
  21. width : number
  22. height : number
  23. }
  24. // Environment information such as platform, buildtype, ...
  25. export interface EnvironmentInfo {
  26. buildType: string;
  27. platform: string;
  28. arch: string;
  29. }
  30. // [EventsEmit](https://wails.io/docs/reference/runtime/events#eventsemit)
  31. // emits the given event. Optional data may be passed with the event.
  32. // This will trigger any event listeners.
  33. export function EventsEmit(eventName: string, ...data: any): void;
  34. // [EventsOn](https://wails.io/docs/reference/runtime/events#eventson) sets up a listener for the given event name.
  35. export function EventsOn(eventName: string, callback: (...data: any) => void): () => void;
  36. // [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
  37. // sets up a listener for the given event name, but will only trigger a given number times.
  38. export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
  39. // [EventsOnce](https://wails.io/docs/reference/runtime/events#eventsonce)
  40. // sets up a listener for the given event name, but will only trigger once.
  41. export function EventsOnce(eventName: string, callback: (...data: any) => void): () => void;
  42. // [EventsOff](https://wails.io/docs/reference/runtime/events#eventsoff)
  43. // unregisters the listener for the given event name.
  44. export function EventsOff(eventName: string, ...additionalEventNames: string[]): void;
  45. // [EventsOffAll](https://wails.io/docs/reference/runtime/events#eventsoffall)
  46. // unregisters all listeners.
  47. export function EventsOffAll(): void;
  48. // [LogPrint](https://wails.io/docs/reference/runtime/log#logprint)
  49. // logs the given message as a raw message
  50. export function LogPrint(message: string): void;
  51. // [LogTrace](https://wails.io/docs/reference/runtime/log#logtrace)
  52. // logs the given message at the `trace` log level.
  53. export function LogTrace(message: string): void;
  54. // [LogDebug](https://wails.io/docs/reference/runtime/log#logdebug)
  55. // logs the given message at the `debug` log level.
  56. export function LogDebug(message: string): void;
  57. // [LogError](https://wails.io/docs/reference/runtime/log#logerror)
  58. // logs the given message at the `error` log level.
  59. export function LogError(message: string): void;
  60. // [LogFatal](https://wails.io/docs/reference/runtime/log#logfatal)
  61. // logs the given message at the `fatal` log level.
  62. // The application will quit after calling this method.
  63. export function LogFatal(message: string): void;
  64. // [LogInfo](https://wails.io/docs/reference/runtime/log#loginfo)
  65. // logs the given message at the `info` log level.
  66. export function LogInfo(message: string): void;
  67. // [LogWarning](https://wails.io/docs/reference/runtime/log#logwarning)
  68. // logs the given message at the `warning` log level.
  69. export function LogWarning(message: string): void;
  70. // [WindowReload](https://wails.io/docs/reference/runtime/window#windowreload)
  71. // Forces a reload by the main application as well as connected browsers.
  72. export function WindowReload(): void;
  73. // [WindowReloadApp](https://wails.io/docs/reference/runtime/window#windowreloadapp)
  74. // Reloads the application frontend.
  75. export function WindowReloadApp(): void;
  76. // [WindowSetAlwaysOnTop](https://wails.io/docs/reference/runtime/window#windowsetalwaysontop)
  77. // Sets the window AlwaysOnTop or not on top.
  78. export function WindowSetAlwaysOnTop(b: boolean): void;
  79. // [WindowSetSystemDefaultTheme](https://wails.io/docs/next/reference/runtime/window#windowsetsystemdefaulttheme)
  80. // *Windows only*
  81. // Sets window theme to system default (dark/light).
  82. export function WindowSetSystemDefaultTheme(): void;
  83. // [WindowSetLightTheme](https://wails.io/docs/next/reference/runtime/window#windowsetlighttheme)
  84. // *Windows only*
  85. // Sets window to light theme.
  86. export function WindowSetLightTheme(): void;
  87. // [WindowSetDarkTheme](https://wails.io/docs/next/reference/runtime/window#windowsetdarktheme)
  88. // *Windows only*
  89. // Sets window to dark theme.
  90. export function WindowSetDarkTheme(): void;
  91. // [WindowCenter](https://wails.io/docs/reference/runtime/window#windowcenter)
  92. // Centers the window on the monitor the window is currently on.
  93. export function WindowCenter(): void;
  94. // [WindowSetTitle](https://wails.io/docs/reference/runtime/window#windowsettitle)
  95. // Sets the text in the window title bar.
  96. export function WindowSetTitle(title: string): void;
  97. // [WindowFullscreen](https://wails.io/docs/reference/runtime/window#windowfullscreen)
  98. // Makes the window full screen.
  99. export function WindowFullscreen(): void;
  100. // [WindowUnfullscreen](https://wails.io/docs/reference/runtime/window#windowunfullscreen)
  101. // Restores the previous window dimensions and position prior to full screen.
  102. export function WindowUnfullscreen(): void;
  103. // [WindowIsFullscreen](https://wails.io/docs/reference/runtime/window#windowisfullscreen)
  104. // Returns the state of the window, i.e. whether the window is in full screen mode or not.
  105. export function WindowIsFullscreen(): Promise<boolean>;
  106. // [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
  107. // Sets the width and height of the window.
  108. export function WindowSetSize(width: number, height: number): Promise<Size>;
  109. // [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
  110. // Gets the width and height of the window.
  111. export function WindowGetSize(): Promise<Size>;
  112. // [WindowSetMaxSize](https://wails.io/docs/reference/runtime/window#windowsetmaxsize)
  113. // Sets the maximum window size. Will resize the window if the window is currently larger than the given dimensions.
  114. // Setting a size of 0,0 will disable this constraint.
  115. export function WindowSetMaxSize(width: number, height: number): void;
  116. // [WindowSetMinSize](https://wails.io/docs/reference/runtime/window#windowsetminsize)
  117. // Sets the minimum window size. Will resize the window if the window is currently smaller than the given dimensions.
  118. // Setting a size of 0,0 will disable this constraint.
  119. export function WindowSetMinSize(width: number, height: number): void;
  120. // [WindowSetPosition](https://wails.io/docs/reference/runtime/window#windowsetposition)
  121. // Sets the window position relative to the monitor the window is currently on.
  122. export function WindowSetPosition(x: number, y: number): void;
  123. // [WindowGetPosition](https://wails.io/docs/reference/runtime/window#windowgetposition)
  124. // Gets the window position relative to the monitor the window is currently on.
  125. export function WindowGetPosition(): Promise<Position>;
  126. // [WindowHide](https://wails.io/docs/reference/runtime/window#windowhide)
  127. // Hides the window.
  128. export function WindowHide(): void;
  129. // [WindowShow](https://wails.io/docs/reference/runtime/window#windowshow)
  130. // Shows the window, if it is currently hidden.
  131. export function WindowShow(): void;
  132. // [WindowMaximise](https://wails.io/docs/reference/runtime/window#windowmaximise)
  133. // Maximises the window to fill the screen.
  134. export function WindowMaximise(): void;
  135. // [WindowToggleMaximise](https://wails.io/docs/reference/runtime/window#windowtogglemaximise)
  136. // Toggles between Maximised and UnMaximised.
  137. export function WindowToggleMaximise(): void;
  138. // [WindowUnmaximise](https://wails.io/docs/reference/runtime/window#windowunmaximise)
  139. // Restores the window to the dimensions and position prior to maximising.
  140. export function WindowUnmaximise(): void;
  141. // [WindowIsMaximised](https://wails.io/docs/reference/runtime/window#windowismaximised)
  142. // Returns the state of the window, i.e. whether the window is maximised or not.
  143. export function WindowIsMaximised(): Promise<boolean>;
  144. // [WindowMinimise](https://wails.io/docs/reference/runtime/window#windowminimise)
  145. // Minimises the window.
  146. export function WindowMinimise(): void;
  147. // [WindowUnminimise](https://wails.io/docs/reference/runtime/window#windowunminimise)
  148. // Restores the window to the dimensions and position prior to minimising.
  149. export function WindowUnminimise(): void;
  150. // [WindowIsMinimised](https://wails.io/docs/reference/runtime/window#windowisminimised)
  151. // Returns the state of the window, i.e. whether the window is minimised or not.
  152. export function WindowIsMinimised(): Promise<boolean>;
  153. // [WindowIsNormal](https://wails.io/docs/reference/runtime/window#windowisnormal)
  154. // Returns the state of the window, i.e. whether the window is normal or not.
  155. export function WindowIsNormal(): Promise<boolean>;
  156. // [WindowSetBackgroundColour](https://wails.io/docs/reference/runtime/window#windowsetbackgroundcolour)
  157. // Sets the background colour of the window to the given RGBA colour definition. This colour will show through for all transparent pixels.
  158. export function WindowSetBackgroundColour(R: number, G: number, B: number, A: number): void;
  159. // [ScreenGetAll](https://wails.io/docs/reference/runtime/window#screengetall)
  160. // Gets the all screens. Call this anew each time you want to refresh data from the underlying windowing system.
  161. export function ScreenGetAll(): Promise<Screen[]>;
  162. // [BrowserOpenURL](https://wails.io/docs/reference/runtime/browser#browseropenurl)
  163. // Opens the given URL in the system browser.
  164. export function BrowserOpenURL(url: string): void;
  165. // [Environment](https://wails.io/docs/reference/runtime/intro#environment)
  166. // Returns information about the environment
  167. export function Environment(): Promise<EnvironmentInfo>;
  168. // [Quit](https://wails.io/docs/reference/runtime/intro#quit)
  169. // Quits the application.
  170. export function Quit(): void;
  171. // [Hide](https://wails.io/docs/reference/runtime/intro#hide)
  172. // Hides the application.
  173. export function Hide(): void;
  174. // [Show](https://wails.io/docs/reference/runtime/intro#show)
  175. // Shows the application.
  176. export function Show(): void;
  177. // [ClipboardGetText](https://wails.io/docs/reference/runtime/clipboard#clipboardgettext)
  178. // Returns the current text stored on clipboard
  179. export function ClipboardGetText(): Promise<string>;
  180. // [ClipboardSetText](https://wails.io/docs/reference/runtime/clipboard#clipboardsettext)
  181. // Sets a text on the clipboard
  182. export function ClipboardSetText(text: string): Promise<boolean>;