@wailsio/runtime 3.0.0-alpha.65 → 3.0.0-alpha.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/{src → dist}/application.js +2 -16
  2. package/dist/browser.js +20 -0
  3. package/dist/callable.js +144 -0
  4. package/dist/calls.js +194 -0
  5. package/dist/cancellable.js +792 -0
  6. package/dist/clipboard.js +30 -0
  7. package/dist/contextmenu.js +80 -0
  8. package/{src → dist}/create.js +2 -33
  9. package/dist/dialogs.js +134 -0
  10. package/dist/drag.js +222 -0
  11. package/dist/event_types.js +232 -0
  12. package/dist/events.js +114 -0
  13. package/dist/flags.js +23 -0
  14. package/dist/index.js +38 -0
  15. package/dist/listener.js +44 -0
  16. package/{src → dist}/nanoid.js +7 -11
  17. package/dist/runtime.js +63 -0
  18. package/dist/screens.js +38 -0
  19. package/dist/system.js +146 -0
  20. package/{src → dist}/utils.js +29 -20
  21. package/dist/window.js +570 -0
  22. package/{src → dist}/wml.js +52 -123
  23. package/package.json +43 -19
  24. package/types/application.d.ts +3 -10
  25. package/types/browser.d.ts +4 -4
  26. package/types/callable.d.ts +3 -0
  27. package/types/calls.d.ts +43 -49
  28. package/types/cancellable.d.ts +434 -0
  29. package/types/clipboard.d.ts +6 -5
  30. package/types/contextmenu.d.ts +1 -0
  31. package/types/create.d.ts +6 -27
  32. package/types/dialogs.d.ts +99 -143
  33. package/types/drag.d.ts +1 -0
  34. package/types/event_types.d.ts +221 -219
  35. package/types/events.d.ts +46 -250
  36. package/types/flags.d.ts +3 -3
  37. package/types/index.d.ts +16 -14
  38. package/types/listener.d.ts +9 -0
  39. package/types/nanoid.d.ts +1 -1
  40. package/types/runtime.d.ts +18 -26
  41. package/types/screens.d.ts +42 -76
  42. package/types/system.d.ts +59 -79
  43. package/types/utils.d.ts +15 -8
  44. package/types/window.d.ts +123 -224
  45. package/types/wml.d.ts +2 -6
  46. package/docs/.nojekyll +0 -1
  47. package/docs/assets/highlight.css +0 -22
  48. package/docs/assets/icons.js +0 -15
  49. package/docs/assets/icons.svg +0 -1
  50. package/docs/assets/main.js +0 -59
  51. package/docs/assets/navigation.js +0 -1
  52. package/docs/assets/search.js +0 -1
  53. package/docs/assets/style.css +0 -1415
  54. package/docs/classes/Call.RuntimeError.html +0 -11
  55. package/docs/classes/Events.WailsEvent.html +0 -4
  56. package/docs/functions/Application.Hide.html +0 -2
  57. package/docs/functions/Application.Quit.html +0 -2
  58. package/docs/functions/Application.Show.html +0 -2
  59. package/docs/functions/Browser.OpenURL.html +0 -3
  60. package/docs/functions/Call.ByID.html +0 -8
  61. package/docs/functions/Call.ByName.html +0 -6
  62. package/docs/functions/Call.Call.html +0 -11
  63. package/docs/functions/Clipboard.SetText.html +0 -6
  64. package/docs/functions/Clipboard.Text.html +0 -3
  65. package/docs/functions/Create.Any.html +0 -2
  66. package/docs/functions/Create.Array.html +0 -4
  67. package/docs/functions/Create.ByteSlice.html +0 -3
  68. package/docs/functions/Create.Map.html +0 -4
  69. package/docs/functions/Create.Nullable.html +0 -3
  70. package/docs/functions/Create.Struct.html +0 -3
  71. package/docs/functions/Dialogs.Error.html +0 -5
  72. package/docs/functions/Dialogs.Info.html +0 -5
  73. package/docs/functions/Dialogs.OpenFile.html +0 -3
  74. package/docs/functions/Dialogs.Question.html +0 -5
  75. package/docs/functions/Dialogs.SaveFile.html +0 -3
  76. package/docs/functions/Dialogs.Warning.html +0 -5
  77. package/docs/functions/Events.Emit.html +0 -6
  78. package/docs/functions/Events.Off.html +0 -4
  79. package/docs/functions/Events.OffAll.html +0 -3
  80. package/docs/functions/Events.On.html +0 -7
  81. package/docs/functions/Events.OnMultiple.html +0 -8
  82. package/docs/functions/Events.Once.html +0 -7
  83. package/docs/functions/Events.setup.html +0 -1
  84. package/docs/functions/Flags.GetFlag.html +0 -6
  85. package/docs/functions/Screens.GetAll.html +0 -3
  86. package/docs/functions/Screens.GetCurrent.html +0 -3
  87. package/docs/functions/Screens.GetPrimary.html +0 -3
  88. package/docs/functions/System.Capabilities.html +0 -4
  89. package/docs/functions/System.Environment.html +0 -5
  90. package/docs/functions/System.IsAMD64.html +0 -3
  91. package/docs/functions/System.IsARM.html +0 -3
  92. package/docs/functions/System.IsARM64.html +0 -5
  93. package/docs/functions/System.IsDarkMode.html +0 -5
  94. package/docs/functions/System.IsDebug.html +0 -1
  95. package/docs/functions/System.IsLinux.html +0 -3
  96. package/docs/functions/System.IsMac.html +0 -3
  97. package/docs/functions/System.IsWindows.html +0 -3
  98. package/docs/functions/System.invoke.html +0 -1
  99. package/docs/functions/WML.Enable.html +0 -2
  100. package/docs/functions/WML.Reload.html +0 -2
  101. package/docs/functions/init.html +0 -1
  102. package/docs/index.html +0 -5
  103. package/docs/interfaces/Call.CallOptions.html +0 -7
  104. package/docs/interfaces/Dialogs.Button.html +0 -7
  105. package/docs/interfaces/Dialogs.FileFilter.html +0 -5
  106. package/docs/interfaces/Dialogs.MessageDialogOptions.html +0 -9
  107. package/docs/interfaces/Dialogs.OpenFileDialogOptions.html +0 -33
  108. package/docs/interfaces/Dialogs.SaveFileDialogOptions.html +0 -35
  109. package/docs/interfaces/Screens.Rect.html +0 -9
  110. package/docs/interfaces/Screens.Screen.html +0 -25
  111. package/docs/interfaces/Screens.Size.html +0 -5
  112. package/docs/interfaces/System.EnvironmentInfo.html +0 -11
  113. package/docs/interfaces/System.OSInfo.html +0 -9
  114. package/docs/modules/Application.html +0 -4
  115. package/docs/modules/Browser.html +0 -2
  116. package/docs/modules/Call.html +0 -6
  117. package/docs/modules/Clipboard.html +0 -3
  118. package/docs/modules/Create.html +0 -7
  119. package/docs/modules/Dialogs.html +0 -12
  120. package/docs/modules/Events.html +0 -10
  121. package/docs/modules/Flags.html +0 -2
  122. package/docs/modules/Screens.html +0 -7
  123. package/docs/modules/System.html +0 -14
  124. package/docs/modules/WML.html +0 -3
  125. package/docs/modules.html +0 -14
  126. package/docs/variables/Events.Types.html +0 -1
  127. package/docs/variables/Window.html +0 -2
  128. package/src/browser.js +0 -24
  129. package/src/calls.js +0 -221
  130. package/src/clipboard.js +0 -35
  131. package/src/contextmenu.js +0 -97
  132. package/src/dialogs.js +0 -200
  133. package/src/drag.js +0 -119
  134. package/src/event_types.js +0 -219
  135. package/src/events.js +0 -140
  136. package/src/flags.js +0 -25
  137. package/src/index.js +0 -60
  138. package/src/runtime.js +0 -92
  139. package/src/screens.js +0 -71
  140. package/src/system.js +0 -143
  141. package/src/window.js +0 -638
  142. package/tsconfig.json +0 -20
@@ -1,219 +0,0 @@
1
-
2
- export const EventTypes = {
3
- Windows: {
4
- APMPowerSettingChange: "windows:APMPowerSettingChange",
5
- APMPowerStatusChange: "windows:APMPowerStatusChange",
6
- APMResumeAutomatic: "windows:APMResumeAutomatic",
7
- APMResumeSuspend: "windows:APMResumeSuspend",
8
- APMSuspend: "windows:APMSuspend",
9
- ApplicationStarted: "windows:ApplicationStarted",
10
- SystemThemeChanged: "windows:SystemThemeChanged",
11
- WebViewNavigationCompleted: "windows:WebViewNavigationCompleted",
12
- WindowActive: "windows:WindowActive",
13
- WindowBackgroundErase: "windows:WindowBackgroundErase",
14
- WindowClickActive: "windows:WindowClickActive",
15
- WindowClosing: "windows:WindowClosing",
16
- WindowDidMove: "windows:WindowDidMove",
17
- WindowDidResize: "windows:WindowDidResize",
18
- WindowDPIChanged: "windows:WindowDPIChanged",
19
- WindowDragDrop: "windows:WindowDragDrop",
20
- WindowDragEnter: "windows:WindowDragEnter",
21
- WindowDragLeave: "windows:WindowDragLeave",
22
- WindowDragOver: "windows:WindowDragOver",
23
- WindowEndMove: "windows:WindowEndMove",
24
- WindowEndResize: "windows:WindowEndResize",
25
- WindowFullscreen: "windows:WindowFullscreen",
26
- WindowHide: "windows:WindowHide",
27
- WindowInactive: "windows:WindowInactive",
28
- WindowKeyDown: "windows:WindowKeyDown",
29
- WindowKeyUp: "windows:WindowKeyUp",
30
- WindowKillFocus: "windows:WindowKillFocus",
31
- WindowNonClientHit: "windows:WindowNonClientHit",
32
- WindowNonClientMouseDown: "windows:WindowNonClientMouseDown",
33
- WindowNonClientMouseLeave: "windows:WindowNonClientMouseLeave",
34
- WindowNonClientMouseMove: "windows:WindowNonClientMouseMove",
35
- WindowNonClientMouseUp: "windows:WindowNonClientMouseUp",
36
- WindowPaint: "windows:WindowPaint",
37
- WindowRestore: "windows:WindowRestore",
38
- WindowSetFocus: "windows:WindowSetFocus",
39
- WindowShow: "windows:WindowShow",
40
- WindowStartMove: "windows:WindowStartMove",
41
- WindowStartResize: "windows:WindowStartResize",
42
- WindowUnFullscreen: "windows:WindowUnFullscreen",
43
- WindowZOrderChanged: "windows:WindowZOrderChanged",
44
- WindowMinimise: "windows:WindowMinimise",
45
- WindowUnMinimise: "windows:WindowUnMinimise",
46
- WindowMaximise: "windows:WindowMaximise",
47
- WindowUnMaximise: "windows:WindowUnMaximise",
48
- },
49
- Mac: {
50
- ApplicationDidBecomeActive: "mac:ApplicationDidBecomeActive",
51
- ApplicationDidChangeBackingProperties: "mac:ApplicationDidChangeBackingProperties",
52
- ApplicationDidChangeEffectiveAppearance: "mac:ApplicationDidChangeEffectiveAppearance",
53
- ApplicationDidChangeIcon: "mac:ApplicationDidChangeIcon",
54
- ApplicationDidChangeOcclusionState: "mac:ApplicationDidChangeOcclusionState",
55
- ApplicationDidChangeScreenParameters: "mac:ApplicationDidChangeScreenParameters",
56
- ApplicationDidChangeStatusBarFrame: "mac:ApplicationDidChangeStatusBarFrame",
57
- ApplicationDidChangeStatusBarOrientation: "mac:ApplicationDidChangeStatusBarOrientation",
58
- ApplicationDidChangeTheme: "mac:ApplicationDidChangeTheme",
59
- ApplicationDidFinishLaunching: "mac:ApplicationDidFinishLaunching",
60
- ApplicationDidHide: "mac:ApplicationDidHide",
61
- ApplicationDidResignActive: "mac:ApplicationDidResignActive",
62
- ApplicationDidUnhide: "mac:ApplicationDidUnhide",
63
- ApplicationDidUpdate: "mac:ApplicationDidUpdate",
64
- ApplicationShouldHandleReopen: "mac:ApplicationShouldHandleReopen",
65
- ApplicationWillBecomeActive: "mac:ApplicationWillBecomeActive",
66
- ApplicationWillFinishLaunching: "mac:ApplicationWillFinishLaunching",
67
- ApplicationWillHide: "mac:ApplicationWillHide",
68
- ApplicationWillResignActive: "mac:ApplicationWillResignActive",
69
- ApplicationWillTerminate: "mac:ApplicationWillTerminate",
70
- ApplicationWillUnhide: "mac:ApplicationWillUnhide",
71
- ApplicationWillUpdate: "mac:ApplicationWillUpdate",
72
- MenuDidAddItem: "mac:MenuDidAddItem",
73
- MenuDidBeginTracking: "mac:MenuDidBeginTracking",
74
- MenuDidClose: "mac:MenuDidClose",
75
- MenuDidDisplayItem: "mac:MenuDidDisplayItem",
76
- MenuDidEndTracking: "mac:MenuDidEndTracking",
77
- MenuDidHighlightItem: "mac:MenuDidHighlightItem",
78
- MenuDidOpen: "mac:MenuDidOpen",
79
- MenuDidPopUp: "mac:MenuDidPopUp",
80
- MenuDidRemoveItem: "mac:MenuDidRemoveItem",
81
- MenuDidSendAction: "mac:MenuDidSendAction",
82
- MenuDidSendActionToItem: "mac:MenuDidSendActionToItem",
83
- MenuDidUpdate: "mac:MenuDidUpdate",
84
- MenuWillAddItem: "mac:MenuWillAddItem",
85
- MenuWillBeginTracking: "mac:MenuWillBeginTracking",
86
- MenuWillDisplayItem: "mac:MenuWillDisplayItem",
87
- MenuWillEndTracking: "mac:MenuWillEndTracking",
88
- MenuWillHighlightItem: "mac:MenuWillHighlightItem",
89
- MenuWillOpen: "mac:MenuWillOpen",
90
- MenuWillPopUp: "mac:MenuWillPopUp",
91
- MenuWillRemoveItem: "mac:MenuWillRemoveItem",
92
- MenuWillSendAction: "mac:MenuWillSendAction",
93
- MenuWillSendActionToItem: "mac:MenuWillSendActionToItem",
94
- MenuWillUpdate: "mac:MenuWillUpdate",
95
- WebViewDidCommitNavigation: "mac:WebViewDidCommitNavigation",
96
- WebViewDidFinishNavigation: "mac:WebViewDidFinishNavigation",
97
- WebViewDidReceiveServerRedirectForProvisionalNavigation: "mac:WebViewDidReceiveServerRedirectForProvisionalNavigation",
98
- WebViewDidStartProvisionalNavigation: "mac:WebViewDidStartProvisionalNavigation",
99
- WindowDidBecomeKey: "mac:WindowDidBecomeKey",
100
- WindowDidBecomeMain: "mac:WindowDidBecomeMain",
101
- WindowDidBeginSheet: "mac:WindowDidBeginSheet",
102
- WindowDidChangeAlpha: "mac:WindowDidChangeAlpha",
103
- WindowDidChangeBackingLocation: "mac:WindowDidChangeBackingLocation",
104
- WindowDidChangeBackingProperties: "mac:WindowDidChangeBackingProperties",
105
- WindowDidChangeCollectionBehavior: "mac:WindowDidChangeCollectionBehavior",
106
- WindowDidChangeEffectiveAppearance: "mac:WindowDidChangeEffectiveAppearance",
107
- WindowDidChangeOcclusionState: "mac:WindowDidChangeOcclusionState",
108
- WindowDidChangeOrderingMode: "mac:WindowDidChangeOrderingMode",
109
- WindowDidChangeScreen: "mac:WindowDidChangeScreen",
110
- WindowDidChangeScreenParameters: "mac:WindowDidChangeScreenParameters",
111
- WindowDidChangeScreenProfile: "mac:WindowDidChangeScreenProfile",
112
- WindowDidChangeScreenSpace: "mac:WindowDidChangeScreenSpace",
113
- WindowDidChangeScreenSpaceProperties: "mac:WindowDidChangeScreenSpaceProperties",
114
- WindowDidChangeSharingType: "mac:WindowDidChangeSharingType",
115
- WindowDidChangeSpace: "mac:WindowDidChangeSpace",
116
- WindowDidChangeSpaceOrderingMode: "mac:WindowDidChangeSpaceOrderingMode",
117
- WindowDidChangeTitle: "mac:WindowDidChangeTitle",
118
- WindowDidChangeToolbar: "mac:WindowDidChangeToolbar",
119
- WindowDidDeminiaturize: "mac:WindowDidDeminiaturize",
120
- WindowDidEndSheet: "mac:WindowDidEndSheet",
121
- WindowDidEnterFullScreen: "mac:WindowDidEnterFullScreen",
122
- WindowDidEnterVersionBrowser: "mac:WindowDidEnterVersionBrowser",
123
- WindowDidExitFullScreen: "mac:WindowDidExitFullScreen",
124
- WindowDidExitVersionBrowser: "mac:WindowDidExitVersionBrowser",
125
- WindowDidExpose: "mac:WindowDidExpose",
126
- WindowDidFocus: "mac:WindowDidFocus",
127
- WindowDidMiniaturize: "mac:WindowDidMiniaturize",
128
- WindowDidMove: "mac:WindowDidMove",
129
- WindowDidOrderOffScreen: "mac:WindowDidOrderOffScreen",
130
- WindowDidOrderOnScreen: "mac:WindowDidOrderOnScreen",
131
- WindowDidResignKey: "mac:WindowDidResignKey",
132
- WindowDidResignMain: "mac:WindowDidResignMain",
133
- WindowDidResize: "mac:WindowDidResize",
134
- WindowDidUpdate: "mac:WindowDidUpdate",
135
- WindowDidUpdateAlpha: "mac:WindowDidUpdateAlpha",
136
- WindowDidUpdateCollectionBehavior: "mac:WindowDidUpdateCollectionBehavior",
137
- WindowDidUpdateCollectionProperties: "mac:WindowDidUpdateCollectionProperties",
138
- WindowDidUpdateShadow: "mac:WindowDidUpdateShadow",
139
- WindowDidUpdateTitle: "mac:WindowDidUpdateTitle",
140
- WindowDidUpdateToolbar: "mac:WindowDidUpdateToolbar",
141
- WindowDidZoom: "mac:WindowDidZoom",
142
- WindowFileDraggingEntered: "mac:WindowFileDraggingEntered",
143
- WindowFileDraggingExited: "mac:WindowFileDraggingExited",
144
- WindowFileDraggingPerformed: "mac:WindowFileDraggingPerformed",
145
- WindowHide: "mac:WindowHide",
146
- WindowMaximise: "mac:WindowMaximise",
147
- WindowUnMaximise: "mac:WindowUnMaximise",
148
- WindowMinimise: "mac:WindowMinimise",
149
- WindowUnMinimise: "mac:WindowUnMinimise",
150
- WindowShouldClose: "mac:WindowShouldClose",
151
- WindowShow: "mac:WindowShow",
152
- WindowWillBecomeKey: "mac:WindowWillBecomeKey",
153
- WindowWillBecomeMain: "mac:WindowWillBecomeMain",
154
- WindowWillBeginSheet: "mac:WindowWillBeginSheet",
155
- WindowWillChangeOrderingMode: "mac:WindowWillChangeOrderingMode",
156
- WindowWillClose: "mac:WindowWillClose",
157
- WindowWillDeminiaturize: "mac:WindowWillDeminiaturize",
158
- WindowWillEnterFullScreen: "mac:WindowWillEnterFullScreen",
159
- WindowWillEnterVersionBrowser: "mac:WindowWillEnterVersionBrowser",
160
- WindowWillExitFullScreen: "mac:WindowWillExitFullScreen",
161
- WindowWillExitVersionBrowser: "mac:WindowWillExitVersionBrowser",
162
- WindowWillFocus: "mac:WindowWillFocus",
163
- WindowWillMiniaturize: "mac:WindowWillMiniaturize",
164
- WindowWillMove: "mac:WindowWillMove",
165
- WindowWillOrderOffScreen: "mac:WindowWillOrderOffScreen",
166
- WindowWillOrderOnScreen: "mac:WindowWillOrderOnScreen",
167
- WindowWillResignMain: "mac:WindowWillResignMain",
168
- WindowWillResize: "mac:WindowWillResize",
169
- WindowWillUnfocus: "mac:WindowWillUnfocus",
170
- WindowWillUpdate: "mac:WindowWillUpdate",
171
- WindowWillUpdateAlpha: "mac:WindowWillUpdateAlpha",
172
- WindowWillUpdateCollectionBehavior: "mac:WindowWillUpdateCollectionBehavior",
173
- WindowWillUpdateCollectionProperties: "mac:WindowWillUpdateCollectionProperties",
174
- WindowWillUpdateShadow: "mac:WindowWillUpdateShadow",
175
- WindowWillUpdateTitle: "mac:WindowWillUpdateTitle",
176
- WindowWillUpdateToolbar: "mac:WindowWillUpdateToolbar",
177
- WindowWillUpdateVisibility: "mac:WindowWillUpdateVisibility",
178
- WindowWillUseStandardFrame: "mac:WindowWillUseStandardFrame",
179
- WindowZoomIn: "mac:WindowZoomIn",
180
- WindowZoomOut: "mac:WindowZoomOut",
181
- WindowZoomReset: "mac:WindowZoomReset",
182
- },
183
- Linux: {
184
- ApplicationStartup: "linux:ApplicationStartup",
185
- SystemThemeChanged: "linux:SystemThemeChanged",
186
- WindowDeleteEvent: "linux:WindowDeleteEvent",
187
- WindowDidMove: "linux:WindowDidMove",
188
- WindowDidResize: "linux:WindowDidResize",
189
- WindowFocusIn: "linux:WindowFocusIn",
190
- WindowFocusOut: "linux:WindowFocusOut",
191
- WindowLoadChanged: "linux:WindowLoadChanged",
192
- },
193
- Common: {
194
- ApplicationOpenedWithFile: "common:ApplicationOpenedWithFile",
195
- ApplicationStarted: "common:ApplicationStarted",
196
- ThemeChanged: "common:ThemeChanged",
197
- WindowClosing: "common:WindowClosing",
198
- WindowDidMove: "common:WindowDidMove",
199
- WindowDidResize: "common:WindowDidResize",
200
- WindowDPIChanged: "common:WindowDPIChanged",
201
- WindowFilesDropped: "common:WindowFilesDropped",
202
- WindowFocus: "common:WindowFocus",
203
- WindowFullscreen: "common:WindowFullscreen",
204
- WindowHide: "common:WindowHide",
205
- WindowLostFocus: "common:WindowLostFocus",
206
- WindowMaximise: "common:WindowMaximise",
207
- WindowMinimise: "common:WindowMinimise",
208
- WindowRestore: "common:WindowRestore",
209
- WindowRuntimeReady: "common:WindowRuntimeReady",
210
- WindowShow: "common:WindowShow",
211
- WindowUnFullscreen: "common:WindowUnFullscreen",
212
- WindowUnMaximise: "common:WindowUnMaximise",
213
- WindowUnMinimise: "common:WindowUnMinimise",
214
- WindowZoom: "common:WindowZoom",
215
- WindowZoomIn: "common:WindowZoomIn",
216
- WindowZoomOut: "common:WindowZoomOut",
217
- WindowZoomReset: "common:WindowZoomReset",
218
- },
219
- };
package/src/events.js DELETED
@@ -1,140 +0,0 @@
1
- /*
2
- _ __ _ __
3
- | | / /___ _(_) /____
4
- | | /| / / __ `/ / / ___/
5
- | |/ |/ / /_/ / / (__ )
6
- |__/|__/\__,_/_/_/____/
7
- The electron alternative for Go
8
- (c) Lea Anthony 2019-present
9
- */
10
-
11
- /* jshint esversion: 9 */
12
-
13
- /**
14
- * @typedef {import("./types").WailsEvent} WailsEvent
15
- */
16
- import {newRuntimeCallerWithID, objectNames} from "./runtime";
17
-
18
- import {EventTypes} from "./event_types";
19
- export const Types = EventTypes;
20
-
21
- // Setup
22
- window._wails = window._wails || {};
23
- window._wails.dispatchWailsEvent = dispatchWailsEvent;
24
-
25
- const call = newRuntimeCallerWithID(objectNames.Events, '');
26
- const EmitMethod = 0;
27
- const eventListeners = new Map();
28
-
29
- class Listener {
30
- constructor(eventName, callback, maxCallbacks) {
31
- this.eventName = eventName;
32
- this.maxCallbacks = maxCallbacks || -1;
33
- this.Callback = (data) => {
34
- callback(data);
35
- if (this.maxCallbacks === -1) return false;
36
- this.maxCallbacks -= 1;
37
- return this.maxCallbacks === 0;
38
- };
39
- }
40
- }
41
-
42
- export class WailsEvent {
43
- constructor(name, data = null) {
44
- this.name = name;
45
- this.data = data;
46
- }
47
- }
48
-
49
- export function setup() {
50
- }
51
-
52
- function dispatchWailsEvent(event) {
53
- let listeners = eventListeners.get(event.name);
54
- if (listeners) {
55
- let toRemove = listeners.filter(listener => {
56
- let remove = listener.Callback(event);
57
- if (remove) return true;
58
- });
59
- if (toRemove.length > 0) {
60
- listeners = listeners.filter(l => !toRemove.includes(l));
61
- if (listeners.length === 0) eventListeners.delete(event.name);
62
- else eventListeners.set(event.name, listeners);
63
- }
64
- }
65
- }
66
-
67
- /**
68
- * Register a callback function to be called multiple times for a specific event.
69
- *
70
- * @param {string} eventName - The name of the event to register the callback for.
71
- * @param {function} callback - The callback function to be called when the event is triggered.
72
- * @param {number} maxCallbacks - The maximum number of times the callback can be called for the event. Once the maximum number is reached, the callback will no longer be called.
73
- *
74
- @return {function} - A function that, when called, will unregister the callback from the event.
75
- */
76
- export function OnMultiple(eventName, callback, maxCallbacks) {
77
- let listeners = eventListeners.get(eventName) || [];
78
- const thisListener = new Listener(eventName, callback, maxCallbacks);
79
- listeners.push(thisListener);
80
- eventListeners.set(eventName, listeners);
81
- return () => listenerOff(thisListener);
82
- }
83
-
84
- /**
85
- * Registers a callback function to be executed when the specified event occurs.
86
- *
87
- * @param {string} eventName - The name of the event.
88
- * @param {function} callback - The callback function to be executed. It takes no parameters.
89
- * @return {function} - A function that, when called, will unregister the callback from the event. */
90
- export function On(eventName, callback) { return OnMultiple(eventName, callback, -1); }
91
-
92
- /**
93
- * Registers a callback function to be executed only once for the specified event.
94
- *
95
- * @param {string} eventName - The name of the event.
96
- * @param {function} callback - The function to be executed when the event occurs.
97
- * @return {function} - A function that, when called, will unregister the callback from the event.
98
- */
99
- export function Once(eventName, callback) { return OnMultiple(eventName, callback, 1); }
100
-
101
- /**
102
- * Removes the specified listener from the event listeners collection.
103
- * If all listeners for the event are removed, the event key is deleted from the collection.
104
- *
105
- * @param {Object} listener - The listener to be removed.
106
- */
107
- function listenerOff(listener) {
108
- const eventName = listener.eventName;
109
- let listeners = eventListeners.get(eventName).filter(l => l !== listener);
110
- if (listeners.length === 0) eventListeners.delete(eventName);
111
- else eventListeners.set(eventName, listeners);
112
- }
113
-
114
-
115
- /**
116
- * Removes event listeners for the specified event names.
117
- *
118
- * @param {string} eventName - The name of the event to remove listeners for.
119
- * @param {...string} additionalEventNames - Additional event names to remove listeners for.
120
- * @return {undefined}
121
- */
122
- export function Off(eventName, ...additionalEventNames) {
123
- let eventsToRemove = [eventName, ...additionalEventNames];
124
- eventsToRemove.forEach(eventName => eventListeners.delete(eventName));
125
- }
126
- /**
127
- * Removes all event listeners.
128
- *
129
- * @function OffAll
130
- * @returns {void}
131
- */
132
- export function OffAll() { eventListeners.clear(); }
133
-
134
- /**
135
- * Emits an event using the given event name.
136
- *
137
- * @param {WailsEvent} event - The name of the event to emit.
138
- * @returns {any} - The result of the emitted event.
139
- */
140
- export function Emit(event) { return call(EmitMethod, event); }
package/src/flags.js DELETED
@@ -1,25 +0,0 @@
1
- /*
2
- _ __ _ __
3
- | | / /___ _(_) /____
4
- | | /| / / __ `/ / / ___/
5
- | |/ |/ / /_/ / / (__ )
6
- |__/|__/\__,_/_/_/____/
7
- The electron alternative for Go
8
- (c) Lea Anthony 2019-present
9
- */
10
-
11
- /* jshint esversion: 9 */
12
-
13
- /**
14
- * Retrieves the value associated with the specified key from the flag map.
15
- *
16
- * @param {string} keyString - The key to retrieve the value for.
17
- * @return {*} - The value associated with the specified key.
18
- */
19
- export function GetFlag(keyString) {
20
- try {
21
- return window._wails.flags[keyString];
22
- } catch (e) {
23
- throw new Error("Unable to retrieve flag '" + keyString + "': " + e);
24
- }
25
- }
package/src/index.js DELETED
@@ -1,60 +0,0 @@
1
- /*
2
- _ __ _ __
3
- | | / /___ _(_) /____
4
- | | /| / / __ `/ / / ___/
5
- | |/ |/ / /_/ / / (__ )
6
- |__/|__/\__,_/_/_/____/
7
- The electron alternative for Go
8
- (c) Lea Anthony 2019-present
9
- */
10
-
11
- // Setup
12
- window._wails = window._wails || {};
13
-
14
- import "./contextmenu";
15
- import "./drag";
16
-
17
- // Re-export public API
18
- import * as Application from "./application";
19
- import * as Browser from "./browser";
20
- import * as Call from "./calls";
21
- import * as Clipboard from "./clipboard";
22
- import * as Create from "./create";
23
- import * as Dialogs from "./dialogs";
24
- import * as Events from "./events";
25
- import * as Flags from "./flags";
26
- import * as Screens from "./screens";
27
- import * as System from "./system";
28
- import Window from "./window";
29
- import * as WML from "./wml";
30
-
31
- export {
32
- Application,
33
- Browser,
34
- Call,
35
- Clipboard,
36
- Create,
37
- Dialogs,
38
- Events,
39
- Flags,
40
- Screens,
41
- System,
42
- Window,
43
- WML
44
- };
45
-
46
- let initialised = false;
47
- export function init() {
48
- window._wails.invoke = System.invoke;
49
- System.invoke("wails:runtime:ready");
50
- initialised = true;
51
- }
52
-
53
- window.addEventListener("load", () => {
54
- if (!initialised) {
55
- init();
56
- }
57
- });
58
-
59
- // Notify backend
60
-
package/src/runtime.js DELETED
@@ -1,92 +0,0 @@
1
- /*
2
- _ __ _ __
3
- | | / /___ _(_) /____
4
- | | /| / / __ `/ / / ___/
5
- | |/ |/ / /_/ / / (__ )
6
- |__/|__/\__,_/_/_/____/
7
- The electron alternative for Go
8
- (c) Lea Anthony 2019-present
9
- */
10
-
11
- /* jshint esversion: 9 */
12
- import { nanoid } from './nanoid.js';
13
-
14
- const runtimeURL = window.location.origin + "/wails/runtime";
15
-
16
- // Object Names
17
- export const objectNames = {
18
- Call: 0,
19
- Clipboard: 1,
20
- Application: 2,
21
- Events: 3,
22
- ContextMenu: 4,
23
- Dialog: 5,
24
- Window: 6,
25
- Screens: 7,
26
- System: 8,
27
- Browser: 9,
28
- CancelCall: 10,
29
- }
30
- export let clientId = nanoid();
31
-
32
- /**
33
- * Creates a runtime caller function that invokes a specified method on a given object within a specified window context.
34
- *
35
- * @param {Object} object - The object on which the method is to be invoked.
36
- * @param {string} windowName - The name of the window context in which the method should be called.
37
- * @returns {Function} A runtime caller function that takes the method name and optionally arguments and invokes the method within the specified window context.
38
- */
39
- export function newRuntimeCaller(object, windowName) {
40
- return function (method, args=null) {
41
- return runtimeCall(object + "." + method, windowName, args);
42
- };
43
- }
44
-
45
- /**
46
- * Creates a new runtime caller with specified ID.
47
- *
48
- * @param {number} object - The object to invoke the method on.
49
- * @param {string} windowName - The name of the window.
50
- * @return {Function} - The new runtime caller function.
51
- */
52
- export function newRuntimeCallerWithID(object, windowName) {
53
- return function (method, args=null) {
54
- return runtimeCallWithID(object, method, windowName, args);
55
- };
56
- }
57
-
58
-
59
- function runtimeCall(method, windowName, args) {
60
- return runtimeCallWithID(null, method, windowName, args);
61
- }
62
-
63
- async function runtimeCallWithID(objectID, method, windowName, args) {
64
- let url = new URL(runtimeURL);
65
- if (objectID != null) {
66
- url.searchParams.append("object", objectID);
67
- }
68
- if (method != null) {
69
- url.searchParams.append("method", method);
70
- }
71
- let fetchOptions = {
72
- headers: {},
73
- };
74
- if (windowName) {
75
- fetchOptions.headers["x-wails-window-name"] = windowName;
76
- }
77
- if (args) {
78
- url.searchParams.append("args", JSON.stringify(args));
79
- }
80
- fetchOptions.headers["x-wails-client-id"] = clientId;
81
-
82
- let response = await fetch(url, fetchOptions);
83
- if (!response.ok) {
84
- throw new Error(await response.text());
85
- }
86
-
87
- if (response.headers.get("Content-Type") && response.headers.get("Content-Type").indexOf("application/json") !== -1) {
88
- return response.json();
89
- } else {
90
- return response.text();
91
- }
92
- }
package/src/screens.js DELETED
@@ -1,71 +0,0 @@
1
- /*
2
- _ __ _ __
3
- | | / /___ _(_) /____
4
- | | /| / / __ `/ / / ___/
5
- | |/ |/ / /_/ / / (__ )
6
- |__/|__/\__,_/_/_/____/
7
- The electron alternative for Go
8
- (c) Lea Anthony 2019-present
9
- */
10
-
11
- /* jshint esversion: 9 */
12
-
13
- /**
14
- * @typedef {Object} Size
15
- * @property {number} Width - The width.
16
- * @property {number} Height - The height.
17
- */
18
-
19
- /**
20
- * @typedef {Object} Rect
21
- * @property {number} X - The X coordinate of the origin.
22
- * @property {number} Y - The Y coordinate of the origin.
23
- * @property {number} Width - The width of the rectangle.
24
- * @property {number} Height - The height of the rectangle.
25
- */
26
-
27
- /**
28
- * @typedef {Object} Screen
29
- * @property {string} ID - Unique identifier for the screen.
30
- * @property {string} Name - Human readable name of the screen.
31
- * @property {number} ScaleFactor - The scale factor of the screen (DPI/96). 1 = standard DPI, 2 = HiDPI (Retina), etc.
32
- * @property {number} X - The X coordinate of the screen.
33
- * @property {number} Y - The Y coordinate of the screen.
34
- * @property {Size} Size - Contains the width and height of the screen.
35
- * @property {Rect} Bounds - Contains the bounds of the screen in terms of X, Y, Width, and Height.
36
- * @property {Rect} PhysicalBounds - Contains the physical bounds of the screen in terms of X, Y, Width, and Height (before scaling).
37
- * @property {Rect} WorkArea - Contains the area of the screen that is actually usable (excluding taskbar and other system UI).
38
- * @property {Rect} PhysicalWorkArea - Contains the physical WorkArea of the screen (before scaling).
39
- * @property {boolean} IsPrimary - True if this is the primary monitor selected by the user in the operating system.
40
- * @property {number} Rotation - The rotation of the screen.
41
- */
42
-
43
- import { newRuntimeCallerWithID, objectNames } from "./runtime";
44
- const call = newRuntimeCallerWithID(objectNames.Screens, "");
45
-
46
- const getAll = 0;
47
- const getPrimary = 1;
48
- const getCurrent = 2;
49
-
50
- /**
51
- * Gets all screens.
52
- * @returns {Promise<Screen[]>} A promise that resolves to an array of Screen objects.
53
- */
54
- export function GetAll() {
55
- return call(getAll);
56
- }
57
- /**
58
- * Gets the primary screen.
59
- * @returns {Promise<Screen>} A promise that resolves to the primary screen.
60
- */
61
- export function GetPrimary() {
62
- return call(getPrimary);
63
- }
64
- /**
65
- * Gets the current active screen.
66
- *
67
- * @returns {Promise<Screen>} A promise that resolves with the current active screen.
68
- */
69
- export function GetCurrent() {
70
- return call(getCurrent);
71
- }