runtime.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. _ __ _ __
  3. | | / /___ _(_) /____
  4. | | /| / / __ `/ / / ___/
  5. | |/ |/ / /_/ / / (__ )
  6. |__/|__/\__,_/_/_/____/
  7. The electron alternative for Go
  8. (c) Lea Anthony 2019-present
  9. */
  10. export function LogPrint(message) {
  11. window.runtime.LogPrint(message);
  12. }
  13. export function LogTrace(message) {
  14. window.runtime.LogTrace(message);
  15. }
  16. export function LogDebug(message) {
  17. window.runtime.LogDebug(message);
  18. }
  19. export function LogInfo(message) {
  20. window.runtime.LogInfo(message);
  21. }
  22. export function LogWarning(message) {
  23. window.runtime.LogWarning(message);
  24. }
  25. export function LogError(message) {
  26. window.runtime.LogError(message);
  27. }
  28. export function LogFatal(message) {
  29. window.runtime.LogFatal(message);
  30. }
  31. export function EventsOnMultiple(eventName, callback, maxCallbacks) {
  32. return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
  33. }
  34. export function EventsOn(eventName, callback) {
  35. return EventsOnMultiple(eventName, callback, -1);
  36. }
  37. export function EventsOff(eventName, ...additionalEventNames) {
  38. return window.runtime.EventsOff(eventName, ...additionalEventNames);
  39. }
  40. export function EventsOffAll() {
  41. return window.runtime.EventsOffAll();
  42. }
  43. export function EventsOnce(eventName, callback) {
  44. return EventsOnMultiple(eventName, callback, 1);
  45. }
  46. export function EventsEmit(eventName) {
  47. let args = [eventName].slice.call(arguments);
  48. return window.runtime.EventsEmit.apply(null, args);
  49. }
  50. export function WindowReload() {
  51. window.runtime.WindowReload();
  52. }
  53. export function WindowReloadApp() {
  54. window.runtime.WindowReloadApp();
  55. }
  56. export function WindowSetAlwaysOnTop(b) {
  57. window.runtime.WindowSetAlwaysOnTop(b);
  58. }
  59. export function WindowSetSystemDefaultTheme() {
  60. window.runtime.WindowSetSystemDefaultTheme();
  61. }
  62. export function WindowSetLightTheme() {
  63. window.runtime.WindowSetLightTheme();
  64. }
  65. export function WindowSetDarkTheme() {
  66. window.runtime.WindowSetDarkTheme();
  67. }
  68. export function WindowCenter() {
  69. window.runtime.WindowCenter();
  70. }
  71. export function WindowSetTitle(title) {
  72. window.runtime.WindowSetTitle(title);
  73. }
  74. export function WindowFullscreen() {
  75. window.runtime.WindowFullscreen();
  76. }
  77. export function WindowUnfullscreen() {
  78. window.runtime.WindowUnfullscreen();
  79. }
  80. export function WindowIsFullscreen() {
  81. return window.runtime.WindowIsFullscreen();
  82. }
  83. export function WindowGetSize() {
  84. return window.runtime.WindowGetSize();
  85. }
  86. export function WindowSetSize(width, height) {
  87. window.runtime.WindowSetSize(width, height);
  88. }
  89. export function WindowSetMaxSize(width, height) {
  90. window.runtime.WindowSetMaxSize(width, height);
  91. }
  92. export function WindowSetMinSize(width, height) {
  93. window.runtime.WindowSetMinSize(width, height);
  94. }
  95. export function WindowSetPosition(x, y) {
  96. window.runtime.WindowSetPosition(x, y);
  97. }
  98. export function WindowGetPosition() {
  99. return window.runtime.WindowGetPosition();
  100. }
  101. export function WindowHide() {
  102. window.runtime.WindowHide();
  103. }
  104. export function WindowShow() {
  105. window.runtime.WindowShow();
  106. }
  107. export function WindowMaximise() {
  108. window.runtime.WindowMaximise();
  109. }
  110. export function WindowToggleMaximise() {
  111. window.runtime.WindowToggleMaximise();
  112. }
  113. export function WindowUnmaximise() {
  114. window.runtime.WindowUnmaximise();
  115. }
  116. export function WindowIsMaximised() {
  117. return window.runtime.WindowIsMaximised();
  118. }
  119. export function WindowMinimise() {
  120. window.runtime.WindowMinimise();
  121. }
  122. export function WindowUnminimise() {
  123. window.runtime.WindowUnminimise();
  124. }
  125. export function WindowSetBackgroundColour(R, G, B, A) {
  126. window.runtime.WindowSetBackgroundColour(R, G, B, A);
  127. }
  128. export function ScreenGetAll() {
  129. return window.runtime.ScreenGetAll();
  130. }
  131. export function WindowIsMinimised() {
  132. return window.runtime.WindowIsMinimised();
  133. }
  134. export function WindowIsNormal() {
  135. return window.runtime.WindowIsNormal();
  136. }
  137. export function BrowserOpenURL(url) {
  138. window.runtime.BrowserOpenURL(url);
  139. }
  140. export function Environment() {
  141. return window.runtime.Environment();
  142. }
  143. export function Quit() {
  144. window.runtime.Quit();
  145. }
  146. export function Hide() {
  147. window.runtime.Hide();
  148. }
  149. export function Show() {
  150. window.runtime.Show();
  151. }
  152. export function ClipboardGetText() {
  153. return window.runtime.ClipboardGetText();
  154. }
  155. export function ClipboardSetText(text) {
  156. return window.runtime.ClipboardSetText(text);
  157. }
  158. /**
  159. * Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
  160. *
  161. * @export
  162. * @callback OnFileDropCallback
  163. * @param {number} x - x coordinate of the drop
  164. * @param {number} y - y coordinate of the drop
  165. * @param {string[]} paths - A list of file paths.
  166. */
  167. /**
  168. * OnFileDrop listens to drag and drop events and calls the callback with the coordinates of the drop and an array of path strings.
  169. *
  170. * @export
  171. * @param {OnFileDropCallback} callback - Callback for OnFileDrop returns a slice of file path strings when a drop is finished.
  172. * @param {boolean} [useDropTarget=true] - Only call the callback when the drop finished on an element that has the drop target style. (--wails-drop-target)
  173. */
  174. export function OnFileDrop(callback, useDropTarget) {
  175. return window.runtime.OnFileDrop(callback, useDropTarget);
  176. }
  177. /**
  178. * OnFileDropOff removes the drag and drop listeners and handlers.
  179. */
  180. export function OnFileDropOff() {
  181. return window.runtime.OnFileDropOff();
  182. }
  183. export function CanResolveFilePaths() {
  184. return window.runtime.CanResolveFilePaths();
  185. }
  186. export function ResolveFilePaths(files) {
  187. return window.runtime.ResolveFilePaths(files);
  188. }